]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERuleset.java
Merge "Remove unused import in DeleteHandler"
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / expressions / ERuleset.java
index 02b8c9ddc0c4922765cbbf5ff321726e4d05ff86..9e863a7a6e1f42fe3eccfee067593d547a3c1a5e 100644 (file)
@@ -21,7 +21,7 @@ import java.util.ArrayList;
 import java.util.Set;\r
 \r
 import org.simantics.scl.compiler.common.exceptions.InternalCompilerError;\r
-import org.simantics.scl.compiler.common.names.Name;\r
+import org.simantics.scl.compiler.common.names.Names;\r
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;\r
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;\r
 import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;\r
@@ -36,7 +36,6 @@ import org.simantics.scl.compiler.internal.elaboration.utils.ExpressionDecorator
 import org.simantics.scl.compiler.internal.elaboration.utils.ForcedClosure;\r
 import org.simantics.scl.compiler.internal.elaboration.utils.StronglyConnectedComponents;\r
 import org.simantics.scl.compiler.top.SCLCompilerConfiguration;\r
-import org.simantics.scl.compiler.types.TCon;\r
 import org.simantics.scl.compiler.types.Type;\r
 import org.simantics.scl.compiler.types.Types;\r
 import org.simantics.scl.compiler.types.exceptions.MatchException;\r
@@ -191,15 +190,6 @@ public class ERuleset extends SimplifiableExpression {
         Variable handleFunc;\r
     }\r
     \r
-    public static final TCon MSet = Types.con("MSet", "T");\r
-    private static final Name MSet_add = Name.create("MSet", "add");\r
-    private static final Name MSet_create = Name.create("MSet", "create");\r
-\r
-    private static final TCon MList = Types.con("MList", "T");\r
-    private static final Name MList_add = Name.create("MList", "add");\r
-    private static final Name MList_create = Name.create("MList", "create");\r
-    private static final Name MList_removeLast = Name.create("MList", "removeLast");\r
-    \r
     public Expression compile(TypingContext context) {\r
         // Create a map from relations to their ids\r
         TObjectIntHashMap<SCLRelation> relationsToIds = new TObjectIntHashMap<SCLRelation>(relations.length,\r
@@ -284,7 +274,7 @@ public class ERuleset extends SimplifiableExpression {
             LocalRelation relation = relations[i];\r
             Type[] parameterTypes = relation.getParameterTypes();\r
             stacks[i] = newVar("stack" + relation.getName(),\r
-                    Types.apply(MList, Types.tuple(parameterTypes))\r
+                    Types.apply(Names.MList_T, Types.tuple(parameterTypes))\r
                     );\r
         }\r
 \r
@@ -305,7 +295,7 @@ public class ERuleset extends SimplifiableExpression {
         ArrayList<Expression> seedExpressions = new ArrayList<Expression>(); \r
         for(DatalogRule rule : rules) {\r
             int id = diffables.get(rule.headRelation).id;\r
-            Expression appendExp = apply(context, Types.PROC, MList_add, Types.tuple(rule.headRelation.getParameterTypes()),\r
+            Expression appendExp = apply(context.getCompilationContext(), Types.PROC, Names.MList_add, Types.tuple(rule.headRelation.getParameterTypes()),\r
                     var(stacks[id]),\r
                     tuple(rule.headParameters)\r
                     );\r
@@ -349,7 +339,7 @@ public class ERuleset extends SimplifiableExpression {
             for(Expression updateExpression : updateExpressions[i])\r
                 handleRow = seq(updateExpression, handleRow);\r
             handleRow = if_(\r
-                    apply(context, Types.PROC, MSet_add, rowType,\r
+                    apply(context.getCompilationContext(), Types.PROC, Names.MSet_add, rowType,\r
                             var(relation.table), var(row)),\r
                     handleRow,\r
                     tuple()\r
@@ -361,7 +351,7 @@ public class ERuleset extends SimplifiableExpression {
                         apply(Types.PROC, var(loops[(i+1)%relations.length]), addInteger(var(counter), integer(-1)))\r
                        );\r
             Expression body = matchWithDefault(\r
-                    apply(context, Types.PROC, MList_removeLast, rowType, var(stacks[i])),\r
+                    apply(context.getCompilationContext(), Types.PROC, Names.MList_removeLast, rowType, var(stacks[i])),\r
                     Just(as(row, tuple(vars(parameters)))), handleRow,\r
                     failure);\r
             \r
@@ -376,7 +366,7 @@ public class ERuleset extends SimplifiableExpression {
         // Create stacks\r
         for(int i=0;i<stacks.length;++i)\r
             continuation = let(stacks[i],\r
-                    apply(context, Types.PROC, MList_create, Types.tuple(relations[i].getParameterTypes()), tuple()),\r
+                    apply(context.getCompilationContext(), Types.PROC, Names.MList_create, Types.tuple(relations[i].getParameterTypes()), tuple()),\r
                     continuation);\r
         \r
         continuation = ForcedClosure.forceClosure(continuation, SCLCompilerConfiguration.EVERY_DATALOG_STRATUM_IN_SEPARATE_METHOD);\r
@@ -384,7 +374,7 @@ public class ERuleset extends SimplifiableExpression {
         // Create relations\r
         for(LocalRelation relation : relations)\r
             continuation = let(relation.table,\r
-                    apply(context, Types.PROC, MSet_create, Types.tuple(relation.getParameterTypes()), tuple()),\r
+                    apply(context.getCompilationContext(), Types.PROC, Names.MSet_create, Types.tuple(relation.getParameterTypes()), tuple()),\r
                     continuation);\r
         \r
         return seq(continuation, in);\r