import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.exceptions.MatchException;
-import gnu.trove.map.hash.TObjectIntHashMap;
-import gnu.trove.set.hash.THashSet;
-import gnu.trove.set.hash.TIntHashSet;
-
public class ESimpleLet extends Expression {
- Variable variable; // may be null
- Expression value;
- Expression in;
+ public Variable variable; // may be null
+ public Expression value;
+ public Expression in;
public ESimpleLet(Variable variable, Expression value, Expression in) {
if(value == null)
this.in = in;
}
- public void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs) {
- value.collectRefs(allRefs, refs);
- in.collectRefs(allRefs, refs);
- }
-
- @Override
- public void collectVars(TObjectIntHashMap<Variable> allVars,
- TIntHashSet vars) {
- value.collectVars(allVars, vars);
- in.collectVars(allVars, vars);
- }
-
@Override
protected void updateType() throws MatchException {
setType(in.getType());
}
-
- @Override
- public IVal toVal(CompilationContext context, CodeWriter w) {
- IVal valueVal = value.toVal(context, w);
- if(variable != null)
- variable.setVal(valueVal);
- return in.toVal(context, w);
- }
@Override
- public void collectFreeVariables(THashSet<Variable> vars) {
- value.collectFreeVariables(vars);
- in.collectFreeVariables(vars);
- vars.remove(variable);
+ public IVal toVal(CompilationContext context, CodeWriter w) {
+ IVal valueVal = value.toVal(context, w);
+ if(variable != null)
+ variable.setVal(valueVal);
+ return in.toVal(context, w);
}
@Override
in = in.checkIgnoredType(context);
return this;
}
-
- @Override
- public void collectEffects(THashSet<Type> effects) {
- value.collectEffects(effects);
- in.collectEffects(effects);
- }
@Override
public void accept(ExpressionVisitor visitor) {