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=8817eb23c6979c25acefb81f7be30c4d87a8bc7c;hb=HEAD;hp=50eec32fe29e9f8c37209f91eba6e2709f88aa59;hpb=fac333b05f9c2651dc8d164e51e1c3468c524415;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 50eec32fe..8817eb23c 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 @@ -6,6 +6,8 @@ import java.util.Arrays; import java.util.Collections; import java.util.List; +import org.simantics.scl.compiler.common.exceptions.InternalCompilerError; +import org.simantics.scl.compiler.environment.Environments; import org.simantics.scl.compiler.errors.Locations; import org.simantics.scl.compiler.internal.parsing.exceptions.SCLSyntaxErrorException; import org.simantics.scl.compiler.internal.parsing.parser.SCLParserImpl; @@ -57,15 +59,6 @@ public class Types { public static final TCon LONG = con(BUILTIN, "Long"); public static final TCon FLOAT = con(BUILTIN, "Float"); public static final TCon DOUBLE = con(BUILTIN, "Double"); - - public static final TCon BOOLEAN_ARRAY = con(BUILTIN, "BooleanArray"); - public static final TCon BYTE_ARRAY = con(BUILTIN, "ByteArray"); - public static final TCon CHARACTER_ARRAY = con(BUILTIN, "CharacterArray"); - public static final TCon SHORT_ARRAY = con(BUILTIN, "ShortArray"); - public static final TCon INTEGER_ARRAY = con(BUILTIN, "IntegerArray"); - public static final TCon LONG_ARRAY = con(BUILTIN, "LongArray"); - public static final TCon FLOAT_ARRAY = con(BUILTIN, "FloatArray"); - public static final TCon DOUBLE_ARRAY = con(BUILTIN, "DoubleArray"); public static final TCon STRING = con(BUILTIN, "String"); public static final TCon ARROW = con(BUILTIN, "->"); @@ -84,6 +77,7 @@ public class Types { public static final TCon TYPEABLE = con(BUILTIN, "Typeable"); public static final TCon SERIALIZABLE = con(BUILTIN, "Serializable"); public static final TCon VEC_COMP = con(BUILTIN, "VecComp"); + public static final TCon CLASS = con(BUILTIN, "Class"); public static final TCon BINDING = con(BUILTIN, "Binding"); public static final TCon TYPE = con(BUILTIN, "Type"); @@ -116,7 +110,15 @@ public class Types { public static final TCon BRANCH_POINT = con(BUILTIN, "BranchPoint"); public static final TCon CHRContext = con(BUILTIN, "CHRContext"); - + + public static final Type BOOLEAN_ARRAY = vector(BOOLEAN); + public static final Type BYTE_ARRAY = vector(BYTE); + public static final Type CHARACTER_ARRAY = vector(CHARACTER); + public static final Type SHORT_ARRAY = vector(SHORT); + public static final Type INTEGER_ARRAY = vector(INTEGER); + public static final Type LONG_ARRAY = vector(LONG); + public static final Type FLOAT_ARRAY = vector(FLOAT); + public static final Type DOUBLE_ARRAY = vector(DOUBLE); private volatile static TCon[] tupleCache = new TCon[] { UNIT, null @@ -642,7 +644,52 @@ public class Types { effect, type); } + + /** + * This function always success, but may return a multi function + * with arity smaller than given parameter + */ + public static MultiFunction unifyFunction2(Type type, int arity) { + type = canonical(type); + Type[] parameterTypes = new Type[arity]; + Type effect = Types.NO_EFFECTS; + int i; + for(i=0;i localTypeVars, String text) throws SCLTypeParseException { - return parseType(new TypeElaborationContext(localTypeVars, environment), text); - } - + /** + * This method uses DUMMY_TYPE_ENVIRONMENT that almost does anything useful. Use + * {@link Environments#getType(org.simantics.scl.compiler.environment.Environment, String)} instead. + */ + @Deprecated public static Type parseType(String text) throws SCLTypeParseException { return parseType(new TypeElaborationContext(DUMMY_TYPE_ENVIRONMENT), text); } - public static Type parseType(THashMap localTypeVars, String text) throws SCLTypeParseException { - return parseType(new TypeElaborationContext(localTypeVars, DUMMY_TYPE_ENVIRONMENT), text); - } - + /** + * Use {@link Environments#getType(org.simantics.scl.compiler.environment.Environment, String)} instead. + */ + @Deprecated private static Type parseType(TypeElaborationContext context, String text) throws SCLTypeParseException { SCLParserImpl parser = new SCLParserImpl(new StringReader(text)); try {