X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.reflection%2Fsrc%2Forg%2Fsimantics%2Fscl%2Freflection%2Finternal%2FtypeRegistry%2FTypeRegistry.java;h=f09877021806e4bfb6ab0a50f13aa72c1488cf61;hb=refs%2Fchanges%2F08%2F1408%2F4;hp=84e9294db8fa67c4ce9c4f21381f368742c8010d;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/typeRegistry/TypeRegistry.java b/bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/typeRegistry/TypeRegistry.java old mode 100755 new mode 100644 index 84e9294db..f09877021 --- a/bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/typeRegistry/TypeRegistry.java +++ b/bundles/org.simantics.scl.reflection/src/org/simantics/scl/reflection/internal/typeRegistry/TypeRegistry.java @@ -1,62 +1,66 @@ -package org.simantics.scl.reflection.internal.typeRegistry; - -import gnu.trove.set.hash.THashSet; - -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -import org.simantics.scl.compiler.types.TCon; -import org.simantics.scl.compiler.types.Types; -import org.simantics.scl.reflection.TypeNotFoundException; -import org.simantics.scl.reflection.internal.registry.BindingRegistry; - -public class TypeRegistry { - private static final ConcurrentHashMap> map = - new ConcurrentHashMap>(); - - private static final THashSet builtins = new THashSet(); - - static { - map.put(Types.BOOLEAN, Boolean.class); - map.put(Types.BYTE, Byte.class); - map.put(Types.CHARACTER, Character.class); - map.put(Types.SHORT, Short.class); - map.put(Types.INTEGER, Integer.class); - map.put(Types.LONG, Long.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) - if(i != 1) - try { - map.put(Types.tupleConstructor(i), - Class.forName("org.simantics.scl.runtime.tuple.Tuple" + i)); - } catch(ClassNotFoundException e) { - e.printStackTrace(); - } - - for(TCon con : map.keySet()) - builtins.add(con.name); - } - - public static Class getClass(TCon type) throws TypeNotFoundException { - Class clazz = map.get(type); - if(clazz == null) { - try { - clazz = BindingRegistry.getClass(type); - } catch(TypeNotFoundException e) { - e.printStackTrace(); - throw e; - } - map.put(type, clazz); - } - return clazz; - } - - public static boolean isBuiltin(String name) { - return builtins.contains(name); - } -} +package org.simantics.scl.reflection.internal.typeRegistry; + +import gnu.trove.set.hash.THashSet; + +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + +import org.simantics.scl.compiler.types.TCon; +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> map = + new ConcurrentHashMap>(); + + private static final THashSet builtins = new THashSet(); + + static { + map.put(Types.BOOLEAN, Boolean.class); + map.put(Types.BYTE, Byte.class); + map.put(Types.CHARACTER, Character.class); + map.put(Types.SHORT, Short.class); + map.put(Types.INTEGER, Integer.class); + map.put(Types.LONG, Long.class); + map.put(Types.FLOAT, Float.class); + map.put(Types.DOUBLE, Double.class); + map.put(Types.STRING, String.class); + + map.put(Types.LIST, List.class); + for(int i=0;i<8;++i) + if(i != 1) + try { + map.put(Types.tupleConstructor(i), + Class.forName("org.simantics.scl.runtime.tuple.Tuple" + i)); + } catch(ClassNotFoundException e) { + LOGGER.error("Could not find class for {}", i, e); + } + + for(TCon con : map.keySet()) + builtins.add(con.name); + } + + public static Class getClass(TCon type) throws TypeNotFoundException { + Class clazz = map.get(type); + if(clazz == null) { + try { + clazz = BindingRegistry.getClass(type); + } catch(TypeNotFoundException e) { + LOGGER.error("Could not get class for type {}", type, e); + throw e; + } + map.put(type, clazz); + } + return clazz; + } + + public static boolean isBuiltin(String name) { + return builtins.contains(name); + } +}