summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2021-12-24 15:08:51 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2021-12-24 15:08:51 +0100
commitbd5fd411691410d2ddb37f108810353b725eb0b1 (patch)
tree1ca4f101f56b50c08bc7383e622dc83582d50fbb
parentc0a0790ca48f3128242b3d322915a4cd2ffb1236 (diff)
Removes 'new' Wyrd instruction.
-rw-r--r--data/examples/blackjack/cards.fate38
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java3
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateLexer.g41
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateParser.g4128
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java65
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/AllocateCompiler.java18
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/util/registers/StackableRegisterContext.java17
-rw-r--r--src/core/src/tonkadur/wyrd/v1/lang/computation/GetAllocableAddress.java (renamed from src/core/src/tonkadur/wyrd/v1/lang/computation/New.java)10
-rw-r--r--src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptInteger.java8
-rw-r--r--src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptString.java8
-rw-r--r--src/core/src/tonkadur/wyrd/v1/lang/meta/ComputationVisitor.java6
-rw-r--r--src/core/src/tonkadur/wyrd/v1/lang/meta/InstructionVisitor.java3
-rw-r--r--src/json-export/src/tonkadur/jsonexport/ComputationCompiler.java4
-rw-r--r--src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java24
14 files changed, 231 insertions, 102 deletions
diff --git a/data/examples/blackjack/cards.fate b/data/examples/blackjack/cards.fate
index b4fa384..4f58c83 100644
--- a/data/examples/blackjack/cards.fate
+++ b/data/examples/blackjack/cards.fate
@@ -11,30 +11,32 @@
(set! card_generator
(lambda ( (string family) )
(list:map
- (lambda
- (
- (int number)
- (string family)
- )
- (struct:set_fields (default #card)
- (number (var number))
- (name
- (text
- (switch (var number)
- (1 Ace)
- (11 Jack)
- (12 Queen)
- (13 Kind)
- (cast string (var number))
+ (partial
+ (lambda
+ (
+ (string family)
+ (int number)
+ )
+ (struct:set_fields (default #card)
+ (number (var number))
+ (name
+ (text
+ (switch (var number)
+ (1 Ace)
+ (11 Jack)
+ (12 Queen)
+ (13 Kind)
+ (cast string (var number))
+ )
+ of (var family)
)
- of (var family)
)
+ (score (clamp 1 number 10))
)
- (score (clamp 1 number 10))
)
+ (var family)
)
(list:range 1 13 1)
- (var family)
)
)
)
diff --git a/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java b/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java
index 33fae6b..12188d2 100644
--- a/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java
+++ b/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java
@@ -46,6 +46,9 @@ public interface InstructionVisitor
public void visit_prompt_string (final PromptString n)
throws Throwable;
+ public void visit_prompt_command (final PromptCommand n)
+ throws Throwable;
+
public void visit_player_choice (final PlayerChoice n)
throws Throwable;
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4 b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
index e0711c8..4cb4774 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
@@ -133,6 +133,7 @@ TEXT_OPTION_KW: L_PAREN ('option'|'user'US'option'|'player'US'option') SEP+;
EVENT_OPTION_KW: L_PAREN ('event'|'user'US'event'|'player'US'event') SEP+;
PROMPT_STRING_KW: L_PAREN 'prompt'US'str''ing'?'!' SEP+;
PROMPT_INTEGER_KW: L_PAREN 'prompt'US'int''eger'?'!' SEP+;
+PROMPT_COMMAND_KW: L_PAREN 'prompt'US('cmd'|'command')'!' SEP+;
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
index e4132d2..52a661e 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
@@ -403,7 +403,7 @@ first_level_instruction
| DECLARE_GLOBAL_VARIABLE_KW
type WS+
name=identifier WS+
- value=computation WS*
+ value=computation[true] WS*
R_PAREN
{
final Origin start_origin, type_origin;
@@ -589,7 +589,7 @@ first_level_instruction
PARSER.add_local_variables(($variable_list.result).as_map());
}
WS*
- computation
+ computation[true]
WS*
R_PAREN
{
@@ -767,7 +767,7 @@ returns [Instruction result]
| DECLARE_LOCAL_VARIABLE_KW
type WS+
name=identifier WS+
- value=computation WS*
+ value=computation[true] WS*
R_PAREN
{
final Origin start_origin, type_origin;
@@ -826,7 +826,7 @@ returns [Instruction result]
);
}
- | DO_WHILE_KW computation WS*
+ | DO_WHILE_KW computation[true] WS*
{
PARSER.increment_breakable_levels();
PARSER.increment_continue_levels();
@@ -856,7 +856,7 @@ returns [Instruction result]
{
PARSER.increase_local_variables_hierarchy();
}
- pre=instruction WS* computation WS* post=instruction WS*
+ pre=instruction WS* computation[true] WS* post=instruction WS*
{
PARSER.increment_breakable_levels();
PARSER.increment_continue_levels();
@@ -884,7 +884,7 @@ returns [Instruction result]
);
}
- | FOR_EACH_KW coll=computation WS+ identifier
+ | FOR_EACH_KW coll=computation[true] WS+ identifier
{
final Variable new_variable;
final Type collection_type;
@@ -959,7 +959,7 @@ returns [Instruction result]
);
}
- | WHILE_KW computation WS*
+ | WHILE_KW computation[true] WS*
{
PARSER.increase_local_variables_hierarchy();
PARSER.increment_breakable_levels();
@@ -984,7 +984,7 @@ returns [Instruction result]
);
}
- | SWITCH_KW computation WS*
+ | SWITCH_KW computation[true] WS*
{
PARSER.increment_breakable_levels();
}
@@ -1015,7 +1015,7 @@ returns [Instruction result]
/******************************************************************************/
/**** IF ELSE *****************************************************************/
/******************************************************************************/
- | IF_KW computation WS*
+ | IF_KW computation[true] WS*
{
PARSER.increase_local_variables_hierarchy();
}
@@ -1037,7 +1037,7 @@ returns [Instruction result]
);
}
- | IF_ELSE_KW computation
+ | IF_ELSE_KW computation[true]
{
PARSER.increase_local_variables_hierarchy();
}
@@ -1075,7 +1075,7 @@ returns [Instruction result]
$result = ($instruction.result);
}
- | IMP_ASSERT_KW computation WS+ paragraph WS* R_PAREN
+ | IMP_ASSERT_KW computation[true] WS+ paragraph WS* R_PAREN
{
$result =
Assert.build
@@ -1094,7 +1094,7 @@ returns [Instruction result]
/**** STRUCTURES **************************************************************/
/******************************************************************************/
- | IMP_SET_FIELDS_KW computation WS* field_value_list WS* R_PAREN
+ | IMP_SET_FIELDS_KW computation[true] WS* field_value_list WS* R_PAREN
{
$result =
SetFields.build
@@ -1130,10 +1130,32 @@ returns [Instruction result]
);
}
+ | PROMPT_COMMAND_KW
+ targetv=computation[true] WS+
+ min_size=computation[true] WS+
+ max_size=computation[true] WS+
+ paragraph WS*
+ R_PAREN
+ {
+ $result =
+ PromptCommand.build
+ (
+ PARSER.get_origin_at
+ (
+ ($PROMPT_COMMAND_KW.getLine()),
+ ($PROMPT_COMMAND_KW.getCharPositionInLine())
+ ),
+ ($targetv.result),
+ ($min_size.result),
+ ($max_size.result),
+ ($paragraph.result)
+ );
+ }
+
| PROMPT_STRING_KW
- targetv=computation WS+
- min_size=computation WS+
- max_size=computation WS+
+ targetv=computation[true] WS+
+ min_size=computation[true] WS+
+ max_size=computation[true] WS+
paragraph WS*
R_PAREN
{
@@ -1153,9 +1175,9 @@ returns [Instruction result]
}
| PROMPT_INTEGER_KW
- targetv=computation WS+
- min_size=computation WS+
- max_size=computation WS+
+ targetv=computation[true] WS+
+ min_size=computation[true] WS+
+ max_size=computation[true] WS+
paragraph WS*
R_PAREN
{
@@ -1177,7 +1199,7 @@ returns [Instruction result]
/******************************************************************************/
/**** SEQUENCE CALL/JUMP ******************************************************/
/******************************************************************************/
- | VISIT_KW computation maybe_computation_list WS* R_PAREN
+ | VISIT_KW computation[true] maybe_computation_list WS* R_PAREN
{
final Origin origin;
final Computation sequence;
@@ -1228,7 +1250,7 @@ returns [Instruction result]
}
}
- | CONTINUE_AS_KW computation maybe_computation_list WS* R_PAREN
+ | CONTINUE_AS_KW computation[true] maybe_computation_list WS* R_PAREN
{
final Origin origin;
final Computation sequence;
@@ -1329,7 +1351,7 @@ returns [List<Cons<Computation, Instruction>> result]
(
(
(
- (L_PAREN WS* computation WS+)
+ (L_PAREN WS* computation[true] WS+)
{
condition = ($computation.result);
}
@@ -1379,7 +1401,7 @@ returns [List<Cons<Computation, Instruction>> result]
}
:
(
- L_PAREN WS* computation WS+
+ L_PAREN WS* computation[true] WS+
{
PARSER.increase_local_variables_hierarchy();
}
@@ -1525,7 +1547,7 @@ returns [Instruction result]
{
// PARSER.enable_restricted_variable_stack_of(pcd);
}
- computation WS*
+ computation[true] WS*
{
// PARSER.disable_restricted_stack_of(pcd);
}
@@ -1549,7 +1571,7 @@ returns [Instruction result]
{
// PARSER.enable_restricted_variable_stack_of(pcd);
}
- computation WS*
+ computation[true] WS*
{
// PARSER.disable_restricted_stack_of(pcd);
}
@@ -1589,7 +1611,7 @@ returns [Instruction result]
{
//PARSER.enable_restricted_variable_stack_of(pcd);
}
- computation WS*
+ computation[true] WS*
{
//PARSER.disable_restricted_stack_of(pcd);
}
@@ -1620,7 +1642,7 @@ returns [Instruction result]
}
choice_for_variable_list[pcd] WS*
R_PAREN WS*
- computation WS*
+ computation[true] WS*
l1=L_PAREN
choice_for_update_variable_list[pcd] WS*
R_PAREN WS*
@@ -1671,7 +1693,7 @@ returns [Instruction result]
//PARSER.enable_restricted_variable_stack_of(pcd);
PARSER.increase_local_variables_hierarchy();
}
- computation WS+
+ computation[true] WS+
{
}
identifier
@@ -1767,7 +1789,7 @@ returns [List<Cons<Computation, Instruction>> result]
(
(
(
- (L_PAREN WS* computation WS+)
+ (L_PAREN WS* computation[true] WS+)
{
condition = ($computation.result);
@@ -1818,7 +1840,7 @@ returns [List<Cons<Computation, Instruction>> result]
:
(
L_PAREN
- WS* computation
+ WS* computation[true]
{
// PARSER.disable_restricted_stack_of(pcd);
}
@@ -2050,7 +2072,7 @@ returns [List<Cons<Variable, Computation>> result]
}
)
)
- WS+ computation WS* R_PAREN
+ WS+ computation[true] WS* R_PAREN
{
final Variable v;
@@ -2122,7 +2144,7 @@ returns [List<Instruction> result]
}
)
)
- WS+ computation WS* R_PAREN
+ WS+ computation[true] WS* R_PAREN
{
$result.add
(
@@ -2198,7 +2220,7 @@ returns [List<Instruction> result]
}
)
)
- WS+ computation WS* R_PAREN
+ WS+ computation[true] WS* R_PAREN
{
final Variable new_var;
@@ -2336,7 +2358,7 @@ returns [List<Cons<Origin, Cons<String, Computation>>> result]
}
)
)
- computation WS* R_PAREN
+ computation[true] WS* R_PAREN
{
$result.add
(
@@ -2381,7 +2403,7 @@ catch [final Throwable e]
/**** VALUES ******************************************************************/
/******************************************************************************/
-computation
+computation [boolean allows_var_shorthand]
returns [Computation result]
@init
{
@@ -2390,7 +2412,11 @@ returns [Computation result]
:
word
{
- if ($word.result.matches("(-?)[0-9]+(\\.[0-9]+)?"))
+ if
+ (
+ !allows_var_shorthand
+ || $word.result.matches("(-?)[0-9]+(\\.[0-9]+)?")
+ )
{
$result = Constant.build(($word.origin), ($word.result));
}
@@ -2413,7 +2439,7 @@ returns [Computation result]
VariableFromWord.generate(PARSER, ($word.origin), ($word.result));
}
- | IGNORE_ERROR_KW word WS+ computation WS* R_PAREN
+ | IGNORE_ERROR_KW word WS+ computation[true] WS* R_PAREN
{
$result = ($computation.result);
/* TODO: temporarily disable an compiler error category */
@@ -2429,7 +2455,7 @@ returns [Computation result]
$result = ($sentence.result);
}
- | FIELD_ACCESS_KW word WS+ computation WS* R_PAREN
+ | FIELD_ACCESS_KW word WS+ computation[true] WS* R_PAREN
{
$result =
FieldAccess.build
@@ -2473,9 +2499,9 @@ returns [Computation result]
}
| SWITCH_KW
- target=computation WS*
+ target=computation[true] WS*
computation_switch_list WS*
- default_val=computation WS*
+ default_val=computation[true] WS*
R_PAREN
{
$result =
@@ -2517,7 +2543,7 @@ returns [Computation result]
PARSER.add_local_variables(($variable_list.result).as_map());
}
WS*
- computation
+ computation[true]
WS*
R_PAREN
{
@@ -2542,7 +2568,7 @@ returns [Computation result]
}
L_PAREN WS* let_variable_list WS* R_PAREN
WS*
- computation
+ computation[true]
WS*
R_PAREN
{
@@ -2565,7 +2591,7 @@ returns [Computation result]
);
}
- | CAST_KW type WS+ computation WS* R_PAREN
+ | CAST_KW type WS+ computation[true] WS* R_PAREN
{
$result =
Cast.build
@@ -2581,7 +2607,7 @@ returns [Computation result]
);
}
- | SET_FIELDS_KW computation WS* field_value_list WS* R_PAREN
+ | SET_FIELDS_KW computation[true] WS* field_value_list WS* R_PAREN
{
$result =
SetFieldsComputation.build
@@ -2710,7 +2736,7 @@ returns [List<Cons<Computation, Computation>> result]
(
(
(
- L_PAREN WS* c=computation WS+
+ L_PAREN WS* c=computation[true] WS+
)
{
condition = ($c.result);
@@ -2734,7 +2760,7 @@ returns [List<Cons<Computation, Computation>> result]
}
)
)
- v=computation WS* R_PAREN WS*
+ v=computation[true] WS* R_PAREN WS*
{
$result.add(new Cons(condition, ($v.result)));
}
@@ -2755,7 +2781,7 @@ returns [List<Cons<Computation, Computation>> result]
}
:
(
- L_PAREN WS* c=computation WS+ v=computation WS* R_PAREN WS*
+ L_PAREN WS* c=computation[true] WS+ v=computation[true] WS* R_PAREN WS*
{
$result.add(new Cons(($c.result), ($v.result)));
}
@@ -2776,7 +2802,7 @@ returns [List<Computation> result]
}
:
(WS+
- computation
+ computation[true]
{
($result).add(($computation.result));
}
@@ -2796,12 +2822,12 @@ returns [List<Computation> result]
$result = new ArrayList<Computation>();
}
:
- computation
+ computation[true]
{
($result).add(($computation.result));
}
(WS+
- computation
+ computation[true]
{
($result).add(($computation.result));
}
@@ -2824,7 +2850,7 @@ returns [List<Computation> result]
just_added_space = false;
}
:
- computation
+ computation[false]
{
if (($computation.result) instanceof Newline)
@@ -2862,7 +2888,7 @@ returns [List<Computation> result]
}
}
)*
- computation
+ computation[false]
{
if (($computation.result) instanceof Newline)
{
diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java
index 22767f0..85d0927 100644
--- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java
+++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java
@@ -27,7 +27,6 @@ import tonkadur.wyrd.v1.lang.computation.IfElseComputation;
import tonkadur.wyrd.v1.lang.computation.Size;
import tonkadur.wyrd.v1.lang.computation.GetLastChoiceIndex;
import tonkadur.wyrd.v1.lang.computation.ValueOf;
-import tonkadur.wyrd.v1.lang.computation.New;
import tonkadur.wyrd.v1.lang.instruction.AddTextOption;
import tonkadur.wyrd.v1.lang.instruction.AddEventOption;
@@ -35,6 +34,7 @@ import tonkadur.wyrd.v1.lang.instruction.Assert;
import tonkadur.wyrd.v1.lang.instruction.Display;
import tonkadur.wyrd.v1.lang.instruction.End;
import tonkadur.wyrd.v1.lang.instruction.Initialize;
+import tonkadur.wyrd.v1.lang.instruction.PromptCommand;
import tonkadur.wyrd.v1.lang.instruction.PromptInteger;
import tonkadur.wyrd.v1.lang.instruction.PromptString;
import tonkadur.wyrd.v1.lang.instruction.Remove;
@@ -1441,6 +1441,69 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor
}
@Override
+ public void visit_prompt_command
+ (
+ final tonkadur.fate.v1.lang.instruction.PromptCommand n
+ )
+ throws Throwable
+ {
+ /*
+ * Fate: (prompt_command target min max label)
+ * Wyrd: (prompt_command target min max label)
+ */
+ final ComputationCompiler target_cc, min_cc, max_cc, label_cc;
+
+ target_cc = new ComputationCompiler(compiler);
+ min_cc = new ComputationCompiler(compiler);
+ max_cc = new ComputationCompiler(compiler);
+ label_cc = new ComputationCompiler(compiler);
+
+ n.get_target().get_visited_by(target_cc);
+
+ if (target_cc.has_init())
+ {
+ result.add(target_cc.get_init());
+ }
+
+ n.get_min().get_visited_by(min_cc);
+
+ if (min_cc.has_init())
+ {
+ result.add(min_cc.get_init());
+ }
+
+ n.get_max().get_visited_by(max_cc);
+
+ if (max_cc.has_init())
+ {
+ result.add(max_cc.get_init());
+ }
+
+ n.get_label().get_visited_by(label_cc);
+
+ if (label_cc.has_init())
+ {
+ result.add(label_cc.get_init());
+ }
+
+ result.add
+ (
+ new PromptCommand
+ (
+ target_cc.get_computation(),
+ min_cc.get_computation(),
+ max_cc.get_computation(),
+ label_cc.get_computation()
+ )
+ );
+
+ target_cc.release_registers(result);
+ min_cc.release_registers(result);
+ max_cc.release_registers(result);
+ label_cc.release_registers(result);
+ }
+
+ @Override
public void visit_prompt_integer
(
final tonkadur.fate.v1.lang.instruction.PromptInteger n
diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/AllocateCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/AllocateCompiler.java
index dbf4a98..42d5808 100644
--- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/AllocateCompiler.java
+++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/instruction/generic/AllocateCompiler.java
@@ -3,9 +3,12 @@ package tonkadur.wyrd.v1.compiler.fate.v1.instruction.generic;
import tonkadur.fate.v1.lang.instruction.generic.Allocate;
import tonkadur.wyrd.v1.lang.computation.Address;
-import tonkadur.wyrd.v1.lang.computation.New;
+import tonkadur.wyrd.v1.lang.computation.GetAllocableAddress;
import tonkadur.wyrd.v1.lang.instruction.SetValue;
+import tonkadur.wyrd.v1.lang.instruction.Initialize;
+
+import tonkadur.wyrd.v1.lang.type.Type;
import tonkadur.wyrd.v1.compiler.fate.v1.Compiler;
import tonkadur.wyrd.v1.compiler.fate.v1.TypeCompiler;
@@ -35,6 +38,7 @@ public class AllocateCompiler extends GenericInstructionCompiler
final Allocate source;
final ComputationCompiler cc;
final Address target;
+ final Type t;
source = (Allocate) instruction;
@@ -61,14 +65,10 @@ public class AllocateCompiler extends GenericInstructionCompiler
System.exit(-1);
}
- result.add
- (
- new SetValue
- (
- target,
- new New(TypeCompiler.compile(compiler, source.get_allocated_type()))
- )
- );
+ t = TypeCompiler.compile(compiler, source.get_allocated_type());
+
+ result.add(new SetValue(target, new GetAllocableAddress(t)));
+ result.add(new Initialize(target, t));
cc.release_registers(result);
}
diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/StackableRegisterContext.java b/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/StackableRegisterContext.java
index 83594b5..0b3ce45 100644
--- a/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/StackableRegisterContext.java
+++ b/src/core/src/tonkadur/wyrd/v1/compiler/util/registers/StackableRegisterContext.java
@@ -12,11 +12,11 @@ import tonkadur.wyrd.v1.lang.meta.Computation;
import tonkadur.wyrd.v1.lang.meta.Instruction;
import tonkadur.wyrd.v1.lang.computation.Address;
+import tonkadur.wyrd.v1.lang.computation.Cast;
+import tonkadur.wyrd.v1.lang.computation.Constant;
+import tonkadur.wyrd.v1.lang.computation.GetAllocableAddress;
import tonkadur.wyrd.v1.lang.computation.Operation;
import tonkadur.wyrd.v1.lang.computation.RelativeAddress;
-import tonkadur.wyrd.v1.lang.computation.Constant;
-import tonkadur.wyrd.v1.lang.computation.Cast;
-import tonkadur.wyrd.v1.lang.computation.New;
import tonkadur.wyrd.v1.lang.computation.ValueOf;
import tonkadur.wyrd.v1.lang.instruction.SetValue;
@@ -122,7 +122,16 @@ class StackableRegisterContext extends RegisterContext
new SetValue
(
current_context_address_holder,
- new New(DictType.WILD)
+ new GetAllocableAddress(DictType.WILD)
+ )
+ );
+
+ result.add
+ (
+ new Initialize
+ (
+ new Address(new ValueOf(current_context_address_holder), DictType.WILD),
+ DictType.WILD
)
);
diff --git a/src/core/src/tonkadur/wyrd/v1/lang/computation/New.java b/src/core/src/tonkadur/wyrd/v1/lang/computation/GetAllocableAddress.java
index c9bcdd8..ad94da3 100644
--- a/src/core/src/tonkadur/wyrd/v1/lang/computation/New.java
+++ b/src/core/src/tonkadur/wyrd/v1/lang/computation/GetAllocableAddress.java
@@ -1,14 +1,12 @@
package tonkadur.wyrd.v1.lang.computation;
-import java.util.List;
-
import tonkadur.wyrd.v1.lang.type.Type;
import tonkadur.wyrd.v1.lang.type.PointerType;
import tonkadur.wyrd.v1.lang.meta.Computation;
import tonkadur.wyrd.v1.lang.meta.ComputationVisitor;
-public class New extends Computation
+public class GetAllocableAddress extends Computation
{
/***************************************************************************/
/**** MEMBERS **************************************************************/
@@ -19,7 +17,7 @@ public class New extends Computation
/**** PUBLIC ***************************************************************/
/***************************************************************************/
/**** Constructors *********************************************************/
- public New (final Type target_type)
+ public GetAllocableAddress (final Type target_type)
{
super(new PointerType(target_type));
@@ -36,7 +34,7 @@ public class New extends Computation
public void get_visited_by (final ComputationVisitor cv)
throws Throwable
{
- cv.visit_new(this);
+ cv.visit_get_allocable_address(this);
}
/**** Misc. ****************************************************************/
@@ -47,7 +45,7 @@ public class New extends Computation
sb = new StringBuilder();
- sb.append("(New ");
+ sb.append("(GetAllocableAddress ");
sb.append(target_type.toString());
sb.append(")");
diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptInteger.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptInteger.java
index cb01cf2..7d1ee59 100644
--- a/src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptInteger.java
+++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptInteger.java
@@ -31,22 +31,22 @@ public class PromptInteger extends Instruction
}
/**** Accessors ************************************************************/
- public Computation get_target()
+ public Computation get_target ()
{
return target;
}
- public Computation get_min()
+ public Computation get_min ()
{
return min;
}
- public Computation get_max()
+ public Computation get_max ()
{
return max;
}
- public Computation get_label()
+ public Computation get_label ()
{
return label;
}
diff --git a/src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptString.java b/src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptString.java
index 0c825b6..1c00516 100644
--- a/src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptString.java
+++ b/src/core/src/tonkadur/wyrd/v1/lang/instruction/PromptString.java
@@ -31,22 +31,22 @@ public class PromptString extends Instruction
}
/**** Accessors ************************************************************/
- public Computation get_target()
+ public Computation get_target ()
{
return target;
}
- public Computation get_min()
+ public Computation get_min ()
{
return min;
}
- public Computation get_max()
+ public Computation get_max ()
{
return max;
}
- public Computation get_label()
+ public Computation get_label ()
{
return label;
}
diff --git a/src/core/src/tonkadur/wyrd/v1/lang/meta/ComputationVisitor.java b/src/core/src/tonkadur/wyrd/v1/lang/meta/ComputationVisitor.java
index d1fefb8..ba04225 100644
--- a/src/core/src/tonkadur/wyrd/v1/lang/meta/ComputationVisitor.java
+++ b/src/core/src/tonkadur/wyrd/v1/lang/meta/ComputationVisitor.java
@@ -19,9 +19,6 @@ public interface ComputationVisitor
public void visit_if_else_computation (final IfElseComputation n)
throws Throwable;
- public void visit_new (final New n)
- throws Throwable;
-
public void visit_newline (final Newline n)
throws Throwable;
@@ -34,6 +31,9 @@ public interface ComputationVisitor
public void visit_relative_address (final RelativeAddress n)
throws Throwable;
+ public void visit_get_allocable_address (final GetAllocableAddress n)
+ throws Throwable;
+
public void visit_get_last_choice_index (final GetLastChoiceIndex n)
throws Throwable;
diff --git a/src/core/src/tonkadur/wyrd/v1/lang/meta/InstructionVisitor.java b/src/core/src/tonkadur/wyrd/v1/lang/meta/InstructionVisitor.java
index e398de6..065037f 100644
--- a/src/core/src/tonkadur/wyrd/v1/lang/meta/InstructionVisitor.java
+++ b/src/core/src/tonkadur/wyrd/v1/lang/meta/InstructionVisitor.java
@@ -31,6 +31,9 @@ public interface InstructionVisitor
public void visit_set_pc (final SetPC n)
throws Throwable;
+ public void visit_prompt_command (final PromptCommand n)
+ throws Throwable;
+
public void visit_prompt_integer (final PromptInteger n)
throws Throwable;
diff --git a/src/json-export/src/tonkadur/jsonexport/ComputationCompiler.java b/src/json-export/src/tonkadur/jsonexport/ComputationCompiler.java
index 4db47a9..538fbde 100644
--- a/src/json-export/src/tonkadur/jsonexport/ComputationCompiler.java
+++ b/src/json-export/src/tonkadur/jsonexport/ComputationCompiler.java
@@ -99,12 +99,12 @@ public class ComputationCompiler implements ComputationVisitor
result.put("if_false", if_false_cc.get_result());
}
- public void visit_new (final New n)
+ public void visit_get_allocable_address (final GetAllocableAddress n)
throws Throwable
{
result = new JSONObject();
- result.put("category", "new");
+ result.put("category", "get_allocable_address");
result.put("target", Translator.compile_type(n.get_target_type()));
}
diff --git a/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java b/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java
index d33901d..c23b5b1 100644
--- a/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java
+++ b/src/json-export/src/tonkadur/jsonexport/InstructionCompiler.java
@@ -190,6 +190,30 @@ public class InstructionCompiler implements InstructionVisitor
result.put("type", Translator.compile_type(n.get_type()));
}
+ public void visit_prompt_command (final PromptCommand n)
+ throws Throwable
+ {
+ final ComputationCompiler target_cc, min_cc, max_cc, label_cc;
+
+ target_cc = new ComputationCompiler();
+ min_cc = new ComputationCompiler();
+ max_cc = new ComputationCompiler();
+ label_cc = new ComputationCompiler();
+
+ n.get_target().get_visited_by(target_cc);
+ n.get_min().get_visited_by(min_cc);
+ n.get_max().get_visited_by(max_cc);
+ n.get_label().get_visited_by(label_cc);
+
+ result = new JSONObject();
+
+ result.put("category", "prompt_command");
+ result.put("target", target_cc.get_result());
+ result.put("min", min_cc.get_result());
+ result.put("max", max_cc.get_result());
+ result.put("label", label_cc.get_result());
+ }
+
public void visit_prompt_integer (final PromptInteger n)
throws Throwable
{