]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/contexts/ReplaceContext.java
Migrated source code from Simantics SVN
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / elaboration / contexts / ReplaceContext.java
diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/contexts/ReplaceContext.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/elaboration/contexts/ReplaceContext.java
new file mode 100755 (executable)
index 0000000..1bb40c5
--- /dev/null
@@ -0,0 +1,40 @@
+package org.simantics.scl.compiler.elaboration.contexts;
+
+import org.simantics.scl.compiler.elaboration.expressions.EVariable;
+import org.simantics.scl.compiler.elaboration.expressions.Expression;
+import org.simantics.scl.compiler.elaboration.expressions.Variable;
+import org.simantics.scl.compiler.types.TVar;
+import org.simantics.scl.compiler.types.Type;
+
+import gnu.trove.map.hash.THashMap;
+
+public class ReplaceContext {
+    public final THashMap<TVar, Type> EMPTY_VARIABLE_MAP = new THashMap<TVar, Type>(); 
+    
+    public THashMap<TVar, Type> tvarMap;
+    public THashMap<Variable, Expression> varMap;
+    public final TypingContext typingContext;
+    public boolean inPattern;
+    
+    public ReplaceContext(THashMap<TVar, Type> tvarMap,
+            THashMap<Variable, Expression> varMap,
+            TypingContext typingContext) {
+        this.tvarMap = tvarMap;
+        this.varMap = varMap;
+        this.typingContext = typingContext;
+        this.inPattern = false;
+    }
+    
+    public ReplaceContext(Variable[] from, Variable[] to) {
+        this.tvarMap = EMPTY_VARIABLE_MAP;        
+        this.typingContext = null;
+        this.inPattern = false;
+        varMap = new THashMap<Variable, Expression>(from.length);
+        for(int i=0;i<from.length;++i)
+            varMap.put(from[i], new EVariable(to[i]));
+    }
+    
+    public ReplaceContext(TypingContext typingContext) {
+        this(new THashMap<TVar, Type>(), new THashMap<Variable, Expression>(), typingContext);
+    }
+}