1 package org.simantics.scl.compiler.internal.types;
3 import gnu.trove.map.hash.THashMap;
5 import org.simantics.scl.compiler.types.TVar;
6 import org.simantics.scl.compiler.types.Type;
7 import org.simantics.scl.compiler.types.Types;
8 import org.simantics.scl.compiler.types.kinds.Kinds;
9 import org.simantics.scl.compiler.types.util.ITypeEnvironment;
11 public class TypeElaborationContext {
13 THashMap<String, TVar> vars;
14 ITypeEnvironment environment;
16 public TypeElaborationContext(
17 THashMap<String, TVar> vars,
18 ITypeEnvironment environment) {
20 this.environment = environment;
23 public TypeElaborationContext(ITypeEnvironment environment) {
24 this(new THashMap<String, TVar>(), environment);
27 public TVar resolveTypeVariable(String varName) {
28 TVar var = vars.get(varName);
30 var = Types.var(Kinds.STAR /* FIXME */);
31 vars.put(varName, var);
36 public TVar push(String varName) {
37 return vars.put(varName, Types.var(Kinds.STAR /* FIXME */));
40 public TVar pop(String varName, TVar oldVar) {
42 return vars.remove(varName);
44 return vars.put(varName, oldVar);
47 public Type resolveTypeConstructor(String name) {
48 return environment.resolve(null, name);
51 public Type resolveTypeConstructor(String namespace, String name) {
52 return environment.resolve(namespace, name);