X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FExpression.java;h=dcb38165e7665ae66bf6af53c458e277dc192700;hb=refs%2Fchanges%2F34%2F1534%2F3;hp=5b60dad423c942ddbb2a0ff4d03906a5e327b0cb;hpb=6dfe20b0f514b91337fcac4de0267ffd8268be07;p=simantics%2Fplatform.git 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..dcb38165e 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; @@ -60,10 +61,10 @@ public abstract class Expression extends Symbol implements Typed { try { updateType(); } catch (MatchException e) { - throw new InternalCompilerError(e); + throw new InternalCompilerError(location, e); } if(type == null) - throw new InternalCompilerError(getClass().getSimpleName() + + throw new InternalCompilerError(location, getClass().getSimpleName() + ".updateType couldn't compute its type."); } return type; @@ -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)); @@ -239,7 +242,7 @@ public abstract class Expression extends Symbol implements Typed { public void getParameters(TranslationContext translationContext, ArrayList parameters) { - throw new InternalCompilerError("Class " + getClass().getSimpleName() + " does not support getParameters."); + throw new InternalCompilerError(location, "Class " + getClass().getSimpleName() + " does not support getParameters."); } public Expression resolveAsPattern(TranslationContext context) { @@ -249,7 +252,7 @@ public abstract class Expression extends Symbol implements Typed { public Expression checkTypeAsPattern(TypingContext context, Type requiredType) { if(context.isInPattern()) - throw new InternalCompilerError("Already in a pattern."); + throw new InternalCompilerError(location, "Already in a pattern."); context.setInPattern(true); Expression expression = checkType(context, requiredType); context.setInPattern(false); @@ -279,7 +282,7 @@ public abstract class Expression extends Symbol implements Typed { } public Expression replace(ReplaceContext context) { - throw new InternalCompilerError(getClass().getSimpleName() + " does not support replace."); + throw new InternalCompilerError(location, getClass().getSimpleName() + " does not support replace."); } public static Expression[] replace(ReplaceContext context, Expression[] expressions) { @@ -317,7 +320,7 @@ public abstract class Expression extends Symbol implements Typed { IVal functionVal = newW.getFunction().getTarget(); for(int i=0;i