summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/Access.java139
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/AccessPointer.java144
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/AddElementAtComputation.java113
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/AddElementComputation.java94
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/AddElementsOfComputation.java104
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/AddressOperator.java60
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/CarCdr.java125
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/ConsComputation.java74
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/CountOperator.java98
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/ExtraComputationInstance.java4
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java20
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/FilterComputation.java136
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/Fold.java170
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/GenericComputation.java162
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/IndexOfOperator.java96
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/IndexedFilterComputation.java137
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/IndexedMapComputation.java140
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/IndexedMergeComputation.java242
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/IndexedPartitionComputation.java151
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/IsEmpty.java81
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/IsMemberOperator.java96
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/MapComputation.java144
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/MergeComputation.java233
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/Operation.java188
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/PartitionComputation.java149
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/PopElementComputation.java91
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/PushElementComputation.java116
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/Range.java109
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/RemoveAllOfElementComputation.java94
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/RemoveElementAtComputation.java98
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/RemoveElementComputation.java93
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/RemoveElementsOfComputation.java105
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/ReverseListComputation.java90
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/ShuffleComputation.java90
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/SizeOperator.java81
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/SortComputation.java129
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/SubListComputation.java100
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/TextJoin.java102
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/VariableReference.java8
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/generic/AddressOperator.java133
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/generic/AtReference.java (renamed from src/core/src/tonkadur/fate/v1/lang/computation/AtReference.java)79
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/generic/LambdaEvaluation.java (renamed from src/core/src/tonkadur/fate/v1/lang/computation/LambdaEvaluation.java)107
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/computation/generic/Operation.java628
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/AddElement.java96
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/AddElementAt.java114
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/AddElementsOf.java105
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/ExtraInstructionInstance.java4
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/Filter.java130
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/Free.java62
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/GenericInstruction.java160
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/IndexedFilter.java132
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMap.java130
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMerge.java216
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/IndexedPartition.java156
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/Map.java130
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/Merge.java210
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/Partition.java155
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/PopElement.java117
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/PushElement.java113
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/RemoveAllOfElement.java96
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/RemoveElement.java96
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/RemoveElementAt.java99
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/RemoveElementsOf.java105
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/ReverseList.java75
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/SetFields.java7
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/SetValue.java9
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/Shuffle.java75
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/Sort.java127
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/SubList.java101
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/generic/Allocate.java (renamed from src/core/src/tonkadur/fate/v1/lang/instruction/Allocate.java)79
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/generic/Clear.java (renamed from src/core/src/tonkadur/fate/v1/lang/instruction/Clear.java)66
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/instruction/generic/Free.java136
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/meta/Computation.java8
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/meta/ComputationVisitor.java123
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/meta/ExtraComputation.java6
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java81
-rw-r--r--src/core/src/tonkadur/fate/v1/lang/meta/VariableFromWord.java20
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/FateParser.g427
-rw-r--r--src/core/src/tonkadur/fate/v1/parser/Parser.java59
-rw-r--r--src/core/src/tonkadur/parser/Location.java7
-rw-r--r--src/core/src/tonkadur/parser/Origin.java6
81 files changed, 1619 insertions, 7172 deletions
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/Access.java b/src/core/src/tonkadur/fate/v1/lang/computation/Access.java
deleted file mode 100644
index 843874c..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/Access.java
+++ /dev/null
@@ -1,139 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-
-import tonkadur.error.ErrorManager;
-
-import tonkadur.fate.v1.error.InvalidTypeException;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Reference;
-
-import tonkadur.fate.v1.lang.type.CollectionType;
-import tonkadur.fate.v1.lang.type.Type;
-
-public class Access extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation parent;
- protected final Computation index;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Access
- (
- final Origin origin,
- final Computation parent,
- final Type type,
- final Computation index
- )
- {
- super(origin, type);
-
- this.parent = parent;
- this.index = index;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static Access build
- (
- final Origin origin,
- Computation parent,
- final Computation index
- )
- throws InvalidTypeException
- {
- Type current_type;
-
- current_type = parent.get_type();
-
- while (current_type.get_act_as_type().equals(Type.PTR))
- {
- parent = AtReference.build(origin, parent);
- current_type = parent.get_type();
- }
-
- if (!index.get_type().can_be_used_as(Type.INT))
- {
- ErrorManager.handle
- (
- new InvalidTypeException
- (
- index.get_origin(),
- current_type,
- Collections.singleton(Type.INT),
- index.toString()
- )
- );
- }
-
- if (!(current_type instanceof CollectionType))
- {
- ErrorManager.handle
- (
- new InvalidTypeException
- (
- origin,
- current_type,
- Collections.singleton(Type.LIST),
- parent.toString()
- )
- );
-
- current_type = Type.ANY;
- }
- else
- {
- current_type = ((CollectionType) current_type).get_content_type();
- }
-
- return new Access(origin, parent, current_type, index);
- }
-
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_access(this);
- }
-
- public Computation get_index ()
- {
- return index;
- }
-
- public Computation get_parent ()
- {
- return parent;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Access (");
- sb.append(type.get_name());
- sb.append(") ");
- sb.append(parent.toString());
- sb.append(".");
- sb.append(index.toString());
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/AccessPointer.java b/src/core/src/tonkadur/fate/v1/lang/computation/AccessPointer.java
deleted file mode 100644
index fbc2ab7..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/AccessPointer.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-
-import tonkadur.error.ErrorManager;
-
-import tonkadur.fate.v1.error.InvalidTypeException;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-
-import tonkadur.fate.v1.lang.type.CollectionType;
-import tonkadur.fate.v1.lang.type.PointerType;
-import tonkadur.fate.v1.lang.type.Type;
-
-public class AccessPointer extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation parent;
- protected final Computation index;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected AccessPointer
- (
- final Origin origin,
- final Computation parent,
- final Type type,
- final Computation index
- )
- {
- super
- (
- origin,
- new PointerType(origin, type, "(ptr " + type.toString() + ") autogen")
- );
-
- this.parent = parent;
- this.index = index;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static AccessPointer build
- (
- final Origin origin,
- Computation parent,
- final Computation index
- )
- throws InvalidTypeException
- {
- Type current_type;
-
- current_type = parent.get_type();
-
- while (current_type.get_act_as_type().equals(Type.PTR))
- {
- parent = AtComputation.build(origin, parent);
- current_type = parent.get_type();
- }
-
- if (!index.get_type().can_be_used_as(Type.INT))
- {
- ErrorManager.handle
- (
- new InvalidTypeException
- (
- index.get_origin(),
- current_type,
- Collections.singleton(Type.INT),
- index.toString()
- )
- );
- }
-
- if (!(current_type instanceof CollectionType))
- {
- ErrorManager.handle
- (
- new InvalidTypeException
- (
- origin,
- current_type,
- Collections.singleton(Type.LIST),
- parent.toString()
- )
- );
-
- current_type = Type.ANY;
- }
- else
- {
- current_type = ((CollectionType) current_type).get_content_type();
- }
-
- return new AccessPointer(origin, parent, current_type, index);
- }
-
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_access_pointer(this);
- }
-
- public Computation get_index ()
- {
- return index;
- }
-
- public Computation get_parent ()
- {
- return parent;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(AccessPointer (");
- sb.append(type.get_name());
- sb.append(") ");
- sb.append(parent.get_name());
- sb.append(".");
- sb.append(index.toString());
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/AddElementAtComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/AddElementAtComputation.java
deleted file mode 100644
index 2b0c06a..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/AddElementAtComputation.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class AddElementAtComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation index;
- protected final Computation element;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected AddElementAtComputation
- (
- final Origin origin,
- final Computation index,
- final Computation element,
- final Computation collection
- )
- {
- super(origin, collection.get_type());
-
- this.index = index;
- this.collection = collection;
- this.element = element;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static AddElementAtComputation build
- (
- final Origin origin,
- final Computation index,
- final Computation element,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_list_of(collection, element);
- RecurrentChecks.assert_can_be_used_as(index, Type.INT);
-
- return new AddElementAtComputation(origin, index, element, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.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/computation/AddElementComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/AddElementComputation.java
deleted file mode 100644
index b99d94c..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/AddElementComputation.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class AddElementComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected AddElementComputation
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- {
- super(origin, collection.get_type());
-
- this.collection = collection;
- this.element = element;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static AddElementComputation build
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of(collection, element);
-
- return new AddElementComputation(origin, element, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_add_element(this);
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(AddElement");
- 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/computation/AddElementsOfComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/AddElementsOfComputation.java
deleted file mode 100644
index 1538fcb..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/AddElementsOfComputation.java
+++ /dev/null
@@ -1,104 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class AddElementsOfComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation other_collection;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected AddElementsOfComputation
- (
- final Origin origin,
- final Computation other_collection,
- final Computation collection
- )
- {
- super(origin, collection.get_type());
-
- this.collection = collection;
- this.other_collection = other_collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static AddElementsOfComputation build
- (
- final Origin origin,
- final Computation other_collection,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
- RecurrentChecks.assert_is_a_collection(other_collection);
- RecurrentChecks.assert_can_be_used_as
- (
- other_collection.get_origin(),
- ((CollectionType) other_collection.get_type()).get_content_type(),
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- return new AddElementsOfComputation(origin, other_collection, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_add_elements_of(this);
- }
-
- public Computation get_source_collection ()
- {
- return other_collection;
- }
-
- public Computation get_target_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- 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/computation/AddressOperator.java b/src/core/src/tonkadur/fate/v1/lang/computation/AddressOperator.java
deleted file mode 100644
index a4482b3..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/AddressOperator.java
+++ /dev/null
@@ -1,60 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-
-import tonkadur.fate.v1.lang.type.PointerType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.Computation;
-
-public class AddressOperator extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Reference referred;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public AddressOperator (final Origin origin, final Reference referred)
- {
- super
- (
- origin,
- new PointerType(origin, referred.get_type(), "auto generated")
- );
- this.referred = referred;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_address_operator(this);
- }
-
- public Reference get_target ()
- {
- return referred;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(AddressOf ");
- sb.append(referred.get_name());
- sb.append(") ");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/CarCdr.java b/src/core/src/tonkadur/fate/v1/lang/computation/CarCdr.java
deleted file mode 100644
index 58e099d..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/CarCdr.java
+++ /dev/null
@@ -1,125 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-
-import tonkadur.parser.Origin;
-
-import tonkadur.error.ErrorManager;
-
-import tonkadur.fate.v1.error.InvalidTypeException;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-
-import tonkadur.fate.v1.lang.type.ConsType;
-import tonkadur.fate.v1.lang.type.Type;
-
-public class CarCdr extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation parent;
- protected final boolean is_car;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected CarCdr
- (
- final Origin origin,
- final Computation parent,
- final boolean is_car,
- final Type type
- )
- {
- super(origin, type);
-
- this.parent = parent;
- this.is_car = is_car;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static CarCdr build
- (
- final Origin origin,
- final Computation parent,
- final boolean is_car
- )
- throws InvalidTypeException
- {
- Type current_type;
-
- current_type = parent.get_type();
-
- if (!(current_type instanceof ConsType))
- {
- ErrorManager.handle
- (
- new InvalidTypeException
- (
- origin,
- current_type,
- Collections.singletonList(Type.CONS)
- )
- );
-
- current_type = Type.ANY;
- }
- else if (is_car)
- {
- current_type = ((ConsType) current_type).get_car_type();
- }
- else
- {
- current_type = ((ConsType) current_type).get_cdr_type();
- }
-
- return new CarCdr(origin, parent, is_car, current_type);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_car_cdr(this);
- }
-
- public Computation get_parent ()
- {
- return parent;
- }
-
- public boolean is_car ()
- {
- return is_car;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- if (is_car)
- {
- sb.append("(car (");
- }
- else
- {
- sb.append("(cdr (");
- }
-
- sb.append(type.get_name());
- sb.append(") ");
- sb.append(parent);
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/ConsComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/ConsComputation.java
deleted file mode 100644
index 04d58ff..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/ConsComputation.java
+++ /dev/null
@@ -1,74 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-
-import tonkadur.fate.v1.lang.type.ConsType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-
-public class ConsComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation car;
- protected final Computation cdr;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public ConsComputation
- (
- final Origin origin,
- final Computation car,
- final Computation cdr
- )
- {
- super
- (
- origin,
- new ConsType(origin, car.get_type(), cdr.get_type(), "auto generated")
- );
-
- this.car = car;
- this.cdr = cdr;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_cons(this);
- }
-
- public Computation get_car ()
- {
- return car;
- }
-
- public Computation get_cdr ()
- {
- return cdr;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Cons ");
- sb.append(car.toString());
- sb.append(" ");
- sb.append(car.toString());
- sb.append(") ");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/CountOperator.java b/src/core/src/tonkadur/fate/v1/lang/computation/CountOperator.java
deleted file mode 100644
index a46387d..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/CountOperator.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.error.ErrorManager;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class CountOperator extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected CountOperator
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- {
- super(origin, Type.INT);
-
- this.collection = collection;
- this.element = element;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static CountOperator build
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of(collection, element);
-
- return new CountOperator(origin, element, collection);
- }
-
- /**** Accessors ************************************************************/
- public Computation get_collection ()
- {
- return collection;
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_count_operator(this);
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(CountOperator");
- 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/computation/ExtraComputationInstance.java b/src/core/src/tonkadur/fate/v1/lang/computation/ExtraComputationInstance.java
index 5f5b572..7cb5178 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/ExtraComputationInstance.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/ExtraComputationInstance.java
@@ -11,7 +11,7 @@ import tonkadur.fate.v1.lang.meta.ComputationVisitor;
import tonkadur.fate.v1.lang.meta.ExtraComputation;
import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-public class ExtraComputationInstance extends Computation
+public class ExtraComputationInstance extends GenericComputation
{
protected final ExtraComputation computation;
protected final List<Computation> parameters;
@@ -27,7 +27,7 @@ public class ExtraComputationInstance extends Computation
final List<Computation> parameters
)
{
- super(origin, computation.get_returned_type());
+ super(origin, computation.get_returned_type(), computation.get_name());
this.computation = computation;
this.parameters = parameters;
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java b/src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java
index 56708ff..3949aca 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/FieldAccess.java
@@ -11,12 +11,13 @@ import tonkadur.fate.v1.error.InvalidTypeException;
import tonkadur.fate.v1.error.UnknownStructureFieldException;
import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
import tonkadur.fate.v1.lang.meta.Computation;
import tonkadur.fate.v1.lang.type.StructType;
import tonkadur.fate.v1.lang.type.Type;
+import tonkadur.fate.v1.lang.computation.generic.AtReference;
+
public class FieldAccess extends Computation
{
/***************************************************************************/
@@ -53,9 +54,7 @@ public class FieldAccess extends Computation
Computation parent,
final String field
)
- throws
- InvalidTypeException,
- UnknownStructureFieldException
+ throws Throwable
{
Type current_type;
@@ -63,7 +62,14 @@ public class FieldAccess extends Computation
while (current_type.get_act_as_type().equals(Type.PTR))
{
- parent = AtReference.build(origin, (Reference) parent);
+ parent =
+ GenericComputation.build
+ (
+ origin,
+ "at",
+ Collections.singletonList(parent)
+ );
+
current_type = parent.get_type();
}
@@ -96,9 +102,7 @@ public class FieldAccess extends Computation
Computation parent,
final List<String> field_sequence
)
- throws
- InvalidTypeException,
- UnknownStructureFieldException
+ throws Throwable
{
for (final String field: field_sequence)
{
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/FilterComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/FilterComputation.java
deleted file mode 100644
index 821c231..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/FilterComputation.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class FilterComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected FilterComputation
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- {
- super(origin, collection.get_type());
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static FilterComputation build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- target_signature.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.BOOL,
- target_signature
- );
-
- return
- new FilterComputation
- (
- origin,
- lambda_function,
- collection,
- extra_params
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_filter(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Filter ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/Fold.java b/src/core/src/tonkadur/fate/v1/lang/computation/Fold.java
deleted file mode 100644
index 1e9041b..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/Fold.java
+++ /dev/null
@@ -1,170 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.LambdaType;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class Fold extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation initial_value;
- protected final Computation collection;
- protected final boolean is_foldl;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Fold
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation initial_value,
- final Computation collection,
- final boolean is_foldl,
- final List<Computation> extra_params,
- final Type act_as
- )
- {
- super(origin, act_as);
-
- this.lambda_function = lambda_function;
- this.initial_value = initial_value;
- this.collection = collection;
- this.is_foldl = is_foldl;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static Fold build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation initial_value,
- final Computation collection,
- final boolean is_foldl,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> types_in;
-
- types_in = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- types_in.add(initial_value.get_type());
- types_in.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- types_in.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- initial_value.get_type(),
- types_in
- );
-
- return
- new Fold
- (
- origin,
- lambda_function,
- initial_value,
- collection,
- is_foldl,
- extra_params,
- initial_value.get_type()
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_fold(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_initial_value ()
- {
- return initial_value;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public boolean is_foldl ()
- {
- return is_foldl;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- if (is_foldl)
- {
- sb.append("(Foldl ");
- }
- else
- {
- sb.append("(Foldr ");
- }
-
- sb.append(lambda_function.toString());
-
- sb.append(" ");
- sb.append(initial_value.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/GenericComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/GenericComputation.java
new file mode 100644
index 0000000..84b5739
--- /dev/null
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/GenericComputation.java
@@ -0,0 +1,162 @@
+package tonkadur.fate.v1.lang.computation;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import tonkadur.parser.Origin;
+
+import tonkadur.functional.Cons;
+
+import tonkadur.fate.v1.lang.type.Type;
+
+import tonkadur.fate.v1.lang.meta.ComputationVisitor;
+import tonkadur.fate.v1.lang.meta.Computation;
+
+public class GenericComputation extends Computation
+{
+ /***************************************************************************/
+ /**** STATIC ***************************************************************/
+ /***************************************************************************/
+ protected static final Map<String, Cons<GenericComputation, Object>>
+ REGISTERED;
+
+ static
+ {
+ REGISTERED = new HashMap<String, Cons<GenericComputation, Object>>();
+ }
+
+ public static GenericComputation build
+ (
+ final Origin origin,
+ final String name,
+ final List<Computation> call_parameters
+ )
+ throws Throwable
+ {
+ final Cons<GenericComputation, Object> target;
+
+ target = REGISTERED.get(name);
+
+ if (target == null)
+ {
+ // TODO Exception handling.
+ }
+
+ return target.get_car().build(origin, call_parameters, target.get_cdr());
+ }
+
+ /***************************************************************************/
+ /**** MEMBERS **************************************************************/
+ /***************************************************************************/
+ protected final String name;
+
+ /***************************************************************************/
+ /**** PROTECTED ************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ protected GenericComputation
+ (
+ final Origin origin,
+ final Type type,
+ final String name
+ )
+ {
+ super(origin, type);
+
+ this.name = name;
+ }
+
+ protected GenericComputation build
+ (
+ final Origin origin,
+ final List<Computation> call_parameters,
+ final Object constructor_parameter
+ )
+ throws Throwable
+ {
+ throw
+ new Exception
+ (
+ "Missing build function for GenericComputation '"
+ + name
+ + "'."
+ );
+ }
+
+ protected void register
+ (
+ final String name,
+ final Object constructor_parameter
+ )
+ throws Exception
+ {
+ if (REGISTERED.containsKey(name))
+ {
+ // TODO Exception handling.
+ new Exception
+ (
+ "There already is a GenericComputation with the name '"
+ + name
+ + "'."
+ );
+
+ return;
+ }
+
+ REGISTERED.put(name, new Cons(this, constructor_parameter));
+ }
+
+ protected void register (final Object constructor_parameter)
+ throws Exception
+ {
+ register(get_name(), constructor_parameter);
+ }
+
+ protected void register
+ (
+ final Collection<String> names,
+ final Object constructor_parameter
+ )
+ throws Exception
+ {
+ for (final String name: names)
+ {
+ register(name, constructor_parameter);
+ }
+ }
+
+ /***************************************************************************/
+ /**** PUBLIC ***************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+
+ /**** Accessors ************************************************************/
+ @Override
+ public void get_visited_by (final ComputationVisitor cv)
+ throws Throwable
+ {
+ cv.visit_generic_computation(this);
+ }
+
+ public String get_name ()
+ {
+ return name;
+ }
+
+ /**** Misc. ****************************************************************/
+ @Override
+ public String toString ()
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append("(GenericInstruction (");
+ sb.append(type.get_name());
+ sb.append(") ");
+ sb.append(get_name());
+ sb.append(")");
+
+ return sb.toString();
+ }
+}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/IndexOfOperator.java b/src/core/src/tonkadur/fate/v1/lang/computation/IndexOfOperator.java
deleted file mode 100644
index 3269dbb..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/IndexOfOperator.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IndexOfOperator extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IndexOfOperator
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- {
- super(origin, Type.INT);
-
- this.collection = collection;
- this.element = element;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IndexOfOperator build
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of(collection, element);
-
- return new IndexOfOperator(origin, element, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_index_of_operator(this);
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(IndexOfOperator");
- 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/computation/IndexedFilterComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/IndexedFilterComputation.java
deleted file mode 100644
index 573a78f..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/IndexedFilterComputation.java
+++ /dev/null
@@ -1,137 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IndexedFilterComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IndexedFilterComputation
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- {
- super(origin, collection.get_type());
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IndexedFilterComputation build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- target_signature.add(Type.INT);
- target_signature.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.BOOL,
- target_signature
- );
-
- return
- new IndexedFilterComputation
- (
- origin,
- lambda_function,
- collection,
- extra_params
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_indexed_filter(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(IndexedFilter ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/IndexedMapComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/IndexedMapComputation.java
deleted file mode 100644
index f85616a..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/IndexedMapComputation.java
+++ /dev/null
@@ -1,140 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.LambdaType;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IndexedMapComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IndexedMapComputation
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params,
- final Type output_type
- )
- {
- super(origin, output_type);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IndexedMapComputation build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- throws Throwable
- {
- final List<Type> in_types;
-
- in_types = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- in_types.add(Type.INT);
- in_types.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- in_types.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types(lambda_function, in_types);
-
- return
- new IndexedMapComputation
- (
- origin,
- lambda_function,
- collection,
- extra_params,
- CollectionType.build
- (
- origin,
- ((LambdaType) lambda_function.get_type()).get_return_type(),
- ((CollectionType) collection.get_type()).is_set(),
- "auto generated"
- )
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_indexed_map(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(IndexedMap ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/IndexedMergeComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/IndexedMergeComputation.java
deleted file mode 100644
index f9f8ae4..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/IndexedMergeComputation.java
+++ /dev/null
@@ -1,242 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.LambdaType;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IndexedMergeComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation collection_in_a;
- protected final Computation default_a;
- protected final Computation collection_in_b;
- protected final Computation default_b;
- protected final boolean to_set;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IndexedMergeComputation
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection_in_a,
- final Computation default_a,
- final Computation collection_in_b,
- final Computation default_b,
- final boolean to_set,
- final List<Computation> extra_params,
- final Type output_type
- )
- {
- super(origin, output_type);
-
- this.lambda_function = lambda_function;
- this.collection_in_a = collection_in_a;
- this.default_a = default_a;
- this.collection_in_b = collection_in_b;
- this.default_b = default_b;
- this.to_set = to_set;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IndexedMergeComputation build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection_in_a,
- final Computation default_a,
- final Computation collection_in_b,
- final Computation default_b,
- final boolean to_set,
- final List<Computation> extra_params
- )
- throws Throwable
- {
- final List<Type> types_in;
-
- types_in = new ArrayList<Type>();
-
- if (default_a == null)
- {
- RecurrentChecks.assert_is_a_collection(collection_in_a);
- }
- else
- {
- RecurrentChecks.assert_is_a_collection_of(collection_in_a, default_a);
- }
-
- if (default_b == null)
- {
- RecurrentChecks.assert_is_a_collection(collection_in_b);
- }
- else
- {
- RecurrentChecks.assert_is_a_collection_of(collection_in_b, default_b);
- }
-
- types_in.add(Type.INT);
-
- types_in.add
- (
- ((CollectionType) collection_in_a.get_type()).get_content_type()
- );
-
- if (default_b != null)
- {
- /*
- * Safe-Mode: two indices.
- * Unsafe-Mode: only one index, since out-of-bound means stopping.
- */
- types_in.add(Type.INT);
- }
-
- types_in.add
- (
- ((CollectionType) collection_in_b.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- types_in.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types(lambda_function, types_in);
-
- return
- new IndexedMergeComputation
- (
- origin,
- lambda_function,
- collection_in_a,
- default_a,
- collection_in_b,
- default_b,
- to_set,
- extra_params,
- CollectionType.build
- (
- origin,
- ((LambdaType) lambda_function.get_type()).get_return_type(),
- to_set,
- "auto generated"
- )
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_indexed_merge(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_collection_in_a ()
- {
- return collection_in_a;
- }
-
- public Computation get_default_a ()
- {
- return default_a;
- }
-
- public Computation get_collection_in_b ()
- {
- return collection_in_b;
- }
-
- public Computation get_default_b ()
- {
- return default_b;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- public boolean to_set ()
- {
- return to_set;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- if (to_set)
- {
- sb.append("(IndexedMergeToSet ");
- }
- else
- {
- sb.append("(IndexedMergeToList ");
- }
-
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection_in_a.toString());
- sb.append(" ");
-
- if (default_a == null)
- {
- sb.append("null");
- }
- else
- {
- sb.append(default_a.toString());
- }
-
- sb.append(" ");
- sb.append(collection_in_b.toString());
- sb.append(" ");
-
- if (default_b == null)
- {
- sb.append("null");
- }
- else
- {
- sb.append(default_b.toString());
- }
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/IndexedPartitionComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/IndexedPartitionComputation.java
deleted file mode 100644
index d192f36..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/IndexedPartitionComputation.java
+++ /dev/null
@@ -1,151 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.CollectionType;
-import tonkadur.fate.v1.lang.type.ConsType;
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IndexedPartitionComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IndexedPartitionComputation
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params,
- final Type output_type
- )
- {
- super(origin, output_type);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IndexedPartitionComputation build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- throws Throwable
- {
- final Type type;
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- target_signature.add(Type.INT);
-
- target_signature.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.BOOL,
- target_signature
- );
-
- type =
- new ConsType
- (
- origin,
- collection.get_type(),
- collection.get_type(),
- "auto generated"
- );
-
- return
- new IndexedPartitionComputation
- (
- origin,
- lambda_function,
- collection,
- extra_params,
- type
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_indexed_partition(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(IndexedPartition ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/IsEmpty.java b/src/core/src/tonkadur/fate/v1/lang/computation/IsEmpty.java
deleted file mode 100644
index 054447b..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/IsEmpty.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-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 ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
-
- 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("(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/IsMemberOperator.java b/src/core/src/tonkadur/fate/v1/lang/computation/IsMemberOperator.java
deleted file mode 100644
index e909213..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/IsMemberOperator.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IsMemberOperator extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IsMemberOperator
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- {
- super(origin, Type.BOOL);
-
- this.collection = collection;
- this.element = element;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IsMemberOperator build
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of(collection, element);
-
- return new IsMemberOperator(origin, element, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_is_member_operator(this);
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(IsMemberOperator");
- 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/computation/MapComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/MapComputation.java
deleted file mode 100644
index 86bd6e4..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/MapComputation.java
+++ /dev/null
@@ -1,144 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.LambdaType;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class MapComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected MapComputation
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params,
- final Type output_type
- )
- {
- super(origin, output_type);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static MapComputation build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- target_signature.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- target_signature
- );
-
- return
- new MapComputation
- (
- origin,
- lambda_function,
- collection,
- extra_params,
- CollectionType.build
- (
- origin,
- ((LambdaType) lambda_function.get_type()).get_return_type(),
- ((CollectionType) collection.get_type()).is_set(),
- "auto generated"
- )
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_map(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Map ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/MergeComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/MergeComputation.java
deleted file mode 100644
index 4df3d3b..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/MergeComputation.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.LambdaType;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.instruction.Merge;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class MergeComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation collection_in_a;
- protected final Computation default_a;
- protected final Computation collection_in_b;
- protected final Computation default_b;
- protected final boolean to_set;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected MergeComputation
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection_in_a,
- final Computation default_a,
- final Computation collection_in_b,
- final Computation default_b,
- final boolean to_set,
- final List<Computation> extra_params,
- final Type output_type
- )
- {
- super(origin, output_type);
-
- this.lambda_function = lambda_function;
- this.collection_in_a = collection_in_a;
- this.default_a = default_a;
- this.collection_in_b = collection_in_b;
- this.default_b = default_b;
- this.to_set = to_set;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static MergeComputation build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection_in_a,
- final Computation default_a,
- final Computation collection_in_b,
- final Computation default_b,
- final boolean to_set,
- final List<Computation> extra_params
- )
- throws Throwable
- {
- final List<Type> types_in;
-
- types_in = new ArrayList<Type>();
-
- if (default_a == null)
- {
- RecurrentChecks.assert_is_a_collection(collection_in_a);
- }
- else
- {
- RecurrentChecks.assert_is_a_collection_of(collection_in_a, default_a);
- }
-
- if (default_b == null)
- {
- RecurrentChecks.assert_is_a_collection(collection_in_b);
- }
- else
- {
- RecurrentChecks.assert_is_a_collection_of(collection_in_b, default_b);
- }
-
- types_in.add
- (
- ((CollectionType) collection_in_a.get_type()).get_content_type()
- );
-
- types_in.add
- (
- ((CollectionType) collection_in_b.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- types_in.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types(lambda_function, types_in);
-
- return
- new MergeComputation
- (
- origin,
- lambda_function,
- collection_in_a,
- default_a,
- collection_in_b,
- default_b,
- to_set,
- extra_params,
- CollectionType.build
- (
- origin,
- ((LambdaType) lambda_function.get_type()).get_return_type(),
- to_set,
- "auto generated"
- )
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_merge(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_collection_in_a ()
- {
- return collection_in_a;
- }
-
- public Computation get_default_a ()
- {
- return default_a;
- }
-
- public Computation get_collection_in_b ()
- {
- return collection_in_b;
- }
-
- public Computation get_default_b ()
- {
- return default_b;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- public boolean to_set ()
- {
- return to_set;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- if (to_set)
- {
- sb.append("(MergeToSet ");
- }
- else
- {
- sb.append("(MergeToList ");
- }
-
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection_in_a.toString());
- sb.append(" ");
-
- if (default_a == null)
- {
- sb.append("null");
- }
- else
- {
- sb.append(default_a.toString());
- }
-
- sb.append(" ");
- sb.append(collection_in_b.toString());
- sb.append(" ");
-
- if (default_b == null)
- {
- sb.append("null");
- }
- else
- {
- sb.append(default_b.toString());
- }
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/Operation.java b/src/core/src/tonkadur/fate/v1/lang/computation/Operation.java
deleted file mode 100644
index d83fe85..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/Operation.java
+++ /dev/null
@@ -1,188 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collection;
-import java.util.List;
-
-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.IncompatibleTypeException;
-import tonkadur.fate.v1.error.InvalidArityException;
-import tonkadur.fate.v1.error.InvalidTypeException;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-
-public class Operation extends Computation
-{
- protected final Operator operator;
- protected final List<Computation> operands;
-
- protected Operation
- (
- final Origin origin,
- final Type result_type,
- final Operator operator,
- final List<Computation> operands
- )
- {
- super(origin, result_type);
-
- this.operator = operator;
- this.operands = operands;
- }
-
- public static Operation build
- (
- final Origin origin,
- final Operator operator,
- final List<Computation> operands
- )
- throws
- //ConflictingTypeException,
- IncomparableTypeException,
- IncompatibleTypeException,
- InvalidArityException,
- InvalidTypeException
- {
- final Collection<Type> allowed_base_types;
- final int operator_max_arity;
- final int operator_min_arity;
- final int operands_size;
- Type computed_type, previous_computed_type;
-
- allowed_base_types = operator.get_allowed_base_types();
- operator_max_arity = operator.get_maximum_arity();
- operator_min_arity = operator.get_minimum_arity();
- operands_size = operands.size();
-
- if
- (
- (operands_size < operator_min_arity)
- ||
- (
- (operator_max_arity != 0)
- && (operator_max_arity < operands_size)
- )
- )
- {
- ErrorManager.handle
- (
- new InvalidArityException
- (
- origin,
- operands_size,
- operator_min_arity,
- operator_max_arity
- )
- );
- }
-
- computed_type = operands.get(0).get_type();
-
- for (final Computation operand: operands)
- {
- final Type operand_type;
-
- operand_type = operand.get_type();
-
- if (!allowed_base_types.contains(operand_type.get_act_as_type()))
- {
- ErrorManager.handle
- (
- new InvalidTypeException
- (
- operand.get_origin(),
- operand_type,
- allowed_base_types
- )
- );
- }
-
- /*
-
- if (computed_type.equals(operand_type))
- {
- continue;
- }
-
- ErrorManager.handle
- (
- new ConflictingTypeException
- (
- operand.get_origin(),
- operand_type,
- computed_type
- )
- );
-
- */
-
- if (operand_type.can_be_used_as(computed_type))
- {
- continue;
- }
-
- previous_computed_type = computed_type;
- computed_type = computed_type.try_merging_with(operand_type);
-
- if (computed_type != null)
- {
- continue;
- }
-
- ErrorManager.handle
- (
- new IncompatibleTypeException
- (
- operand.get_origin(),
- operand_type,
- previous_computed_type
- )
- );
-
- computed_type =
- (Type) previous_computed_type.generate_comparable_to(operand_type);
-
- if (computed_type.equals(Type.ANY))
- {
- ErrorManager.handle
- (
- new IncomparableTypeException
- (
- operand.get_origin(),
- operand_type,
- previous_computed_type
- )
- );
- }
- }
-
- computed_type = operator.transform_type(computed_type);
-
- return new Operation(origin, computed_type, operator, operands);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_operation(this);
- }
-
- public Operator get_operator ()
- {
- return operator;
- }
-
- public List<Computation> get_operands ()
- {
- return operands;
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/PartitionComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/PartitionComputation.java
deleted file mode 100644
index b240915..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/PartitionComputation.java
+++ /dev/null
@@ -1,149 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.CollectionType;
-import tonkadur.fate.v1.lang.type.ConsType;
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class PartitionComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected PartitionComputation
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params,
- final Type output_type
- )
- {
- super(origin, output_type);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static PartitionComputation build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- throws Throwable
- {
- final Type type;
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- target_signature.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.BOOL,
- target_signature
- );
-
- type =
- new ConsType
- (
- origin,
- collection.get_type(),
- collection.get_type(),
- "auto generated"
- );
-
- return
- new PartitionComputation
- (
- origin,
- lambda_function,
- collection,
- extra_params,
- type
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_partition(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Partition ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/PopElementComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/PopElementComputation.java
deleted file mode 100644
index 5d50018..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/PopElementComputation.java
+++ /dev/null
@@ -1,91 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class PopElementComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation collection;
- protected final boolean is_from_left;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected PopElementComputation
- (
- final Origin origin,
- final Computation collection,
- final boolean is_from_left
- )
- {
- super(origin, collection.get_type());
-
- this.collection = collection;
- this.is_from_left = is_from_left;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static PopElementComputation build
- (
- final Origin origin,
- final Computation collection,
- final boolean is_from_left
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
-
- return new PopElementComputation(origin, collection, is_from_left);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_pop_element(this);
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public boolean is_from_left ()
- {
- return is_from_left;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- if (is_from_left)
- {
- sb.append("(PopLeftElement ");
- }
- else
- {
- sb.append("(PopRightElement ");
- }
-
- sb.append(collection.toString());
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/PushElementComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/PushElementComputation.java
deleted file mode 100644
index f13e1c7..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/PushElementComputation.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class PushElementComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Computation collection;
- protected final boolean is_from_left;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected PushElementComputation
- (
- final Origin origin,
- final Computation element,
- final Computation collection,
- final boolean is_from_left
- )
- {
- super(origin, collection.get_type());
-
- this.collection = collection;
- this.element = element;
- this.is_from_left = is_from_left;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static PushElementComputation build
- (
- final Origin origin,
- final Computation element,
- final Computation collection,
- final boolean is_from_left
- )
- throws ParsingError
- {
- return
- new PushElementComputation
- (
- origin,
- element,
- collection,
- is_from_left
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_push_element(this);
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- public boolean is_from_left ()
- {
- return is_from_left;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- if (is_from_left)
- {
- sb.append("(LeftPushElement");
- }
- else
- {
- sb.append("(RightPushElement");
- }
-
- 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/computation/Range.java b/src/core/src/tonkadur/fate/v1/lang/computation/Range.java
deleted file mode 100644
index 736ecf7..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/Range.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-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;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class Range extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation start;
- protected final Computation end;
- protected final Computation increment;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Range
- (
- final Origin origin,
- final Computation start,
- final Computation end,
- final Computation increment,
- final Type target_type
- )
- {
- super(origin, target_type);
-
- this.start = start;
- this.end = end;
- this.increment = increment;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static Range build
- (
- final Origin origin,
- final Computation start,
- final Computation end,
- final Computation increment
- )
- throws ParsingError
- {
- RecurrentChecks.assert_can_be_used_as(start, Type.INT);
- RecurrentChecks.assert_can_be_used_as(end, Type.INT);
- RecurrentChecks.assert_can_be_used_as(increment, Type.INT);
-
- return
- new Range
- (
- origin,
- start,
- end,
- increment,
- CollectionType.build(origin, Type.INT, false, "auto generated")
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_range(this);
- }
-
- public Computation get_start ()
- {
- return start;
- }
-
- public Computation get_end ()
- {
- return end;
- }
-
- public Computation get_increment ()
- {
- return increment;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Range ");
- sb.append(start.toString());
- sb.append(" ");
- sb.append(end.toString());
- sb.append(" ");
- sb.append(increment.toString());
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/RemoveAllOfElementComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/RemoveAllOfElementComputation.java
deleted file mode 100644
index a3fd529..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/RemoveAllOfElementComputation.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class RemoveAllOfElementComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected RemoveAllOfElementComputation
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- {
- super(origin, collection.get_type());
-
- this.collection = collection;
- this.element = element;
- }
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static RemoveAllOfElementComputation build
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of(collection, element);
-
- return new RemoveAllOfElementComputation(origin, element, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_remove_all_of_element(this);
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(RemoveAllOfElement");
- 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/computation/RemoveElementAtComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/RemoveElementAtComputation.java
deleted file mode 100644
index 4863992..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/RemoveElementAtComputation.java
+++ /dev/null
@@ -1,98 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class RemoveElementAtComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation index;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected RemoveElementAtComputation
- (
- final Origin origin,
- final Computation index,
- final Computation collection
- )
- {
- super(origin, collection.get_type());
-
- this.collection = collection;
- this.index = index;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static RemoveElementAtComputation build
- (
- final Origin origin,
- final Computation index,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
- RecurrentChecks.assert_can_be_used_as(index, Type.INT);
-
- return new RemoveElementAtComputation(origin, index, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_remove_element_at(this);
- }
-
- public Computation get_index ()
- {
- return index;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(RemoveElementAt");
- 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("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/RemoveElementComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/RemoveElementComputation.java
deleted file mode 100644
index a484de3..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/RemoveElementComputation.java
+++ /dev/null
@@ -1,93 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class RemoveElementComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected RemoveElementComputation
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- {
- super(origin, collection.get_type());
-
- this.collection = collection;
- this.element = element;
- }
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static RemoveElementComputation build
- (
- final Origin origin,
- final Computation element,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of(collection, element);
-
- return new RemoveElementComputation(origin, element, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_remove_element(this);
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(RemoveElement");
- 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/computation/RemoveElementsOfComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/RemoveElementsOfComputation.java
deleted file mode 100644
index f32acc4..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/RemoveElementsOfComputation.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class RemoveElementsOfComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation other_collection;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected RemoveElementsOfComputation
- (
- final Origin origin,
- final Computation other_collection,
- final Computation collection
- )
- {
- super(origin, collection.get_type());
-
- this.collection = collection;
- this.other_collection = other_collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static RemoveElementsOfComputation build
- (
- final Origin origin,
- final Computation other_collection,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
- RecurrentChecks.assert_is_a_collection(other_collection);
- RecurrentChecks.assert_can_be_used_as
- (
- other_collection.get_origin(),
- ((CollectionType) other_collection.get_type()).get_content_type(),
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- return
- new RemoveElementsOfComputation(origin, other_collection, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_remove_elements_of(this);
- }
-
- public Computation get_source_collection ()
- {
- return other_collection;
- }
-
- public Computation get_target_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(RemoveElementsOf");
- 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/computation/ReverseListComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/ReverseListComputation.java
deleted file mode 100644
index 2d23e5c..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/ReverseListComputation.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-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;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class ReverseListComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected ReverseListComputation
- (
- final Origin origin,
- final Computation collection,
- final Type result_type
- )
- {
- super(origin, result_type);
-
- this.collection = collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static ReverseListComputation build
- (
- final Origin origin,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
-
- return
- new ReverseListComputation
- (
- origin,
- collection,
- CollectionType.build
- (
- origin,
- (((CollectionType) collection.get_type()).get_content_type()),
- false,
- "auto generated"
- )
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_reverse_list(this);
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(ReverseList ");
- sb.append(collection.toString());
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/ShuffleComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/ShuffleComputation.java
deleted file mode 100644
index 41a747e..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/ShuffleComputation.java
+++ /dev/null
@@ -1,90 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-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;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class ShuffleComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected ShuffleComputation
- (
- final Origin origin,
- final Computation collection,
- final Type result_type
- )
- {
- super(origin, result_type);
-
- this.collection = collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static ShuffleComputation build
- (
- final Origin origin,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
-
- return
- new ShuffleComputation
- (
- origin,
- collection,
- CollectionType.build
- (
- origin,
- (((CollectionType) collection.get_type()).get_content_type()),
- false,
- "auto generated"
- )
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_shuffle(this);
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Shuffle ");
- sb.append(collection.toString());
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/SizeOperator.java b/src/core/src/tonkadur/fate/v1/lang/computation/SizeOperator.java
deleted file mode 100644
index b0bf57f..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/SizeOperator.java
+++ /dev/null
@@ -1,81 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class SizeOperator extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected SizeOperator
- (
- final Origin origin,
- final Computation collection
- )
- {
- super(origin, Type.INT);
-
- this.collection = collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static SizeOperator build
- (
- final Origin origin,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
-
- return new SizeOperator(origin, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_size_operator(this);
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(SizeOperator");
- 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/SortComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/SortComputation.java
deleted file mode 100644
index ebb9279..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/SortComputation.java
+++ /dev/null
@@ -1,129 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.instruction.Sort;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class SortComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected SortComputation
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- {
- super(origin, collection.get_type());
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static SortComputation build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> types_in;
-
- types_in = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_list(collection);
-
- types_in.add(((CollectionType) collection.get_type()).get_content_type());
- types_in.add(types_in.get(0));
-
- for (final Computation c: extra_params)
- {
- types_in.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.INT,
- types_in
- );
-
- return
- new SortComputation(origin, lambda_function, collection, extra_params);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_sort(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Sort ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/SubListComputation.java b/src/core/src/tonkadur/fate/v1/lang/computation/SubListComputation.java
deleted file mode 100644
index 23304b1..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/SubListComputation.java
+++ /dev/null
@@ -1,100 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class SubListComputation extends Computation
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation start;
- protected final Computation end;
- protected final Computation collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected SubListComputation
- (
- final Origin origin,
- final Computation start,
- final Computation end,
- final Computation collection
- )
- {
- super(origin, collection.get_type());
-
- this.start = start;
- this.end = end;
- this.collection = collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static SubListComputation build
- (
- final Origin origin,
- final Computation start,
- final Computation end,
- final Computation collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_can_be_used_as(start, Type.INT);
- RecurrentChecks.assert_can_be_used_as(end, Type.INT);
- RecurrentChecks.assert_is_a_collection(collection);
-
- return new SubListComputation(origin, start, end, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_sublist(this);
- }
-
- public Computation get_collection ()
- {
- return collection;
- }
-
- public Computation get_start_index ()
- {
- return start;
- }
-
- public Computation get_end_index ()
- {
- return end;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(SubList ");
- sb.append(start.toString());
- sb.append(" ");
- sb.append(end.toString());
- sb.append(" ");
- sb.append(collection.toString());
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/TextJoin.java b/src/core/src/tonkadur/fate/v1/lang/computation/TextJoin.java
deleted file mode 100644
index 831bd8f..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/computation/TextJoin.java
+++ /dev/null
@@ -1,102 +0,0 @@
-package tonkadur.fate.v1.lang.computation;
-
-import java.util.List;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.TextNode;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class TextJoin extends TextNode
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation text_collection;
- protected final Computation link;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected TextJoin
- (
- final Origin origin,
- final Computation text_collection,
- final Computation link
- )
- {
- super(origin);
-
- this.text_collection = text_collection;
- this.link = link;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static TextJoin build
- (
- final Origin origin,
- final Computation text_collection,
- final Computation link
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of
- (
- origin,
- text_collection.get_type(),
- origin,
- Type.TEXT
- );
-
- RecurrentChecks.assert_can_be_used_as
- (
- link,
- Type.TEXT
- );
-
- return new TextJoin (origin, text_collection, link);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_text_join(this);
- }
-
- public Computation get_text_collection ()
- {
- return text_collection;
- }
-
- public Computation get_link ()
- {
- return link;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(TextJoin ");
- sb.append(link.toString());
- sb.append(" ");
- sb.append(text_collection.toString());
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/VariableReference.java b/src/core/src/tonkadur/fate/v1/lang/computation/VariableReference.java
index 72b6068..6a8e428 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/VariableReference.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/VariableReference.java
@@ -5,11 +5,11 @@ import tonkadur.parser.Origin;
import tonkadur.fate.v1.lang.Variable;
import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
+import tonkadur.fate.v1.lang.meta.Computation;
import tonkadur.fate.v1.lang.type.Type;
-public class VariableReference extends Reference
+public class VariableReference extends Computation
{
/***************************************************************************/
/**** MEMBERS **************************************************************/
@@ -26,7 +26,7 @@ public class VariableReference extends Reference
final Variable variable
)
{
- super(origin, reported_type, variable.get_name());
+ super(origin, reported_type);
this.variable = variable;
}
/**** Constructors *********************************************************/
@@ -41,7 +41,7 @@ public class VariableReference extends Reference
final Variable variable
)
{
- super(origin, variable.get_type(), variable.get_name());
+ super(origin, variable.get_type());
this.variable = variable;
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/generic/AddressOperator.java b/src/core/src/tonkadur/fate/v1/lang/computation/generic/AddressOperator.java
new file mode 100644
index 0000000..5f51f1d
--- /dev/null
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/generic/AddressOperator.java
@@ -0,0 +1,133 @@
+package tonkadur.fate.v1.lang.computation.generic;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import tonkadur.parser.Origin;
+
+import tonkadur.fate.v1.lang.type.PointerType;
+
+import tonkadur.fate.v1.lang.meta.ComputationVisitor;
+import tonkadur.fate.v1.lang.meta.Computation;
+
+import tonkadur.fate.v1.lang.computation.GenericComputation;
+import tonkadur.fate.v1.lang.computation.Constant;
+
+
+public class AddressOperator extends GenericComputation
+{
+ protected static final AddressOperator ARCHETYPE;
+
+ static
+ {
+ final List<String> aliases;
+
+ ARCHETYPE =
+ new AddressOperator
+ (
+ Origin.BASE_LANGUAGE,
+ Constant.build_boolean(Origin.BASE_LANGUAGE, true)
+ );
+
+ aliases = new ArrayList<String>();
+
+ aliases.add("address_of");
+ aliases.add("addressof");
+ aliases.add("addressOf");
+
+ aliases.add("address");
+ aliases.add("addr");
+
+ aliases.add("pointer_to");
+ aliases.add("pointerto");
+ aliases.add("pointerTo");
+
+ aliases.add("pointer");
+ aliases.add("ptr");
+
+ aliases.add("reference_to");
+ aliases.add("referenceto");
+ aliases.add("referenceTo");
+
+ aliases.add("reference");
+ aliases.add("ref");
+
+ try
+ {
+ ARCHETYPE.register(aliases, null);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+ }
+
+ public static void initialize_class ()
+ {
+ }
+
+ /***************************************************************************/
+ /**** MEMBERS **************************************************************/
+ /***************************************************************************/
+ protected final Computation referred;
+
+ /***************************************************************************/
+ /**** PROTECTED ************************************************************/
+ /***************************************************************************/
+
+ /***************************************************************************/
+ /**** PUBLIC ***************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ public AddressOperator (final Origin origin, final Computation referred)
+ {
+ super
+ (
+ origin,
+ new PointerType(origin, referred.get_type(), "auto generated"),
+ "address_of"
+ );
+
+ this.referred = referred;
+ }
+
+ @Override
+ public GenericComputation build
+ (
+ final Origin origin,
+ final List<Computation> call_parameters,
+ final Object _registered_parameter
+ )
+ throws Throwable
+ {
+ if (call_parameters.size() != 1)
+ {
+ // TODO: Error.
+ }
+
+ call_parameters.get(0).expect_non_string();
+
+ return new AddressOperator(origin, call_parameters.get(0));
+ }
+
+ /**** Accessors ************************************************************/
+ public Computation get_target ()
+ {
+ return referred;
+ }
+
+ /**** Misc. ****************************************************************/
+ @Override
+ public String toString ()
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append("(AddressOf ");
+ sb.append(referred.toString());
+ sb.append(") ");
+
+ return sb.toString();
+ }
+}
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/AtReference.java b/src/core/src/tonkadur/fate/v1/lang/computation/generic/AtReference.java
index 7ae1e1f..ec81da7 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/AtReference.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/generic/AtReference.java
@@ -1,6 +1,8 @@
-package tonkadur.fate.v1.lang.computation;
+package tonkadur.fate.v1.lang.computation.generic;
import java.util.Collections;
+import java.util.List;
+import java.util.ArrayList;
import tonkadur.parser.Origin;
@@ -9,17 +11,63 @@ import tonkadur.error.ErrorManager;
import tonkadur.fate.v1.error.InvalidTypeException;
import tonkadur.fate.v1.error.UnknownStructureFieldException;
+
import tonkadur.fate.v1.lang.Variable;
import tonkadur.fate.v1.lang.meta.ComputationVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
import tonkadur.fate.v1.lang.meta.Computation;
import tonkadur.fate.v1.lang.type.PointerType;
import tonkadur.fate.v1.lang.type.Type;
-public class AtReference extends Reference
+import tonkadur.fate.v1.lang.computation.Default;
+import tonkadur.fate.v1.lang.computation.GenericComputation;
+
+public class AtReference extends GenericComputation
{
+ protected static final AtReference ARCHETYPE;
+
+ static
+ {
+ final List<String> aliases;
+
+ ARCHETYPE =
+ new AtReference
+ (
+ Origin.BASE_LANGUAGE,
+ Type.INT,
+ new Default
+ (
+ Origin.BASE_LANGUAGE,
+ new PointerType
+ (
+ Origin.BASE_LANGUAGE,
+ Type.INT,
+ "(ptr int)"
+ )
+ )
+ );
+
+ aliases = new ArrayList<String>();
+
+ aliases.add("at");
+
+ try
+ {
+ ARCHETYPE.register(aliases, null);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+ }
+
+ public static void initialize_class ()
+ {
+ }
+
/***************************************************************************/
/**** MEMBERS **************************************************************/
/***************************************************************************/
@@ -35,7 +83,7 @@ public class AtReference extends Reference
final Computation parent
)
{
- super(origin, reported_type, ("(At " + parent.toString() + ")"));
+ super(origin, reported_type, "at");
this.parent = parent;
}
@@ -45,16 +93,24 @@ public class AtReference extends Reference
/**** PUBLIC ***************************************************************/
/***************************************************************************/
/**** Constructors *********************************************************/
- public static AtReference build
+ @Override
+ public GenericComputation build
(
final Origin origin,
- final Computation parent
+ final List<Computation> call_parameters,
+ final Object _registered_parameter
)
- throws
- InvalidTypeException
+ throws Throwable
{
Type current_type;
+ if (call_parameters.size() != 1)
+ {
+ // TODO: Error.
+ }
+
+ call_parameters.get(0).expect_non_string();
+
current_type = parent.get_type();
if (!(current_type instanceof PointerType))
@@ -80,13 +136,6 @@ public class AtReference extends Reference
}
/**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_at_reference(this);
- }
-
public Computation get_parent ()
{
return parent;
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/LambdaEvaluation.java b/src/core/src/tonkadur/fate/v1/lang/computation/generic/LambdaEvaluation.java
index fc66a49..dc5fcb5 100644
--- a/src/core/src/tonkadur/fate/v1/lang/computation/LambdaEvaluation.java
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/generic/LambdaEvaluation.java
@@ -1,10 +1,13 @@
package tonkadur.fate.v1.lang.computation;
import java.util.List;
+import java.util.ArrayList;
import tonkadur.parser.Origin;
import tonkadur.parser.ParsingError;
+import tonkadur.functional.Merge;
+
import tonkadur.fate.v1.lang.type.Type;
import tonkadur.fate.v1.lang.type.LambdaType;
@@ -12,8 +15,40 @@ import tonkadur.fate.v1.lang.meta.ComputationVisitor;
import tonkadur.fate.v1.lang.meta.Computation;
import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-public class LambdaEvaluation extends Computation
+public class LambdaEvaluation extends GenericComputation
{
+ protected static final LambdaEvaluation ARCHETYPE;
+
+ static
+ {
+ final List<String> aliases;
+
+ ARCHETYPE =
+ new LambdaEvaluation
+ (
+ Origin.BASE_LANGUAGE,
+ null,
+ null,
+ Type.BOOL
+ );
+
+ aliases = new ArrayList<String>();
+
+ aliases.add("eval");
+ aliases.add("evaluate");
+
+ try
+ {
+ ARCHETYPE.register(aliases, null);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+ }
+
/***************************************************************************/
/**** MEMBERS **************************************************************/
/***************************************************************************/
@@ -32,7 +67,7 @@ public class LambdaEvaluation extends Computation
final Type act_as
)
{
- super(origin, act_as);
+ super(origin, act_as, "eval");
this.lambda_function = lambda_function;
this.parameters = parameters;
@@ -42,18 +77,65 @@ public class LambdaEvaluation extends Computation
/**** PUBLIC ***************************************************************/
/***************************************************************************/
/**** Constructors *********************************************************/
- public static LambdaEvaluation build
+ @Override
+ public GenericComputation build
(
final Origin origin,
- final Computation lambda_function,
- final List<Computation> parameters
+ final List<Computation> call_parameters,
+ final Object _registered_parameter
)
- throws ParsingError
+ throws Throwable
{
- RecurrentChecks.assert_lambda_matches_computations
+ final Computation lambda_function;
+ final List<Type> lambda_signature;
+
+ if (call_parameters.size() < 1)
+ {
+ // TODO: Error.
+ }
+
+ lambda_function = call_parameters.get(0);
+
+ lambda_function.expect_non_string();
+
+ RecurrentChecks.assert_is_a_lambda_function(lambda_function);
+
+ lambda_signature =
+ ((LambdaType) lambda_function.get_type()).get_signature();
+
+ call_parameters.remove(0);
+
+ /* String vs Variable resolution */
+ try
+ {
+ (new Merge<Type, Computation, Boolean>()
+ {
+ @Override
+ public Boolean risky_lambda (final Type t, final Computation p)
+ throws ParsingError
+ {
+ if (t.can_be_used_as(Type.STRING))
+ {
+ p.expect_string();
+ }
+ else
+ {
+ p.expect_non_string();
+ }
+ return Boolean.TRUE;
+ }
+ }).risky_merge(lambda_signature, call_parameters);
+ }
+ catch (final Throwable e)
+ {
+ // Will be handled better in the check below.
+ }
+
+ RecurrentChecks.assert_computations_matches_signature
(
- lambda_function,
- parameters
+ origin,
+ call_parameters,
+ lambda_signature
);
return
@@ -67,13 +149,6 @@ public class LambdaEvaluation extends Computation
}
/**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final ComputationVisitor cv)
- throws Throwable
- {
- cv.visit_lambda_evaluation(this);
- }
-
public Computation get_lambda_function ()
{
return lambda_function;
diff --git a/src/core/src/tonkadur/fate/v1/lang/computation/generic/Operation.java b/src/core/src/tonkadur/fate/v1/lang/computation/generic/Operation.java
new file mode 100644
index 0000000..48cf0a9
--- /dev/null
+++ b/src/core/src/tonkadur/fate/v1/lang/computation/generic/Operation.java
@@ -0,0 +1,628 @@
+package tonkadur.fate.v1.lang.computation.generic;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.ArrayList;
+
+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.IncompatibleTypeException;
+import tonkadur.fate.v1.error.InvalidArityException;
+import tonkadur.fate.v1.error.InvalidTypeException;
+
+import tonkadur.fate.v1.lang.type.Type;
+
+import tonkadur.fate.v1.lang.meta.ComputationVisitor;
+import tonkadur.fate.v1.lang.meta.Computation;
+import tonkadur.fate.v1.lang.meta.Computation;
+
+import tonkadur.fate.v1.lang.computation.GenericComputation;
+import tonkadur.fate.v1.lang.computation.Operator;
+import tonkadur.fate.v1.lang.computation.Constant;
+
+public class Operation extends GenericComputation
+{
+ protected static final Operation ARCHETYPE;
+
+ static
+ {
+ final List<Computation> operands;
+ List<String> aliases;
+
+ operands = new ArrayList<Computation>();
+
+ operands.add
+ (
+ Constant.build_boolean
+ (
+ Origin.BASE_LANGUAGE,
+ false
+ )
+ );
+
+ operands.add(operands.get(0));
+
+ ARCHETYPE =
+ new Operation
+ (
+ Origin.BASE_LANGUAGE,
+ Type.BOOL,
+ Operator.AND,
+ operands
+ );
+
+ /**** PLUS **************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("+");
+ aliases.add("plus");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.PLUS);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** MINUS *************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("-");
+ aliases.add("minus");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.MINUS);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** TIMES *************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("*");
+ aliases.add("times");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.TIMES);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** DIVIDE ************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("/");
+ aliases.add("div");
+ aliases.add("divide");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.DIVIDE);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** POWER *************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("**");
+ aliases.add("^");
+ aliases.add("pow");
+ aliases.add("power");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.POWER);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** MODULO ************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("%");
+ aliases.add("mod");
+ aliases.add("modulo");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.MODULO);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** MIN ***************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("min");
+ aliases.add("minimum");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.MIN);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** MAX ***************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("max");
+ aliases.add("maximum");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.MAX);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** CLAMP *************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("clamp");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.CLAMP);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** ABS ***************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("abs");
+ aliases.add("absolute");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.ABS);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** RANDOM ************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("rnd");
+ aliases.add("rand");
+ aliases.add("random");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.RANDOM);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** AND ***************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("and");
+ aliases.add("/\\");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.AND);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** OR ****************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("or");
+ aliases.add("\\/");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.OR);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** NOT ***************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("not");
+ aliases.add("~");
+ aliases.add("!");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.NOT);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** IMPLIES ***********************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("implies");
+ aliases.add("=>");
+ aliases.add("->");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.IMPLIES);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** ONE IN ************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("exactlyOneIn");
+ aliases.add("exactlyonein");
+ aliases.add("exactly_one_in");
+ aliases.add("OneIn");
+ aliases.add("onein");
+ aliases.add("one_in");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.ONE_IN);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** EQUALS ************************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("equals");
+ aliases.add("eq");
+ aliases.add("=");
+ aliases.add("==");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.EQUALS);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** LOWER THAN ********************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("lowerThan");
+ aliases.add("lowerthan");
+ aliases.add("lower_than");
+ aliases.add("lt");
+ aliases.add("<");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.LOWER_THAN);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** LOWER EQUAL THAN **************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("lowerEqualThan");
+ aliases.add("lowerequalthan");
+ aliases.add("lower_equal_than");
+ aliases.add("le");
+ aliases.add("<=");
+ aliases.add("=<");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.LOWER_EQUAL_THAN);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** GREATER EQUAL THAN **************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("greaterEqualThan");
+ aliases.add("greaterequalthan");
+ aliases.add("greater_equal_than");
+ aliases.add("ge");
+ aliases.add(">=");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.GREATER_EQUAL_THAN);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+
+ /**** GREATER THAN ******************************************************/
+ aliases = new ArrayList<String>();
+
+ aliases.add("greaterThan");
+ aliases.add("greaterthan");
+ aliases.add("greater_than");
+ aliases.add("gt");
+ aliases.add(">");
+
+ try
+ {
+ ARCHETYPE.register(aliases, Operator.GREATER_THAN);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+ }
+
+ public static void initialize_class ()
+ {
+ }
+
+ /***************************************************************************/
+ /**** MEMBERS **************************************************************/
+ /***************************************************************************/
+ protected final Operator operator;
+ protected final List<Computation> operands;
+
+ /***************************************************************************/
+ /**** PROTECTED ************************************************************/
+ /***************************************************************************/
+ protected Operation
+ (
+ final Origin origin,
+ final Type result_type,
+ final Operator operator,
+ final List<Computation> operands
+ )
+ {
+ super(origin, result_type, "+");
+
+ this.operator = operator;
+ this.operands = operands;
+ }
+
+ @Override
+ public GenericComputation build
+ (
+ final Origin origin,
+ final List<Computation> operands,
+ final Object registered_parameter
+ )
+ throws Throwable
+ {
+ final Operator operator;
+ final Collection<Type> allowed_base_types;
+ final int operator_max_arity;
+ final int operator_min_arity;
+ final int operands_size;
+ Type computed_type, previous_computed_type;
+
+ operator = (Operator) registered_parameter;
+
+ allowed_base_types = operator.get_allowed_base_types();
+ operator_max_arity = operator.get_maximum_arity();
+ operator_min_arity = operator.get_minimum_arity();
+ operands_size = operands.size();
+
+ if
+ (
+ (operands_size < operator_min_arity)
+ ||
+ (
+ (operator_max_arity != 0)
+ && (operator_max_arity < operands_size)
+ )
+ )
+ {
+ ErrorManager.handle
+ (
+ new InvalidArityException
+ (
+ origin,
+ operands_size,
+ operator_min_arity,
+ operator_max_arity
+ )
+ );
+ }
+
+ computed_type = operands.get(0).get_type();
+
+ for (final Computation operand: operands)
+ {
+ final Type operand_type;
+
+ operand_type = operand.get_type();
+
+ if (!allowed_base_types.contains(operand_type.get_act_as_type()))
+ {
+ ErrorManager.handle
+ (
+ new InvalidTypeException
+ (
+ operand.get_origin(),
+ operand_type,
+ allowed_base_types
+ )
+ );
+ }
+
+ /*
+
+ if (computed_type.equals(operand_type))
+ {
+ continue;
+ }
+
+ ErrorManager.handle
+ (
+ new ConflictingTypeException
+ (
+ operand.get_origin(),
+ operand_type,
+ computed_type
+ )
+ );
+
+ */
+
+ if (operand_type.can_be_used_as(computed_type))
+ {
+ continue;
+ }
+
+ previous_computed_type = computed_type;
+ computed_type = computed_type.try_merging_with(operand_type);
+
+ if (computed_type != null)
+ {
+ continue;
+ }
+
+ ErrorManager.handle
+ (
+ new IncompatibleTypeException
+ (
+ operand.get_origin(),
+ operand_type,
+ previous_computed_type
+ )
+ );
+
+ computed_type =
+ (Type) previous_computed_type.generate_comparable_to(operand_type);
+
+ if (computed_type.equals(Type.ANY))
+ {
+ ErrorManager.handle
+ (
+ new IncomparableTypeException
+ (
+ operand.get_origin(),
+ operand_type,
+ previous_computed_type
+ )
+ );
+ }
+ }
+
+ computed_type = operator.transform_type(computed_type);
+
+ return new Operation(origin, computed_type, operator, operands);
+ }
+
+ /**** Accessors ************************************************************/
+ public Operator get_operator ()
+ {
+ return operator;
+ }
+
+ public List<Computation> get_operands ()
+ {
+ return operands;
+ }
+
+ /**** Misc. ****************************************************************/
+ @Override
+ public String toString ()
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append("(Operation ");
+ sb.append(operator.toString());
+
+ for (final Computation c: operands)
+ {
+ sb.append(" ");
+ sb.append(c.toString());
+ }
+
+ sb.append(")");
+
+ return sb.toString();
+ }
+}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/AddElement.java b/src/core/src/tonkadur/fate/v1/lang/instruction/AddElement.java
deleted file mode 100644
index 84828ca..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/AddElement.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class AddElement extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected AddElement
- (
- final Origin origin,
- final Computation element,
- final Reference collection
- )
- {
- super(origin);
-
- this.collection = collection;
- this.element = element;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static AddElement build
- (
- final Origin origin,
- final Computation element,
- final Reference collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of(collection, element);
-
- return new AddElement(origin, element, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_add_element(this);
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(AddElement");
- 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/AddElementAt.java b/src/core/src/tonkadur/fate/v1/lang/instruction/AddElementAt.java
deleted file mode 100644
index 56329ed..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/AddElementAt.java
+++ /dev/null
@@ -1,114 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-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;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class AddElementAt extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation index;
- protected final Computation element;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected AddElementAt
- (
- final Origin origin,
- final Computation index,
- final Computation element,
- final Reference 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 Reference collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_list_of(collection, element);
- RecurrentChecks.assert_can_be_used_as(index, Type.INT);
-
- 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 Reference 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
deleted file mode 100644
index f992c44..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/AddElementsOf.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class AddElementsOf extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation other_collection;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected AddElementsOf
- (
- final Origin origin,
- final Computation 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 Computation other_collection,
- final Reference collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
- RecurrentChecks.assert_is_a_collection(other_collection);
- RecurrentChecks.assert_can_be_used_as
- (
- other_collection.get_origin(),
- ((CollectionType) other_collection.get_type()).get_content_type(),
- ((CollectionType) collection.get_type()).get_content_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 Computation 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("(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/instruction/ExtraInstructionInstance.java b/src/core/src/tonkadur/fate/v1/lang/instruction/ExtraInstructionInstance.java
index f13e05a..ecfa012 100644
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/ExtraInstructionInstance.java
+++ b/src/core/src/tonkadur/fate/v1/lang/instruction/ExtraInstructionInstance.java
@@ -12,7 +12,7 @@ import tonkadur.fate.v1.lang.meta.InstructionVisitor;
import tonkadur.fate.v1.lang.meta.ExtraInstruction;
import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-public class ExtraInstructionInstance extends Instruction
+public class ExtraInstructionInstance extends GenericInstruction
{
protected final ExtraInstruction instruction;
protected final List<Computation> parameters;
@@ -28,7 +28,7 @@ public class ExtraInstructionInstance extends Instruction
final List<Computation> parameters
)
{
- super(origin);
+ super(origin, instruction.get_name());
this.instruction = instruction;
this.parameters = parameters;
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Filter.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Filter.java
deleted file mode 100644
index d91f297..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/Filter.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.LambdaType;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class Filter extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Filter
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- {
- super(origin);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static Filter build
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- target_signature.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.BOOL,
- target_signature
- );
-
- return new Filter(origin, lambda_function, collection, extra_params);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_filter(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Filter ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Free.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Free.java
deleted file mode 100644
index 65e6e6f..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/Free.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.error.ErrorManager;
-
-import tonkadur.parser.Origin;
-
-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 Free extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Reference value_reference;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public Free (final Origin origin, final Reference value_reference)
- {
- super(origin);
-
- this.value_reference = value_reference;
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_free(this);
- }
-
- public Reference get_reference ()
- {
- return value_reference;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Free ");
- sb.append(value_reference.toString());
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/GenericInstruction.java b/src/core/src/tonkadur/fate/v1/lang/instruction/GenericInstruction.java
new file mode 100644
index 0000000..0035ac0
--- /dev/null
+++ b/src/core/src/tonkadur/fate/v1/lang/instruction/GenericInstruction.java
@@ -0,0 +1,160 @@
+package tonkadur.fate.v1.lang.instruction;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import tonkadur.parser.Origin;
+
+import tonkadur.functional.Cons;
+
+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 GenericInstruction extends Instruction
+{
+ /***************************************************************************/
+ /**** STATIC ***************************************************************/
+ /***************************************************************************/
+ protected static final Map<String, Cons<GenericInstruction, Object>>
+ REGISTERED;
+
+ static
+ {
+ REGISTERED = new HashMap<String, Cons<GenericInstruction, Object>>();
+ }
+
+ public static GenericInstruction build
+ (
+ final Origin origin,
+ final String name,
+ final List<Computation> call_parameters
+ )
+ throws Throwable
+ {
+ final Cons<GenericInstruction, Object> target;
+
+ target = REGISTERED.get(name);
+
+ if (target == null)
+ {
+ // TODO Exception handling.
+ }
+
+ return target.get_car().build(origin, call_parameters, target.get_cdr());
+ }
+
+ /***************************************************************************/
+ /**** MEMBERS **************************************************************/
+ /***************************************************************************/
+ protected final String name;
+
+ /***************************************************************************/
+ /**** PROTECTED ************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ protected GenericInstruction
+ (
+ final Origin origin,
+ final String name
+ )
+ {
+ super(origin);
+
+ this.name = name;
+ }
+
+ protected GenericInstruction build
+ (
+ final Origin origin,
+ final List<Computation> call_parameters,
+ final Object constructor_parameter
+ )
+ throws Throwable
+ {
+ throw
+ new Exception
+ (
+ "Missing build function for GenericInstruction '"
+ + name
+ + "'."
+ );
+ }
+
+ protected void register
+ (
+ final String name,
+ final Object constructor_parameter
+ )
+ throws Exception
+ {
+ if (REGISTERED.containsKey(name))
+ {
+ // TODO Exception handling.
+ new Exception
+ (
+ "There already is a GenericInstruction with the name '"
+ + name
+ + "'."
+ );
+
+ return;
+ }
+
+ REGISTERED.put(name, new Cons(this, constructor_parameter));
+ }
+
+ protected void register (final Object constructor_parameter)
+ throws Exception
+ {
+ register(get_name(), constructor_parameter);
+ }
+
+ protected void register
+ (
+ final Collection<String> names,
+ final Object constructor_parameter
+ )
+ throws Exception
+ {
+ for (final String name: names)
+ {
+ register(name, constructor_parameter);
+ }
+ }
+
+ /***************************************************************************/
+ /**** PUBLIC ***************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+
+ /**** Accessors ************************************************************/
+ @Override
+ public void get_visited_by (final InstructionVisitor cv)
+ throws Throwable
+ {
+ cv.visit_generic_instruction(this);
+ }
+
+ public String get_name ()
+ {
+ return name;
+ }
+
+ /**** Misc. ****************************************************************/
+ @Override
+ public String toString ()
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append("(GenericInstruction ");
+ sb.append(get_name());
+ sb.append(")");
+
+ return sb.toString();
+ }
+}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedFilter.java b/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedFilter.java
deleted file mode 100644
index 6e3da57..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedFilter.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.LambdaType;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IndexedFilter extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IndexedFilter
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- {
- super(origin);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IndexedFilter build
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- target_signature.add(Type.INT);
- target_signature.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.BOOL,
- target_signature
- );
-
- return new IndexedFilter(origin, lambda_function, collection, extra_params);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_indexed_filter(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(IndexedFilter ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMap.java b/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMap.java
deleted file mode 100644
index e603332..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMap.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IndexedMap extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IndexedMap
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- {
- super(origin);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IndexedMap build
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- throws Throwable
- {
- final List<Type> in_types;
-
- in_types = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- in_types.add(Type.INT);
- in_types.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- in_types.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- ((CollectionType) collection.get_type()).get_content_type(),
- in_types
- );
-
- return new IndexedMap(origin, lambda_function, collection, extra_params);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_indexed_map(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(IndexedMap ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMerge.java b/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMerge.java
deleted file mode 100644
index 060438c..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedMerge.java
+++ /dev/null
@@ -1,216 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IndexedMerge extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Reference collection;
- protected final Computation default_a;
- protected final Computation collection_in_b;
- protected final Computation default_b;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IndexedMerge
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection_in_b,
- final Computation default_b,
- final Reference collection,
- final Computation default_a,
- final List<Computation> extra_params
- )
- {
- super(origin);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.default_a = default_a;
- this.collection_in_b = collection_in_b;
- this.default_b = default_b;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IndexedMerge build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection_in_b,
- final Computation default_b,
- final Reference collection,
- final Computation default_a,
- final List<Computation> extra_params
- )
- throws Throwable
- {
- final List<Type> types_in;
-
- types_in = new ArrayList<Type>();
-
- if (default_a == null)
- {
- RecurrentChecks.assert_is_a_collection(collection);
- }
- else
- {
- RecurrentChecks.assert_is_a_collection_of(collection, default_a);
- }
-
- if (default_b == null)
- {
- RecurrentChecks.assert_is_a_collection(collection_in_b);
- }
- else
- {
- RecurrentChecks.assert_is_a_collection_of(collection_in_b, default_b);
- }
-
- types_in.add(Type.INT);
- types_in.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- if (default_b != null)
- {
- types_in.add(Type.INT);
- }
-
- types_in.add
- (
- ((CollectionType) collection_in_b.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- types_in.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- ((CollectionType) collection.get_type()).get_content_type(),
- types_in
- );
-
- return
- new IndexedMerge
- (
- origin,
- lambda_function,
- collection_in_b,
- default_b,
- collection,
- default_a,
- extra_params
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_indexed_merge(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_main_default ()
- {
- return default_a;
- }
-
- public Computation get_secondary_collection ()
- {
- return collection_in_b;
- }
-
- public Computation get_secondary_default ()
- {
- return default_b;
- }
-
- public Reference get_main_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(IndexedMerge ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
- sb.append(" ");
-
- if (default_a == null)
- {
- sb.append("null");
- }
- else
- {
- sb.append(default_a.toString());
- }
-
- sb.append(" ");
- sb.append(collection_in_b.toString());
- sb.append(" ");
-
- if (default_b == null)
- {
- sb.append("null");
- }
- else
- {
- sb.append(default_b.toString());
- }
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedPartition.java b/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedPartition.java
deleted file mode 100644
index cec125a..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/IndexedPartition.java
+++ /dev/null
@@ -1,156 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class IndexedPartition extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Reference collection_in;
- protected final Reference collection_out;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected IndexedPartition
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection_in,
- final Reference collection_out,
- final List<Computation> extra_params
- )
- {
- super(origin);
-
- this.lambda_function = lambda_function;
- this.collection_in = collection_in;
- this.collection_out = collection_out;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static IndexedPartition build
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection_in,
- final Reference collection_out,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection_in);
- RecurrentChecks.assert_is_a_collection(collection_out);
- RecurrentChecks.assert_can_be_used_as
- (
- collection_in,
- collection_out.get_type()
- );
-
- target_signature.add(Type.INT);
- target_signature.add
- (
- ((CollectionType) collection_in.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.BOOL,
- target_signature
- );
-
- return
- new IndexedPartition
- (
- origin,
- lambda_function,
- collection_in,
- collection_out,
- extra_params
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_indexed_partition(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Reference get_collection_in ()
- {
- return collection_in;
- }
-
- public Reference get_collection_out ()
- {
- return collection_out;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(IndexedPartition ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection_in.toString());
- sb.append(" ");
- sb.append(collection_out.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Map.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Map.java
deleted file mode 100644
index 1bcb1e4..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/Map.java
+++ /dev/null
@@ -1,130 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class Map extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Map
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- {
- super(origin);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static Map build
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection);
-
- target_signature.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- ((CollectionType) collection.get_type()).get_content_type(),
- target_signature
- );
-
- return new Map(origin, lambda_function, collection, extra_params);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_map(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Map ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Merge.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Merge.java
deleted file mode 100644
index 9a40f2f..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/Merge.java
+++ /dev/null
@@ -1,210 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class Merge extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Reference collection;
- protected final Computation default_a;
- protected final Computation collection_in_b;
- protected final Computation default_b;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Merge
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection_in_b,
- final Computation default_b,
- final Reference collection,
- final Computation default_a,
- final List<Computation> extra_params
- )
- {
- super(origin);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.default_a = default_a;
- this.collection_in_b = collection_in_b;
- this.default_b = default_b;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static Merge build
- (
- final Origin origin,
- final Computation lambda_function,
- final Computation collection_in_b,
- final Computation default_b,
- final Reference collection,
- final Computation default_a,
- final List<Computation> extra_params
- )
- throws Throwable
- {
- final List<Type> types_in;
-
- types_in = new ArrayList<Type>();
-
- if (default_a == null)
- {
- RecurrentChecks.assert_is_a_collection(collection);
- }
- else
- {
- RecurrentChecks.assert_is_a_collection_of(collection, default_a);
- }
-
- if (default_b == null)
- {
- RecurrentChecks.assert_is_a_collection(collection_in_b);
- }
- else
- {
- RecurrentChecks.assert_is_a_collection_of(collection_in_b, default_b);
- }
-
- types_in.add
- (
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- types_in.add
- (
- ((CollectionType) collection_in_b.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- types_in.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- ((CollectionType) collection.get_type()).get_content_type(),
- types_in
- );
-
- return
- new Merge
- (
- origin,
- lambda_function,
- collection_in_b,
- default_b,
- collection,
- default_a,
- extra_params
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_merge(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Computation get_main_default ()
- {
- return default_a;
- }
-
- public Computation get_secondary_collection ()
- {
- return collection_in_b;
- }
-
- public Computation get_secondary_default ()
- {
- return default_b;
- }
-
- public Reference get_main_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Merge ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
- sb.append(" ");
-
- if (default_a == null)
- {
- sb.append("null");
- }
- else
- {
- sb.append(default_a.toString());
- }
-
- sb.append(" ");
- sb.append(collection_in_b.toString());
- sb.append(" ");
-
- if (default_b == null)
- {
- sb.append("null");
- }
- else
- {
- sb.append(default_b.toString());
- }
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Partition.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Partition.java
deleted file mode 100644
index 33cb152..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/Partition.java
+++ /dev/null
@@ -1,155 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.ArrayList;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class Partition extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Reference collection_in;
- protected final Reference collection_out;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Partition
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection_in,
- final Reference collection_out,
- final List<Computation> extra_params
- )
- {
- super(origin);
-
- this.lambda_function = lambda_function;
- this.collection_in = collection_in;
- this.collection_out = collection_out;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static Partition build
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection_in,
- final Reference collection_out,
- final List<Computation> extra_params
- )
- throws ParsingError
- {
- final List<Type> target_signature;
-
- target_signature = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_collection(collection_in);
- RecurrentChecks.assert_is_a_collection(collection_out);
- RecurrentChecks.assert_can_be_used_as
- (
- collection_in,
- collection_out.get_type()
- );
-
- target_signature.add
- (
- ((CollectionType) collection_in.get_type()).get_content_type()
- );
-
- for (final Computation c: extra_params)
- {
- target_signature.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.BOOL,
- target_signature
- );
-
- return
- new Partition
- (
- origin,
- lambda_function,
- collection_in,
- collection_out,
- extra_params
- );
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_partition(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Reference get_collection_in ()
- {
- return collection_in;
- }
-
- public Reference get_collection_out ()
- {
- return collection_out;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Partition ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection_in.toString());
- sb.append(" ");
- sb.append(collection_out.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/PopElement.java b/src/core/src/tonkadur/fate/v1/lang/instruction/PopElement.java
deleted file mode 100644
index 4d64652..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/PopElement.java
+++ /dev/null
@@ -1,117 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.PointerType;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class PopElement extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation storage_ptr;
- protected final Reference collection;
- protected final boolean is_from_left;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected PopElement
- (
- final Origin origin,
- final Computation storage_ptr,
- final Reference collection,
- final boolean is_from_left
- )
- {
- super(origin);
-
- this.storage_ptr = storage_ptr;
- this.collection = collection;
- this.is_from_left = is_from_left;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static PopElement build
- (
- final Origin origin,
- final Computation storage_ptr,
- final Reference collection,
- final boolean is_from_left
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
- RecurrentChecks.assert_can_be_used_as
- (
- storage_ptr,
- new PointerType
- (
- origin,
- ((CollectionType) collection.get_type()).get_content_type(),
- "auto generated"
- )
- );
-
- return new PopElement(origin, storage_ptr, collection, is_from_left);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_pop_element(this);
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- public Computation get_storage_pointer ()
- {
- return storage_ptr;
- }
-
- public boolean is_from_left ()
- {
- return is_from_left;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- if (is_from_left)
- {
- sb.append("(PopLeftElement ");
- }
- else
- {
- sb.append("(PopRightElement ");
- }
-
- sb.append(collection.toString());
-
- sb.append(" ");
- sb.append(storage_ptr.toString());
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/PushElement.java b/src/core/src/tonkadur/fate/v1/lang/instruction/PushElement.java
deleted file mode 100644
index f07ef89..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/PushElement.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class PushElement extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Reference collection;
- protected final boolean is_from_left;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected PushElement
- (
- final Origin origin,
- final Computation element,
- final Reference collection,
- final boolean is_from_left
- )
- {
- super(origin);
-
- this.collection = collection;
- this.element = element;
- this.is_from_left = is_from_left;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static PushElement build
- (
- final Origin origin,
- final Computation element,
- final Reference collection,
- final boolean is_from_left
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_list_of(collection, element);
-
- return new PushElement(origin, element, collection, is_from_left);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_push_element(this);
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- public boolean is_from_left ()
- {
- return is_from_left;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- if (is_from_left)
- {
- sb.append("(LeftPushElement");
- }
- else
- {
- sb.append("(RightPushElement");
- }
-
- 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/RemoveAllOfElement.java b/src/core/src/tonkadur/fate/v1/lang/instruction/RemoveAllOfElement.java
deleted file mode 100644
index 5384baa..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/RemoveAllOfElement.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class RemoveAllOfElement extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected RemoveAllOfElement
- (
- final Origin origin,
- final Computation element,
- final Reference collection
- )
- {
- super(origin);
-
- this.collection = collection;
- this.element = element;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static RemoveAllOfElement build
- (
- final Origin origin,
- final Computation element,
- final Reference collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of(collection, element);
-
- return new RemoveAllOfElement(origin, element, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_remove_all_of_element(this);
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(RemoveAllOfElement");
- 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/RemoveElement.java b/src/core/src/tonkadur/fate/v1/lang/instruction/RemoveElement.java
deleted file mode 100644
index d2a2e50..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/RemoveElement.java
+++ /dev/null
@@ -1,96 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class RemoveElement extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation element;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected RemoveElement
- (
- final Origin origin,
- final Computation element,
- final Reference collection
- )
- {
- super(origin);
-
- this.collection = collection;
- this.element = element;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static RemoveElement build
- (
- final Origin origin,
- final Computation element,
- final Reference collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection_of(collection, element);
-
- return new RemoveElement(origin, element, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_remove_element(this);
- }
-
- public Computation get_element ()
- {
- return element;
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(RemoveElement");
- 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/RemoveElementAt.java b/src/core/src/tonkadur/fate/v1/lang/instruction/RemoveElementAt.java
deleted file mode 100644
index a036970..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/RemoveElementAt.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-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;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class RemoveElementAt extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation index;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected RemoveElementAt
- (
- final Origin origin,
- final Computation index,
- final Reference collection
- )
- {
- super(origin);
-
- this.collection = collection;
- this.index = index;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static RemoveElementAt build
- (
- final Origin origin,
- final Computation index,
- final Reference collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
- RecurrentChecks.assert_can_be_used_as(index, Type.INT);
-
- return new RemoveElementAt(origin, index, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_remove_element_at(this);
- }
-
- public Computation get_index ()
- {
- return index;
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(RemoveElementAt");
- 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("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/RemoveElementsOf.java b/src/core/src/tonkadur/fate/v1/lang/instruction/RemoveElementsOf.java
deleted file mode 100644
index ca91e7a..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/RemoveElementsOf.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class RemoveElementsOf extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation other_collection;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected RemoveElementsOf
- (
- final Origin origin,
- final Computation other_collection,
- final Reference collection
- )
- {
- super(origin);
-
- this.collection = collection;
- this.other_collection = other_collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static RemoveElementsOf build
- (
- final Origin origin,
- final Computation other_collection,
- final Reference collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_collection(collection);
- RecurrentChecks.assert_is_a_collection(other_collection);
- RecurrentChecks.assert_can_be_used_as
- (
- other_collection.get_origin(),
- ((CollectionType) other_collection.get_type()).get_content_type(),
- ((CollectionType) collection.get_type()).get_content_type()
- );
-
- return new RemoveElementsOf(origin, other_collection, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_remove_elements_of(this);
- }
-
- public Computation 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("(RemoveElementsOf");
- 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/instruction/ReverseList.java b/src/core/src/tonkadur/fate/v1/lang/instruction/ReverseList.java
deleted file mode 100644
index 79caeac..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/ReverseList.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class ReverseList extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected ReverseList
- (
- final Origin origin,
- final Reference collection
- )
- {
- super(origin);
-
- this.collection = collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static ReverseList build
- (
- final Origin origin,
- final Reference collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_list(collection);
-
- return new ReverseList(origin, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_reverse_list(this);
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(ReverseList ");
- sb.append(collection.toString());
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/SetFields.java b/src/core/src/tonkadur/fate/v1/lang/instruction/SetFields.java
index db2fb73..fff2a2b 100644
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/SetFields.java
+++ b/src/core/src/tonkadur/fate/v1/lang/instruction/SetFields.java
@@ -8,7 +8,6 @@ import tonkadur.functional.Cons;
import tonkadur.fate.v1.lang.meta.InstructionVisitor;
import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Reference;
import tonkadur.fate.v1.lang.meta.Computation;
public class SetFields extends Instruction
@@ -16,7 +15,7 @@ public class SetFields extends Instruction
/***************************************************************************/
/**** MEMBERS **************************************************************/
/***************************************************************************/
- protected final Reference target;
+ protected final Computation target;
protected final List<Cons<String, Computation>> field_assignments;
/***************************************************************************/
@@ -30,7 +29,7 @@ public class SetFields extends Instruction
public SetFields
(
final Origin origin,
- final Reference target,
+ final Computation target,
final List<Cons<String, Computation>> field_assignments
)
{
@@ -48,7 +47,7 @@ public class SetFields extends Instruction
iv.visit_set_fields(this);
}
- public Reference get_target ()
+ public Computation get_target ()
{
return target;
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/SetValue.java b/src/core/src/tonkadur/fate/v1/lang/instruction/SetValue.java
index 2e4dd79..672756a 100644
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/SetValue.java
+++ b/src/core/src/tonkadur/fate/v1/lang/instruction/SetValue.java
@@ -7,7 +7,6 @@ import tonkadur.parser.ParsingError;
import tonkadur.fate.v1.lang.meta.InstructionVisitor;
import tonkadur.fate.v1.lang.meta.Instruction;
import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Reference;
import tonkadur.fate.v1.lang.meta.RecurrentChecks;
public class SetValue extends Instruction
@@ -16,7 +15,7 @@ public class SetValue extends Instruction
/**** MEMBERS **************************************************************/
/***************************************************************************/
protected final Computation element;
- protected final Reference value_reference;
+ protected final Computation value_reference;
/***************************************************************************/
/**** PROTECTED ************************************************************/
@@ -26,7 +25,7 @@ public class SetValue extends Instruction
(
final Origin origin,
final Computation element,
- final Reference value_reference
+ final Computation value_reference
)
{
super(origin);
@@ -43,7 +42,7 @@ public class SetValue extends Instruction
(
final Origin origin,
final Computation element,
- final Reference value_reference
+ final Computation value_reference
)
throws ParsingError
{
@@ -65,7 +64,7 @@ public class SetValue extends Instruction
return element;
}
- public Reference get_reference ()
+ public Computation get_reference ()
{
return value_reference;
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Shuffle.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Shuffle.java
deleted file mode 100644
index bf12da6..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/Shuffle.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class Shuffle extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Shuffle
- (
- final Origin origin,
- final Reference collection
- )
- {
- super(origin);
-
- this.collection = collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static Shuffle build
- (
- final Origin origin,
- final Reference collection
- )
- throws ParsingError
- {
- RecurrentChecks.assert_is_a_list(collection);
-
- return new Shuffle(origin, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_shuffle(this);
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Shuffle ");
- sb.append(collection.toString());
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Sort.java b/src/core/src/tonkadur/fate/v1/lang/instruction/Sort.java
deleted file mode 100644
index f19a4fc..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/Sort.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-import tonkadur.fate.v1.lang.type.CollectionType;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class Sort extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final List<Computation> extra_params;
- protected final Computation lambda_function;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected Sort
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- {
- super(origin);
-
- this.lambda_function = lambda_function;
- this.collection = collection;
- this.extra_params = extra_params;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static Sort build
- (
- final Origin origin,
- final Computation lambda_function,
- final Reference collection,
- final List<Computation> extra_params
- )
- throws Throwable
- {
- final List<Type> types_in;
-
- types_in = new ArrayList<Type>();
-
- RecurrentChecks.assert_is_a_list(collection);
-
- types_in.add(((CollectionType) collection.get_type()).get_content_type());
- types_in.add(types_in.get(0));
-
- for (final Computation c: extra_params)
- {
- types_in.add(c.get_type());
- }
-
- RecurrentChecks.assert_lambda_matches_types
- (
- lambda_function,
- Type.INT,
- types_in
- );
-
- return new Sort(origin, lambda_function, collection, extra_params);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_sort(this);
- }
-
- public Computation get_lambda_function ()
- {
- return lambda_function;
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- public List<Computation> get_extra_parameters ()
- {
- return extra_params;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(Sort ");
- sb.append(lambda_function.toString());
- sb.append(" ");
- sb.append(collection.toString());
-
- for (final Computation c: extra_params)
- {
- sb.append(" ");
- sb.append(c.toString());
- }
-
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/SubList.java b/src/core/src/tonkadur/fate/v1/lang/instruction/SubList.java
deleted file mode 100644
index a80325b..0000000
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/SubList.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package tonkadur.fate.v1.lang.instruction;
-
-import tonkadur.parser.Origin;
-import tonkadur.parser.ParsingError;
-
-import tonkadur.fate.v1.lang.type.Type;
-
-import tonkadur.fate.v1.lang.meta.Computation;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Reference;
-import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-
-public class SubList extends Instruction
-{
- /***************************************************************************/
- /**** MEMBERS **************************************************************/
- /***************************************************************************/
- protected final Computation start;
- protected final Computation end;
- protected final Reference collection;
-
- /***************************************************************************/
- /**** PROTECTED ************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- protected SubList
- (
- final Origin origin,
- final Computation start,
- final Computation end,
- final Reference collection
- )
- {
- super(origin);
-
- this.start = start;
- this.end = end;
- this.collection = collection;
- }
-
- /***************************************************************************/
- /**** PUBLIC ***************************************************************/
- /***************************************************************************/
- /**** Constructors *********************************************************/
- public static SubList build
- (
- final Origin origin,
- final Computation start,
- final Computation end,
- final Reference collection
- )
- throws Throwable
- {
- RecurrentChecks.assert_is_a_collection(collection);
- RecurrentChecks.assert_can_be_used_as(start, Type.INT);
- RecurrentChecks.assert_can_be_used_as(end, Type.INT);
-
- return new SubList(origin, start, end, collection);
- }
-
- /**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_sublist(this);
- }
-
- public Computation get_start_index ()
- {
- return start;
- }
-
- public Computation get_end_index ()
- {
- return end;
- }
-
- public Reference get_collection ()
- {
- return collection;
- }
-
- /**** Misc. ****************************************************************/
- @Override
- public String toString ()
- {
- final StringBuilder sb = new StringBuilder();
-
- sb.append("(SubList ");
- sb.append(start.toString());
- sb.append(" ");
- sb.append(end.toString());
- sb.append(" ");
- sb.append(collection.toString());
- sb.append(")");
-
- return sb.toString();
- }
-}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Allocate.java b/src/core/src/tonkadur/fate/v1/lang/instruction/generic/Allocate.java
index 32c7241..cc159f5 100644
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/Allocate.java
+++ b/src/core/src/tonkadur/fate/v1/lang/instruction/generic/Allocate.java
@@ -1,6 +1,8 @@
-package tonkadur.fate.v1.lang.instruction;
+package tonkadur.fate.v1.lang.instruction.generic;
+import java.util.ArrayList;
import java.util.Collections;
+import java.util.List;
import tonkadur.error.ErrorManager;
@@ -12,16 +14,51 @@ import tonkadur.fate.v1.error.InvalidTypeException;
import tonkadur.fate.v1.lang.type.Type;
import tonkadur.fate.v1.lang.type.PointerType;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
-import tonkadur.fate.v1.lang.meta.Reference;
+import tonkadur.fate.v1.lang.meta.Computation;
-public class Allocate extends Instruction
+import tonkadur.fate.v1.lang.instruction.GenericInstruction;
+
+public class Allocate extends GenericInstruction
{
+ protected static final Allocate ARCHETYPE;
+
+ static
+ {
+ final List<String> aliases;
+
+ aliases = new ArrayList<String>();
+
+ ARCHETYPE =
+ new Allocate
+ (
+ Origin.BASE_LANGUAGE,
+ null,
+ null
+ );
+
+ aliases.add("allocate");
+ aliases.add("alloc");
+ aliases.add("malloc");
+ aliases.add("malloc");
+ aliases.add("new");
+ aliases.add("create");
+
+ try
+ {
+ ARCHETYPE.register(aliases, null);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+ }
+
/***************************************************************************/
/**** MEMBERS **************************************************************/
/***************************************************************************/
- protected final Reference target;
+ protected final Computation target;
protected final Type allocated_type;
/***************************************************************************/
@@ -32,10 +69,10 @@ public class Allocate extends Instruction
(
final Origin origin,
final Type allocated_type,
- final Reference target
+ final Computation target
)
{
- super(origin);
+ super(origin, "allocate");
this.allocated_type = allocated_type;
this.target = target;
@@ -45,11 +82,24 @@ public class Allocate extends Instruction
/**** PUBLIC ***************************************************************/
/***************************************************************************/
/**** Constructors *********************************************************/
- public static Allocate build (final Origin origin, final Reference target)
- throws ParsingError
+ @Override
+ public GenericInstruction build
+ (
+ final Origin origin,
+ final List<Computation> call_parameters,
+ final Object _constructor_parameter
+ )
+ throws Throwable
{
final Type target_type;
+ if (call_parameters.size() != 1)
+ {
+ // Error.
+ }
+
+ call_parameters.get(0).expect_non_string();
+
target_type = target.get_type();
if (target_type instanceof PointerType)
@@ -80,14 +130,7 @@ public class Allocate extends Instruction
}
/**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_allocate(this);
- }
-
- public Reference get_target ()
+ public Computation get_target ()
{
return target;
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/Clear.java b/src/core/src/tonkadur/fate/v1/lang/instruction/generic/Clear.java
index fe8943f..124f3f8 100644
--- a/src/core/src/tonkadur/fate/v1/lang/instruction/Clear.java
+++ b/src/core/src/tonkadur/fate/v1/lang/instruction/generic/Clear.java
@@ -1,15 +1,47 @@
package tonkadur.fate.v1.lang.instruction;
+import java.util.List;
+import java.util.ArrayList;
+
import tonkadur.parser.Origin;
import tonkadur.parser.ParsingError;
-import tonkadur.fate.v1.lang.meta.InstructionVisitor;
-import tonkadur.fate.v1.lang.meta.Instruction;
import tonkadur.fate.v1.lang.meta.Computation;
import tonkadur.fate.v1.lang.meta.RecurrentChecks;
-public class Clear extends Instruction
+public class Clear extends GenericInstruction
{
+ protected static final Clear ARCHETYPE;
+
+ static
+ {
+ final List<String> aliases;
+
+ ARCHETYPE = new Clear(Origin.BASE_LANGUAGE, null);
+
+ aliases = new ArrayList<String>();
+
+ aliases.add("clear");
+ aliases.add("empty");
+
+ aliases.add("list:clear");
+ aliases.add("list:empty");
+
+ aliases.add("set:clear");
+ aliases.add("set:empty");
+
+ try
+ {
+ ARCHETYPE.register(aliases, null);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+ }
+
/***************************************************************************/
/**** MEMBERS **************************************************************/
/***************************************************************************/
@@ -25,7 +57,7 @@ public class Clear extends Instruction
final Computation collection
)
{
- super(origin);
+ super(origin, "clear");
this.collection = collection;
}
@@ -34,26 +66,32 @@ public class Clear extends Instruction
/**** PUBLIC ***************************************************************/
/***************************************************************************/
/**** Constructors *********************************************************/
- public static Clear build
+ @Override
+ public GenericInstruction build
(
final Origin origin,
- final Computation collection
+ final List<Computation> call_parameters,
+ final Object _constructor_parameter
)
- throws ParsingError
+ throws Throwable
{
+ final Computation collection;
+
+ if (call_parameters.size() != 1)
+ {
+ // Error.
+ }
+
+ collection = call_parameters.get(0);
+
+ collection.expect_non_string();
+
RecurrentChecks.assert_is_a_collection(collection);
return new Clear(origin, collection);
}
/**** Accessors ************************************************************/
- @Override
- public void get_visited_by (final InstructionVisitor iv)
- throws Throwable
- {
- iv.visit_clear(this);
- }
-
public Computation get_collection ()
{
return collection;
diff --git a/src/core/src/tonkadur/fate/v1/lang/instruction/generic/Free.java b/src/core/src/tonkadur/fate/v1/lang/instruction/generic/Free.java
new file mode 100644
index 0000000..64e02cf
--- /dev/null
+++ b/src/core/src/tonkadur/fate/v1/lang/instruction/generic/Free.java
@@ -0,0 +1,136 @@
+package tonkadur.fate.v1.lang.instruction;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Collections;
+
+import tonkadur.error.ErrorManager;
+
+import tonkadur.parser.Origin;
+
+import tonkadur.fate.v1.error.InvalidTypeException;
+
+import tonkadur.fate.v1.lang.type.Type;
+import tonkadur.fate.v1.lang.type.PointerType;
+
+import tonkadur.fate.v1.lang.meta.Computation;
+
+import tonkadur.fate.v1.lang.instruction.GenericInstruction;
+
+public class Free extends GenericInstruction
+{
+ protected static final Free ARCHETYPE;
+
+ static
+ {
+ final List<String> aliases;
+
+ aliases = new ArrayList<String>();
+
+ ARCHETYPE =
+ new Free
+ (
+ Origin.BASE_LANGUAGE,
+ null
+ );
+
+ aliases.add("free");
+ aliases.add("delete");
+ aliases.add("destroy");
+
+ try
+ {
+ ARCHETYPE.register(aliases, null);
+ }
+ catch (final Exception e)
+ {
+ e.printStackTrace();
+
+ System.exit(-1);
+ }
+ }
+ /***************************************************************************/
+ /**** MEMBERS **************************************************************/
+ /***************************************************************************/
+ protected final Computation value_reference;
+
+ /***************************************************************************/
+ /**** PROTECTED ************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+
+ /***************************************************************************/
+ /**** PUBLIC ***************************************************************/
+ /***************************************************************************/
+ /**** Constructors *********************************************************/
+ protected Free (final Origin origin, final Computation value_reference)
+ {
+ super(origin, "free");
+
+ this.value_reference = value_reference;
+ }
+
+ @Override
+ public GenericInstruction build
+ (
+ final Origin origin,
+ final List<Computation> call_parameters,
+ final Object _constructor_parameter
+ )
+ throws Throwable
+ {
+ final Computation target;
+ final Type target_type;
+
+ if (call_parameters.size() != 1)
+ {
+ // Error.
+ }
+
+ call_parameters.get(0).expect_non_string();
+
+ target = call_parameters.get(0);
+
+ target_type = target.get_type();
+
+ if (target_type instanceof PointerType)
+ {
+ return new Free(origin, target);
+ }
+
+ ErrorManager.handle
+ (
+ new InvalidTypeException
+ (
+ origin,
+ target_type,
+ Collections.singletonList
+ (
+ new PointerType(origin, Type.ANY, "Any Pointer")
+ )
+ )
+ );
+
+ return new Free(origin, target);
+ }
+
+ /**** Accessors ************************************************************/
+ public Computation get_reference ()
+ {
+ return value_reference;
+ }
+
+ /**** Misc. ****************************************************************/
+ @Override
+ public String toString ()
+ {
+ final StringBuilder sb = new StringBuilder();
+
+ sb.append("(Free ");
+ sb.append(value_reference.toString());
+
+ sb.append(")");
+
+ return sb.toString();
+ }
+}
diff --git a/src/core/src/tonkadur/fate/v1/lang/meta/Computation.java b/src/core/src/tonkadur/fate/v1/lang/meta/Computation.java
index 082478e..303dfd1 100644
--- a/src/core/src/tonkadur/fate/v1/lang/meta/Computation.java
+++ b/src/core/src/tonkadur/fate/v1/lang/meta/Computation.java
@@ -37,6 +37,14 @@ public abstract class Computation extends Node
return type;
}
+ public void expect_non_string ()
+ {
+ }
+
+ public void expect_string ()
+ {
+ }
+
/**** Misc. ****************************************************************/
@Override
public String 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 5d04922..25cdeea 100644
--- a/src/core/src/tonkadur/fate/v1/lang/meta/ComputationVisitor.java
+++ b/src/core/src/tonkadur/fate/v1/lang/meta/ComputationVisitor.java
@@ -4,36 +4,12 @@ import tonkadur.fate.v1.lang.computation.*;
public interface ComputationVisitor
{
- public void visit_extra_computation (final ExtraComputationInstance n)
- throws Throwable;
-
- public void visit_at_reference (final AtReference n)
- throws Throwable;
-
- public void visit_text_join (final TextJoin n)
- throws Throwable;
-
- public void visit_access (final Access n)
- throws Throwable;
-
- public void visit_access_pointer (final AccessPointer n)
- throws Throwable;
-
public void visit_field_access (final FieldAccess n)
throws Throwable;
- public void visit_access_as_reference (final AccessAsReference n)
- throws Throwable;
-
public void visit_cast (final Cast n)
throws Throwable;
- public void visit_cons (final ConsComputation n)
- throws Throwable;
-
- public void visit_fold (final Fold n)
- throws Throwable;
-
public void visit_default (final Default n)
throws Throwable;
@@ -46,51 +22,24 @@ public interface ComputationVisitor
public void visit_constant (final Constant n)
throws Throwable;
- public void visit_count_operator (final CountOperator n)
- throws Throwable;
-
- public void visit_field_reference (final FieldReference n)
- throws Throwable;
-
public void visit_if_else_value (final IfElseValue n)
throws Throwable;
- public void visit_is_member_operator (final IsMemberOperator n)
- throws Throwable;
-
- public void visit_index_of_operator (final IndexOfOperator n)
- throws Throwable;
-
- public void visit_size_operator (final SizeOperator n)
- throws Throwable;
-
public void visit_lambda_expression (final LambdaExpression n)
throws Throwable;
- public void visit_lambda_evaluation (final LambdaEvaluation n)
- throws Throwable;
-
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;
- public void visit_operation (final Operation n)
- throws Throwable;
-
public void visit_sequence_reference (final SequenceReference n)
throws Throwable;
public void visit_paragraph (final Paragraph n)
throws Throwable;
- public void visit_address_operator (final AddressOperator n)
- throws Throwable;
-
public void visit_text_with_effect (final TextWithEffect n)
throws Throwable;
@@ -100,78 +49,12 @@ public interface ComputationVisitor
public void visit_variable_reference (final VariableReference n)
throws Throwable;
- public void visit_car_cdr (final CarCdr n)
- throws Throwable;
-
- public void visit_add_element (final AddElementComputation n)
- throws Throwable;
-
- public void visit_add_element_at (final AddElementAtComputation n)
- throws Throwable;
-
- public void visit_add_elements_of (final AddElementsOfComputation n)
- throws Throwable;
-
- public void visit_remove_elements_of (final RemoveElementsOfComputation n)
- throws Throwable;
-
- public void visit_map (final MapComputation n)
- throws Throwable;
-
- public void visit_indexed_map (final IndexedMapComputation n)
- throws Throwable;
-
- public void visit_sort (final SortComputation n)
- throws Throwable;
-
- public void visit_range (final Range n)
- throws Throwable;
-
- public void visit_remove_all_of_element
- (
- final RemoveAllOfElementComputation n
- )
- throws Throwable;
-
- public void visit_remove_element_at (final RemoveElementAtComputation n)
- throws Throwable;
-
- public void visit_remove_element (final RemoveElementComputation n)
- throws Throwable;
-
- public void visit_reverse_list (final ReverseListComputation n)
- throws Throwable;
-
- public void visit_shuffle (final ShuffleComputation n)
- throws Throwable;
-
- public void visit_merge (final MergeComputation n)
- throws Throwable;
-
- public void visit_indexed_merge (final IndexedMergeComputation n)
- throws Throwable;
-
- public void visit_filter (final FilterComputation n)
- throws Throwable;
-
- public void visit_indexed_filter (final IndexedFilterComputation n)
- throws Throwable;
-
- public void visit_sublist (final SubListComputation n)
- throws Throwable;
-
- public void visit_partition (final PartitionComputation n)
- throws Throwable;
-
- public void visit_indexed_partition (final IndexedPartitionComputation n)
- throws Throwable;
-
- public void visit_push_element (final PushElementComputation n)
+ public void visit_set_fields (final SetFieldsComputation n)
throws Throwable;
- public void visit_pop_element (final PopElementComputation n)
+ public void visit_extra_computation (final ExtraComputationInstance n)
throws Throwable;
- public void visit_set_fields (final SetFieldsComputation n)
+ public void visit_generic_computation (final GenericComputation n)
throws Throwable;
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/meta/ExtraComputation.java b/src/core/src/tonkadur/fate/v1/lang/meta/ExtraComputation.java
index 6cefa54..f3a913e 100644
--- a/src/core/src/tonkadur/fate/v1/lang/meta/ExtraComputation.java
+++ b/src/core/src/tonkadur/fate/v1/lang/meta/ExtraComputation.java
@@ -13,6 +13,12 @@ import tonkadur.fate.v1.lang.type.Type;
import tonkadur.fate.v1.lang.computation.ExtraComputationInstance;
+
+// This is for computations that are not compiled to Wyrd, but simply declared
+// in Fate and implemented by the wyrd interpreter.
+// This class should become something like a sub-GenericComputation thing.
+// Declaring an ExtraComputation should register an ExtraComputation object as a
+// GenericComputation, thus making it seamless from the user's point of view.
public class ExtraComputation extends DeclaredEntity
{
protected static final ExtraComputation ANY;
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 06c8525..8b43486 100644
--- a/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java
+++ b/src/core/src/tonkadur/fate/v1/lang/meta/InstructionVisitor.java
@@ -5,21 +5,6 @@ import tonkadur.fate.v1.lang.instruction.*;
public interface InstructionVisitor
{
/* Instruction Nodes */
- public void visit_add_element (final AddElement n)
- throws Throwable;
-
- public void visit_extra_instruction (final ExtraInstructionInstance n)
- 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_remove_elements_of (final RemoveElementsOf n)
- throws Throwable;
-
public void visit_assert (final Assert n)
throws Throwable;
@@ -32,12 +17,6 @@ public interface InstructionVisitor
public void visit_done (final Done n)
throws Throwable;
- public void visit_allocate (final Allocate n)
- throws Throwable;
-
- public void visit_free (final Free n)
- throws Throwable;
-
public void visit_while (final While n)
throws Throwable;
@@ -47,57 +26,9 @@ public interface InstructionVisitor
public void visit_for (final For n)
throws Throwable;
- public void visit_remove_element_at (final RemoveElementAt n)
- throws Throwable;
-
public void visit_for_each (final ForEach n)
throws Throwable;
- public void visit_clear (final Clear n)
- throws Throwable;
-
- public void visit_map (final Map n)
- throws Throwable;
-
- public void visit_merge (final Merge n)
- throws Throwable;
-
- public void visit_indexed_merge (final IndexedMerge n)
- throws Throwable;
-
- public void visit_filter (final Filter n)
- throws Throwable;
-
- public void visit_indexed_filter (final IndexedFilter n)
- throws Throwable;
-
- public void visit_sublist (final SubList n)
- throws Throwable;
-
- public void visit_partition (final Partition n)
- throws Throwable;
-
- public void visit_indexed_partition (final IndexedPartition n)
- throws Throwable;
-
- public void visit_sort (final Sort n)
- throws Throwable;
-
- public void visit_indexed_map (final IndexedMap c)
- throws Throwable;
-
- public void visit_shuffle (final Shuffle c)
- throws Throwable;
-
- public void visit_pop_element (final PopElement c)
- throws Throwable;
-
- public void visit_push_element (final PushElement c)
- throws Throwable;
-
- public void visit_reverse_list (final ReverseList n)
- throws Throwable;
-
public void visit_cond_instruction (final CondInstruction n)
throws Throwable;
@@ -131,12 +62,6 @@ public interface InstructionVisitor
public void visit_event_option (final EventOption n)
throws Throwable;
- public void visit_remove_all_of_element (final RemoveAllOfElement n)
- throws Throwable;
-
- public void visit_remove_element (final RemoveElement n)
- throws Throwable;
-
public void visit_sequence_call (final SequenceCall n)
throws Throwable;
@@ -157,4 +82,10 @@ public interface InstructionVisitor
public void visit_set_fields (final SetFields n)
throws Throwable;
+
+ public void visit_extra_instruction (final ExtraInstructionInstance n)
+ throws Throwable;
+
+ public void visit_generic_instruction (final GenericInstruction n)
+ throws Throwable;
}
diff --git a/src/core/src/tonkadur/fate/v1/lang/meta/VariableFromWord.java b/src/core/src/tonkadur/fate/v1/lang/meta/VariableFromWord.java
index 97a7777..b6c933e 100644
--- a/src/core/src/tonkadur/fate/v1/lang/meta/VariableFromWord.java
+++ b/src/core/src/tonkadur/fate/v1/lang/meta/VariableFromWord.java
@@ -10,12 +10,11 @@ import java.util.ArrayList;
import tonkadur.parser.Origin;
import tonkadur.parser.ParsingError;
+import tonkadur.fate.v1.parser.Parser;
import tonkadur.fate.v1.lang.Variable;
-import tonkadur.fate.v1.lang.World;
-import tonkadur.fate.v1.lang.computation.AccessAsReference;
import tonkadur.fate.v1.lang.computation.Constant;
-import tonkadur.fate.v1.lang.computation.FieldReference;
+import tonkadur.fate.v1.lang.computation.FieldAccess;
import tonkadur.fate.v1.lang.computation.VariableReference;
import tonkadur.fate.v1.lang.type.CollectionType;
@@ -28,26 +27,25 @@ public class VariableFromWord
/* Utility Class */
private VariableFromWord () { }
- public static Reference generate
+ public static Computation generate
(
- final World WORLD,
- final Deque<Map<String, Variable>> LOCAL_VARIABLES,
+ final Parser parser,
final Origin origin,
final String word
)
throws ParsingError
{
final String[] subrefs;
- Reference result;
+ Computation result;
Variable target_var;
subrefs = word.split("\\.");
- target_var = LOCAL_VARIABLES.peekFirst().get(subrefs[0]);
+ target_var = parser.maybe_get_local_variable(subrefs[0]);
if (target_var == null)
{
- target_var = WORLD.variables().get(origin, subrefs[0]);
+ target_var = parser.get_world().variables().get(origin, subrefs[0]);
}
result = new VariableReference(origin, target_var);
@@ -70,7 +68,7 @@ public class VariableFromWord
{
t = ((PointerType) t).get_referenced_type();
}
-
+/*
if (t instanceof CollectionType)
{
result =
@@ -91,7 +89,7 @@ public class VariableFromWord
Collections.singletonList(subref)
);
}
- else
+ else */
{
/* TODO: error */
System.err.println("Unimplemented error in VariableFromWord.");
diff --git a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4 b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
index 686fde2..d211d03 100644
--- a/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
+++ b/src/core/src/tonkadur/fate/v1/parser/FateParser.g4
@@ -1394,7 +1394,7 @@ returns [List<Cons<Computation, Instruction>> result]
condition = null;
$result = new ArrayList<Cons<Computation, Instruction>>();
- // TODO: pcd enable.
+ PARSER.enable_restricted_stack_of(pcd);
}
:
(
@@ -1403,7 +1403,8 @@ returns [List<Cons<Computation, Instruction>> result]
(L_PAREN WS* computation WS+)
{
condition = ($computation.result);
- // TODO: pcd disable.
+
+ PARSER.disable_restricted_stack_of(pcd);
}
)
|
@@ -1421,7 +1422,8 @@ returns [List<Cons<Computation, Instruction>> result]
),
($something_else.text).substring(1).trim()
);
- // TODO: pcd disable.
+
+ PARSER.disable_restricted_stack_of(pcd);
}
)
)
@@ -1444,14 +1446,14 @@ returns [List<Cons<Computation, Instruction>> result]
@init
{
$result = new ArrayList<Cons<Computation, Instruction>>();
- // todo: pcd enable
+ PARSER.enable_restricted_stack_of(pcd);
}
:
(
L_PAREN
WS* computation
{
- //todo: pcd disable
+ PARSER.disable_restricted_stack_of(pcd);
}
WS* player_choice[pcd] WS*
R_PAREN
@@ -1989,6 +1991,21 @@ returns [Computation result]
);
}
+ | VARIABLE_KW WORD WS* R_PAREN
+ {
+ $result =
+ VariableFromWord.generate
+ (
+ PARSER,
+ CONTEXT.get_origin_at
+ (
+ ($WORD.getLine()),
+ ($WORD.getCharPositionInLine())
+ ),
+ ($WORD.text)
+ );
+ }
+
| IGNORE_ERROR_KW WORD WS+ computation WS* R_PAREN
{
$result = ($computation.result);
diff --git a/src/core/src/tonkadur/fate/v1/parser/Parser.java b/src/core/src/tonkadur/fate/v1/parser/Parser.java
index 3caa7b2..4fc978d 100644
--- a/src/core/src/tonkadur/fate/v1/parser/Parser.java
+++ b/src/core/src/tonkadur/fate/v1/parser/Parser.java
@@ -3,8 +3,10 @@ package tonkadur.fate.v1.parser;
import java.io.IOException;
import java.util.Collection;
+import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashSet;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -15,6 +17,10 @@ import org.antlr.v4.runtime.CommonTokenStream;
import tonkadur.parser.Context;
import tonkadur.parser.Origin;
+import tonkadur.error.ErrorManager;
+
+import tonkadur.fate.v1.error.DuplicateLocalVariableException;
+
import tonkadur.fate.v1.lang.Variable;
import tonkadur.fate.v1.lang.World;
@@ -37,7 +43,7 @@ public class Parser
breakable_levels = 0;
continue_levels = 0;
- context = new Context();
+ context = Context.BASE_LANGUAGE.clone();
}
public Origin get_origin_at (final int line, final int column)
@@ -90,7 +96,7 @@ public class Parser
/**** LOCAL VARIABLES ******************************************************/
public Variable maybe_get_local_variable (final String name)
{
- for (final Map<String, Variable> level: context_variables)
+ for (final Map<String, Variable> level: local_variables.stack)
{
final Variable v;
@@ -106,7 +112,7 @@ public class Parser
}
public void add_local_variables (final Map<String, Variable> collection)
- throws Trowable
+ throws Throwable
{
for (final Variable variable: collection.values())
{
@@ -115,11 +121,12 @@ public class Parser
}
public void add_local_variable (final Variable variable)
- throws Trowable
+ throws Throwable
{
- final Map<String, Variable> current_hierarchy = local_variables.peek();
+ final Map<String, Variable> current_hierarchy;
final Variable previous_entry;
+ current_hierarchy = local_variables.stack.peek();
previous_entry = current_hierarchy.get(variable.get_name());
if (previous_entry != null)
@@ -139,18 +146,18 @@ public class Parser
public void increase_local_variables_hierarchy ()
{
- local_variables.push(new HashMap<String, Variable>());
+ local_variables.stack.push(new HashMap<String, Variable>());
}
public void decrease_local_variables_hierarchy ()
{
- local_variables.pop();
+ local_variables.stack.pop();
}
/* I don't think it's needed ATM. */
public Collection<Variable> get_local_variables_at_current_hierarchy ()
{
- return local_variables.peek().values();
+ return local_variables.stack.peek().values();
}
public LocalVariables get_local_variables_stack ()
@@ -176,7 +183,7 @@ public class Parser
{
if ((e.getMessage() == null) || !e.getMessage().startsWith("Require"))
{
- kthrow
+ throw
new ParseCancellationException
(
(
@@ -203,17 +210,9 @@ public class Parser
tokens = new CommonTokenStream(lexer);
parser = new FateParser(tokens);
- if (origin != null)
- {
- context.push(origin);
- }
-
+ context.push(origin.get_location(), filename);
parser.fate_file(this);
-
- if (origin != null)
- {
- context.pop();
- }
+ context.pop();
world.add_loaded_file(filename);
@@ -241,8 +240,26 @@ public class Parser
}
- public static class LocalVariables extends Deque<Map<String, Variable>>
+ /* Internal class to make moving LocalVariable objects around easier. */
+ public static class LocalVariables
{
+ protected final Deque<Map<String, Variable>> stack;
+
+ protected LocalVariables ()
+ {
+ stack = new ArrayDeque<Map<String, Variable>>();
+ }
+
+ protected LocalVariables (final Deque<Map<String, Variable>> stack)
+ {
+ this.stack = stack.clone();
+ }
+
+ @Override
+ public LocalVariables clone ()
+ {
+ return new LocalVariables(stack);
+ }
}
public static class PlayerChoiceData
@@ -283,7 +300,7 @@ public class Parser
{
for (final Set<String> variable_names: player_choice_variable_names)
{
- if (variables_names.has(name))
+ if (variable_names.contains(name))
{
return true;
}
diff --git a/src/core/src/tonkadur/parser/Location.java b/src/core/src/tonkadur/parser/Location.java
index 8e86a95..af89e7b 100644
--- a/src/core/src/tonkadur/parser/Location.java
+++ b/src/core/src/tonkadur/parser/Location.java
@@ -123,4 +123,11 @@ public class Location
{
return (filename.hashCode() + line + column);
}
+
+
+ @Override
+ public Location clone ()
+ {
+ return new Location(is_base_language, directory, filename, line, column);
+ }
}
diff --git a/src/core/src/tonkadur/parser/Origin.java b/src/core/src/tonkadur/parser/Origin.java
index 9d41fac..99f1cb4 100644
--- a/src/core/src/tonkadur/parser/Origin.java
+++ b/src/core/src/tonkadur/parser/Origin.java
@@ -48,4 +48,10 @@ public class Origin
return sb.toString();
}
+
+ @Override
+ public Origin clone ()
+ {
+ return new Origin(context.clone(), location.clone());
+ }
}