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.IExpression;
import org.simantics.scl.compiler.top.ExpressionInterpretationContext;
import org.simantics.scl.compiler.types.TVar;
-import org.simantics.scl.compiler.types.Type;
import org.simantics.scl.compiler.types.Types;
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 ELambdaType extends Expression {
public TVar[] parameters;
public Expression value;
this.value = value;
}
- public void collectRefs(TObjectIntHashMap<Object> allRefs, TIntHashSet refs) {
- value.collectRefs(allRefs, refs);
+ @Override
+ protected void updateType() throws MatchException {
+ setType(Types.forAll(parameters, value.getType()));
}
-
- @Override
- public void collectVars(TObjectIntHashMap<Variable> allVars,
- TIntHashSet vars) {
- value.collectVars(allVars, vars);
- }
-
- @Override
- protected void updateType() throws MatchException {
- setType(Types.forAll(parameters, value.getType()));
- }
- @Override
+ @Override
public IVal toVal(CompilationContext context, CodeWriter w) {
return lambdaToVal(context, w);
}
- @Override
- public void collectFreeVariables(THashSet<Variable> vars) {
- value.collectFreeVariables(vars);
- }
-
@Override
public Expression simplify(SimplificationContext context) {
value = value.simplify(context);
throw new InternalCompilerError("Should not type check " + getClass().getSimpleName() + ".");
}
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- value = value.decorate(decorator);
- return decorator.decorate(this);
- }
-
- @Override
- public void collectEffects(THashSet<Type> effects) {
- }
-
@Override
public void setLocationDeep(long loc) {
if(location == Locations.NO_LOCATION) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- value.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {