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.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 EAsPattern extends Expression {
- Variable var;
- EVar eVar;
- Expression pattern;
+ public Variable var;
+ public EVar eVar;
+ public Expression pattern;
public EAsPattern(EVar eVar, Expression pattern) {
this.eVar = eVar;
public Expression getPattern() {
return pattern;
}
-
- @Override
- public void collectRefs(TObjectIntHashMap<Object> allRefs,
- TIntHashSet refs) {
- pattern.collectRefs(allRefs, refs);
- }
-
- @Override
- public void collectVars(TObjectIntHashMap<Variable> allVars,
- TIntHashSet vars) {
- int id = allVars.get(var);
- if(id >= 0)
- vars.add(id);
- pattern.collectVars(allVars, vars);
- }
-
- @Override
- public void collectFreeVariables(THashSet<Variable> vars) {
- throw new InternalCompilerError(location, "Cannot collect free variables for a pattern.");
- }
-
- @Override
- public void removeFreeVariables(THashSet<Variable> vars) {
- vars.remove(var);
- pattern.removeFreeVariables(vars);
- }
@Override
public Expression simplify(SimplificationContext context) {
var.setType(pattern.getType());
return this;
}
-
- @Override
- public Expression decorate(ExpressionDecorator decorator) {
- pattern = pattern.decorate(decorator);
- return decorator.decorate(this);
- }
@Override
public Expression replace(ReplaceContext context) {
return result;
}
-
- @Override
- public void collectEffects(THashSet<Type> effects) {
- pattern.collectEffects(effects);
- }
@Override
public void setLocationDeep(long loc) {
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
-
- @Override
- public void forVariables(VariableProcedure procedure) {
- procedure.execute(eVar.location, var);
- pattern.forVariables(procedure);
- }
@Override
public Expression accept(ExpressionTransformer transformer) {