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%2FEVariable.java;h=7fe0e0a92d3220ceaf604c24715d9a48a0865044;hb=b77d6bc2e8713d4138a0af0afb64a97f92a21052;hp=669867ff6ca0e825f83c3906b50e3e63a652530f;hpb=dcb08ba8db427e1e9951e61892c653c23977a8cc;p=simantics%2Fplatform.git 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 669867ff6..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 @@ -1,6 +1,8 @@ package org.simantics.scl.compiler.elaboration.expressions; import java.util.ArrayList; +import java.util.Collections; +import java.util.Set; import org.simantics.scl.compiler.common.exceptions.InternalCompilerError; import org.simantics.scl.compiler.compilation.CompilationContext; @@ -20,10 +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.THashSet; -import gnu.trove.set.hash.TIntHashSet; - public class EVariable extends Expression { public static final EVariable[] EMPTY_ARRAY = new EVariable[0]; @@ -46,34 +44,26 @@ public class EVariable extends Expression { this.variable = variable; } - public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { - } - - @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) + return Collections.emptySet(); + else + return Collections.singleton(variable); + } - public void toString(StringBuilder b, TypeUnparsingContext tuc) { + public void toString(StringBuilder b, TypeUnparsingContext tuc) { b.append(variable == null ? "???" : variable.toString()); } - @Override - protected void updateType() throws MatchException { - setType(variable.getType()); - } - - @Override - public IVal toVal(CompilationContext context, CodeWriter w) { - return variable.getVal(); + @Override + protected void updateType() throws MatchException { + setType(variable.getType()); } @Override - public void collectFreeVariables(THashSet vars) { - vars.add(variable); + public IVal toVal(CompilationContext context, CodeWriter w) { + return variable.getVal(); } @Override @@ -95,11 +85,6 @@ public class EVariable extends Expression { ArrayList parameters) { } - @Override - public void removeFreeVariables(THashSet vars) { - vars.remove(variable); - } - @Override public Expression resolveAsPattern(TranslationContext context) { return this; @@ -166,10 +151,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)