diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeSystemCodeGenerator.java @ 16755:bd28da642eea

Truffle-DSL: Several new features implemented: Implementation of a new code generation layout which shares code between generated nodes. Declaration order of specializations is now used as specialization order. Specializations do no longer perform fallthrough on respecialization, they now always respecialize from the first specialization. Implemented support for contains relations between specializations. Improved reachability error messages. Preliminary support for @Implies.
author Christian Humer <christian.humer@gmail.com>
date Mon, 11 Aug 2014 15:53:05 +0200
parents bd5c996b5d25
children
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeSystemCodeGenerator.java	Mon Aug 11 15:53:05 2014 +0200
+++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/typesystem/TypeSystemCodeGenerator.java	Mon Aug 11 15:53:05 2014 +0200
@@ -36,10 +36,6 @@
 
 public class TypeSystemCodeGenerator extends CompilationUnitFactory<TypeSystemData> {
 
-    public TypeSystemCodeGenerator(ProcessorContext context) {
-        super(context);
-    }
-
     public static String isTypeMethodName(TypeData type) {
         return "is" + Utils.getTypeId(type.getBoxedType());
     }
@@ -64,28 +60,33 @@
         return "expect" + Utils.getTypeId(type.getBoxedType());
     }
 
+    public static String typeName(TypeSystemData typeSystem) {
+        String name = getSimpleName(typeSystem.getTemplateType());
+        return name + "Gen";
+    }
+
+    public static String singletonName(TypeSystemData type) {
+        return createConstantName(getSimpleName(type.getTemplateType().asType()));
+    }
+
     /**
      * Finds the generated singleton field for a TypeSytemData instance. TypeSystemCodeGenerator
      * must be applied to the TypeSystemData model before use.
      */
     public static VariableElement findSingleton(ProcessorContext context, TypeSystemData typeSystem) {
-        TypeMirror type = context.findGeneratedClassBySimpleName(TypeClassFactory.typeName(typeSystem), typeSystem);
-        return Utils.findDeclaredField(type, TypeClassFactory.singletonName(typeSystem.getTemplateType().asType()));
+        TypeMirror type = context.findGeneratedClassBySimpleName(typeName(typeSystem), typeSystem);
+        return Utils.findDeclaredField(type, singletonName(typeSystem));
     }
 
     @Override
     protected void createChildren(TypeSystemData m) {
-        add(new TypeClassFactory(context), m);
+        add(new TypeClassFactory(), m);
     }
 
     protected static class TypeClassFactory extends ClassElementFactory<TypeSystemData> {
 
         private static final String LOCAL_VALUE = "value";
 
-        public TypeClassFactory(ProcessorContext context) {
-            super(context);
-        }
-
         @Override
         public CodeTypeElement create(TypeSystemData typeSystem) {
             String name = typeName(typeSystem);
@@ -127,17 +128,8 @@
             return new ArrayList<>(sourceTypes);
         }
 
-        private static String typeName(TypeSystemData typeSystem) {
-            String name = getSimpleName(typeSystem.getTemplateType());
-            return name + "Gen";
-        }
-
-        private static String singletonName(TypeMirror type) {
-            return createConstantName(getSimpleName(type));
-        }
-
         private CodeVariableElement createSingleton(CodeTypeElement clazz) {
-            CodeVariableElement field = new CodeVariableElement(modifiers(PUBLIC, STATIC, FINAL), clazz.asType(), singletonName(getModel().getTemplateType().asType()));
+            CodeVariableElement field = new CodeVariableElement(modifiers(PUBLIC, STATIC, FINAL), clazz.asType(), singletonName(getModel()));
             field.createInitBuilder().startNew(clazz.asType()).end();
             return field;
         }