]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRQuery.java
(refs #7375) Replaced collectFreeVariables method by a visitor
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / chr / CHRQuery.java
index 5cb0f2aee230acb6f79838fd358612c81edc024f..5c0fdaea20f929f1a38ecfd93e29dab950ab1ea0 100644 (file)
@@ -9,10 +9,10 @@ import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
 import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
 import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;
 import org.simantics.scl.compiler.errors.Locations;
 import org.simantics.scl.compiler.internal.parsing.Symbol;
+import org.simantics.scl.compiler.types.Type;
 
 import gnu.trove.map.hash.TObjectIntHashMap;
 import gnu.trove.set.hash.THashSet;
@@ -30,11 +30,6 @@ public class CHRQuery extends Symbol {
             literal.resolve(context);
     }
 
-    public void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs) {
-        for(CHRLiteral literal : literals)
-            literal.collectRefs(allRefs, refs);
-    }
-
     public void checkType(TypingContext context) {
         for(CHRLiteral literal : literals)
             literal.checkType(context);
@@ -44,17 +39,7 @@ public class CHRQuery extends Symbol {
         for(CHRLiteral literal : literals)
             literal.collectVars(allVars, vars);
     }
-
-    public void forVariables(VariableProcedure procedure) {
-        for(CHRLiteral literal : literals)
-            literal.forVariables(procedure);
-    }
-
-    public void collectFreeVariables(THashSet<Variable> vars) {
-        for(CHRLiteral literal : literals)
-            literal.collectFreeVariables(vars);
-    }
-
+    
     public void setLocationDeep(long loc) {
         if(location == Locations.NO_LOCATION) {
             this.location = loc;
@@ -71,7 +56,7 @@ public class CHRQuery extends Symbol {
             else
                 context.add(literal, i);
         }
-        if(activeLiteralId == -1) {
+        if(activeLiteralId == -1 && inputFact != null) {
             context.addInitFact(initConstraint, inputFact);
         }      
         return context.createQueryPlan();
@@ -95,4 +80,14 @@ public class CHRQuery extends Symbol {
         visitor.visit(this);
         return b.toString();
     }
+
+    public void collectQueryEffects(THashSet<Type> effects) {
+        for(CHRLiteral literal : literals)
+            literal.collectQueryEffects(effects);
+    }
+    
+    public void collectEnforceEffects(THashSet<Type> effects) {
+        for(CHRLiteral literal : literals)
+            literal.collectEnforceEffects(effects);
+    }
 }