Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/generator/NodeFactoryFactory.java @ 18766:a720bf2e2f43
Truffle-DSL: checkstyle fixes.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 30 Dec 2014 00:37:39 +0100 |
parents | a665483c3881 |
children | f4d78e4a878d |
rev | line source |
---|---|
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.dsl.processor.generator; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import static com.oracle.truffle.dsl.processor.java.ElementUtils.*; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 import static javax.lang.model.element.Modifier.*; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import java.util.*; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import javax.lang.model.element.*; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 import javax.lang.model.type.*; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 import com.oracle.truffle.api.dsl.*; |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
34 import com.oracle.truffle.api.dsl.internal.*; |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
35 import com.oracle.truffle.dsl.processor.*; |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 import com.oracle.truffle.dsl.processor.java.*; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
37 import com.oracle.truffle.dsl.processor.java.model.*; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 import com.oracle.truffle.dsl.processor.java.model.CodeTypeMirror.ArrayCodeTypeMirror; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 import com.oracle.truffle.dsl.processor.model.*; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
41 class NodeFactoryFactory { |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
42 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 static final String FACTORY_METHOD_NAME = "create0"; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
45 private final ProcessorContext context; |
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
46 private final NodeData node; |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
47 private final TypeSystemData typeSystem; |
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
48 private final DSLOptions options; |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
49 private final CodeTypeElement createdFactoryElement; |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
51 public NodeFactoryFactory(ProcessorContext context, NodeData node, CodeTypeElement createdClass) { |
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
52 this.context = context; |
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
53 this.node = node; |
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
54 this.createdFactoryElement = createdClass; |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
55 this.typeSystem = node.getTypeSystem(); |
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
56 this.options = typeSystem.getOptions(); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
57 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 |
18754
59bf50cc5a32
Truffle-DSL: implemented @GenerateNodeFactory to enable generation of factories. Factory generation is now disabled by default.
Christian Humer <christian.humer@gmail.com>
parents:
18753
diff
changeset
|
59 public static String factoryClassName(NodeData node) { |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 return node.getNodeId() + "Factory"; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
63 public CodeTypeElement create() { |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
64 Modifier visibility = ElementUtils.getVisibility(node.getTemplateType().getModifiers()); |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
65 TypeMirror nodeFactory = ElementUtils.getDeclaredType(ElementUtils.fromTypeMirror(context.getTruffleTypes().getNodeFactoryBase()), node.getNodeType()); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
66 |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
67 CodeTypeElement clazz = GeneratorUtils.createClass(node, null, modifiers(), factoryClassName(node), null); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 if (visibility != null) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 clazz.getModifiers().add(visibility); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 clazz.getModifiers().add(Modifier.FINAL); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
73 if (createdFactoryElement != null) { |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
74 createFactoryMethods(clazz, visibility); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
75 clazz.setSuperClass(nodeFactory); |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
76 clazz.add(createNodeFactoryConstructor()); |
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
77 clazz.add(createCreateNodeMethod()); |
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
78 clazz.add(createGetInstanceMethod(visibility)); |
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
79 clazz.add(createInstanceConstant(clazz.asType())); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
80 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
81 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
82 return clazz; |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
83 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
84 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
85 private Element createNodeFactoryConstructor() { |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 CodeExecutableElement method = new CodeExecutableElement(modifiers(PRIVATE), null, factoryClassName(node)); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
87 CodeTreeBuilder builder = method.createBuilder(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
88 builder.startStatement(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
89 builder.startCall("super"); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
90 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 // node type |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
92 builder.typeLiteral(node.getNodeType()); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 // execution signature |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 builder.startGroup(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
96 if (node.getChildExecutions().isEmpty()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 builder.staticReference(context.getTruffleTypes().getDslMetadata(), NodeBaseFactory.EMPTY_CLASS_ARRAY); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
98 } else { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 builder.startNewArray(new ArrayCodeTypeMirror(context.getType(Class.class)), null); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
100 for (NodeExecutionData execution : node.getChildExecutions()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 builder.typeLiteral(execution.getNodeType()); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
105 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
106 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
107 // node signatures |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 builder.startGroup(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 builder.startNewArray(new ArrayCodeTypeMirror(new ArrayCodeTypeMirror(context.getType(Class.class))), null); |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
110 List<ExecutableElement> constructors = NodeBaseFactory.findUserConstructors(createdFactoryElement.asType()); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 for (ExecutableElement constructor : constructors) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
112 builder.startGroup(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
113 if (constructor.getParameters().isEmpty()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
114 builder.staticReference(context.getTruffleTypes().getDslMetadata(), NodeBaseFactory.EMPTY_CLASS_ARRAY); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
115 } else { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
116 builder.startNewArray(new ArrayCodeTypeMirror(context.getType(Class.class)), null); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
117 for (VariableElement var : constructor.getParameters()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
118 builder.typeLiteral(var.asType()); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
119 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
120 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
121 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
122 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
123 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
124 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
125 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
126 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
127 builder.end().end().end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
128 return method; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
129 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
130 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
131 private CodeExecutableElement createCreateNodeMethod() { |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
132 CodeExecutableElement method = new CodeExecutableElement(modifiers(PUBLIC), node.getNodeType(), "createNode"); |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
133 CodeVariableElement arguments = new CodeVariableElement(context.getType(Object.class), "arguments"); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
134 method.setVarArgs(true); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
135 method.addParameter(arguments); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
136 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
137 CodeTreeBuilder builder = method.createBuilder(); |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
138 List<ExecutableElement> signatures = NodeBaseFactory.findUserConstructors(createdFactoryElement.asType()); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
139 boolean ifStarted = false; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
140 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
141 for (ExecutableElement element : signatures) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
142 ifStarted = builder.startIf(ifStarted); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
143 builder.string("arguments.length == " + element.getParameters().size()); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
144 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
145 int index = 0; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
146 for (VariableElement param : element.getParameters()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
147 if (ElementUtils.isObject(param.asType())) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
148 continue; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
149 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
150 builder.string(" && "); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
151 if (!param.asType().getKind().isPrimitive()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
152 builder.string("(arguments[" + index + "] == null || "); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
153 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
154 builder.string("arguments[" + index + "] instanceof "); |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
155 builder.type(ElementUtils.boxType(context, param.asType())); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
156 if (!param.asType().getKind().isPrimitive()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
157 builder.string(")"); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
158 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
159 index++; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
160 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
161 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
162 builder.startBlock(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
163 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
164 builder.startReturn().startCall("create"); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
165 index = 0; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
166 for (VariableElement param : element.getParameters()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
167 builder.startGroup(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
168 if (!ElementUtils.isObject(param.asType())) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
169 builder.string("(").type(param.asType()).string(") "); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
170 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
171 builder.string("arguments[").string(String.valueOf(index)).string("]"); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
172 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
173 index++; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
174 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
175 builder.end().end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
176 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
177 builder.end(); // block |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
178 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
179 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
180 builder.startElseBlock(); |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
181 builder.startThrow().startNew(context.getType(IllegalArgumentException.class)); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
182 builder.doubleQuote("Invalid create signature."); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
183 builder.end().end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
184 builder.end(); // else block |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
185 return method; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
186 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
187 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
188 private ExecutableElement createGetInstanceMethod(Modifier visibility) { |
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
189 TypeElement nodeFactoryType = ElementUtils.fromTypeMirror(context.getType(NodeFactory.class)); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
190 TypeMirror returnType = ElementUtils.getDeclaredType(nodeFactoryType, node.getNodeType()); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
191 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
192 CodeExecutableElement method = new CodeExecutableElement(modifiers(), returnType, "getInstance"); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
193 if (visibility != null) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
194 method.getModifiers().add(visibility); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
195 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
196 method.getModifiers().add(Modifier.STATIC); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
197 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
198 String varName = instanceVarName(node); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
199 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
200 CodeTreeBuilder builder = method.createBuilder(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
201 builder.startIf(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
202 builder.string(varName).string(" == null"); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
203 builder.end().startBlock(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
204 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
205 builder.startStatement(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
206 builder.string(varName); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
207 builder.string(" = "); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
208 builder.startNew(factoryClassName(node)).end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
209 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
210 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
211 builder.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
212 builder.startReturn().string(varName).end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
213 return method; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
214 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
215 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
216 private static String instanceVarName(NodeData node) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
217 if (node.getDeclaringNode() != null) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
218 return ElementUtils.firstLetterLowerCase(factoryClassName(node)) + "Instance"; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
219 } else { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
220 return "instance"; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
221 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
222 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
223 |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
224 private CodeVariableElement createInstanceConstant(TypeMirror factoryType) { |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
225 String varName = instanceVarName(node); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
226 CodeVariableElement var = new CodeVariableElement(modifiers(), factoryType, varName); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
227 var.getModifiers().add(Modifier.PRIVATE); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
228 var.getModifiers().add(Modifier.STATIC); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
229 return var; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
230 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
231 |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
232 public void createFactoryMethods(CodeTypeElement clazz, Modifier createVisibility) { |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
233 List<ExecutableElement> constructors = NodeBaseFactory.findUserConstructors(createdFactoryElement.asType()); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
234 for (ExecutableElement constructor : constructors) { |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
235 clazz.add(createCreateMethod(createVisibility, constructor)); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
236 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
237 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
238 |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
239 private CodeExecutableElement createCreateMethod(Modifier visibility, ExecutableElement constructor) { |
18753
f6b8787dc113
Truffle-DSL: replace complex factory system with a much simpler version
Christian Humer <christian.humer@gmail.com>
parents:
18752
diff
changeset
|
240 CodeExecutableElement method = CodeExecutableElement.clone(context.getEnvironment(), constructor); |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
241 method.setSimpleName(CodeNames.of("create")); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
242 method.getModifiers().clear(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
243 if (visibility != null) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
244 method.getModifiers().add(visibility); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
245 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
246 method.getModifiers().add(Modifier.STATIC); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
247 method.setReturnType(node.getNodeType()); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
248 |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
249 CodeTreeBuilder body = method.createBuilder(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
250 body.startReturn(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
251 if (node.getSpecializations().isEmpty()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
252 body.nullLiteral(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
253 } else { |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
254 if (options.useNewLayout()) { |
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
255 body.startNew(NodeGenFactory.nodeType(node)); |
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
256 } else { |
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
257 body.startCall(NodeBaseFactory.nodeSpecializationClassName(node.getSpecializations().get(0)), FACTORY_METHOD_NAME); |
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
258 } |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
259 for (VariableElement var : method.getParameters()) { |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
260 body.string(var.getSimpleName().toString()); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
261 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
262 body.end(); |
18761
a665483c3881
Truffle-DSL: new node layout implementation.
Christian Humer <christian.humer@gmail.com>
parents:
18754
diff
changeset
|
263 |
18752
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
264 } |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
265 body.end(); |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
266 return method; |
1acaa69ff61b
Truffle-DSL: refactor generator classes
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
267 } |
18766
a720bf2e2f43
Truffle-DSL: checkstyle fixes.
Christian Humer <christian.humer@gmail.com>
parents:
18761
diff
changeset
|
268 } |