Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethodParser.java @ 8237:6b74ffe38183
Implemented support for executing nodes in @Children fields.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 01 Mar 2013 17:03:57 +0100 |
parents | c17ee8823d72 |
children | ac4e8c16ffdf |
rev | line source |
---|---|
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.codegen.processor.template; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import static com.oracle.truffle.codegen.processor.Utils.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import java.lang.annotation.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import java.util.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import javax.lang.model.element.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 import javax.lang.model.type.*; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
32 import javax.lang.model.util.*; |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 import com.oracle.truffle.codegen.processor.*; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 import com.oracle.truffle.codegen.processor.template.ParameterSpec.Cardinality; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
37 public abstract class TemplateMethodParser<T extends Template, E extends TemplateMethod> { |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
38 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
39 private final ProcessorContext context; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
40 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
41 protected final T template; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
42 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
43 private boolean emitErrors = true; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
44 private boolean parseNullOnError = true; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
45 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
46 public TemplateMethodParser(ProcessorContext context, T template) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
47 this.template = template; |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 this.context = context; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
51 public boolean isEmitErrors() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
52 return emitErrors; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
53 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
54 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
55 public void setParseNullOnError(boolean nullOnError) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
56 this.parseNullOnError = nullOnError; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
57 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
58 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
59 public boolean isParseNullOnError() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
60 return parseNullOnError; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
61 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
62 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
63 public void setEmitErrors(boolean emitErrors) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
64 this.emitErrors = emitErrors; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
65 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
66 |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
67 public ProcessorContext getContext() { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
68 return context; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
69 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
70 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
71 public abstract MethodSpec createSpecification(ExecutableElement method, AnnotationMirror mirror); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
72 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
73 public abstract E create(TemplateMethod method); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
74 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
75 public abstract boolean isParsable(ExecutableElement method); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
76 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
77 public Class<? extends Annotation> getAnnotationType() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
78 return null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
79 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
80 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
81 public final List<E> parse(List<? extends Element> elements) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
82 List<ExecutableElement> methods = new ArrayList<>(); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
83 methods.addAll(ElementFilter.methodsIn(elements)); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
84 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
85 List<E> parsedMethods = new ArrayList<>(); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
86 boolean valid = true; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
87 for (ExecutableElement method : methods) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
88 if (!isParsable(method)) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
89 continue; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
90 } |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
91 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
92 Class<? extends Annotation> annotationType = getAnnotationType(); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
93 AnnotationMirror mirror = null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
94 if (annotationType != null) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
95 mirror = Utils.findAnnotationMirror(getContext().getEnvironment(), method, annotationType); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
96 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
97 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
98 if (method.getModifiers().contains(Modifier.PRIVATE)) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
99 getContext().getLog().error(method, "Method must not be private."); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
100 valid = false; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
101 continue; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
102 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
103 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
104 E parsedMethod = parseNew(method, mirror); |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
105 if (parsedMethod != null) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
106 parsedMethods.add(parsedMethod); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
107 } else { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
108 valid = false; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
109 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
110 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
111 if (!valid && parseNullOnError) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
112 return null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
113 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
114 return parsedMethods; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
115 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
116 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
117 private E parseNew(ExecutableElement method, AnnotationMirror annotation) { |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
118 MethodSpec methodSpecification = createSpecification(method, annotation); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
119 if (methodSpecification == null) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
120 return null; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
121 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
122 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
123 List<TypeDef> typeDefs = createTypeDefinitions(methodSpecification.getReturnType(), methodSpecification.getParameters()); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
124 |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
125 ParameterSpec returnTypeSpec = methodSpecification.getReturnType(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
126 List<ParameterSpec> parameterSpecs = new ArrayList<>(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
127 parameterSpecs.addAll(methodSpecification.getParameters()); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
128 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
129 ActualParameter returnTypeMirror = matchParameter(returnTypeSpec, method.getReturnType(), template, 0); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
130 if (returnTypeMirror == null) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
131 if (isEmitErrors()) { |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
132 String expectedReturnType = createTypeSignature(returnTypeSpec, typeDefs, true); |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
133 String actualReturnType = Utils.getSimpleName(method.getReturnType()); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
134 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
135 String message = String.format("The provided return type \"%s\" does not match expected return type \"%s\".\nExpected signature: \n %s", actualReturnType, expectedReturnType, |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
136 createExpectedSignature(method.getSimpleName().toString(), returnTypeSpec, parameterSpecs, typeDefs)); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
137 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
138 context.getLog().error(method, annotation, message); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
139 } |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
140 return null; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
141 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
142 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
143 List<ActualParameter> parameters = parseParameters(method, parameterSpecs); |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
144 if (parameters == null) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
145 if (isEmitErrors()) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
146 String message = String.format("Method signature mismatch. Expected signature: \n%s", |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
147 createExpectedSignature(method.getSimpleName().toString(), returnTypeSpec, parameterSpecs, typeDefs)); |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
148 context.getLog().error(method, annotation, message); |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
149 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
150 return null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
151 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
152 ActualParameter[] paramMirrors = parameters.toArray(new ActualParameter[parameters.size()]); |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
153 return create(new TemplateMethod(template, methodSpecification, method, annotation, returnTypeMirror, paramMirrors)); |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
154 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
155 |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
156 private List<ActualParameter> parseParameters(ExecutableElement method, List<ParameterSpec> parameterSpecs) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
157 Iterator<? extends VariableElement> parameterIterator = method.getParameters().iterator(); |
7530
5e3d1a68664e
applied mx eclipseformat to all Java files
Doug Simon <doug.simon@oracle.com>
parents:
7502
diff
changeset
|
158 Iterator<? extends ParameterSpec> specificationIterator = parameterSpecs.iterator(); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
159 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
160 VariableElement parameter = parameterIterator.hasNext() ? parameterIterator.next() : null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
161 ParameterSpec specification = specificationIterator.hasNext() ? specificationIterator.next() : null; |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
162 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
163 int specificationIndex = 0; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
164 List<ActualParameter> resolvedParameters = new ArrayList<>(); |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
165 while (parameter != null || specification != null) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
166 if (parameter == null || specification == null) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
167 if (specification != null && (specification.isOptional() || specification.getCardinality() == Cardinality.MULTIPLE)) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
168 specification = specificationIterator.hasNext() ? specificationIterator.next() : null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
169 specificationIndex = 0; |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
170 continue; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
171 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
172 return null; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
173 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
174 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
175 ActualParameter resolvedParameter = matchParameter(specification, parameter.asType(), template, specificationIndex); |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
176 if (resolvedParameter == null) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
177 // mismatch |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
178 if (specification.isOptional()) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
179 specification = specificationIterator.hasNext() ? specificationIterator.next() : null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
180 specificationIndex = 0; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
181 } else { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
182 return null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
183 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
184 } else { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
185 resolvedParameters.add(resolvedParameter); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
186 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
187 // match |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
188 if (specification.getCardinality() == Cardinality.ONE) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
189 parameter = parameterIterator.hasNext() ? parameterIterator.next() : null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
190 specification = specificationIterator.hasNext() ? specificationIterator.next() : null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
191 specificationIndex = 0; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
192 } else if (specification.getCardinality() == Cardinality.MULTIPLE) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
193 parameter = parameterIterator.hasNext() ? parameterIterator.next() : null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
194 specificationIndex++; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
195 } |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
196 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
197 } |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
198 return resolvedParameters; |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
199 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
200 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
201 private ActualParameter matchParameter(ParameterSpec specification, TypeMirror mirror, Template typeSystem, int index) { |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
202 TypeMirror resolvedType = mirror; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
203 if (hasError(resolvedType)) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
204 resolvedType = context.resolveNotYetCompiledType(mirror, typeSystem); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
205 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
206 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
207 if (!specification.matches(resolvedType)) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
208 return null; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
209 } |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
210 return new ActualParameter(specification, resolvedType, index); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
211 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
212 |
7753
c17ee8823d72
Fixed bug in method parsing error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7679
diff
changeset
|
213 protected List<TypeDef> createTypeDefinitions(ParameterSpec returnType, List<? extends ParameterSpec> parameters) { |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
214 List<TypeDef> typeDefs = new ArrayList<>(); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
215 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
216 List<ParameterSpec> allParams = new ArrayList<>(); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
217 allParams.add(returnType); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
218 allParams.addAll(parameters); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
219 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
220 int defIndex = 0; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
221 for (ParameterSpec spec : allParams) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
222 TypeMirror[] allowedTypes = spec.getAllowedTypes(); |
7753
c17ee8823d72
Fixed bug in method parsing error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7679
diff
changeset
|
223 TypeMirror[] types = spec.getAllowedTypes(); |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
224 if (types != null && allowedTypes.length > 1) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
225 TypeDef foundDef = null; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
226 for (TypeDef def : typeDefs) { |
7753
c17ee8823d72
Fixed bug in method parsing error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7679
diff
changeset
|
227 if (Arrays.equals(allowedTypes, def.getTypes())) { |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
228 foundDef = def; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
229 break; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
230 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
231 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
232 if (foundDef == null) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
233 foundDef = new TypeDef(types, "Types" + defIndex); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
234 typeDefs.add(foundDef); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
235 defIndex++; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
236 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
237 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
238 foundDef.getParameters().add(spec); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
239 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
240 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
241 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
242 return typeDefs; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
243 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
244 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
245 protected static class TypeDef { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
246 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
247 private final TypeMirror[] types; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
248 private final String name; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
249 private final List<ParameterSpec> parameters = new ArrayList<>(); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
250 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
251 public TypeDef(TypeMirror[] types, String name) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
252 this.types = types; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
253 this.name = name; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
254 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
255 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
256 public List<ParameterSpec> getParameters() { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
257 return parameters; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
258 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
259 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
260 public TypeMirror[] getTypes() { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
261 return types; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
262 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
263 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
264 public String getName() { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
265 return name; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
266 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
267 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
268 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
269 public static String createExpectedSignature(String methodName, ParameterSpec returnType, List<? extends ParameterSpec> parameters, List<TypeDef> typeDefs) { |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
270 StringBuilder b = new StringBuilder(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
271 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
272 b.append(" "); |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
273 b.append(createTypeSignature(returnType, typeDefs, true)); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
274 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
275 b.append(" "); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
276 b.append(methodName); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
277 b.append("("); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
278 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
279 for (int i = 0; i < parameters.size(); i++) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
280 ParameterSpec specification = parameters.get(i); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
281 if (specification.isOptional()) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
282 b.append("["); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
283 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
284 if (specification.getCardinality() == Cardinality.MULTIPLE) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
285 b.append("{"); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
286 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
287 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
288 b.append(createTypeSignature(specification, typeDefs, false)); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
289 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
290 if (specification.isOptional()) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
291 b.append("]"); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
292 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
293 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
294 if (specification.getCardinality() == Cardinality.MULTIPLE) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
295 b.append("}"); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
296 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
297 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
298 if (i < parameters.size() - 1) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
299 b.append(", "); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
300 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
301 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
302 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
303 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
304 b.append(")"); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
305 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
306 if (!typeDefs.isEmpty()) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
307 b.append("\n\n"); |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
308 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
309 String lineSep = ""; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
310 for (TypeDef def : typeDefs) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
311 b.append(lineSep); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
312 b.append(" <").append(def.getName()).append(">"); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
313 b.append(" = {"); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
314 String separator = ""; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
315 for (TypeMirror type : def.getTypes()) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
316 b.append(separator).append(Utils.getSimpleName(type)); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
317 separator = ", "; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
318 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
319 b.append("}"); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
320 lineSep = "\n"; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
321 |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
322 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
323 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
324 return b.toString(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
325 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
326 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
327 private static String createTypeSignature(ParameterSpec spec, List<TypeDef> typeDefs, boolean typeOnly) { |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
328 StringBuilder builder = new StringBuilder(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
329 if (spec.getAllowedTypes().length > 1) { |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
330 TypeDef foundTypeDef = null; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
331 for (TypeDef typeDef : typeDefs) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
332 if (typeDef.getParameters().contains(spec)) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
333 foundTypeDef = typeDef; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
334 break; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
335 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
336 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
337 if (foundTypeDef != null) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
338 builder.append("<" + foundTypeDef.getName() + ">"); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
339 } |
7291
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
340 } else if (spec.getAllowedTypes().length == 1) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
341 builder.append(Utils.getSimpleName(spec.getAllowedTypes()[0])); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
342 } else { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
343 builder.append("void"); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
344 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
345 if (!typeOnly) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
346 builder.append(" "); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
347 builder.append(spec.getName()); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
348 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
349 return builder.toString(); |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
350 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
351 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
352 } |