X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Felaboration%2Fexpressions%2FEConstant.java;h=9fcb4ca46ebb5190018b5b15b4d6e16c3a242624;hb=6dfe20b0f514b91337fcac4de0267ffd8268be07;hp=c5b4681a86d233e4ee87fa8fe5b152ae6aa7baeb;hpb=747231cca0974ca9ed5f78caa6517ee9dcb8e4fc;p=simantics%2Fplatform.git 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 c5b4681a8..9fcb4ca46 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 @@ -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.names.Name; import org.simantics.scl.compiler.common.precedence.Precedence; @@ -31,11 +33,10 @@ 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.THashSet; import gnu.trove.set.hash.TIntHashSet; public class EConstant extends Expression { - SCLValue value; + public SCLValue value; Type[] typeParameters; public EConstant(SCLValue value, Type ... typeParameters) { @@ -83,23 +84,22 @@ public class EConstant extends Expression { return this; } - public void collectRefs(TObjectIntHashMap allRefs, TIntHashSet refs) { - int id = allRefs.get(value); - if(id >= 0) - refs.add(id); + @Override + public void collectVars(TObjectIntHashMap allVars, + TIntHashSet vars) { + } + + @Override + public Set getFreeVariables() { + return Collections.emptySet(); } - - @Override - public void collectVars(TObjectIntHashMap allVars, - TIntHashSet vars) { - } - public void toString(StringBuilder b, TypeUnparsingContext tuc) { - Name name = value.getName(); - if(name.module.equals("Builtin") || name.module.equals("Prelude")) - b.append(name.name); - else - b.append(name); + public void toString(StringBuilder b, TypeUnparsingContext tuc) { + Name name = value.getName(); + if(name.module.equals("Builtin") || name.module.equals("Prelude")) + b.append(name.name); + else + b.append(name); /*for(Type type : typeParameters) { b.append(" <"); b.append(type.toString(tuc)); @@ -112,17 +112,13 @@ public class EConstant extends Expression { setType(Types.instantiate(value.getType(), typeParameters)); } - @Override - public IVal toVal(CompilationContext context, CodeWriter w) { - IVal val = value.getValue(); - if(typeParameters.length > 0) { - val = val.createSpecialization(typeParameters); - } - return val; - } - @Override - public void collectFreeVariables(THashSet vars) { + public IVal toVal(CompilationContext context, CodeWriter w) { + IVal val = value.getValue(); + if(typeParameters.length > 0) { + val = val.createSpecialization(typeParameters); + } + return val; } @Override @@ -157,10 +153,6 @@ public class EConstant extends Expression { public Expression resolveAsPattern(TranslationContext context) { return this; } - - @Override - public void removeFreeVariables(THashSet vars) { - } @Override public Expression replace(ReplaceContext context) { @@ -236,11 +228,7 @@ public class EConstant extends Expression { @Override public boolean isEffectful() { - return false; - } - - @Override - public void collectEffects(THashSet effects) { + return false; } @Override @@ -258,10 +246,6 @@ public class EConstant extends Expression { public Precedence getPrecedence() { return value.getPrecedence(); } - - @Override - public void forVariables(VariableProcedure procedure) { - } @Override public boolean isPattern(int arity) {