]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
(refs #7375) Replaced forVariables by a visitor 50/750/1
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 24 Jul 2017 07:34:38 +0000 (10:34 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Mon, 24 Jul 2017 07:34:38 +0000 (10:34 +0300)
Change-Id: I5737e75491a1341711f89fbcf9749ee88d953c92

72 files changed:
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRLiteral.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRQuery.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRule.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/CHRRuleset.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/chr/plan/AssignOp.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqBasic.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqGuard.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/Equation.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ASTExpression.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Assignment.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Case.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/DecoratingExpression.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAmbiguous.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApplyType.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAsPattern.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRSelect.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEnforce.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEquations.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EError.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EExternalConstant.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EFieldAccess.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EGetConstraint.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIntegerLiteral.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambda.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambdaType.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELet.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListComprehension.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELiteral.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERealLiteral.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERuleset.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESelect.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLambda.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLet.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETransformation.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETypeAnnotation.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EViewPattern.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EWhen.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/GuardedExpression.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/GuardedExpressionGroup.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/StandardExpressionVisitor.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/ExpressionAccessor.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/FieldAccessor.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/IdAccessor.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/StringAccessor.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListAssignment.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGenerator.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGuard.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListQualifier.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListSeq.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListThen.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/visitors/ForVariablesUsesVisitor.java [new file with mode: 0644]
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractCombiner.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractModifier.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAtom.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QExists.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QIf.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QMapping.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/Query.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/pre/PreQuery.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/relations/TransitiveClosureRelation.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/transformations/TransformationBuilder.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/internal/elaboration/transformations/UnifiableFactory.java

index 918dd9fb309ef25d4d9dfd3f156e60b7d4b097e5..e8bb00a6e1b7a7a66dca38f7e7e3a28bf8a9cb77 100644 (file)
@@ -12,7 +12,6 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.expressions.ERecord;
 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.elaboration.expressions.records.FieldAssignment;
 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
@@ -157,14 +156,6 @@ public class CHRLiteral extends Symbol {
                 parameter.collectVars(allVars, vars);
     }
 
-    public void forVariables(VariableProcedure procedure) {
-        for(Expression parameter : parameters)
-            parameter.forVariables(procedure);
-        if(typeConstraintEvidenceParameters != null)
-            for(Expression parameter : typeConstraintEvidenceParameters)
-                parameter.forVariables(procedure);
-    }
-
     public void collectFreeVariables(THashSet<Variable> vars) {
         if(relation == SpecialCHRRelation.ASSIGN) {
             parameters[1].collectFreeVariables(vars);
index 4e5670fcd955edc0945e466ee8a4413e7a9909fb..777dc9f6c4b8847ed24c15e64f6c7336020aff32 100644 (file)
@@ -10,7 +10,6 @@ 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;
@@ -47,11 +46,6 @@ public class CHRQuery extends Symbol {
             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);
index c668005d7f1f6b07ea714d3101ef944d28957d45..31d0ec48c1e185700fcfb393a465490511277be9 100644 (file)
@@ -11,7 +11,6 @@ import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.expressions.EVariable;
 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;
@@ -75,11 +74,6 @@ public class CHRRule extends Symbol {
         body.collectVars(allVars, vars);
     }
 
-    public void forVariables(VariableProcedure procedure) {
-        head.forVariables(procedure);
-        body.forVariables(procedure);
-    }
-
     public void collectFreeVariables(THashSet<Variable> vars) {
         head.collectFreeVariables(vars);
         body.collectFreeVariables(vars);
index 63a8344f220d93fdc63296eb05abcc6fe0b267d5..9eca12aa9b32e57be811635db7fee9e76460128d 100644 (file)
@@ -23,7 +23,6 @@ import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
 import org.simantics.scl.compiler.elaboration.expressions.block.IncludeStatement;
 import org.simantics.scl.compiler.environment.AmbiguousNameException;
 import org.simantics.scl.compiler.errors.Locations;
@@ -144,13 +143,6 @@ public class CHRRuleset extends Symbol {
             rule.collectVars(allVars, vars);
     }
 
-    public void forVariables(VariableProcedure procedure) {
-        for(IncludeStatement include : includes)
-            include.value.forVariables(procedure);
-        for(CHRRule rule : rules)
-            rule.forVariables(procedure);
-    }
-
     public void collectFreeVariables(THashSet<Variable> vars) {
         for(IncludeStatement include : includes)
             include.value.collectFreeVariables(vars);
index 5ef54ea82ac414b071e516d0e6308317ee342769..730caba73302d88ea74e660370fd2508cf17d3ce 100644 (file)
@@ -25,6 +25,4 @@ public class AssignOp extends PlanOp {
         variable.setVal(expression.toVal(context, w));
         planContext.nextOp(w);
     }
-
-    
 }
index 121166f6b893ad1d1c84198681de0d2c552a81ac..67608de2d89bbe25dd6d180393ae7d6f4c162ae1 100644 (file)
@@ -5,7 +5,6 @@ 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.errors.Locations;
 import org.simantics.scl.compiler.types.Type;
 
@@ -36,12 +35,6 @@ public class EqBasic extends Equation {
         }
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        left.forVariables(procedure);
-        right.forVariables(procedure);
-    }
-
     @Override
     public void collectFreeVariables(THashSet<Variable> vars) {
         left.collectFreeVariables(vars);
index bbd46413974827c683c7b3591db3b4382a78dfa2..2e434b461296433feeaf3e00af7e58870caaaab7 100644 (file)
@@ -33,11 +33,6 @@ public class EqGuard extends Equation {
         }
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        guard.forVariables(procedure);
-    }
-
     @Override
     public void collectFreeVariables(THashSet<Variable> vars) {
         guard.collectFreeVariables(vars);
index 34ef7539515dafdbacb5b0a9d459d117fc822359..dcf11a3e6ec3aef54726f14aef1eec2da2e36efb 100644 (file)
@@ -17,7 +17,6 @@ public abstract class Equation extends Symbol {
 
     public abstract void setLocationDeep(long loc);
 
-    public abstract void forVariables(VariableProcedure procedure);
     public abstract void collectFreeVariables(THashSet<Variable> vars);
     public abstract void collectEffects(THashSet<Type> effects);
     public abstract void checkType(TypingContext context);
index a853dfff6731f9309699b822fce6fec5d3d5999a..4a65459b864d615493b6141540610beb26c18efe 100644 (file)
@@ -69,12 +69,6 @@ public abstract class ASTExpression extends SimplifiableExpression {
                 getClass().getSimpleName() + " does not implement method inferType.");
     }
     
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        throw new InternalCompilerError("Class " + 
-                getClass().getSimpleName() + " does not implement method forVariables.");
-    }
-    
     @Override
     public void setLocationDeep(long loc) {
         if(location == Locations.NO_LOCATION)
index 04b70deb0ac47042e38732a7e831afd16a418555..cb525a9adfdef3bde0c5ab1b8dfdae5d63e51a19 100644 (file)
@@ -28,8 +28,4 @@ public class Assignment {
         pattern.setLocationDeep(loc);
         value.setLocationDeep(loc);
     }
-
-    public void forVariables(VariableProcedure procedure) {
-        value.forVariables(procedure);
-    }
 }
index 3765fbefc1a78bfc7be8e23f811619b6cbfa3eea..54be27b3cc2de0e0d23170ecc0567d8498acf10f 100644 (file)
@@ -109,8 +109,4 @@ public class Case extends Symbol {
             patterns[i] = patterns[i].checkTypeAsPattern(context, parameterTypes[i]);
         value = value.checkIgnoredType(context);
     }
-
-    public void forVariables(VariableProcedure procedure) {
-        value.forVariables(procedure);
-    }
 }
index 5d91fbc3c63c474882ef371d4f1776b9a4c16fae..9b6c2645cd95e1fb0fd6e5265ee655e1214248b8 100644 (file)
@@ -100,11 +100,6 @@ public abstract class DecoratingExpression extends SimplifiableExpression {
         }
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        expression.forVariables(procedure);
-    }
-
     @Override
     public IVal toVal(CompilationContext context, CodeWriter w) {
         throw new InternalCompilerError("Cannot generate code for " + getClass().getSimpleName() + ".");
index 09cbcf25bf2557e5f48d82a04ae494455684008a..73c4fa3a0b88877209185020de6e52b0c5c59dcb 100644 (file)
@@ -52,10 +52,6 @@ public class EAmbiguous extends SimplifiableExpression {
             TIntHashSet vars) {
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-    }
-
     @Override
     protected void updateType() throws MatchException {
         throw new InternalCompilerError();
index 2b488068d547108d0341950bd71968463cd6ce75..375039e0b6ec76173e300bc0e000175b1d7e395e 100644 (file)
@@ -369,13 +369,6 @@ public class EApply extends Expression {
             return false;
         }
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        function.forVariables(procedure);
-        for(Expression parameter : parameters)
-            parameter.forVariables(procedure);
-    }
     
     @Override
     public boolean isPattern(int arity) {
index e7a9d42468bc19f8068128e2d93a5ed9f8084c25..cd54a44d6b30531fa803442bcf87bb8322200f84 100644 (file)
@@ -133,11 +133,6 @@ public class EApplyType extends Expression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        expression.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 305d5309307bb059ef8dcb11eb5efce69ba3a547..1a4a5bbd04c3e2c8091a8f01c4b4d2063edc647c 100644 (file)
@@ -18,9 +18,9 @@ import gnu.trove.set.hash.TIntHashSet;
 
 public class EAsPattern extends Expression {
 
-    Variable var;
-    EVar eVar;
-    Expression pattern;
+    public Variable var;
+    public EVar eVar;
+    public Expression pattern;
 
     public EAsPattern(EVar eVar, Expression pattern) {
         this.eVar = eVar;
@@ -143,12 +143,6 @@ public class EAsPattern extends Expression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        procedure.execute(eVar.location, var);
-        pattern.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 196ddc90fbc2423d72f22b8c675db70972e5c680..b4d824caaaa8d9d02d22c51173e01781dc42110e 100644 (file)
@@ -23,7 +23,7 @@ public class EBind extends SimplifiableExpression {
     public Expression pattern;
     public Expression value;
     public Expression in;
-    private EVariable monadEvidence;
+    EVariable monadEvidence;
     SCLValue bindFunction;
     Type monadType;
     Type valueContentType;
@@ -158,14 +158,6 @@ public class EBind extends SimplifiableExpression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        pattern.forVariables(procedure);
-        value.forVariables(procedure);
-        if(monadEvidence != null)
-            monadEvidence.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 2f87719306901bde69636d1206a33efdea077acd..d23b2e4cee3b19710a8bf1d855c3144c153fa295 100644 (file)
@@ -37,11 +37,6 @@ public class ECHRRuleset extends Expression {
         in.collectVars(allVars, vars);
     }
     @Override
-    public void forVariables(VariableProcedure procedure) {
-        ruleset.forVariables(procedure);
-        in.forVariables(procedure);
-    }
-    @Override
     protected void updateType() throws MatchException {
         setType(in.getType());
     }
index ce0385f815623760edf9a276c6a69e10da7f697a..25ae61345d77f5e7c085591d6a414699e58d1068 100644 (file)
@@ -34,10 +34,6 @@ public class ECHRRulesetConstructor extends Expression {
         ruleset.collectVars(allVars, vars);
     }
     @Override
-    public void forVariables(VariableProcedure procedure) {
-        ruleset.forVariables(procedure);
-    }
-    @Override
     protected void updateType() throws MatchException {
         throw new InternalCompilerError("Type of ECHRRulesetConstructor should be already given.");
     }
index aa232cdb59ab7e10e29f01e14f72e7c2e7abeef6..6b4a7fe8625e99d120221c113428b6e5ae14062a 100644 (file)
@@ -50,12 +50,6 @@ public class ECHRSelect extends Expression {
         expression.collectVars(allVars, vars);
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        query.forVariables(procedure);
-        expression.forVariables(procedure);
-    }
-
     @Override
     protected void updateType() throws MatchException {
         setType(Types.list(expression.getType()));
index c5b4681a86d233e4ee87fa8fe5b152ae6aa7baeb..037144a4c63d20f15157410640c1e1a313ddea8d 100644 (file)
@@ -258,10 +258,6 @@ public class EConstant extends Expression {
     public Precedence getPrecedence() {
         return value.getPrecedence();
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-    }
     
     @Override
     public boolean isPattern(int arity) {
index ea657f8b1459d3fb64bbf58b8147e336ebae49a3..49d010bceef46bff083648434ab92d6483e69ae1 100644 (file)
@@ -96,11 +96,6 @@ public class EEnforce extends SimplifiableExpression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        query.forVariables(procedure);
-    }
     
     @Override
     public Expression replace(ReplaceContext context) {
index eec5a5888d24f24491cbd5ba52d34834d6031bb7..dd1a7e415d1adecef3d59aae92cd1242fa50b186 100644 (file)
@@ -61,12 +61,6 @@ public class EEquations extends SimplifiableExpression {
             equation.collectVars(allVars, vars);
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(Equation equation : equations)
-            equation.forVariables(procedure);
-    }
-
     @Override
     protected void updateType() throws MatchException {
         setType(Types.UNIT);
index fbe8cde2ab646a5bc745e3bb0de558dfb2954f4b..c7ea89b30678c8d15037241108028c509fdbe4de 100644 (file)
@@ -87,10 +87,6 @@ public class EError extends Expression {
     public Expression replace(ReplaceContext context) {
         return this;
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 1e8341e66cbd4a7f408c8cd05ef6fe4d70bbd30e..611e96d368ea3fa33c939b18d575fa5b061b3c6c 100644 (file)
@@ -116,10 +116,6 @@ public class EExternalConstant extends Expression {
     public IExpression toIExpression(ExpressionInterpretationContext context) {
         return new IConstant(value);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index da9a7b38be68463ce404b20a1e87adbf0d9d59fc..0bc8a431788d530b0aed43e5f91070014d966fec 100644 (file)
@@ -185,12 +185,6 @@ public class EFieldAccess extends SimplifiableExpression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        parent.forVariables(procedure);
-        accessor.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index fc437cfd8c8d68be07fc997cd0b3a22063f1286c..5f9a1eb59adbe1002189f376dd19092d3b8199b5 100644 (file)
@@ -81,11 +81,6 @@ public class EGetConstraint extends SimplifiableExpression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        evidence.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 1f3dccc3e9b848aa29a407c6c2cfb3743a2faf1e..418ba69c9cda9c2e3b1c352daedc02176e8b1570 100644 (file)
@@ -170,13 +170,6 @@ public class EIf extends Expression {
                 else_ != null ? else_.toIExpression(target) : new IConstant(Tuple0.INSTANCE));
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        condition.forVariables(procedure);
-        then_.forVariables(procedure);
-        if(else_ != null)
-            else_.forVariables(procedure);
-    }
     @Override
     public Expression accept(ExpressionTransformer transformer) {
         return transformer.transform(this);
index 17cf6e58edb59a23b6601f087595dd8d1df8b725..0b5d1a16dd8ec64671c22750480277fe792b0872 100644 (file)
@@ -140,12 +140,6 @@ public class EIntegerLiteral extends SimplifiableExpression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        if(constraint != null)
-            constraint.forVariables(procedure);
-    }
     
     @Override
     public boolean isPattern(int arity) {
index 573abfbb86055f081f57f49aba4d54db3cb08287..5138ec596290fe0f32e524e4e36f09cfe8a8f7ad 100644 (file)
@@ -191,12 +191,6 @@ public class ELambda extends SimplifiableExpression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(Case case_ : cases)
-            case_.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 34464fae41a7e7986fd88e72d5916cf4a089839e..d413b8c35ecd4d9767ed1f649d636ca36dfdb174 100644 (file)
@@ -108,11 +108,6 @@ public class ELambdaType extends Expression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        value.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index de72c0c1cdc0ebe63bb7e9cf5740ab79f393ec39..5bde43500f6d7c3ab2c07b41c9d61bbf316de801 100644 (file)
@@ -235,13 +235,6 @@ public class ELet extends Expression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(Assignment assignment : assignments)
-            assignment.forVariables(procedure);
-        in.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 7a8b71ebb7b2758c7c01d87673a8c8a7b41a5470..fa21346f1202528560cf5878dd39b9e5945a3d76 100644 (file)
@@ -119,12 +119,6 @@ public class EListComprehension extends SimplifiableExpression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        head.forVariables(procedure);
-        qualifier.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index d8d5f76658e4c6947edb11a6302bf974ba763987..5c2a0d9d4c07e5f4e1a51f08bee1f95703f8bfe6 100644 (file)
@@ -140,12 +140,6 @@ public class EListLiteral extends SimplifiableExpression {
             componentExpressions[i] = components[i].toIExpression(target);
         return new IListLiteral(componentExpressions);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(Expression component : components)
-            component.forVariables(procedure);
-    }
     
     @Override
     public Expression replace(ReplaceContext context) {
index 0d9d844b6f1c06f55ff61d72c5fce23b2eddd4bd..d2a671a1d96cdd1a3a60b451061acd897b42d067 100644 (file)
@@ -119,10 +119,6 @@ public class ELiteral extends Expression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-    }
     
     @Override
     public boolean isPattern(int arity) {
index a7a726879f566e114653316d546ff8ff00ee6046..4ad8135c43803367f9584fe3e3158a45f92d106a 100644 (file)
@@ -186,14 +186,6 @@ public class EMatch extends Expression {
     public Case[] getCases() {
         return cases;
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(Expression s : scrutinee)
-            s.forVariables(procedure);
-        for(Case case_ : cases)
-            case_.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 4860055c19d3fecc0ae04d9d0202383951c73175..9468342bb899bbb870521ffb73100faaac4617c9 100644 (file)
@@ -128,12 +128,6 @@ public class ERealLiteral extends SimplifiableExpression {
     public String getValue() {
         return value;
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        if(constraint != null)
-            constraint.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index b9e55d8497c90a7fb13bf6000fe72e4a9e6dd0cb..41d43dd067987bcc6a33c74ebaf870c0324b0e98 100644 (file)
@@ -94,12 +94,6 @@ public class ERuleset extends SimplifiableExpression {
             visitor.visit(this);
             return b.toString();
         }
-
-        public void forVariables(VariableProcedure procedure) {
-            for(Expression headParameter : headParameters)
-                headParameter.forVariables(procedure);
-            body.forVariables(procedure);
-        }
     }
     
     private void checkRuleTypes(TypingContext context) {
@@ -400,13 +394,6 @@ public class ERuleset extends SimplifiableExpression {
     public Expression getIn() {
         return in;
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(DatalogRule rule : rules)
-            rule.forVariables(procedure);
-        in.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 34aca4adcaccb8512ed29a0e39d2cdbb032a8650..42fdc6f106536465ad0350fbbd66c794392074ee 100644 (file)
@@ -170,12 +170,6 @@ public class ESelect extends SimplifiableExpression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        expression.forVariables(procedure);
-        query.forVariables(procedure);
-    }
     
     @Override
     public Expression simplify(SimplificationContext context) {
index 91de49eb2e3d455d0f93f777675f1d2df0daebb4..0038dbf384c759541b8e6e29ce56a53750384b71 100644 (file)
@@ -226,11 +226,6 @@ public class ESimpleLambda extends Expression {
     public Variable getParameter() {
         return parameter;
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        value.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 0a5d67651cc92ca4055e84984d7692844a4018d6..1a084b3666283ae79e6fa5758e6fec82d047aceb 100644 (file)
@@ -198,12 +198,6 @@ public class ESimpleLet extends Expression {
         return in;
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        value.forVariables(procedure);
-        in.forVariables(procedure);
-    }
-    
     @Override
     public Expression accept(ExpressionTransformer transformer) {
         return transformer.transform(this);
index e00514151f335c6772b6c761da66a51a4dbecefb..3e8f61b036cf8f932895bfaca47879836835210d 100644 (file)
@@ -111,11 +111,6 @@ public class ETransformation extends SimplifiableExpression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        seed.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 568b3c10818ea47740e3492b202c9b55e4e3f263..6452812fc370f82989e662b643cb7675f85a65ac 100644 (file)
@@ -93,11 +93,6 @@ public class ETypeAnnotation extends SimplifiableExpression {
     public Expression getValue() {
         return value;
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        value.forVariables(procedure);
-    }
     
     @Override
     public Expression accept(ExpressionTransformer transformer) {
index 761ed0f2f23da45b7cdac5b39bffdb6d22d43c2b..669867ff6ca0e825f83c3906b50e3e63a652530f 100644 (file)
@@ -27,7 +27,7 @@ import gnu.trove.set.hash.TIntHashSet;
 public class EVariable extends Expression {
     public static final EVariable[] EMPTY_ARRAY = new EVariable[0];
     
-    Variable variable;
+    public Variable variable;
     
     public EVariable(Variable variable) {
         this.variable = variable;
@@ -180,12 +180,6 @@ public class EVariable extends Expression {
     public void accept(ExpressionVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        if(variable != null)
-            procedure.execute(location, variable);
-    }
     
     @Override
     public boolean isPattern(int arity) {
index 4997fa592e49e84c2fe6bc82d9cca2208e19406c..2561e63b979fefef95900181133391600f8de844 100644 (file)
@@ -37,12 +37,6 @@ public class EViewPattern extends Expression {
         expression.collectVars(allVars, vars);
         pattern.collectVars(allVars, vars);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        expression.forVariables(procedure);
-        pattern.forVariables(procedure);
-    }
     
     @Override
     public Expression inferType(TypingContext context) {
index d8b42fca47e921bc26759442b77f41c7218e46b5..9cdb6eab222ae3f22d99f8932b073b552f33a255 100644 (file)
@@ -149,12 +149,6 @@ public class EWhen extends SimplifiableExpression {
     public Expression getAction() {
         return action;
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        query.forVariables(procedure);
-        action.forVariables(procedure);
-    }
     
     @Override
     public Expression simplify(SimplificationContext context) {
index d3e226cf490b5e70a1aae97fd2d654e7ff448adc..da3afdbfa08ea1df7ccef191f859790b1d34f0d9 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.scl.compiler.elaboration.errors.NotPatternException;
 import org.simantics.scl.compiler.elaboration.expressions.lhstype.LhsType;
 import org.simantics.scl.compiler.elaboration.expressions.lhstype.PatternMatchingLhs;
 import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToStringVisitor;
+import org.simantics.scl.compiler.elaboration.expressions.visitors.ForVariablesUsesVisitor;
 import org.simantics.scl.compiler.elaboration.query.QAtom;
 import org.simantics.scl.compiler.elaboration.relations.SCLRelation;
 import org.simantics.scl.compiler.internal.codegen.references.IVal;
@@ -156,9 +157,12 @@ public abstract class Expression extends Symbol implements Typed {
 
        public abstract void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs);
        public abstract void collectVars(TObjectIntHashMap<Variable> allVars, TIntHashSet vars);
-       public abstract void forVariables(VariableProcedure procedure);
-       
-       public Expression decomposeMatching() {
+
+    public void forVariableUses(VariableProcedure procedure) {
+        accept(new ForVariablesUsesVisitor(procedure));
+    }
+
+    public Expression decomposeMatching() {
         return this;
     }
 
index fa67162d5620df596630bde077ae49bc031ea751..f1e62b2f7d61930e3832c8d93bdab673c5546832 100644 (file)
@@ -27,10 +27,4 @@ public class GuardedExpression extends Symbol {
             value.setLocationDeep(loc);
         }
     }
-
-    public void forVariables(VariableProcedure procedure) {
-        for(Expression guard : guards)
-            guard.forVariables(procedure);
-        value.forVariables(procedure);
-    }
 }
index 992a9939e89de06706fc49aaa7803f37b6d94def..07fbc50a6f8b5f578833003a5d59840308552ad0 100644 (file)
@@ -160,12 +160,6 @@ public class GuardedExpressionGroup extends Expression {
         visitor.visit(this);
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(GuardedExpression expression : expressions)
-            expression.forVariables(procedure);
-    }
-
     @Override
     public Expression accept(ExpressionTransformer transformer) {
         return transformer.transform(this);
index d75080095d1c45a455e7eb08d20ea58eca96be2b..3cdb32b72c93e12c3ad65a722260b8dc29926a3b 100644 (file)
@@ -73,6 +73,8 @@ EquationVisitor, StatementVisitor, CHRAstQueryVisitor {
         expression.pattern.accept(this);
         expression.value.accept(this);
         expression.in.accept(this);
+        if(expression.monadEvidence != null)
+            visit(expression.monadEvidence);
     }
 
     @Override
@@ -145,6 +147,7 @@ EquationVisitor, StatementVisitor, CHRAstQueryVisitor {
     public void visit(ELet expression) {
         for(Assignment assignment : expression.assignments)
             visit(assignment);
+        expression.in.accept(this);
     }
 
     public void visit(Assignment assignment) {
@@ -380,6 +383,8 @@ EquationVisitor, StatementVisitor, CHRAstQueryVisitor {
             visit(rule.head);
             visit(rule.body);
         }
+        for(IncludeStatement include : ruleset.includes)
+            include.value.accept(this);
     }
 
     @Override
index 793bd006531a4bdc87135691360a00ba405eb52d..e4cdd0937f7027e0498f270d79a0126de5676488 100644 (file)
@@ -5,7 +5,6 @@ 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.errors.Locations;
 import org.simantics.scl.compiler.types.Types;
 
@@ -70,9 +69,4 @@ public class ExpressionAccessor extends FieldAccessor {
     public void accept(FieldAccessorVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        fieldName.forVariables(procedure);
-    }
 }
index 0f0d8417f3cbead247f8b11dc3b83550d89803e2..aaf80610aaa9bd369dd36353adb48cac461e0ce6 100644 (file)
@@ -5,7 +5,6 @@ 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.internal.parsing.Symbol;
 
 import gnu.trove.map.hash.TObjectIntHashMap;
@@ -48,6 +47,4 @@ public abstract class FieldAccessor extends Symbol {
     public abstract void setLocationDeep(long loc);
 
     public abstract void accept(FieldAccessorVisitor visitor);
-
-    public abstract void forVariables(VariableProcedure procedure);
 }
index 9cb37e58ff12c610207aad0a828a7dc2a8fabd60..920a816061e39a3344e6d9745b7762db7dfbe457 100644 (file)
@@ -3,7 +3,6 @@ package org.simantics.scl.compiler.elaboration.expressions.accessor;
 import org.simantics.scl.compiler.constants.StringConstant;
 import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
 import org.simantics.scl.compiler.errors.Locations;
 
 public class IdAccessor extends FieldAccessor {
@@ -34,8 +33,4 @@ public class IdAccessor extends FieldAccessor {
     public void accept(FieldAccessorVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-    }
 }
index d08a4383fa8816b11c641d3518586ec189b668b9..ac038d12c1877a876583c875672f84036116de46 100644 (file)
@@ -3,7 +3,6 @@ package org.simantics.scl.compiler.elaboration.expressions.accessor;
 import org.simantics.scl.compiler.constants.StringConstant;
 import org.simantics.scl.compiler.elaboration.expressions.ELiteral;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
 import org.simantics.scl.compiler.errors.Locations;
 
 public class StringAccessor extends FieldAccessor {
@@ -29,8 +28,4 @@ public class StringAccessor extends FieldAccessor {
     public void accept(FieldAccessorVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-    }
 }
index b1efd2ca95d965802528feab0381fe4978f68268..a0073b889d62e6e23b50f1bd99176eb9d8006c2e 100644 (file)
@@ -7,7 +7,6 @@ import org.simantics.scl.compiler.elaboration.expressions.Case;
 import org.simantics.scl.compiler.elaboration.expressions.EVariable;
 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.errors.Locations;
 import org.simantics.scl.compiler.types.Type;
 
@@ -99,11 +98,6 @@ public class ListAssignment extends ListQualifier {
         visitor.visit(this);
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        value.forVariables(procedure);
-    }
-
     @Override
     public ListQualifier accept(ListQualifierTransformer transformer) {
         return transformer.transform(this);
index 90b68c5dd3dffec03aca7fe474ff0ad30e807f01..c7f89ba7678e86fadec291186f7f3173d3978260 100644 (file)
@@ -7,7 +7,6 @@ import org.simantics.scl.compiler.elaboration.expressions.Case;
 import org.simantics.scl.compiler.elaboration.expressions.EVariable;
 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.errors.Locations;
 import org.simantics.scl.compiler.types.TMetaVar;
 import org.simantics.scl.compiler.types.Type;
@@ -105,11 +104,6 @@ public class ListGenerator extends ListQualifier {
         visitor.visit(this);
     }
     
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        value.forVariables(procedure);
-    }
-    
     @Override
     public ListQualifier accept(ListQualifierTransformer transformer) {
         return transformer.transform(this);
index 626bd48cb75e50d3a8585e30e05559dd1d8d76ff..c9e29ca5b9d8a7b8c2a759929860e49c2472f3bb 100644 (file)
@@ -5,7 +5,6 @@ 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.errors.Locations;
 import org.simantics.scl.compiler.types.Type;
 import org.simantics.scl.compiler.types.Types;
@@ -73,11 +72,6 @@ public class ListGuard extends ListQualifier {
         visitor.visit(this);
     }
     
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        condition.forVariables(procedure);
-    }
-    
     @Override
     public ListQualifier accept(ListQualifierTransformer transformer) {
         return transformer.transform(this);
index 939e6fd66a4f238e7ca239685fb2684b791bde21..048b525f7edb1362474dc9a304aba08d260d8456 100644 (file)
@@ -4,7 +4,6 @@ import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
 import org.simantics.scl.compiler.internal.parsing.Symbol;
 import org.simantics.scl.compiler.types.Type;
 
@@ -27,6 +26,5 @@ public abstract class ListQualifier extends Symbol {
     public abstract void setLocationDeep(long loc);
     public abstract void accept(ListQualifierVisitor visitor);
     public abstract ListQualifier accept(ListQualifierTransformer transformer);
-    public abstract void forVariables(VariableProcedure procedure);
     
 }
index f56820d2a3e9496af3cdb5b6b67c85d1b92401f7..5d633d8d01aaf5b47326600c94f24c66a612b72f 100644 (file)
@@ -5,7 +5,6 @@ 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.errors.Locations;
 import org.simantics.scl.compiler.types.Type;
 
@@ -95,12 +94,6 @@ public class ListSeq extends ListQualifier {
         visitor.visit(this);
     }
     
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        a.forVariables(procedure);
-        b.forVariables(procedure);
-    }
-    
     @Override
     public ListQualifier accept(ListQualifierTransformer transformer) {
         return transformer.transform(this);
index fbc153226926a8aa64d1cf429c46f5a2ab74949a..451493ba3f6764965c8ec1662b2c1a34059abe93 100644 (file)
@@ -5,7 +5,6 @@ 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.errors.Locations;
 import org.simantics.scl.compiler.types.TMetaVar;
 import org.simantics.scl.compiler.types.Type;
@@ -122,14 +121,6 @@ public class ListThen extends ListQualifier {
     public void accept(ListQualifierVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        left.forVariables(procedure);
-        transformer.forVariables(procedure);
-        if(by != null)
-            by.forVariables(procedure);
-    }
     
     @Override
     public ListQualifier accept(ListQualifierTransformer transformer) {
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/visitors/ForVariablesUsesVisitor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/visitors/ForVariablesUsesVisitor.java
new file mode 100644 (file)
index 0000000..b4d1fd4
--- /dev/null
@@ -0,0 +1,25 @@
+package org.simantics.scl.compiler.elaboration.expressions.visitors;
+
+import org.simantics.scl.compiler.elaboration.expressions.EAsPattern;
+import org.simantics.scl.compiler.elaboration.expressions.EVariable;
+import org.simantics.scl.compiler.elaboration.expressions.StandardExpressionVisitor;
+import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
+
+public class ForVariablesUsesVisitor extends StandardExpressionVisitor {
+    VariableProcedure procedure;
+    
+    public ForVariablesUsesVisitor(VariableProcedure procedure) {
+        this.procedure = procedure;
+    }
+    
+    @Override
+    public void visit(EVariable expression) {
+        if(expression.variable != null)
+            procedure.execute(expression.location, expression.variable);
+    }
+    @Override
+    public void visit(EAsPattern expression) {
+        expression.pattern.accept(this);
+        procedure.execute(expression.eVar.location, expression.var);
+    }
+}
index 53eb780fdaf2174393a8235d15a755aa8363d5be..52a59585f1b88b375b8db78f499f290937f7301e 100644 (file)
@@ -8,7 +8,6 @@ import org.simantics.scl.compiler.elaboration.expressions.EApply;
 import org.simantics.scl.compiler.elaboration.expressions.EVar;
 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.query.pre.QPreExists;
 import org.simantics.scl.compiler.elaboration.query.pre.QPreGuard;
 import org.simantics.scl.compiler.errors.Locations;
@@ -95,10 +94,4 @@ public abstract class QAbstractCombiner extends Query {
                 query.setLocationDeep(loc);
         }
     }
-    
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(Query query : queries)
-            query.forVariables(procedure);
-    }
 }
index e04246e40e7d4224837205d7622c404527bae0aa..2b6c6771135ba2ace7d009a153870d6bc21340ae 100644 (file)
@@ -3,7 +3,6 @@ package org.simantics.scl.compiler.elaboration.query;
 import org.simantics.scl.compiler.elaboration.contexts.TranslationContext;
 import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
 import org.simantics.scl.compiler.errors.Locations;
 
 import gnu.trove.map.hash.TObjectIntHashMap;
@@ -51,9 +50,4 @@ public abstract class QAbstractModifier extends Query {
             query.setLocationDeep(loc);
         }
     }
-    
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        query.forVariables(procedure);
-    }
 }
index fd7dacb799b625984ccf280c1b4f96380701c950..7a20ae3c5f2df7f003392ac25d56afe4cfaf73eb 100644 (file)
@@ -129,7 +129,7 @@ public class QAtom extends Query {
                     }
                     else {
                         optionalVariableByParameter[i] = -1;
-                        parameter.forVariables(procedure);
+                        parameter.forVariableUses(procedure);
                     }
                 }
             }
@@ -250,12 +250,6 @@ public class QAtom extends Query {
         visitor.visit(this);
     }
 
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(Expression parameter : parameters)
-            parameter.forVariables(procedure);
-    }
-
     @Override
     public void splitToPhases(TIntObjectHashMap<ArrayList<Query>> result) {
         int phase = relation.getPhase();
index 5356eccc2708987042bb174f215a2ab374782084..293c8bf707ba55142a9bbfc28ed9d899a69e1e87 100644 (file)
@@ -8,7 +8,6 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.expressions.EVariable;
 import org.simantics.scl.compiler.elaboration.expressions.QueryTransformer;
 import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
 import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext;
 import org.simantics.scl.compiler.elaboration.query.compilation.DerivateException;
 import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException;
@@ -92,13 +91,6 @@ public class QExists extends QAbstractModifier {
         visitor.visit(this);
     }
     
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(Variable variable : variables)
-            procedure.execute(location, variable);
-        super.forVariables(procedure);
-    }
-    
     @Override
     public Query accept(QueryTransformer transformer) {
         return transformer.transform(this);
index 62ff9583ce97317519fe2074254f818b61cf6027..719f474b6b115d3d800d65c801cadb4f55ce8c9a 100644 (file)
@@ -5,7 +5,6 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
 import org.simantics.scl.compiler.elaboration.expressions.QueryTransformer;
 import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
 import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext;
 import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException;
 import org.simantics.scl.compiler.errors.Locations;
@@ -82,13 +81,6 @@ public class QIf extends Query {
     public void accept(QueryVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        condition.forVariables(procedure);
-        elseQuery.forVariables(procedure);
-        thenQuery.forVariables(procedure);
-    }
     
     @Override
     public Query accept(QueryTransformer transformer) {
index ca9378c89f19da98d41b699e95ef88c75f497048..12da9da3b8ddc5dfe3d7073d08c053616c7fdc11 100644 (file)
@@ -6,7 +6,6 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext;
 import org.simantics.scl.compiler.elaboration.expressions.Expression;
 import org.simantics.scl.compiler.elaboration.expressions.QueryTransformer;
 import org.simantics.scl.compiler.elaboration.expressions.Variable;
-import org.simantics.scl.compiler.elaboration.expressions.VariableProcedure;
 import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext;
 import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException;
 import org.simantics.scl.compiler.elaboration.rules.MappingRelation;
@@ -82,12 +81,6 @@ public class QMapping extends Query {
     public void accept(QueryVisitor visitor) {
         visitor.visit(this);
     }
-
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        for(Expression parameter : parameters)
-            parameter.forVariables(procedure);
-    }
     
     @Override
     public Query accept(QueryTransformer transformer) {
index 0ac54e22ec29d72b8468bde640220c4676a4ed39..0b804caf356cada38c2d35d14e6a04158b646b10 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.scl.compiler.elaboration.expressions.StandardExpressionVisi
 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.elaboration.expressions.visitors.ForVariablesUsesVisitor;
 import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext;
 import org.simantics.scl.compiler.elaboration.query.compilation.DerivateException;
 import org.simantics.scl.compiler.elaboration.query.compilation.DynamicProgrammingOrdering;
@@ -135,8 +136,6 @@ public abstract class Query extends Symbol {
         });
     }
     
-    public abstract void forVariables(VariableProcedure procedure);
-    
     public TIntObjectHashMap<ArrayList<Query>> splitToPhases() {
         TIntObjectHashMap<ArrayList<Query>> result = new TIntObjectHashMap<ArrayList<Query>>(2);
         splitToPhases(result);
@@ -156,4 +155,8 @@ public abstract class Query extends Symbol {
     }
     
     public abstract Query accept(QueryTransformer transformer);
+    
+    public void forVariables(VariableProcedure procedure) {
+        accept(new ForVariablesUsesVisitor(procedure));
+    }
 }
index ee96433d3e11e35c7e98370916de82f6b3c0d7f8..dc398f85768ca6eaedc4c927ec63c720f3cf98f6 100644 (file)
@@ -71,9 +71,4 @@ public abstract class PreQuery extends Query {
             query = new QExists(extraVariables.toArray(new Variable[extraVariables.size()]), query);
         return query;
     }
-    
-    @Override
-    public void forVariables(VariableProcedure procedure) {
-        throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support forVariables.");
-    }
 }
index 42eb9530d3717401b427b78f7c951c99620f8675..b404b1c53577741eb06ba69e40cc47ebedf0503f 100644 (file)
@@ -8,7 +8,6 @@ import static org.simantics.scl.compiler.elaboration.expressions.Expressions.let
 import static org.simantics.scl.compiler.elaboration.expressions.Expressions.tuple;
 import static org.simantics.scl.compiler.elaboration.expressions.Expressions.var;
 
-import org.simantics.scl.compiler.common.names.Name;
 import org.simantics.scl.compiler.common.names.Names;
 import org.simantics.scl.compiler.elaboration.expressions.EApply;
 import org.simantics.scl.compiler.elaboration.expressions.EVariable;
index 6060315c4d3103f34933dc9e6fcee61ab2ea7233..50958221ca9e0ac063895ed5ba65573deb895c7b 100644 (file)
@@ -184,7 +184,7 @@ public class TransformationBuilder {
                 }
             };
             for(QMapping mapping : decomposed.targetMappings)
-                mapping.parameters[0].forVariables(check);
+                mapping.parameters[0].forVariableUses(check);
             sourceVariables = sourceVariableList.toArray(new Variable[sourceVariableList.size()]);
         }
         
@@ -220,7 +220,7 @@ public class TransformationBuilder {
             }
             else {
                 PatternAnalyzer analyzer = new PatternAnalyzer(variableSet, mappedVariableUseCount); 
-                expression.forVariables(analyzer);
+                expression.forVariableUses(analyzer);
 
                 if(analyzer.containsVariables)
                     semiopenMappings.add(mapping);
index 75b083f0c9fbadc3a138e77b0b8a7a65b613bed4..06da2356294d80dd89e3803e940c71bb37953a74 100644 (file)
@@ -186,7 +186,7 @@ public class UnifiableFactory {
         
         // Default action
         final THashSet<Variable> dependences = new THashSet<Variable>();
-        expression.forVariables(new VariableProcedure() {
+        expression.forVariableUses(new VariableProcedure() {
             
             @Override
             public void execute(long location, Variable variable) {