1 package org.simantics.scl.compiler.elaboration.contexts;
3 import org.simantics.scl.compiler.elaboration.expressions.EVariable;
4 import org.simantics.scl.compiler.elaboration.expressions.Expression;
5 import org.simantics.scl.compiler.elaboration.expressions.Variable;
6 import org.simantics.scl.compiler.types.TVar;
7 import org.simantics.scl.compiler.types.Type;
9 import gnu.trove.map.hash.THashMap;
11 public class ReplaceContext {
12 public final THashMap<TVar, Type> EMPTY_VARIABLE_MAP = new THashMap<TVar, Type>();
14 public THashMap<TVar, Type> tvarMap;
15 public THashMap<Variable, Expression> varMap;
16 public final TypingContext typingContext;
17 public boolean inPattern;
19 public ReplaceContext(THashMap<TVar, Type> tvarMap,
20 THashMap<Variable, Expression> varMap,
21 TypingContext typingContext) {
22 this.tvarMap = tvarMap;
24 this.typingContext = typingContext;
25 this.inPattern = false;
28 public ReplaceContext(Variable[] from, Variable[] to) {
29 this.tvarMap = EMPTY_VARIABLE_MAP;
30 this.typingContext = null;
31 this.inPattern = false;
32 varMap = new THashMap<Variable, Expression>(from.length);
33 for(int i=0;i<from.length;++i)
34 varMap.put(from[i], new EVariable(to[i]));
37 public ReplaceContext(TypingContext typingContext) {
38 this(new THashMap<TVar, Type>(), new THashMap<Variable, Expression>(), typingContext);