]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/scl/GraphRelation.java
(refs #7375) Fixed implementation of collectEffects
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / scl / GraphRelation.java
index 625a073845a0cdee11babdaf68d9c5ca46a085ae..f1c8a79f8b9fcc6c1d8a596d7f78b2ef9a55f65e 100644 (file)
@@ -2,6 +2,7 @@ package org.simantics.modeling.scl;
 
 import org.simantics.db.Resource;
 import org.simantics.scl.compiler.common.names.Name;
+import org.simantics.scl.compiler.compilation.CompilationContext;
 import org.simantics.scl.compiler.elaboration.chr.plan.PlanContext;
 import org.simantics.scl.compiler.elaboration.expressions.EApply;
 import org.simantics.scl.compiler.elaboration.expressions.EExternalConstant;
@@ -11,7 +12,6 @@ import org.simantics.scl.compiler.elaboration.expressions.Variable;
 import org.simantics.scl.compiler.elaboration.query.compilation.EnforcingContext;
 import org.simantics.scl.compiler.elaboration.query.compilation.QueryCompilationContext;
 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
-import org.simantics.scl.compiler.environment.Environment;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter;
 import org.simantics.scl.compiler.types.TVar;
@@ -138,14 +138,14 @@ public class GraphRelation implements SCLRelation {
 
     @Override
     public void generateIterate(PlanContext context, CodeWriter w, long location, int boundMask, Variable[] variables,
-            Expression[] expressions) {
-        Environment env = context.context.environment;
+            Expression[] expressions, Expression[] typeConstraintEvidenceParameters) {
+        CompilationContext compilationContext = context.context;
         switch(boundMask) {
         case BF:
             context.iterateList(location, w, variables[1],
                     w.apply(location,
-                            env.getValue(GET_OBJECTS).getValue(),
-                            expressions[0].toVal(env, w),
+                            compilationContext.environment.getValue(GET_OBJECTS).getValue(),
+                            expressions[0].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(relation, Types.RESOURCE)));
             break;
         case FB:
@@ -153,33 +153,44 @@ public class GraphRelation implements SCLRelation {
                 throw new IllegalArgumentException();
             context.iterateList(location, w, variables[0],
                     w.apply(location,
-                            env.getValue(GET_OBJECTS).getValue(),
-                            expressions[1].toVal(env, w),
+                            compilationContext.environment.getValue(GET_OBJECTS).getValue(),
+                            expressions[1].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(inverseRelation, Types.RESOURCE)));
             break;
         case BB:
             context.check(location, w, 
                     inverseRelation == null || relationSelectivity <= inverseRelationSelectivity
-                    ? w.apply(location, env.getValue(HAS_STATEMENT).getValue(), 
-                            expressions[0].toVal(env, w),
+                    ? w.apply(location, compilationContext.environment.getValue(HAS_STATEMENT).getValue(), 
+                            expressions[0].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(relation, Types.RESOURCE),
-                            expressions[1].toVal(env, w))
-                    : w.apply(location, env.getValue(HAS_STATEMENT).getValue(), 
-                            expressions[1].toVal(env, w),
+                            expressions[1].toVal(compilationContext, w))
+                    : w.apply(location, compilationContext.environment.getValue(HAS_STATEMENT).getValue(), 
+                            expressions[1].toVal(compilationContext, w),
                             w.getModuleWriter().getExternalConstant(inverseRelation, Types.RESOURCE),
-                            expressions[0].toVal(env, w)));
+                            expressions[0].toVal(compilationContext, w)));
             break;
         default: throw new IllegalArgumentException();
         }
     }
 
     @Override
-    public void generateEnforce(PlanContext context, CodeWriter w, long location, Expression[] parameters) {
-        Environment env = context.context.environment;
+    public void generateEnforce(PlanContext context, CodeWriter w, long location, Expression[] parameters,
+            Expression[] typeConstraintEvidenceParameters) {
+        CompilationContext compilationContext = context.context;
         w.apply(location,
-                env.getValue(CLAIM).getValue(),
-                parameters[0].toVal(env, w),
+                compilationContext.environment.getValue(CLAIM).getValue(),
+                parameters[0].toVal(compilationContext, w),
                 w.getModuleWriter().getExternalConstant(relation, Types.RESOURCE),
-                parameters[1].toVal(env, w));
+                parameters[1].toVal(compilationContext, w));
+    }
+    
+    @Override
+    public Type getEnforceEffect() {
+        return Types.WRITE_GRAPH;
+    }
+
+    @Override
+    public Type getQueryEffect() {
+        return Types.READ_GRAPH;
     }
 }