1 package org.simantics.scl.reflection.internal.typeRegistry;
3 import gnu.trove.set.hash.THashSet;
6 import java.util.concurrent.ConcurrentHashMap;
8 import org.simantics.scl.compiler.types.TCon;
9 import org.simantics.scl.compiler.types.Types;
10 import org.simantics.scl.reflection.TypeNotFoundException;
11 import org.simantics.scl.reflection.internal.registry.BindingRegistry;
13 public class TypeRegistry {
14 private static final ConcurrentHashMap<TCon, Class<?>> map =
15 new ConcurrentHashMap<TCon, Class<?>>();
17 private static final THashSet<String> builtins = new THashSet<String>();
20 map.put(Types.BOOLEAN, Boolean.class);
21 map.put(Types.BYTE, Byte.class);
22 map.put(Types.CHARACTER, Character.class);
23 map.put(Types.SHORT, Short.class);
24 map.put(Types.INTEGER, Integer.class);
25 map.put(Types.LONG, Long.class);
26 map.put(Types.FLOAT, Float.class);
27 map.put(Types.DOUBLE, Double.class);
28 map.put(Types.STRING, String.class);
29 map.put(Types.BYTE_ARRAY, byte[].class);
31 map.put(Types.LIST, List.class);
35 map.put(Types.tupleConstructor(i),
36 Class.forName("org.simantics.scl.runtime.tuple.Tuple" + i));
37 } catch(ClassNotFoundException e) {
41 for(TCon con : map.keySet())
42 builtins.add(con.name);
45 public static Class<?> getClass(TCon type) throws TypeNotFoundException {
46 Class<?> clazz = map.get(type);
49 clazz = BindingRegistry.getClass(type);
50 } catch(TypeNotFoundException e) {
59 public static boolean isBuiltin(String name) {
60 return builtins.contains(name);