X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ftypes%2FTypes.java;h=9ea064cfd11bf4abf4094a900a53d9951dc24878;hb=84b211a0aa05c956d33e038a1106bb0464ce373a;hp=f0c9dbddfb2e1383ff746aa9b1a1ce7f1f12e552;hpb=eecd74faded034bd067094b42bbac0d286d8d9fa;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java index f0c9dbddf..9ea064cfd 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/types/Types.java @@ -86,6 +86,8 @@ public class Types { public static final TCon VEC_COMP = con(BUILTIN, "VecComp"); public static final TCon BINDING = con(BUILTIN, "Binding"); + public static final TCon TYPE = con(BUILTIN, "Type"); + public static final TCon DYNAMIC = con("Prelude", "Dynamic"); public static final TCon VARIANT = con(BUILTIN, "Variant"); @@ -96,9 +98,7 @@ public class Types { public static final TCon ORDERED_RING = con("Prelude", "OrderedRing"); public static final TCon REAL = con("Prelude", "Real"); public static final TCon SHOW = con("Prelude", "Show"); - public static final TCon EQ = con("Prelude", "Eq"); public static final TCon ORD = con("Prelude", "Ord"); - public static final TCon HASHABLE = con("Prelude", "Hashable"); public static final TCon IO = con("Serialization", "IO"); public static final Type REF = con("Prelude", "Ref"); @@ -112,6 +112,9 @@ public class Types { public static final TCon PROC = con(BUILTIN, "Proc"); public static final TCon BRANCH_POINT = con(BUILTIN, "BranchPoint"); + + public static final TCon CHRContext = con(BUILTIN, "CHRContext"); + private volatile static TCon[] tupleCache = new TCon[] { UNIT, null @@ -128,7 +131,7 @@ public class Types { } }; - + public static boolean isPrimitive(Type type) { return type == BOOLEAN || type == BYTE || type == CHARACTER || type == SHORT || type == INTEGER || type == LONG || type == FLOAT || type == DOUBLE || type == STRING; @@ -152,11 +155,13 @@ public class Types { * Get the concrete type pointed to by a chain of type meta-variables. */ public static Type canonical(Type type) { - while(type instanceof TMetaVar) { + if(type instanceof TMetaVar) { TMetaVar metaVar = (TMetaVar)type; type = metaVar.ref; if(type == null) return metaVar; + else + return metaVar.ref = canonical(type); } return type; } @@ -552,7 +557,15 @@ public class Types { parameters.add(Types.canonical(apply.parameter)); type = canonical(apply.function); } - return new MultiApply(type, parameters.toArray(new Type[parameters.size()])); + Type[] parametersArray; + if(parameters.isEmpty()) + parametersArray = Type.EMPTY_ARRAY; + else { + parametersArray = new Type[parameters.size()]; + for(int i=0,j=parametersArray.length-1;i Type[] replace(Type[] types, THashMap map) { if(types.length == 0) return Type.EMPTY_ARRAY; @@ -1022,6 +1044,10 @@ public class Types { else return new TUnion(effects); } + + public static Type union(Type effect1, Type effect2) { + return new TUnion(effect1, effect2); + } public static Type union(List effects) { if(effects.size() == 0)