summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-08-31 00:44:25 +0200
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2020-08-31 00:44:25 +0200
commit0ebd88472a6bd195f2f5ff34165c7fa79053105d (patch)
tree8488f24e7cb16c7ed589703361ce9604c317520a /src
parent23c5a3b1bd89e7a394a4cc4881e0764d601632c7 (diff)
Adds more list instr, Blackjack example.
Diffstat (limited to 'src')
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/World.java1
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/IsEmpty.java97
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/ValueToRichText.java6
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/AddElementAt.java199
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/AddElementsOf.java170
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/meta/ComputationVisitor.java3
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java6
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateLexer.g45
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateParser.g445
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java19
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/InstructionCompiler.java123
-rw-r--r--src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/TypeCompiler.java28
12 files changed, 673 insertions, 29 deletions
diff --git a/src/core/src/tonkadur/fate/v1/lang/World.java b/src/core/src/tonkadur/fate/v1/lang/World.java
index 893b0e6..047f1d5 100644
--- a/src/core/src/tonkadur/fate/v1/lang/World.java
+++ b/src/core/src/tonkadur/fate/v1/lang/World.java
@@ -284,6 +284,7 @@ public class World
//type_collection.add(Type.LIST);
//type_collection.add(Type.SET);
type_collection.add(Type.STRING);
+ type_collection.add(Type.RICH_TEXT);
}
catch (final Throwable t)
{
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/IsEmpty.java b/src/core/src/tonkadur/fate/v1/lang/computation/IsEmpty.java
new file mode 100644
index 0000000..66d40f0
--- /dev/null
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/IsEmpty.java
@@ -0,0 +1,97 @@
+package tonkadur.fate.v1.lang.computation;
+
+import tonkadur.error.ErrorManager;
+
+import tonkadur.parser.Origin;
+
+import tonkadur.fate.v1.error.InvalidTypeException;
+
+import tonkadur.fate.v1.lang.type.CollectionType;
+import tonkadur.fate.v1.lang.type.Type;
+
+import tonkadur.fate.v1.lang.meta.ComputationVisitor;
+import tonkadur.fate.v1.lang.meta.Computation;
+
+public class IsEmpty extends Computation
+{
+ /***************************************************************************/
+ /**** MEMBERS **************************************************************/
+ /***************************************************************************/
+ protected final Computation collection;
+
+ /***************************************************************************/
+ /**** PROTECTED ************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ protected IsEmpty
+ (
+ final Origin origin,
+ final Computation collection
+ )
+ {
+ super(origin, Type.BOOL);
+
+ this.collection = collection;
+ }
+
+ /***************************************************************************/
+ /**** PUBLIC ***************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ public static IsEmpty build
+ (
+ final Origin origin,
+ final Computation collection
+ )
+ throws InvalidTypeException
+ {
+
+ if (!(collection.get_type() instanceof CollectionType))
+ {
+ ErrorManager.handle
+ (
+ new InvalidTypeException
+ (
+ collection.get_origin(),
+ collection.get_type(),
+ Type.COLLECTION_TYPES
+ )
+ );
+ }
+
+ return new IsEmpty(origin, collection);
+ }
+
+ /**** Accessors ************************************************************/
+ @Override
+ public void get_visited_by (final ComputationVisitor cv)
+ throws Throwable
+ {
+ cv.visit_is_empty(this);
+ }
+
+ public Computation get_collection ()
+ {
+ return collection;
+ }
+
+ /**** Misc. ****************************************************************/
+ @Override
+ public String toString ()
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append(origin.toString());
+ sb.append("(IsEmpty");
+ sb.append(System.lineSeparator());
+ sb.append(System.lineSeparator());
+
+ sb.append("collection:");
+ sb.append(System.lineSeparator());
+ sb.append(collection.toString());
+
+ sb.append(")");
+
+ return sb.toString();
+ }
+}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/ValueToRichText.java b/src/core/src/tonkadur/fate/v1/lang/computation/ValueToRichText.java
index 43c8371..b21024b 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/ValueToRichText.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/ValueToRichText.java
@@ -42,7 +42,11 @@ public class ValueToRichText extends RichTextNode
value_base_type = value.get_type().get_base_type();
- if (value_base_type.equals(Type.STRING))
+ if
+ (
+ value_base_type.equals(Type.STRING)
+ || value_base_type.equals(Type.RICH_TEXT)
+ )
{
return new ValueToRichText(value);
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/AddElementAt.java b/src/core/src/tonkadur/fate/v1/lang/instruction/AddElementAt.java
new file mode 100644
index 0000000..4cd192f
--- /dev/null
+++ b/src/core/src/tonkadur/fate/v1/lang/instruction/AddElementAt.java
@@ -0,0 +1,199 @@
+package tonkadur.fate.v1.lang.instruction;
+
+import java.util.Collections;
+
+import tonkadur.error.ErrorManager;
+
+import tonkadur.parser.Origin;
+
+import tonkadur.fate.v1.error.ConflictingTypeException;
+import tonkadur.fate.v1.error.IncomparableTypeException;
+import tonkadur.fate.v1.error.InvalidTypeException;
+
+import tonkadur.fate.v1.lang.type.CollectionType;
+import tonkadur.fate.v1.lang.type.Type;
+
+import tonkadur.fate.v1.lang.meta.InstructionVisitor;
+import tonkadur.fate.v1.lang.meta.Instruction;
+import tonkadur.fate.v1.lang.meta.Computation;
+
+public class AddElementAt extends Instruction
+{
+ /***************************************************************************/
+ /**** MEMBERS **************************************************************/
+ /***************************************************************************/
+ protected final Computation index;
+ protected final Computation element;
+ protected final Computation collection;
+
+ /***************************************************************************/
+ /**** PROTECTED ************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ protected AddElementAt
+ (
+ final Origin origin,
+ final Computation index,
+ final Computation element,
+ final Computation collection
+ )
+ {
+ super(origin);
+
+ this.index = index;
+ this.collection = collection;
+ this.element = element;
+ }
+
+ /***************************************************************************/
+ /**** PUBLIC ***************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ public static AddElementAt build
+ (
+ final Origin origin,
+ final Computation index,
+ final Computation element,
+ final Computation collection
+ )
+ throws
+ InvalidTypeException,
+ ConflictingTypeException,
+ IncomparableTypeException
+ {
+ final Type hint;
+ final Type collection_type;
+ final CollectionType collection_true_type;
+ final Type collection_element_type;
+
+ collection_type = collection.get_type();
+
+ if
+ (
+ (!(collection_type instanceof CollectionType))
+ || (((CollectionType) collection_type).is_set())
+ )
+ {
+ ErrorManager.handle
+ (
+ new InvalidTypeException
+ (
+ collection.get_origin(),
+ collection.get_type(),
+ Collections.singletonList(Type.LIST)
+ )
+ );
+ }
+
+ if (!index.get_type().can_be_used_as(Type.INT))
+ {
+ ErrorManager.handle
+ (
+ new InvalidTypeException
+ (
+ index.get_origin(),
+ index.get_type(),
+ Collections.singletonList(Type.INT)
+ )
+ );
+ }
+
+ collection_true_type = (CollectionType) collection_type;
+ collection_element_type = collection_true_type.get_content_type();
+
+ if
+ (
+ element.get_type().can_be_used_as(collection_element_type)
+ ||
+ (element.get_type().try_merging_with(collection_element_type) != null)
+ )
+ {
+ return new AddElementAt(origin, index, element, collection);
+ }
+
+ ErrorManager.handle
+ (
+ new ConflictingTypeException
+ (
+ element.get_origin(),
+ element.get_type(),
+ collection_element_type
+ )
+ );
+
+ hint =
+ (Type) element.get_type().generate_comparable_to
+ (
+ collection_element_type
+ );
+
+ if (hint.equals(Type.ANY))
+ {
+ ErrorManager.handle
+ (
+ new IncomparableTypeException
+ (
+ element.get_origin(),
+ element.get_type(),
+ collection_element_type
+ )
+ );
+ }
+
+ return new AddElementAt(origin, index, element, collection);
+ }
+
+ /**** Accessors ************************************************************/
+ @Override
+ public void get_visited_by (final InstructionVisitor iv)
+ throws Throwable
+ {
+ iv.visit_add_element_at(this);
+ }
+
+ public Computation get_collection ()
+ {
+ return collection;
+ }
+
+ public Computation get_index ()
+ {
+ return index;
+ }
+
+ public Computation get_element ()
+ {
+ return element;
+ }
+
+ /**** Misc. ****************************************************************/
+ @Override
+ public String toString ()
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append("(AddElementAt");
+ sb.append(System.lineSeparator());
+ sb.append(System.lineSeparator());
+
+ sb.append("index:");
+ sb.append(System.lineSeparator());
+ sb.append(index.toString());
+ sb.append(System.lineSeparator());
+ sb.append(System.lineSeparator());
+
+ sb.append("element:");
+ sb.append(System.lineSeparator());
+ sb.append(element.toString());
+ sb.append(System.lineSeparator());
+ sb.append(System.lineSeparator());
+
+ sb.append("collection:");
+ sb.append(System.lineSeparator());
+ sb.append(collection.toString());
+
+ sb.append(")");
+
+ return sb.toString();
+ }
+}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/AddElementsOf.java b/src/core/src/tonkadur/fate/v1/lang/instruction/AddElementsOf.java
new file mode 100644
index 0000000..7409b2b
--- /dev/null
+++ b/src/core/src/tonkadur/fate/v1/lang/instruction/AddElementsOf.java
@@ -0,0 +1,170 @@
+package tonkadur.fate.v1.lang.instruction;
+
+import tonkadur.error.ErrorManager;
+
+import tonkadur.parser.Origin;
+
+import tonkadur.fate.v1.error.ConflictingTypeException;
+import tonkadur.fate.v1.error.IncomparableTypeException;
+import tonkadur.fate.v1.error.InvalidTypeException;
+
+import tonkadur.fate.v1.lang.type.CollectionType;
+import tonkadur.fate.v1.lang.type.Type;
+
+import tonkadur.fate.v1.lang.meta.InstructionVisitor;
+import tonkadur.fate.v1.lang.meta.Instruction;
+import tonkadur.fate.v1.lang.meta.Reference;
+
+public class AddElementsOf extends Instruction
+{
+ /***************************************************************************/
+ /**** MEMBERS **************************************************************/
+ /***************************************************************************/
+ protected final Reference other_collection;
+ protected final Reference collection;
+
+ /***************************************************************************/
+ /**** PROTECTED ************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ protected AddElementsOf
+ (
+ final Origin origin,
+ final Reference other_collection,
+ final Reference collection
+ )
+ {
+ super(origin);
+
+ this.collection = collection;
+ this.other_collection = other_collection;
+ }
+
+ /***************************************************************************/
+ /**** PUBLIC ***************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ public static AddElementsOf build
+ (
+ final Origin origin,
+ final Reference other_collection,
+ final Reference collection
+ )
+ throws
+ InvalidTypeException,
+ ConflictingTypeException,
+ IncomparableTypeException
+ {
+ final Type hint;
+ final Type collection_type, other_collection_type;
+
+ collection_type = collection.get_type();
+ other_collection_type = other_collection.get_type();
+
+ if (!(collection_type instanceof CollectionType))
+ {
+ ErrorManager.handle
+ (
+ new InvalidTypeException
+ (
+ collection.get_origin(),
+ collection_type,
+ Type.COLLECTION_TYPES
+ )
+ );
+ }
+
+ if (!(other_collection_type instanceof CollectionType))
+ {
+ ErrorManager.handle
+ (
+ new InvalidTypeException
+ (
+ other_collection.get_origin(),
+ other_collection_type,
+ Type.COLLECTION_TYPES
+ )
+ );
+ }
+
+ if (other_collection_type.can_be_used_as(collection_type))
+ {
+ return new AddElementsOf(origin, other_collection, collection);
+ }
+
+ ErrorManager.handle
+ (
+ new ConflictingTypeException
+ (
+ other_collection.get_origin(),
+ other_collection_type,
+ collection_type
+ )
+ );
+
+ hint =
+ (Type) other_collection.get_type().generate_comparable_to
+ (
+ collection_type
+ );
+
+ if (hint.equals(Type.ANY))
+ {
+ ErrorManager.handle
+ (
+ new IncomparableTypeException
+ (
+ other_collection.get_origin(),
+ other_collection_type,
+ collection_type
+ )
+ );
+ }
+
+ return new AddElementsOf(origin, other_collection, collection);
+ }
+
+ /**** Accessors ************************************************************/
+ @Override
+ public void get_visited_by (final InstructionVisitor iv)
+ throws Throwable
+ {
+ iv.visit_add_elements_of(this);
+ }
+
+ public Reference get_source_collection ()
+ {
+ return other_collection;
+ }
+
+ public Reference get_target_collection ()
+ {
+ return collection;
+ }
+
+ /**** Misc. ****************************************************************/
+ @Override
+ public String toString ()
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append(origin.toString());
+ sb.append("(AddElementsOf");
+ sb.append(System.lineSeparator());
+ sb.append(System.lineSeparator());
+
+ sb.append("other_collection:");
+ sb.append(System.lineSeparator());
+ sb.append(other_collection.toString());
+ sb.append(System.lineSeparator());
+ sb.append(System.lineSeparator());
+
+ sb.append("collection:");
+ sb.append(System.lineSeparator());
+ sb.append(collection.toString());
+
+ sb.append(")");
+
+ return sb.toString();
+ }
+}
diff --git a/src/core/src/tonkadur/fate/v1/lang/meta/ComputationVisitor.java b/src/core/src/tonkadur/fate/v1/lang/meta/ComputationVisitor.java
index 09b9135..1cdbcf5 100644
--- a/src/core/src/tonkadur/fate/v1/lang/meta/ComputationVisitor.java
+++ b/src/core/src/tonkadur/fate/v1/lang/meta/ComputationVisitor.java
@@ -52,6 +52,9 @@ public interface ComputationVisitor
public void visit_let (final Let n)
throws Throwable;
+ public void visit_is_empty (final IsEmpty n)
+ throws Throwable;
+
public void visit_newline (final Newline n)
throws Throwable;
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 6e0da72..30acc7d 100644
--- a/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java
+++ b/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java
@@ -8,6 +8,12 @@ public interface InstructionVisitor
public void visit_add_element (final AddElement ae)
throws Throwable;
+ public void visit_add_element_at (final AddElementAt n)
+ throws Throwable;
+
+ public void visit_add_elements_of (final AddElementsOf n)
+ throws Throwable;
+
public void visit_assert (final Assert a)
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 271a766..03014ac 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateLexer.g4
@@ -17,6 +17,8 @@ R_PAREN: ')';
ABS_KW: L_PAREN 'abs'('olute'?) SEP+;
ACCESS_KW: L_PAREN 'access' SEP+;
ADD_KW: L_PAREN 'add'(US'element')? SEP+;
+ADD_AT_KW: L_PAREN 'add'(US'element')?US'at' SEP+;
+ADD_ALL_KW: L_PAREN 'add'US'all'(US'elements')? SEP+;
AND_KW: L_PAREN ('and'|'/\\') SEP+;
ASSERT_KW: L_PAREN 'assert' SEP+;
AT_KW: L_PAREN 'at' SEP+;
@@ -28,7 +30,7 @@ COUNT_KW: L_PAREN 'count' SEP+;
DECLARE_ALIAS_TYPE_KW:
L_PAREN ((('declare'|'define'|'def')US(('sub'|'alias')US)?'type')|'typedef') SEP+;
DECLARE_DICT_TYPE_KW: L_PAREN
-('declare'|'define'|'def')US('dict'|('struct''ure'?))(US'type')? SEP+;
+ ('declare'|'define'|'def')US('dict'|('struct''ure'?))(US'type')? SEP+;
DECLARE_EVENT_TYPE_KW: L_PAREN ('declare'|'define'|'def')US'event'(US'type')? SEP+;
DECLARE_TEXT_EFFECT_KW: L_PAREN ('declare'|'define'|'def')US'text'US'effect' SEP+;
DECLARE_VARIABLE_KW: L_PAREN 'global' SEP+;
@@ -58,6 +60,7 @@ IMPLIES_KW: L_PAREN ('implies'|'=>'|'->') SEP+;
INCLUDE_KW: L_PAREN 'include' SEP+;
INDEX_OF_KW: L_PAREN ('index'US'of') SEP+;
IS_MEMBER_KW: L_PAREN ('is'US'member'|'contains'|'has') SEP+;
+IS_EMPTY_KW: L_PAREN 'is'US'empty' SEP+;
LOWER_EQUAL_THAN_KW: L_PAREN ('lower'US'equal'US'than'|'=<'|'<='|'le') SEP+;
LOWER_THAN_KW: L_PAREN ('lower'US'than'|'<'|'lt') SEP+;
LET_KW: L_PAREN 'let' SEP+;
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
index 4c0a7a0..4cf3f8f 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
@@ -571,6 +571,37 @@ returns [Instruction result]
);
}
+ | ADD_AT_KW index=value WS+ element=value WS+ value_reference WS* R_PAREN
+ {
+ $result =
+ AddElementAt.build
+ (
+ CONTEXT.get_origin_at
+ (
+ ($ADD_AT_KW.getLine()),
+ ($ADD_AT_KW.getCharPositionInLine())
+ ),
+ ($index.result),
+ ($element.result),
+ ($value_reference.result)
+ );
+ }
+
+ | ADD_ALL_KW source=value_reference WS+ target=value_reference WS* R_PAREN
+ {
+ $result =
+ AddElementsOf.build
+ (
+ CONTEXT.get_origin_at
+ (
+ ($ADD_ALL_KW.getLine()),
+ ($ADD_ALL_KW.getCharPositionInLine())
+ ),
+ ($source.result),
+ ($target.result)
+ );
+ }
+
| END_KW
{
$result =
@@ -2247,6 +2278,20 @@ returns [Computation result]:
);
}
+ | IS_EMPTY_KW value_reference WS* R_PAREN
+ {
+ $result =
+ IsEmpty.build
+ (
+ CONTEXT.get_origin_at
+ (
+ ($IS_EMPTY_KW.getLine()),
+ ($IS_EMPTY_KW.getCharPositionInLine())
+ ),
+ ($value_reference.result)
+ );
+ }
+
| INDEX_OF_KW value WS+ value_reference WS* R_PAREN
{
$result =
diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java
index f30d433..996a246 100644
--- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java
+++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/ComputationCompiler.java
@@ -1229,6 +1229,25 @@ implements tonkadur.fate.v1.lang.meta.ComputationVisitor
}
@Override
+ public void visit_is_empty
+ (
+ final tonkadur.fate.v1.lang.computation.IsEmpty n
+ )
+ throws Throwable
+ {
+ final ComputationCompiler cc;
+
+ cc = new ComputationCompiler(compiler);
+
+ n.get_collection().get_visited_by(cc);
+
+ assimilate(cc);
+
+ result_as_computation =
+ Operation.equals(new Size(cc.get_address()), Constant.ZERO);
+ }
+
+ @Override
public void visit_index_of_operator
(
final tonkadur.fate.v1.lang.computation.IndexOfOperator n
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 deb0772..55ff4a2 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
@@ -23,6 +23,7 @@ import tonkadur.wyrd.v1.lang.computation.Constant;
import tonkadur.wyrd.v1.lang.computation.Operation;
import tonkadur.wyrd.v1.lang.computation.Address;
import tonkadur.wyrd.v1.lang.computation.RelativeAddress;
+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;
@@ -248,6 +249,128 @@ implements tonkadur.fate.v1.lang.meta.InstructionVisitor
}
@Override
+ public void visit_add_elements_of
+ (
+ final tonkadur.fate.v1.lang.instruction.AddElementsOf n
+ )
+ throws Throwable
+ {
+ final tonkadur.fate.v1.lang.meta.Instruction as_fate;
+
+
+ as_fate =
+ new tonkadur.fate.v1.lang.instruction.ForEach
+ (
+ n.get_origin(),
+ n.get_source_collection(),
+ ".secret var of doom",
+ Collections.singletonList
+ (
+ tonkadur.fate.v1.lang.instruction.AddElement.build
+ (
+ n.get_origin(),
+ new tonkadur.fate.v1.lang.computation.VariableReference
+ (
+ n.get_origin(),
+ new tonkadur.fate.v1.lang.Variable
+ (
+ n.get_origin(),
+ (
+ (tonkadur.fate.v1.lang.type.CollectionType)
+ n.get_source_collection().get_type()
+ ).get_content_type(),
+ ".secret var of doom"
+ )
+ ),
+ n.get_target_collection()
+ )
+ )
+ );
+
+ as_fate.get_visited_by(this);
+ }
+
+ @Override
+ public void visit_add_element_at
+ (
+ final tonkadur.fate.v1.lang.instruction.AddElementAt n
+ )
+ throws Throwable
+ {
+ final Address collection_as_address;
+ final ComputationCompiler index_compiler, element_compiler;
+ final ComputationCompiler collection_compiler;
+ final Register index_holder;
+
+ index_holder = compiler.registers().reserve(Type.INT);
+
+ index_compiler = new ComputationCompiler(compiler);
+
+ n.get_index().get_visited_by(index_compiler);
+
+ if (index_compiler.has_init())
+ {
+ result.add(index_compiler.get_init());
+ }
+
+
+ element_compiler = new ComputationCompiler(compiler);
+
+ n.get_element().get_visited_by(element_compiler);
+
+ if (element_compiler.has_init())
+ {
+ result.add(element_compiler.get_init());
+ }
+
+ collection_compiler = new ComputationCompiler(compiler);
+
+ n.get_collection().get_visited_by(collection_compiler);
+
+ if (collection_compiler.has_init())
+ {
+ result.add(collection_compiler.get_init());
+ }
+
+ result.add
+ (
+ new SetValue
+ (
+ index_holder.get_address(),
+ new IfElseComputation
+ (
+ Operation.greater_than
+ (
+ index_compiler.get_computation(),
+ new Size(collection_compiler.get_address())
+ ),
+ new Size(collection_compiler.get_address()),
+ index_compiler.get_computation()
+ )
+ )
+ );
+
+ result.add
+ (
+ InsertAt.generate
+ (
+ compiler.registers(),
+ compiler.assembler(),
+ index_holder.get_address(),
+ element_compiler.get_computation(),
+ new Size(collection_compiler.get_address()),
+ collection_compiler.get_address()
+ )
+ );
+
+ compiler.registers().release(index_holder);
+
+ index_compiler.release_registers();
+ element_compiler.release_registers();
+ collection_compiler.release_registers();
+ }
+
+ @Override
public void visit_add_element
(
final tonkadur.fate.v1.lang.instruction.AddElement ae
diff --git a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/TypeCompiler.java b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/TypeCompiler.java
index 177be18..3792080 100644
--- a/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/TypeCompiler.java
+++ b/src/core/src/tonkadur/wyrd/v1/compiler/fate/v1/TypeCompiler.java
@@ -176,32 +176,6 @@ public class TypeCompiler
return MapType.MAP_TO_INT;
}
- if (fate_content_type instanceof tonkadur.fate.v1.lang.type.PointerType)
- {
- return
- new MapType
- (
- new PointerType
- (
- compile
- (
- compiler,
- (
- (tonkadur.fate.v1.lang.type.PointerType)
- fate_content_type
- ).get_referenced_type()
- )
- )
- );
- }
-
- System.err.println
- (
- "[P] Unknown collection member fate type '"
- + fate_content_type
- + "'."
- );
-
- return null;
+ return new MapType(compile(compiler, fate_content_type));
}
}