From: Hannu Niemistö Date: Mon, 24 Jul 2017 12:08:41 +0000 (+0300) Subject: (refs #7375) Replaced collectVars method by a visitor X-Git-Tag: v1.31.0~264^2~32 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=666ee533a3cfa9f59e79215a269f8342227cdbda;p=simantics%2Fplatform.git (refs #7375) Replaced collectVars method by a visitor Change-Id: I4838702fadeca47449433693dae9630d5cac895d --- diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqBasic.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqBasic.java index 71dcd0425..785c27da0 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqBasic.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqBasic.java @@ -4,12 +4,8 @@ import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext; 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.errors.Locations; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EqBasic extends Equation { public Expression left; public Expression right; @@ -39,12 +35,6 @@ public class EqBasic extends Equation { right = right.checkType(context, left.getType()); } - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - left.collectVars(allVars, vars); - right.collectVars(allVars, vars); - } - @Override public void resolve(TranslationContext context) { left = left.resolve(context); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqGuard.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqGuard.java index aa66cd890..c72d9433f 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqGuard.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/EqGuard.java @@ -4,12 +4,8 @@ import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext; 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.errors.Locations; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EqGuard extends Equation { public Expression guard; @@ -35,11 +31,6 @@ public class EqGuard extends Equation { guard = guard.checkIgnoredType(context); } - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - guard.collectVars(allVars, vars); - } - @Override public void resolve(TranslationContext context) { guard = guard.resolve(context); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/Equation.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/Equation.java index 5b4268691..cb801a33d 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/Equation.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/equation/Equation.java @@ -3,19 +3,14 @@ package org.simantics.scl.compiler.elaboration.equation; import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext; 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.internal.parsing.Symbol; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public abstract class Equation extends Symbol { public static final Equation[] EMPTY_ARRAY = new Equation[0]; public abstract void setLocationDeep(long loc); public abstract void checkType(TypingContext context); - public abstract void collectVars(TObjectIntHashMap allVars, TIntHashSet vars); public abstract void resolve(TranslationContext context); public abstract void accept(EquationVisitor visitor); public abstract Equation replace(ReplaceContext context); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ASTExpression.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ASTExpression.java index 2858a579c..c96218b65 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ASTExpression.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ASTExpression.java @@ -7,9 +7,6 @@ import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public abstract class ASTExpression extends SimplifiableExpression { public ASTExpression() { } @@ -19,12 +16,6 @@ public abstract class ASTExpression extends SimplifiableExpression { throw new InternalCompilerError(getClass().getSimpleName() + " does not support simplify."); } - @Override - final public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - throw new InternalCompilerError(getClass().getSimpleName() + " does not support collectVars."); - } - @Override final protected void updateType() throws MatchException { throw new InternalCompilerError(getClass().getSimpleName() + " does not support updateType."); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Case.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Case.java index 2669b4733..a50bcc2dd 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Case.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Case.java @@ -8,9 +8,6 @@ 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.TIntHashSet; - public class Case extends Symbol { public Expression[] patterns; public Expression value; @@ -34,11 +31,6 @@ public class Case extends Symbol { return lhs; } - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - value.collectVars(allVars, vars); - } - public void resolve(TranslationContext context) { context.pushFrame(); for(int i=0;i allVars, - TIntHashSet vars) { - expression.collectVars(allVars, vars); - } @Override protected void updateType() throws MatchException { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAmbiguous.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAmbiguous.java index 0826bbbca..7434bf2ac 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAmbiguous.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAmbiguous.java @@ -16,8 +16,6 @@ import org.simantics.scl.compiler.types.util.TypeListener; import org.simantics.scl.compiler.types.util.TypeUnparsingContext; import gnu.trove.map.hash.THashMap; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; public class EAmbiguous extends SimplifiableExpression { public static final boolean DEBUG = false; @@ -41,11 +39,6 @@ public class EAmbiguous extends SimplifiableExpression { this.activeCount = alternatives.length; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - } - @Override protected void updateType() throws MatchException { throw new InternalCompilerError(); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java index 14366a4c9..02c7dff45 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApply.java @@ -32,9 +32,6 @@ import org.simantics.scl.compiler.types.exceptions.UnificationException; import org.simantics.scl.compiler.types.kinds.Kinds; import org.simantics.scl.compiler.types.util.MultiFunction; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EApply extends Expression { public Expression function; public Expression[] parameters; @@ -74,15 +71,9 @@ public class EApply extends Expression { public Expression[] getParameters() { return parameters; } - - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - function.collectVars(allVars, vars); - for(Expression parameter : parameters) - parameter.collectVars(allVars, vars); - } - - @Override - protected void updateType() throws MatchException { + + @Override + protected void updateType() throws MatchException { MultiFunction mfun = Types.matchFunction(function.getType(), parameters.length); /*for(int i=0;i allVars, TIntHashSet vars) { - expression.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(Types.instantiate(expression.getType(), parameter)); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAsPattern.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAsPattern.java index 59538d603..21248179f 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAsPattern.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EAsPattern.java @@ -12,9 +12,6 @@ import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EAsPattern extends Expression { public Variable var; @@ -38,15 +35,6 @@ public class EAsPattern extends Expression { public Expression getPattern() { return pattern; } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - int id = allVars.get(var); - if(id >= 0) - vars.add(id); - pattern.collectVars(allVars, vars); - } @Override public Expression simplify(SimplificationContext context) { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java index ce72e282a..5c4a729e2 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EBind.java @@ -15,9 +15,6 @@ import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.exceptions.UnificationException; import org.simantics.scl.compiler.types.kinds.Kinds; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EBind extends SimplifiableExpression { public Expression pattern; public Expression value; @@ -43,13 +40,6 @@ public class EBind extends SimplifiableExpression { this.in = in; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - value.collectVars(allVars, vars); - in.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(in.getType()); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java index e1495588a..e3fc0a4f2 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java @@ -12,9 +12,6 @@ import org.simantics.scl.compiler.internal.interpreted.IExpression; import org.simantics.scl.compiler.top.ExpressionInterpretationContext; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ECHRRuleset extends Expression { public CHRRuleset ruleset; public Expression in; @@ -23,12 +20,6 @@ public class ECHRRuleset extends Expression { this.ruleset = ruleset; this.in = in; } - - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - ruleset.collectVars(allVars, vars); - in.collectVars(allVars, vars); - } @Override protected void updateType() throws MatchException { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java index 5d7b490e7..431bd850d 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRulesetConstructor.java @@ -13,9 +13,6 @@ import org.simantics.scl.compiler.internal.interpreted.IExpression; import org.simantics.scl.compiler.top.ExpressionInterpretationContext; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ECHRRulesetConstructor extends Expression { public CHRRuleset ruleset; @@ -23,11 +20,6 @@ public class ECHRRulesetConstructor extends Expression { this.ruleset = ruleset; } - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - ruleset.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { throw new InternalCompilerError("Type of ECHRRulesetConstructor should be already given."); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRSelect.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRSelect.java index 71c4a43e0..bf3b818f5 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRSelect.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRSelect.java @@ -21,9 +21,6 @@ import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.kinds.Kinds; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ECHRSelect extends Expression { public CHRQuery query; public Variable[] existentialVariables; @@ -36,12 +33,6 @@ public class ECHRSelect extends Expression { this.query = query; } - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - query.collectVars(allVars, vars); - expression.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(Types.list(expression.getType())); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java index 9fcb4ca46..a668fe12b 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EConstant.java @@ -32,9 +32,6 @@ import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.util.MultiFunction; import org.simantics.scl.compiler.types.util.TypeUnparsingContext; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EConstant extends Expression { public SCLValue value; Type[] typeParameters; @@ -83,11 +80,6 @@ public class EConstant extends Expression { setType(Types.instantiate(getType(), type)); return this; } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - } @Override public Set getFreeVariables() { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEnforce.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEnforce.java index 3bd337963..8e1adf784 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEnforce.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEnforce.java @@ -12,9 +12,6 @@ import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EEnforce extends SimplifiableExpression { public Query query; @@ -27,12 +24,6 @@ public class EEnforce extends SimplifiableExpression { return query; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - query.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(Types.tupleConstructor(0)); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEquations.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEquations.java index 268cc2497..7773a5346 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEquations.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EEquations.java @@ -10,9 +10,6 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EEquations extends SimplifiableExpression { public Equation[] equations; @@ -48,12 +45,6 @@ public class EEquations extends SimplifiableExpression { return transformer.transform(this); } - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - for(Equation equation : equations) - equation.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(Types.UNIT); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EError.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EError.java index def408716..997a5723b 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EError.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EError.java @@ -13,9 +13,6 @@ import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.kinds.Kinds; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EError extends Expression { public EError(long loc, Type type) { @@ -30,11 +27,6 @@ public class EError extends Expression { this(loc, Types.metaVar(Kinds.STAR)); } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - } - @Override protected void updateType() throws MatchException { setType(Types.metaVar(Kinds.STAR)); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EExternalConstant.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EExternalConstant.java index 0321ae3fc..788483dbe 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EExternalConstant.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EExternalConstant.java @@ -19,9 +19,6 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.util.TypeUnparsingContext; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EExternalConstant extends Expression { Object value; @@ -34,11 +31,6 @@ public class EExternalConstant extends Expression { return value; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - } - public void toString(StringBuilder b, TypeUnparsingContext tuc) { b.append(value); } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EFieldAccess.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EFieldAccess.java index 668c05393..04a5840f5 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EFieldAccess.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EFieldAccess.java @@ -16,9 +16,6 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EFieldAccess extends SimplifiableExpression { private static final Type VARIABLE = Types.con("Simantics/Variables", "Variable"); @@ -34,13 +31,6 @@ public class EFieldAccess extends SimplifiableExpression { ((EFieldAccess)parent).lastAccessor = false; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - parent.collectVars(allVars, vars); - accessor.collectVars(allVars, vars); - } - private boolean returnsValue() { return accessor.accessSeparator == '#' && !accessor.isVariableId(); } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EGetConstraint.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EGetConstraint.java index a070ba8da..24ff0a149 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EGetConstraint.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EGetConstraint.java @@ -7,9 +7,6 @@ import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.types.TPred; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EGetConstraint extends SimplifiableExpression { TPred constraint; public EVariable evidence; @@ -19,13 +16,6 @@ public class EGetConstraint extends SimplifiableExpression { this.constraint = constraint; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - if(evidence != null) - evidence.collectVars(allVars, vars); - } - @Override public Expression inferType(TypingContext context) { Variable variable = new Variable("evidence"); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java index a65748243..fe6216fe1 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java @@ -17,9 +17,6 @@ import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.runtime.tuple.Tuple0; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EIf extends Expression { public Expression condition; public Expression then_; @@ -38,15 +35,6 @@ public class EIf extends Expression { this.else_ = else_; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - condition.collectVars(allVars, vars); - then_.collectVars(allVars, vars); - if(else_ != null) - else_.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(then_.getType()); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIntegerLiteral.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIntegerLiteral.java index fa4db7ff1..dc265934a 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIntegerLiteral.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIntegerLiteral.java @@ -16,9 +16,6 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EIntegerLiteral extends SimplifiableExpression { public String value; public EVariable constraint; @@ -26,11 +23,6 @@ public class EIntegerLiteral extends SimplifiableExpression { public EIntegerLiteral(String value) { this.value = value; } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - } public String getValue() { return value; diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambda.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambda.java index bc3e925b0..ccf86bbf5 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambda.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambda.java @@ -12,9 +12,6 @@ import org.simantics.scl.compiler.types.exceptions.UnificationException; import org.simantics.scl.compiler.types.kinds.Kinds; import org.simantics.scl.compiler.types.util.MultiFunction; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ELambda extends SimplifiableExpression { public Case[] cases; Type effect = Types.NO_EFFECTS; @@ -36,13 +33,6 @@ public class ELambda extends SimplifiableExpression { this(loc, new Case(new Expression[] {pat}, exp)); } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(Case case_ : cases) - case_.collectVars(allVars, vars); - } - public Expression decomposeMatching() { Expression[] patterns = cases[0].patterns; int arity = patterns.length; diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambdaType.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambdaType.java index 9aed4450e..73e38397d 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambdaType.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELambdaType.java @@ -15,9 +15,6 @@ import org.simantics.scl.compiler.types.TVar; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ELambdaType extends Expression { public TVar[] parameters; public Expression value; @@ -28,12 +25,6 @@ public class ELambdaType extends Expression { this.value = value; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - value.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(Types.forAll(parameters, value.getType())); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELet.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELet.java index 711953524..23c5b0be2 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELet.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELet.java @@ -36,14 +36,6 @@ public class ELet extends Expression { this.in = in; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(Assignment assign : assignments) - assign.value.collectVars(allVars, vars); - in.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(in.getType()); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListComprehension.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListComprehension.java index a6d79e817..78f7ce115 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListComprehension.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListComprehension.java @@ -10,9 +10,6 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EListComprehension extends SimplifiableExpression { public Expression head; @@ -29,13 +26,6 @@ public class EListComprehension extends SimplifiableExpression { this.head = head; this.qualifier = qualifier; } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - head.collectVars(allVars, vars); - qualifier.collectVars(allVars, vars); - } @Override public Expression checkBasicType(TypingContext context, Type requiredType) { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java index 797dbc2e5..0f9ae5a15 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java @@ -15,9 +15,6 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EListLiteral extends SimplifiableExpression { public Expression[] components; @@ -35,13 +32,6 @@ public class EListLiteral extends SimplifiableExpression { public Expression[] getComponents() { return components; } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(Expression component : components) - component.collectVars(allVars, vars); - } @Override public Expression simplify(SimplificationContext context) { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELiteral.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELiteral.java index 3f65de3b6..bef28f20f 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELiteral.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELiteral.java @@ -19,9 +19,6 @@ import org.simantics.scl.compiler.top.ExpressionInterpretationContext; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.util.TypeUnparsingContext; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ELiteral extends Expression { Constant value; @@ -38,11 +35,6 @@ public class ELiteral extends Expression { public Constant getValue() { return value; } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - } @Override public Set getFreeVariables() { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java index ba9cee65e..279815ecf 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EMatch.java @@ -17,9 +17,6 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.kinds.Kinds; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EMatch extends Expression { public Expression[] scrutinee; @@ -40,15 +37,6 @@ public class EMatch extends Expression { this.cases = cases; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(Expression s : scrutinee) - s.collectVars(allVars, vars); - for(Case case_ : cases) - case_.collectVars(allVars, vars); - } - @Override protected void updateType() { setType(cases[0].value.getType()); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERealLiteral.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERealLiteral.java index 8c861004c..90cc94bef 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERealLiteral.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERealLiteral.java @@ -15,9 +15,6 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ERealLiteral extends SimplifiableExpression { public String value; public EVariable constraint; @@ -26,11 +23,6 @@ public class ERealLiteral extends SimplifiableExpression { this.value = value; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - } - private Expression tryToConvertToPrimitive(ErrorLog errorLog, Type requiredType) { if(requiredType.equals(Types.DOUBLE)) return new ELiteral(new DoubleConstant(Double.parseDouble(value))); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERuleset.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERuleset.java index dadf52797..9663a2a72 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERuleset.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ERuleset.java @@ -128,17 +128,6 @@ public class ERuleset extends SimplifiableExpression { in = in.checkIgnoredType(context); return compile(context); } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(DatalogRule rule : rules) { - for(Expression parameter : rule.headParameters) - parameter.collectVars(allVars, vars); - rule.body.collectVars(allVars, vars); - } - in.collectVars(allVars, vars); - } @Override public Expression resolve(TranslationContext context) { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESelect.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESelect.java index 09079377f..e7014a865 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESelect.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESelect.java @@ -26,9 +26,6 @@ import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.kinds.Kinds; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ESelect extends SimplifiableExpression { private final Type ARRAY_LIST = Types.con("ArrayList", "T"); @@ -44,13 +41,6 @@ public class ESelect extends SimplifiableExpression { this.query = query; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - expression.collectVars(allVars, vars); - query.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(selectVariant==SCLTerminals.SELECT_FIRST diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLambda.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLambda.java index 13c75db78..833e3e9e3 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLambda.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLambda.java @@ -23,9 +23,6 @@ import org.simantics.scl.compiler.types.exceptions.UnificationException; import org.simantics.scl.compiler.types.kinds.Kinds; import org.simantics.scl.compiler.types.util.MultiFunction; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ESimpleLambda extends Expression { public Variable parameter; public Expression value; @@ -55,12 +52,6 @@ public class ESimpleLambda extends Expression { this.effect = effect; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - value.collectVars(allVars, vars); - } - public Expression decomposeMatching() { value = value.decomposeMatching(); return this; diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLet.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLet.java index 4957b578d..aedb05d4b 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLet.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLet.java @@ -15,9 +15,6 @@ import org.simantics.scl.compiler.top.ExpressionInterpretationContext; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ESimpleLet extends Expression { public Variable variable; // may be null public Expression value; @@ -44,13 +41,6 @@ public class ESimpleLet extends Expression { this.in = in; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - value.collectVars(allVars, vars); - in.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(in.getType()); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETransformation.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETransformation.java index e6f57ac86..b96907ea3 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETransformation.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETransformation.java @@ -14,9 +14,6 @@ import org.simantics.scl.compiler.top.SCLCompilerConfiguration; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ETransformation extends SimplifiableExpression { public static final Object TRANSFORMATION_RULES_TYPECHECKED = new Object(); @@ -28,12 +25,6 @@ public class ETransformation extends SimplifiableExpression { this.seed = seed; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - seed.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(Types.UNIT); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETypeAnnotation.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETypeAnnotation.java index 872da88f1..713342ed5 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETypeAnnotation.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ETypeAnnotation.java @@ -8,9 +8,6 @@ import org.simantics.scl.compiler.internal.parsing.types.TypeAst; import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ETypeAnnotation extends SimplifiableExpression { public Expression value; Type type; @@ -27,12 +24,6 @@ public class ETypeAnnotation extends SimplifiableExpression { this.type = type; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - value.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(type); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java index fccc62e98..7fe0e0a92 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java @@ -22,9 +22,6 @@ import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.kinds.Kinds; import org.simantics.scl.compiler.types.util.TypeUnparsingContext; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EVariable extends Expression { public static final EVariable[] EMPTY_ARRAY = new EVariable[0]; @@ -47,14 +44,6 @@ public class EVariable extends Expression { this.variable = variable; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - int id = allVars.get(variable); - if(id >= 0) - vars.add(id); - } - @Override public Set getFreeVariables() { if(variable == null) diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EViewPattern.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EViewPattern.java index f2a017edd..4957f7c85 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EViewPattern.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EViewPattern.java @@ -12,9 +12,6 @@ import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.util.MultiFunction; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EViewPattern extends Expression { public Expression expression; public Expression pattern; @@ -23,12 +20,6 @@ public class EViewPattern extends Expression { this.expression = expression; this.pattern = pattern; } - - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - expression.collectVars(allVars, vars); - pattern.collectVars(allVars, vars); - } @Override public Expression inferType(TypingContext context) { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EWhen.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EWhen.java index 55ea86baf..df6d56888 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EWhen.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EWhen.java @@ -16,9 +16,6 @@ import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.exceptions.UnificationException; import org.simantics.scl.compiler.types.kinds.Kinds; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class EWhen extends SimplifiableExpression { public Query query; @@ -41,13 +38,6 @@ public class EWhen extends SimplifiableExpression { this.variables = variables; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - query.collectVars(allVars, vars); - action.collectVars(allVars, vars); - } - @Override protected void updateType() throws MatchException { setType(Types.UNIT); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java index 5b60dad42..427acbd19 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/Expression.java @@ -18,6 +18,7 @@ import org.simantics.scl.compiler.elaboration.expressions.printing.ExpressionToS import org.simantics.scl.compiler.elaboration.expressions.visitors.CollectEffectsVisitor; import org.simantics.scl.compiler.elaboration.expressions.visitors.CollectFreeVariablesVisitor; import org.simantics.scl.compiler.elaboration.expressions.visitors.CollectRefsVisitor; +import org.simantics.scl.compiler.elaboration.expressions.visitors.CollectVarsVisitor; import org.simantics.scl.compiler.elaboration.expressions.visitors.ForVariablesUsesVisitor; import org.simantics.scl.compiler.elaboration.expressions.visitors.StandardExpressionVisitor; import org.simantics.scl.compiler.elaboration.query.QAtom; @@ -163,7 +164,9 @@ public abstract class Expression extends Symbol implements Typed { accept(new CollectRefsVisitor(allRefs, refs)); } - public abstract void collectVars(TObjectIntHashMap allVars, TIntHashSet vars); + public final void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { + accept(new CollectVarsVisitor(allVars, vars)); + } public final void forVariableUses(VariableProcedure procedure) { accept(new ForVariablesUsesVisitor(procedure)); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/GuardedExpressionGroup.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/GuardedExpressionGroup.java index 90e13d750..48283a887 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/GuardedExpressionGroup.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/GuardedExpressionGroup.java @@ -14,9 +14,6 @@ import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class GuardedExpressionGroup extends Expression { public GuardedExpression[] expressions; @@ -24,16 +21,6 @@ public class GuardedExpressionGroup extends Expression { this.expressions = expressions; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(GuardedExpression expression : expressions) { - for(Expression guard : expression.guards) - guard.collectVars(allVars, vars); - expression.value.collectVars(allVars, vars); - } - } - @Override protected void updateType() throws MatchException { setType(expressions[0].value.getType()); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/ExpressionAccessor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/ExpressionAccessor.java index 2febc404f..3df40521a 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/ExpressionAccessor.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/ExpressionAccessor.java @@ -4,13 +4,9 @@ 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.Expression; -import org.simantics.scl.compiler.elaboration.expressions.Variable; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.types.Types; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ExpressionAccessor extends FieldAccessor { public Expression fieldName; @@ -19,12 +15,6 @@ public class ExpressionAccessor extends FieldAccessor { this.fieldName = fieldName; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - fieldName.collectVars(allVars, vars); - } - @Override public void resolve(TranslationContext context) { fieldName = fieldName.resolve(context); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/FieldAccessor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/FieldAccessor.java index 21c892ce4..de02aa695 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/FieldAccessor.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/accessor/FieldAccessor.java @@ -4,13 +4,8 @@ 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.Expression; -import org.simantics.scl.compiler.elaboration.expressions.Variable; import org.simantics.scl.compiler.internal.parsing.Symbol; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.THashSet; -import gnu.trove.set.hash.TIntHashSet; - public abstract class FieldAccessor extends Symbol { public char accessSeparator; @@ -18,20 +13,13 @@ public abstract class FieldAccessor extends Symbol { this.accessSeparator = accessSeparator; } - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - } - - public void collectFreeVariables(THashSet vars) { - } - public void simplify(SimplificationContext context) { } public void resolve(TranslationContext context) { } - public void checkType(TypingContext context) { + public void checkType(TypingContext context) { } public abstract Expression asExpression(); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListAssignment.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListAssignment.java index 47aeef1a5..cddcffc77 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListAssignment.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListAssignment.java @@ -11,9 +11,6 @@ import org.simantics.scl.compiler.elaboration.expressions.Expression; import org.simantics.scl.compiler.elaboration.expressions.Variable; import org.simantics.scl.compiler.errors.Locations; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ListAssignment extends ListQualifier { public Expression pattern; public Expression value; @@ -29,12 +26,6 @@ public class ListAssignment extends ListQualifier { pattern.checkTypeAsPattern(context, value.getType()); } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - value.collectVars(allVars, vars); - } - @Override public CompiledQualifier compile(SimplificationContext context) { if(pattern instanceof EVariable) diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGenerator.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGenerator.java index 959e3bf3d..e0401e6dc 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGenerator.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGenerator.java @@ -14,9 +14,6 @@ import org.simantics.scl.compiler.types.TMetaVar; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.kinds.Kinds; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ListGenerator extends ListQualifier { public Expression pattern; public Expression value; @@ -33,12 +30,6 @@ public class ListGenerator extends ListQualifier { pattern.checkTypeAsPattern(context, componentType); } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - value.collectVars(allVars, vars); - } - @Override public CompiledQualifier compile(SimplificationContext context) { if(pattern instanceof EVariable) diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGuard.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGuard.java index 9a5c37bdc..e5e8ee9d4 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGuard.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGuard.java @@ -4,13 +4,9 @@ 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.Expression; -import org.simantics.scl.compiler.elaboration.expressions.Variable; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.types.Types; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ListGuard extends ListQualifier { public Expression condition; @@ -23,12 +19,6 @@ public class ListGuard extends ListQualifier { condition.checkType(context, Types.BOOLEAN); } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - condition.collectVars(allVars, vars); - } - @Override public CompiledQualifier compile(SimplificationContext context) { return new CompiledQualifier( diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListQualifier.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListQualifier.java index 9365e6a87..69818ef01 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListQualifier.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListQualifier.java @@ -3,16 +3,11 @@ package org.simantics.scl.compiler.elaboration.expressions.list; 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.internal.parsing.Symbol; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public abstract class ListQualifier extends Symbol { public abstract void checkType(TypingContext context); - public abstract void collectVars(TObjectIntHashMap allVars, TIntHashSet vars); /** * Called in simplification. */ diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListSeq.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListSeq.java index 6bab8c91e..f1126121f 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListSeq.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListSeq.java @@ -7,9 +7,6 @@ import org.simantics.scl.compiler.elaboration.expressions.Expression; import org.simantics.scl.compiler.elaboration.expressions.Variable; import org.simantics.scl.compiler.errors.Locations; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ListSeq extends ListQualifier { public ListQualifier a; public ListQualifier b; @@ -25,13 +22,6 @@ public class ListSeq extends ListQualifier { b.checkType(context); } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - a.collectVars(allVars, vars); - b.collectVars(allVars, vars); - } - @Override public CompiledQualifier compile(SimplificationContext context) { CompiledQualifier cA = a.compile(context); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListThen.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListThen.java index b8bd39566..df1d1f2b0 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListThen.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListThen.java @@ -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.Expression; -import org.simantics.scl.compiler.elaboration.expressions.Variable; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.types.TMetaVar; import org.simantics.scl.compiler.types.Type; @@ -12,9 +11,6 @@ import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.UnificationException; import org.simantics.scl.compiler.types.kinds.Kinds; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class ListThen extends ListQualifier { public ListQualifier left; public Expression transformer; @@ -46,15 +42,6 @@ public class ListThen extends ListQualifier { } } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - left.collectVars(allVars, vars); - transformer.collectVars(allVars, vars); - if(by != null) - by.collectVars(allVars, vars); - } - @Override public CompiledQualifier compile(SimplificationContext context) { CompiledQualifier q = left.compile(context); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/visitors/CollectVarsVisitor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/visitors/CollectVarsVisitor.java new file mode 100644 index 000000000..7c4bee0f1 --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/visitors/CollectVarsVisitor.java @@ -0,0 +1,35 @@ +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.Variable; + +import gnu.trove.map.hash.TObjectIntHashMap; +import gnu.trove.set.hash.TIntHashSet; + +public class CollectVarsVisitor extends StandardExpressionVisitor { + private final TObjectIntHashMap allVars; + private final TIntHashSet vars; + + public CollectVarsVisitor(TObjectIntHashMap allVars, TIntHashSet vars) { + this.allVars = allVars; + this.vars = vars; + } + + @Override + public void visit(EVariable expression) { + if(expression.variable != null) { + int id = allVars.get(expression.variable); + if(id >= 0) + vars.add(id); + } + } + + @Override + public void visit(EAsPattern expression) { + int id = allVars.get(expression.var); + if(id >= 0) + vars.add(id); + expression.pattern.accept(this); + } +} diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractCombiner.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractCombiner.java index e711d372c..a3ca43d36 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractCombiner.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractCombiner.java @@ -7,14 +7,10 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext; 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.query.pre.QPreExists; import org.simantics.scl.compiler.elaboration.query.pre.QPreGuard; import org.simantics.scl.compiler.errors.Locations; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public abstract class QAbstractCombiner extends Query { public Query[] queries; @@ -68,12 +64,6 @@ public abstract class QAbstractCombiner extends Query { query.checkType(context); } - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - for(Query query : queries) - query.collectVars(allVars, vars); - } - @Override public void setLocationDeep(long loc) { if(location == Locations.NO_LOCATION) { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractModifier.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractModifier.java index 234c8b615..d580f2bb0 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractModifier.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAbstractModifier.java @@ -2,12 +2,8 @@ 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.errors.Locations; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public abstract class QAbstractModifier extends Query { public Query query; @@ -26,12 +22,6 @@ public abstract class QAbstractModifier extends Query { query.checkType(context); } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - query.collectVars(allVars, vars); - } - @Override public void setLocationDeep(long loc) { if(location == Locations.NO_LOCATION) { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAtom.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAtom.java index 208513b21..5f13bfd7b 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAtom.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QAtom.java @@ -27,7 +27,6 @@ import org.simantics.scl.compiler.types.Types; import gnu.trove.map.hash.THashMap; import gnu.trove.map.hash.TIntObjectHashMap; -import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.set.hash.TIntHashSet; public class QAtom extends Query { @@ -140,13 +139,6 @@ public class QAtom extends Query { } } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(Expression parameter : parameters) - parameter.collectVars(allVars, vars); - } - @Override public Query replace(ReplaceContext context) { Type[] newTypeParameters; diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QIf.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QIf.java index 85950c24a..03bcec3e9 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QIf.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QIf.java @@ -4,15 +4,11 @@ import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext; 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.query.compilation.ConstraintCollectionContext; import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.types.Types; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class QIf extends Query { public Expression condition; public Query thenQuery; @@ -23,14 +19,7 @@ public class QIf extends Query { this.thenQuery = thenQuery; this.elseQuery = elseQuery; } - - @Override - public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { - condition.collectVars(allVars, vars); - thenQuery.collectVars(allVars, vars); - elseQuery.collectVars(allVars, vars); - } - + @Override public void checkType(TypingContext context) { condition.checkType(context, Types.BOOLEAN); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QMapping.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QMapping.java index 428ed922c..02061b798 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QMapping.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/QMapping.java @@ -5,16 +5,12 @@ import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext; 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.query.compilation.ConstraintCollectionContext; import org.simantics.scl.compiler.elaboration.query.compilation.UnsolvableQueryException; import org.simantics.scl.compiler.elaboration.rules.MappingRelation; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.types.Type; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - public class QMapping extends Query { public final MappingRelation mappingRelation; public final Expression[] parameters; @@ -24,13 +20,6 @@ public class QMapping extends Query { this.parameters = parameters; } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - for(Expression parameter : parameters) - parameter.collectVars(allVars, vars); - } - @Override public void checkType(TypingContext context) { // Check parameter types diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/Query.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/Query.java index cea31bbe8..58f780754 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/Query.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/Query.java @@ -14,6 +14,7 @@ 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.CollectRefsVisitor; +import org.simantics.scl.compiler.elaboration.expressions.visitors.CollectVarsVisitor; import org.simantics.scl.compiler.elaboration.expressions.visitors.ForVariablesUsesVisitor; import org.simantics.scl.compiler.elaboration.expressions.visitors.StandardExpressionVisitor; import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext; @@ -36,7 +37,6 @@ import gnu.trove.set.hash.TIntHashSet; public abstract class Query extends Symbol { public static final Query[] EMPTY_ARRAY = new Query[0]; - public abstract void collectVars(TObjectIntHashMap allVars, TIntHashSet vars); public abstract void checkType(TypingContext context); public Query resolve(TranslationContext context) { @@ -160,4 +160,8 @@ public abstract class Query extends Symbol { public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { accept(new CollectRefsVisitor(allRefs, refs)); } + + public void collectVars(TObjectIntHashMap allVars, TIntHashSet vars) { + accept(new CollectVarsVisitor(allVars, vars)); + } } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/pre/PreQuery.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/pre/PreQuery.java index b7b9f964b..2f4d14bae 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/pre/PreQuery.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/query/pre/PreQuery.java @@ -12,9 +12,6 @@ import org.simantics.scl.compiler.elaboration.query.Query; import org.simantics.scl.compiler.elaboration.query.QueryVisitor; import org.simantics.scl.compiler.elaboration.query.compilation.ConstraintCollectionContext; -import gnu.trove.map.hash.TObjectIntHashMap; -import gnu.trove.set.hash.TIntHashSet; - /** * Query classes that may exist before resolving */ @@ -33,12 +30,6 @@ public abstract class PreQuery extends Query { throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support collectConstraints."); } - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support collectVars."); - } - @Override public Query replace(ReplaceContext replaceContext) { throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support replace.");