X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FEVariable.java;h=fccc62e9869cfc4f5469d2804588d4ed465baf41;hp=669867ff6ca0e825f83c3906b50e3e63a652530f;hb=6dfe20b0f514b91337fcac4de0267ffd8268be07;hpb=2f63e7a58e49a233b28c6968b848281060117c43 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..fccc62e98 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; @@ -21,7 +23,6 @@ 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 { @@ -46,34 +47,34 @@ 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 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 +96,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 +162,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)