]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRule.java
(refs #7377) Refactoring CHR query parsing
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / chr / CHRRule.java
index 20dda072cfa03cb7bfb9dc8c2f228c2b16dcb186..c668005d7f1f6b07ea714d3101ef944d28957d45 100644 (file)
@@ -45,10 +45,15 @@ public class CHRRule extends Symbol {
         this.body = body;
         this.existentialVariables = existentialVariables;
     }
+    
+    public CHRRule(long location, CHRQuery head, CHRQuery body) {
+        this(location, head, body, null);
+    }
 
     public void resolve(TranslationContext context) {
         context.pushExistentialFrame();
         head.resolve(context);
+        context.disallowNewExistentials();
         body.resolve(context);
         existentialVariables = context.popExistentialFrame();
     }
@@ -103,7 +108,7 @@ public class CHRRule extends Symbol {
             
             Variable activeFact = new Variable("activeFact", constraint.factType);
             QueryPlanningContext context = new QueryPlanningContext(compilationContext, existentialVariables);
-            if(!head.createQueryPlan(context, new EVariable(activeFact), i))
+            if(!head.createQueryPlan(context, new EVariable(activeFact), i, initConstraint))
                 return;
             body.createEnforcePlan(context, priority);
             addPlan(new CHRSearchPlan(constraint, activeFact, context.getPlanOps()));
@@ -114,7 +119,7 @@ public class CHRRule extends Symbol {
         if(!hasLocalActiveLiteral) {
             Variable activeFact = new Variable("activeFact", initConstraint.factType);
             QueryPlanningContext context = new QueryPlanningContext(compilationContext, existentialVariables);
-            if(!head.createQueryPlan(context, null, -1))
+            if(!head.createQueryPlan(context, new EVariable(activeFact), -1, initConstraint))
                 return;
             body.createEnforcePlan(context, priority);
             /*System.out.println(this);