TYPE_MAP.put("Vector Float", Types.vector(Types.FLOAT));
TYPE_MAP.put("Vector Double", Types.vector(Types.DOUBLE));
TYPE_MAP.put("Vector String", Types.vector(Types.STRING));
+ TYPE_MAP.put("ByteArray", Types.BYTE_ARRAY);
- add(Types.BYTE_ARRAY);
add((TCon)Types.RESOURCE);
add(Types.con("Simantics/Variables", "VariableMap"));
}
"64-bit floating point number"));
addTypeDescriptor("String", new StandardTypeConstructor(Types.STRING, Kinds.STAR, TypeDesc.STRING,
"Unicode string"));
-
- addTypeDescriptor("BooleanArray", new StandardTypeConstructor(Types.BOOLEAN_ARRAY, Kinds.STAR, TypeDesc.forClass(boolean[].class)));
- addTypeDescriptor("ByteArray", new StandardTypeConstructor(Types.BYTE_ARRAY, Kinds.STAR, TypeDesc.forClass(byte[].class)));
- addTypeDescriptor("CharacterArray", new StandardTypeConstructor(Types.CHARACTER_ARRAY, Kinds.STAR, TypeDesc.forClass(char[].class)));
- addTypeDescriptor("ShortArray", new StandardTypeConstructor(Types.SHORT_ARRAY, Kinds.STAR, TypeDesc.forClass(short[].class)));
- addTypeDescriptor("IntegerArray", new StandardTypeConstructor(Types.INTEGER_ARRAY, Kinds.STAR, TypeDesc.forClass(int[].class)));
- addTypeDescriptor("LongArray", new StandardTypeConstructor(Types.LONG_ARRAY, Kinds.STAR, TypeDesc.forClass(long[].class)));
- addTypeDescriptor("FloatArray", new StandardTypeConstructor(Types.FLOAT_ARRAY, Kinds.STAR, TypeDesc.forClass(float[].class)));
- addTypeDescriptor("DoubleArray", new StandardTypeConstructor(Types.DOUBLE_ARRAY, Kinds.STAR, TypeDesc.forClass(double[].class)));
-
+
addTypeDescriptor("Array", new StandardTypeConstructor(Types.con(Types.BUILTIN, "Array"), Kinds.STAR_TO_STAR, TypeDesc.forClass(Object[].class)));
addTypeDescriptor("Maybe", MaybeType.INSTANCE);
BINDING_CONSTANTS0.put(Types.LONG, new JavaStaticField("org/simantics/databoard/Bindings", "LONG", Types.NO_EFFECTS, TypeDesc.forClass("org/simantics/databoard/binding/LongBinding"), SERIALIZABLE_LONG, -1));
BINDING_CONSTANTS0.put(Types.UNIT, new JavaStaticField("org/simantics/databoard/Bindings", "VOID", Types.NO_EFFECTS, TypeDesc.forClass("org/simantics/databoard/binding/Binding"), SERIALIZABLE_TUPLE0, -1));
BINDING_CONSTANTS0.put(Types.VARIANT, new JavaStaticField("org/simantics/databoard/Bindings", "VARIANT", Types.NO_EFFECTS, TypeDesc.forClass("org/simantics/databoard/binding/VariantBinding"), SERIALIZABLE_VARIANT, -1));
- BINDING_CONSTANTS0.put(Types.DOUBLE_ARRAY, new JavaStaticField("org/simantics/databoard/Bindings", "DOUBLE_ARRAY", Types.NO_EFFECTS, TypeDesc.forClass("org/simantics/databoard/binding/ArrayBinding"), SERIALIZABLE_DOUBLE_ARRAY, -1));
- BINDING_CONSTANTS0.put(Types.INTEGER_ARRAY, new JavaStaticField("org/simantics/databoard/Bindings", "INTEGER_ARRAY", Types.NO_EFFECTS, TypeDesc.forClass("org/simantics/databoard/binding/ArrayBinding"), SERIALIZABLE_INTEGER_ARRAY, -1));
- BINDING_CONSTANTS0.put(Types.BOOLEAN_ARRAY, new JavaStaticField("org/simantics/databoard/Bindings", "BOOLEAN_ARRAY", Types.NO_EFFECTS, TypeDesc.forClass("org/simantics/databoard/binding/ArrayBinding"), SERIALIZABLE_BOOLEAN_ARRAY, -1));
- BINDING_CONSTANTS0.put(Types.BYTE_ARRAY, new JavaStaticField("org/simantics/databoard/Bindings", "BYTE_ARRAY", Types.NO_EFFECTS, TypeDesc.forClass("org/simantics/databoard/binding/ArrayBinding"), SERIALIZABLE_BYTE_ARRAY, -1));
- BINDING_CONSTANTS0.put(Types.FLOAT_ARRAY, new JavaStaticField("org/simantics/databoard/Bindings", "FLOAT_ARRAY", Types.NO_EFFECTS, TypeDesc.forClass("org/simantics/databoard/binding/ArrayBinding"), SERIALIZABLE_FLOAT_ARRAY, -1));
- BINDING_CONSTANTS0.put(Types.LONG_ARRAY, new JavaStaticField("org/simantics/databoard/Bindings", "LONG_ARRAY", Types.NO_EFFECTS, TypeDesc.forClass("org/simantics/databoard/binding/ArrayBinding"), SERIALIZABLE_LONG_ARRAY, -1));
}
private static final THashMap<TCon,Constant> BINDING_CONSTANTS1 = new THashMap<TCon,Constant>();
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, "->");
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
import org.simantics.scl.compiler.types.Types;
import org.simantics.scl.reflection.TypeNotFoundException;
import org.simantics.scl.reflection.internal.registry.BindingRegistry;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class TypeRegistry {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(TypeRegistry.class);
+
private static final ConcurrentHashMap<TCon, Class<?>> map =
new ConcurrentHashMap<TCon, Class<?>>();
map.put(Types.FLOAT, Float.class);
map.put(Types.DOUBLE, Double.class);
map.put(Types.STRING, String.class);
- map.put(Types.BYTE_ARRAY, byte[].class);
map.put(Types.LIST, List.class);
for(int i=0;i<8;++i)
map.put(Types.tupleConstructor(i),
Class.forName("org.simantics.scl.runtime.tuple.Tuple" + i));
} catch(ClassNotFoundException e) {
- e.printStackTrace();
+ LOGGER.error("Could not find class for {}", i, e);
}
for(TCon con : map.keySet())
try {
clazz = BindingRegistry.getClass(type);
} catch(TypeNotFoundException e) {
- e.printStackTrace();
+ LOGGER.error("Could not get class for type {}", type, e);
throw e;
}
map.put(type, clazz);
binding :: Serializable a => Binding a
***********************************************************/
+type BooleanArray = Vector Boolean
+type ByteArray = Vector Byte
+type CharacterArray = Vector Character
+type ShortArray = Vector Short
+type IntegerArray = Vector Integer
+type LongArray = Vector Long
+type FloatArray = Vector Float
+type DoubleArray = Vector Double
+
importJava "java.util.Arrays" where
@private
@JavaName toString
read = readString
ioSize = ioSizeString
-instance IO DoubleArray where
- write = writeDoubleArray
- read = readDoubleArray
- //ioSize v = do
- // l = length v
- // ioSizeLength l + 8 * l
-
instance (IO a) => IO (Maybe a) where
read s = if read s
then Just (read s)