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;
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.internal.elaboration.utils.ExpressionDecorator;
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.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) {
setType(Types.instantiate(getType(), type));
return this;
}
-
- public void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs) {
- int id = allRefs.get(value);
- if(id >= 0)
- refs.add(id);
+
+ @Override
+ public Set<Variable> getFreeVariables() {
+ return Collections.emptySet();
}
-
- @Override
- public void collectVars(TObjectIntHashMap<Variable> 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));
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<Variable> vars) {
+ public IVal toVal(CompilationContext context, CodeWriter w) {
+ IVal val = value.getValue();
+ if(typeParameters.length > 0) {
+ val = val.createSpecialization(typeParameters);
+ }
+ return val;
}
@Override
public Expression resolveAsPattern(TranslationContext context) {
return this;
}
-
- @Override
- public void removeFreeVariables(THashSet<Variable> vars) {
- }
@Override
public Expression replace(ReplaceContext context) {
else
return applyPUnit(context);
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- return decorator.decorate(this);
- }
@Override
public boolean isEffectful() {
- return false;
- }
-
- @Override
- public void collectEffects(THashSet<Type> effects) {
+ return false;
}
@Override
public Precedence getPrecedence() {
return value.getPrecedence();
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- }
@Override
public boolean isPattern(int arity) {