From: Hannu Niemistö Date: Mon, 24 Jul 2017 10:02:04 +0000 (+0300) Subject: (refs #7375) Replaced collectEffects by CollectEffectsVisitor X-Git-Tag: v1.31.0~264^2~34^2 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F53%2F753%2F1;p=simantics%2Fplatform.git (refs #7375) Replaced collectEffects by CollectEffectsVisitor Change-Id: I41b489ad872140bf7a0f0a83714a50431b48c3a6 --- 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 08b1a0726..8dcfe0863 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 @@ -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.Variable; 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.THashSet; @@ -41,12 +40,6 @@ public class EqBasic extends Equation { right.collectFreeVariables(vars); } - @Override - public void collectEffects(THashSet effects) { - left.collectEffects(effects); - right.collectEffects(effects); - } - @Override public void checkType(TypingContext context) { left = left.inferType(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 5dac9fce4..8b10872e9 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 @@ -5,9 +5,7 @@ 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 gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.set.hash.THashSet; @@ -38,11 +36,6 @@ public class EqGuard extends Equation { guard.collectFreeVariables(vars); } - @Override - public void collectEffects(THashSet effects) { - guard.collectEffects(effects); - } - @Override public void checkType(TypingContext context) { guard = guard.checkIgnoredType(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 ca4102c96..94283436a 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 @@ -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.Variable; import org.simantics.scl.compiler.internal.parsing.Symbol; -import org.simantics.scl.compiler.types.Type; import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.set.hash.THashSet; @@ -17,7 +16,6 @@ public abstract class Equation extends Symbol { public abstract void setLocationDeep(long loc); public abstract void collectFreeVariables(THashSet vars); - public abstract void collectEffects(THashSet effects); public abstract void checkType(TypingContext context); public abstract void collectVars(TObjectIntHashMap allVars, TIntHashSet vars); public abstract void resolve(TranslationContext 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 fa54f8ab2..7e804c2a2 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 @@ -36,11 +36,6 @@ public abstract class ASTExpression extends SimplifiableExpression { throw new InternalCompilerError(getClass().getSimpleName() + " does not support updateType."); } - @Override - final public void collectEffects(THashSet effects) { - throw new InternalCompilerError(getClass().getSimpleName() + " does not support collectEffects."); - } - @Override public void accept(ExpressionVisitor visitor) { throw new InternalCompilerError(getClass().getSimpleName() + " does not support accept."); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/DecoratingExpression.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/DecoratingExpression.java index 796a41c69..97b223d56 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/DecoratingExpression.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/DecoratingExpression.java @@ -81,11 +81,6 @@ public abstract class DecoratingExpression extends SimplifiableExpression { public int getFunctionDefinitionPatternArity() throws NotPatternException { return expression.getFunctionDefinitionPatternArity(); } - - @Override - public void collectEffects(THashSet effects) { - expression.collectEffects(effects); - } @Override public void setLocationDeep(long loc) { 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 2b5c813a1..d52cc3f2e 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 @@ -179,14 +179,9 @@ public class EAmbiguous extends SimplifiableExpression { location = loc; } - @Override - public void collectEffects(THashSet effects) { - // TODO Auto-generated method stub - } - @Override public void accept(ExpressionVisitor visitor) { - // TODO Auto-generated method stub + visitor.visit(this); } @Override 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 4065f463a..d45e7fc8c 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 @@ -39,7 +39,7 @@ import gnu.trove.set.hash.TIntHashSet; public class EApply extends Expression { public Expression function; public Expression[] parameters; - Type effect = Types.NO_EFFECTS; + public Type effect = Types.NO_EFFECTS; public EApply(Expression function, Expression ... parameters) { this.function = function; @@ -340,14 +340,6 @@ public class EApply extends Expression { return function.isConstructorApplication(); } - @Override - public void collectEffects(THashSet effects) { - effects.add(effect); - function.collectEffects(effects); - for(Expression parameter : parameters) - parameter.collectEffects(effects); - } - @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApplyType.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApplyType.java index f441a1be5..df945eabb 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApplyType.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EApplyType.java @@ -111,11 +111,6 @@ public class EApplyType extends Expression { public boolean isEffectful() { return expression.isEffectful(); } - - @Override - public void collectEffects(THashSet effects) { - expression.collectEffects(effects); - } @Override public void setLocationDeep(long loc) { 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 98c54844c..6d29526ea 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 @@ -117,11 +117,6 @@ public class EAsPattern extends Expression { return result; } - - @Override - public void collectEffects(THashSet effects) { - pattern.collectEffects(effects); - } @Override public void setLocationDeep(long loc) { 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 3bec2aaa1..2d3a7ce92 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 @@ -131,13 +131,6 @@ public class EBind extends SimplifiableExpression { return this; } - @Override - public void collectEffects(THashSet effects) { - pattern.collectEffects(effects); - value.collectEffects(effects); - in.collectEffects(effects); - } - @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/expressions/ECHRRuleset.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ECHRRuleset.java index a8ad1480d..121653993 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 @@ -10,7 +10,6 @@ import org.simantics.scl.compiler.internal.codegen.references.IVal; import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; import org.simantics.scl.compiler.internal.interpreted.IExpression; 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; @@ -76,11 +75,7 @@ public class ECHRRuleset extends Expression { in.setLocationDeep(loc); } } - @Override - public void collectEffects(THashSet effects) { - ruleset.collectEffects(effects); - in.collectEffects(effects); - } + @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); 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 734fd71b4..7df6fb595 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 @@ -11,7 +11,6 @@ import org.simantics.scl.compiler.internal.codegen.references.IVal; import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; import org.simantics.scl.compiler.internal.interpreted.IExpression; 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; @@ -62,10 +61,6 @@ public class ECHRRulesetConstructor extends Expression { } } @Override - public void collectEffects(THashSet effects) { - ruleset.collectEffects(effects); - } - @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); } 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 fbaff1200..d1873e4e6 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 @@ -17,7 +17,6 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.internal.codegen.references.IVal; import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; -import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.kinds.Kinds; @@ -114,13 +113,6 @@ public class ECHRSelect extends Expression { } } - @Override - public void collectEffects(THashSet effects) { - expression.collectEffects(effects); - query.collectQueryEffects(effects); - effects.add(Types.PROC); - } - @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); 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 4a2e07f43..1bab4ff64 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 @@ -230,11 +230,7 @@ public class EConstant extends Expression { @Override public boolean isEffectful() { - return false; - } - - @Override - public void collectEffects(THashSet effects) { + return false; } @Override 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 bfaf699ed..9b0a13b20 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 @@ -9,7 +9,6 @@ import org.simantics.scl.compiler.elaboration.query.QExists; import org.simantics.scl.compiler.elaboration.query.Query; import org.simantics.scl.compiler.elaboration.query.compilation.EnforcingContext; import org.simantics.scl.compiler.errors.Locations; -import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; @@ -34,11 +33,6 @@ public class EEnforce extends SimplifiableExpression { TIntHashSet vars) { query.collectVars(allVars, vars); } - - @Override - public void collectEffects(THashSet effects) { - throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support collectEffects."); - } @Override protected void updateType() throws MatchException { 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 bffb7f026..d2d31713b 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 @@ -66,12 +66,6 @@ public class EEquations extends SimplifiableExpression { equation.collectFreeVariables(vars); } - @Override - public void collectEffects(THashSet effects) { - for(Equation equation : equations) - equation.collectEffects(effects); - } - @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); 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 b3f4f6488..82c6d5d52 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 @@ -64,10 +64,6 @@ public class EError extends Expression { public Expression inferType(TypingContext context) { return this; } - - @Override - public void collectEffects(THashSet effects) { - } @Override public void setLocationDeep(long loc) { 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 0b5678f99..213c30bf1 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 @@ -93,10 +93,6 @@ public class EExternalConstant extends Expression { public Expression inferType(TypingContext context) { return this; } - - @Override - public void collectEffects(THashSet effects) { - } @Override public void setLocationDeep(long loc) { 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 0a4d0ee16..c5ee9bc7a 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 @@ -158,12 +158,6 @@ public class EFieldAccess extends SimplifiableExpression { accessor.resolve(context); return this; } - - @Override - public void collectEffects(THashSet effects) { - // FIXME - effects.add(Types.READ_GRAPH); - } @Override public void setLocationDeep(long loc) { 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 8534f4624..95948d45c 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 @@ -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.errors.Locations; import org.simantics.scl.compiler.types.TPred; -import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.exceptions.MatchException; import gnu.trove.map.hash.TObjectIntHashMap; @@ -59,10 +58,6 @@ public class EGetConstraint extends SimplifiableExpression { return this; } - @Override - public void collectEffects(THashSet effects) { - } - @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/expressions/EIf.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EIf.java index ea64ac034..7b56d22fa 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 @@ -132,14 +132,6 @@ public class EIf extends Expression { public boolean isEffectful() { return condition.isEffectful() || then_.isEffectful() || (else_ != null && else_.isEffectful()); } - - @Override - public void collectEffects(THashSet effects) { - condition.collectEffects(effects); - then_.collectEffects(effects); - if(else_ != null) - else_.collectEffects(effects); - } @Override public void setLocationDeep(long loc) { 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 856dcd371..a70e50160 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 @@ -117,10 +117,6 @@ public class EIntegerLiteral extends SimplifiableExpression { public boolean isEffectful() { return false; } - - @Override - public void collectEffects(THashSet effects) { - } @Override public void setLocationDeep(long loc) { 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 51b1f909e..5aa77046e 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 @@ -172,15 +172,6 @@ public class ELambda extends SimplifiableExpression { public boolean isEffectful() { return false; } - - @Override - public void collectEffects(THashSet effects) { - for(Case case_ : cases) { - for(Expression pattern : case_.patterns) - pattern.collectEffects(effects); - case_.value.collectEffects(effects); - } - } @Override public void accept(ExpressionVisitor visitor) { 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 b06f7b770..fec64d6d0 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 @@ -12,7 +12,6 @@ import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; import org.simantics.scl.compiler.internal.interpreted.IExpression; import org.simantics.scl.compiler.top.ExpressionInterpretationContext; import org.simantics.scl.compiler.types.TVar; -import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; @@ -87,10 +86,6 @@ public class ELambdaType extends Expression { public Expression inferType(TypingContext context) { throw new InternalCompilerError("Should not type check " + getClass().getSimpleName() + "."); } - - @Override - public void collectEffects(THashSet effects) { - } @Override public void setLocationDeep(long loc) { 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 7b7338a78..71ee13076 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 @@ -204,15 +204,6 @@ public class ELet extends Expression { in = in.checkIgnoredType(context); return this; } - - @Override - public void collectEffects(THashSet effects) { - for(Assignment assignment : assignments) { - assignment.pattern.collectEffects(effects); - assignment.value.collectEffects(effects); - } - in.collectEffects(effects); - } @Override public void setLocationDeep(long loc) { 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 a06100dd7..102d64658 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 @@ -93,12 +93,6 @@ public class EListComprehension extends SimplifiableExpression { return this; } - @Override - public void collectEffects(THashSet effects) { - head.collectEffects(effects); - qualifier.collectEffects(effects); - } - @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/expressions/EListLiteral.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EListLiteral.java index d2a1d3509..478d7b311 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 @@ -106,12 +106,6 @@ public class EListLiteral extends SimplifiableExpression { return this; } - @Override - public void collectEffects(THashSet effects) { - for(Expression component : components) - component.collectEffects(effects); - } - @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/expressions/ELiteral.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ELiteral.java index 14bd02344..388fbb37a 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 @@ -14,7 +14,6 @@ import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; import org.simantics.scl.compiler.internal.interpreted.IConstant; import org.simantics.scl.compiler.internal.interpreted.IExpression; import org.simantics.scl.compiler.top.ExpressionInterpretationContext; -import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.util.TypeUnparsingContext; @@ -101,10 +100,6 @@ public class ELiteral extends Expression { public Expression inferType(TypingContext context) { return this; } - - @Override - public void collectEffects(THashSet effects) { - } @Override public void setLocationDeep(long loc) { 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 0ca1d5442..18f89ccdf 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 @@ -155,17 +155,6 @@ public class EMatch extends Expression { setType(Types.UNIT); return this; } - - @Override - public void collectEffects(THashSet effects) { - for(Expression s : scrutinee) - s.collectEffects(effects); - for(Case case_ : cases) { - for(Expression pattern : case_.patterns) - pattern.collectEffects(effects); - case_.value.collectEffects(effects); - } - } @Override public void accept(ExpressionVisitor visitor) { 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 5f274dadd..5312c7543 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 @@ -101,10 +101,6 @@ public class ERealLiteral extends SimplifiableExpression { copy.setType(getType().replace(context.tvarMap)); return copy; } - - @Override - public void collectEffects(THashSet effects) { - } @Override public void setLocationDeep(long loc) { 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 1a133b6f9..e84e0500c 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 @@ -152,11 +152,6 @@ public class ERuleset extends SimplifiableExpression { } in.collectVars(allVars, vars); } - - @Override - public void collectEffects(THashSet effects) { - throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support collectEffects."); - } @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 ce4d66bd7..473c403da 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 @@ -51,11 +51,6 @@ public class ESelect extends SimplifiableExpression { expression.collectVars(allVars, vars); query.collectVars(allVars, vars); } - - @Override - public void collectEffects(THashSet effects) { - throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support collectEffects."); - } @Override protected void updateType() throws MatchException { 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 8f59b3b44..9b3ee8df7 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 @@ -198,10 +198,6 @@ public class ESimpleLambda extends Expression { return false; } - @Override - public void collectEffects(THashSet effects) { - } - @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/expressions/ESimpleLet.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ESimpleLet.java index 422bbea11..e69a27121 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 @@ -169,12 +169,6 @@ public class ESimpleLet extends Expression { in = in.checkIgnoredType(context); return this; } - - @Override - public void collectEffects(THashSet effects) { - value.collectEffects(effects); - in.collectEffects(effects); - } @Override public void accept(ExpressionVisitor visitor) { 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 346e46cd3..761741658 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 @@ -11,7 +11,6 @@ import org.simantics.scl.compiler.elaboration.rules.TransformationRule; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.internal.elaboration.transformations.TransformationBuilder; import org.simantics.scl.compiler.top.SCLCompilerConfiguration; -import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; @@ -90,12 +89,6 @@ public class ETransformation extends SimplifiableExpression { } } - @Override - public void collectEffects(THashSet effects) { - effects.add(Types.PROC); - //seed.collectEffects(Query.RW, effects); // FIXME - } - @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); 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 10c8e6f7a..89caebad0 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 @@ -68,11 +68,6 @@ public class ETypeAnnotation extends SimplifiableExpression { return value.checkType(context, type); } - @Override - public void collectEffects(THashSet effects) { - value.collectEffects(effects); - } - @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/expressions/EVariable.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EVariable.java index 44c03a2ac..aa2789282 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 @@ -163,10 +163,6 @@ public class EVariable extends Expression { return false; } - @Override - public void collectEffects(THashSet effects) { - } - @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/expressions/EViewPattern.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/EViewPattern.java index a2a0a02c5..c0dfb5a75 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 @@ -8,7 +8,6 @@ import org.simantics.scl.compiler.elaboration.contexts.TypingContext; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.internal.codegen.references.IVal; import org.simantics.scl.compiler.internal.codegen.writer.CodeWriter; -import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.exceptions.MatchException; import org.simantics.scl.compiler.types.util.MultiFunction; @@ -93,11 +92,6 @@ public class EViewPattern extends Expression { } } - @Override - public void collectEffects(THashSet effects) { - expression.collectEffects(effects); - } - @Override public void accept(ExpressionVisitor visitor) { visitor.visit(this); 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 a9fd0367b..9ea5ddb1e 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 @@ -1,6 +1,5 @@ package org.simantics.scl.compiler.elaboration.expressions; -import org.simantics.scl.compiler.common.exceptions.InternalCompilerError; import org.simantics.scl.compiler.elaboration.contexts.ReplaceContext; import org.simantics.scl.compiler.elaboration.contexts.SimplificationContext; import org.simantics.scl.compiler.elaboration.contexts.TranslationContext; @@ -49,11 +48,6 @@ public class EWhen extends SimplifiableExpression { query.collectVars(allVars, vars); action.collectVars(allVars, vars); } - - @Override - public void collectEffects(THashSet effects) { - throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support collectEffects."); - } @Override protected void updateType() throws MatchException { 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 221bc8067..507d335e3 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 @@ -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.CollectEffectsVisitor; import org.simantics.scl.compiler.elaboration.expressions.visitors.CollectRefsVisitor; import org.simantics.scl.compiler.elaboration.expressions.visitors.ForVariablesUsesVisitor; import org.simantics.scl.compiler.elaboration.query.QAtom; @@ -351,12 +352,10 @@ public abstract class Expression extends Symbol implements Typed { return false; } - public abstract void collectEffects(THashSet effects); - public Type getEffect() { - THashSet effects = new THashSet(); - collectEffects(effects); - return Types.union(effects.toArray(new Type[effects.size()])); + CollectEffectsVisitor visitor = new CollectEffectsVisitor(); + accept(visitor); + return visitor.getCombinedEffect(); } public abstract void accept(ExpressionVisitor visitor); diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ExpressionVisitor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ExpressionVisitor.java index 861cf48a7..7dbcf69e2 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ExpressionVisitor.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/ExpressionVisitor.java @@ -2,6 +2,7 @@ package org.simantics.scl.compiler.elaboration.expressions; public interface ExpressionVisitor { + void visit(EAmbiguous eAmbiguous); void visit(EApply expression); void visit(EApplyType expression); void visit(EAsPattern expression); 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 1e2cd05c4..62bbe45b9 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 @@ -126,15 +126,6 @@ public class GuardedExpressionGroup extends Expression { newExpressions[i] = expressions[i].replace(context); return new GuardedExpressionGroup(newExpressions); } - - @Override - public void collectEffects(THashSet effects) { - for(GuardedExpression ge : expressions) { - for(Expression guard : ge.guards) - guard.collectEffects(effects); - ge.value.collectEffects(effects); - } - } @Override public void setLocationDeep(long loc) { diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/StandardExpressionVisitor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/StandardExpressionVisitor.java index 3cdb32b72..7ef827fb6 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/StandardExpressionVisitor.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/StandardExpressionVisitor.java @@ -499,4 +499,10 @@ EquationVisitor, StatementVisitor, CHRAstQueryVisitor { public void visit(CHRAstNegation query) { query.subquery.accept(this); } + + @Override + public void visit(EAmbiguous expression) { + if(expression.resolvedExpression != null) + expression.resolvedExpression.accept(this); + } } 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 1283cc059..2477a4f5f 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 @@ -8,7 +8,6 @@ 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.errors.Locations; -import org.simantics.scl.compiler.types.Type; import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.set.hash.THashSet; @@ -72,12 +71,6 @@ public class ListAssignment extends ListQualifier { pattern = pattern.resolveAsPattern(context); } - @Override - public void collectEffects(THashSet effects) { - pattern.collectEffects(effects); - value.collectEffects(effects); - } - @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/expressions/list/ListGenerator.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGenerator.java index db12689c8..59f45bb36 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 @@ -9,7 +9,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 org.simantics.scl.compiler.types.TMetaVar; -import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import org.simantics.scl.compiler.types.kinds.Kinds; @@ -77,13 +76,7 @@ public class ListGenerator extends ListQualifier { value = value.resolve(context); pattern = pattern.resolveAsPattern(context); } - - @Override - public void collectEffects(THashSet effects) { - pattern.collectEffects(effects); - value.collectEffects(effects); - } - + @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/expressions/list/ListGuard.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListGuard.java index 2fe49150f..1deaf92fa 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 @@ -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.Variable; import org.simantics.scl.compiler.errors.Locations; -import org.simantics.scl.compiler.types.Type; import org.simantics.scl.compiler.types.Types; import gnu.trove.map.hash.TObjectIntHashMap; @@ -45,14 +44,9 @@ public class ListGuard extends ListQualifier { @Override public void resolve(TranslationContext context) { - condition = condition.resolve(context); + condition = condition.resolve(context); } - - @Override - public void collectEffects(THashSet effects) { - condition.collectEffects(effects); - } - + @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/expressions/list/ListQualifier.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListQualifier.java index 47c9cf6d8..352c7514e 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 @@ -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.Variable; import org.simantics.scl.compiler.internal.parsing.Symbol; -import org.simantics.scl.compiler.types.Type; import gnu.trove.map.hash.TObjectIntHashMap; import gnu.trove.set.hash.THashSet; @@ -21,7 +20,6 @@ public abstract class ListQualifier extends Symbol { */ public abstract CompiledQualifier compile(SimplificationContext context); public abstract void resolve(TranslationContext context); - public abstract void collectEffects(THashSet effects); public abstract void setLocationDeep(long loc); public abstract void accept(ListQualifierVisitor visitor); public abstract ListQualifier accept(ListQualifierTransformer transformer); 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 a802a80ac..50de4a7dd 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 @@ -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.Variable; 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.THashSet; @@ -67,12 +66,6 @@ public class ListSeq extends ListQualifier { b.resolve(context); } - @Override - public void collectEffects(THashSet effects) { - a.collectEffects(effects); - b.collectEffects(effects); - } - @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/expressions/list/ListThen.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/list/ListThen.java index e1061564f..706611bbb 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 @@ -89,14 +89,6 @@ public class ListThen extends ListQualifier { by = by.resolve(context); } - @Override - public void collectEffects(THashSet effects) { - left.collectEffects(effects); - transformer.collectEffects(effects); - if(by != null) - by.collectEffects(effects); - } - @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/expressions/printing/ExpressionToStringVisitor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/printing/ExpressionToStringVisitor.java index edf951711..b1a05d70e 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/printing/ExpressionToStringVisitor.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/printing/ExpressionToStringVisitor.java @@ -8,6 +8,7 @@ import org.simantics.scl.compiler.elaboration.chr.CHRRule; import org.simantics.scl.compiler.elaboration.chr.relations.CHRConstraint; import org.simantics.scl.compiler.elaboration.expressions.Assignment; import org.simantics.scl.compiler.elaboration.expressions.Case; +import org.simantics.scl.compiler.elaboration.expressions.EAmbiguous; import org.simantics.scl.compiler.elaboration.expressions.EApply; import org.simantics.scl.compiler.elaboration.expressions.EApplyType; import org.simantics.scl.compiler.elaboration.expressions.EAsPattern; @@ -612,4 +613,9 @@ public class ExpressionToStringVisitor implements ExpressionVisitor, QueryVisito } b.append('"'); } + + @Override + public void visit(EAmbiguous eAmbiguous) { + b.append("EAmbigious"); + } } diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/visitors/CollectEffectsVisitor.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/visitors/CollectEffectsVisitor.java new file mode 100644 index 000000000..aec3d84dc --- /dev/null +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/expressions/visitors/CollectEffectsVisitor.java @@ -0,0 +1,62 @@ +package org.simantics.scl.compiler.elaboration.expressions.visitors; + +import org.simantics.scl.compiler.elaboration.expressions.EApply; +import org.simantics.scl.compiler.elaboration.expressions.ECHRRuleset; +import org.simantics.scl.compiler.elaboration.expressions.ECHRSelect; +import org.simantics.scl.compiler.elaboration.expressions.EFieldAccess; +import org.simantics.scl.compiler.elaboration.expressions.ELambda; +import org.simantics.scl.compiler.elaboration.expressions.ESimpleLambda; +import org.simantics.scl.compiler.elaboration.expressions.ETransformation; +import org.simantics.scl.compiler.elaboration.expressions.StandardExpressionVisitor; +import org.simantics.scl.compiler.types.Type; +import org.simantics.scl.compiler.types.Types; + +import gnu.trove.set.hash.THashSet; + +public class CollectEffectsVisitor extends StandardExpressionVisitor { + public final THashSet effects = new THashSet(); + + @Override + public void visit(EApply expression) { + effects.add(expression.effect); + super.visit(expression); + } + + @Override + public void visit(ECHRRuleset expression) { + effects.add(Types.PROC); + super.visit(expression); + } + + @Override + public void visit(ECHRSelect expression) { + effects.add(Types.PROC); + super.visit(expression); + } + + @Override + public void visit(EFieldAccess expression) { + // FIXME + effects.add(Types.READ_GRAPH); + super.visit(expression); + } + + @Override + public void visit(ETransformation expression) { + // FIXME + effects.add(Types.PROC); + super.visit(expression); + } + + @Override + public void visit(ELambda expression) { + } + + @Override + public void visit(ESimpleLambda expression) { + } + + public Type getCombinedEffect() { + return Types.union(effects.toArray(new Type[effects.size()])); + } +}