]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRQuery.java
(refs #7365) Fixed the bug in the test CHR11.scl
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / chr / CHRQuery.java
index 9e2bf6f343c026637ff5dfd0db3ae2af6663c512..5cb0f2aee230acb6f79838fd358612c81edc024f 100644 (file)
@@ -3,6 +3,7 @@ package org.simantics.scl.compiler.elaboration.chr;
 import org.simantics.scl.compiler.elaboration.chr.plan.PostCommitOp;
 import org.simantics.scl.compiler.elaboration.chr.plan.PreCommitOp;
 import org.simantics.scl.compiler.elaboration.chr.planning.QueryPlanningContext;
+import org.simantics.scl.compiler.elaboration.chr.relations.CHRConstraint;
 import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
@@ -62,7 +63,7 @@ public class CHRQuery extends Symbol {
         }
     }
     
-    public boolean createQueryPlan(QueryPlanningContext context, Expression inputFact, int activeLiteralId) {
+    public boolean createQueryPlan(QueryPlanningContext context, Expression inputFact, int activeLiteralId, CHRConstraint initConstraint) {
         for(int i=0;i<literals.length;++i) {
             CHRLiteral literal = literals[i];
             if(i == activeLiteralId)
@@ -70,6 +71,9 @@ public class CHRQuery extends Symbol {
             else
                 context.add(literal, i);
         }
+        if(activeLiteralId == -1) {
+            context.addInitFact(initConstraint, inputFact);
+        }      
         return context.createQueryPlan();
     }