Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethodParser.java @ 8242:ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 04 Mar 2013 15:14:11 +0100 |
parents | 6b74ffe38183 |
children | 703c09f8640c |
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 |
8242
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
34 import com.oracle.truffle.api.codegen.*; |
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
|
35 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
|
36 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
|
37 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
38 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
|
39 |
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 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
|
41 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
42 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
|
43 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
44 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
|
45 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
|
46 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
47 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
|
48 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
|
49 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
|
50 } |
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
|
51 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
52 public boolean isEmitErrors() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
53 return emitErrors; |
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 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
56 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
|
57 this.parseNullOnError = nullOnError; |
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 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
60 public boolean isParseNullOnError() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
61 return parseNullOnError; |
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 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
64 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
|
65 this.emitErrors = emitErrors; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
66 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
67 |
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
|
68 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
|
69 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
|
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 |
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 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
|
73 |
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 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
|
75 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
76 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
|
77 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
78 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
|
79 return null; |
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 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
82 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
|
83 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
|
84 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
|
85 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
86 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
|
87 boolean valid = true; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
88 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
|
89 if (!isParsable(method)) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
90 continue; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
91 } |
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
|
92 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
93 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
|
94 AnnotationMirror mirror = null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
95 if (annotationType != null) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
96 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
|
97 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
98 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
99 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
|
100 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
|
101 valid = false; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
102 continue; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
103 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
104 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
105 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
|
106 if (parsedMethod != null) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
107 parsedMethods.add(parsedMethod); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
108 } else { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
109 valid = false; |
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 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
112 if (!valid && parseNullOnError) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
113 return null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
114 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
115 return parsedMethods; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
116 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
117 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
118 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
|
119 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
|
120 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
|
121 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
|
122 } |
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
|
123 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
124 List<TypeDef> typeDefs = createTypeDefinitions(methodSpecification.getReturnType(), methodSpecification.getParameters()); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
125 |
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
|
126 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
|
127 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
|
128 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
|
129 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
130 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
|
131 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
|
132 if (isEmitErrors()) { |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
133 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
|
134 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
|
135 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
136 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
|
137 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
|
138 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
139 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
|
140 } |
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
|
141 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
|
142 } |
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
|
143 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
144 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
|
145 if (parameters == null) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
146 if (isEmitErrors()) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
147 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
|
148 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
|
149 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
|
150 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
151 return null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
152 } |
8242
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
153 |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
154 String id = method.getSimpleName().toString(); |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
155 AnnotationMirror idAnnotation = Utils.findAnnotationMirror(context.getEnvironment(), method, NodeId.class); |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
156 if (idAnnotation != null) { |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
157 id = Utils.getAnnotationValueString(idAnnotation, "value"); |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
158 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
159 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
160 ActualParameter[] paramMirrors = parameters.toArray(new ActualParameter[parameters.size()]); |
8242
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
161 return create(new TemplateMethod(id, template, methodSpecification, method, annotation, returnTypeMirror, paramMirrors)); |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
162 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
163 |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
164 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
|
165 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
|
166 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
|
167 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
168 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
|
169 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
|
170 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
171 int specificationIndex = 0; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
172 List<ActualParameter> resolvedParameters = new ArrayList<>(); |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
173 while (parameter != null || specification != null) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
174 if (parameter == null || specification == null) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
175 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
|
176 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
|
177 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
|
178 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
|
179 } |
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
|
180 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
|
181 } |
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
|
182 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
183 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
|
184 if (resolvedParameter == null) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
185 // mismatch |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
186 if (specification.isOptional()) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
187 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
|
188 specificationIndex = 0; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
189 } else { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
190 return null; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
191 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
192 } else { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
193 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
|
194 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
195 // match |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
196 if (specification.getCardinality() == Cardinality.ONE) { |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
197 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
|
198 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
|
199 specificationIndex = 0; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
200 } 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
|
201 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
|
202 specificationIndex++; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
203 } |
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
|
204 } |
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 } |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
206 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
|
207 } |
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 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
209 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
|
210 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
|
211 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
|
212 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
|
213 } |
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
|
214 |
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
|
215 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
|
216 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
|
217 } |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7753
diff
changeset
|
218 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
|
219 } |
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
|
220 |
7753
c17ee8823d72
Fixed bug in method parsing error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7679
diff
changeset
|
221 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
|
222 List<TypeDef> typeDefs = new ArrayList<>(); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
223 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
224 List<ParameterSpec> allParams = new ArrayList<>(); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
225 allParams.add(returnType); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
226 allParams.addAll(parameters); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
227 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
228 int defIndex = 0; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
229 for (ParameterSpec spec : allParams) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
230 TypeMirror[] allowedTypes = spec.getAllowedTypes(); |
7753
c17ee8823d72
Fixed bug in method parsing error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7679
diff
changeset
|
231 TypeMirror[] types = spec.getAllowedTypes(); |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
232 if (types != null && allowedTypes.length > 1) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
233 TypeDef foundDef = null; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
234 for (TypeDef def : typeDefs) { |
7753
c17ee8823d72
Fixed bug in method parsing error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7679
diff
changeset
|
235 if (Arrays.equals(allowedTypes, def.getTypes())) { |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
236 foundDef = def; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
237 break; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
238 } |
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 if (foundDef == null) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
241 foundDef = new TypeDef(types, "Types" + defIndex); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
242 typeDefs.add(foundDef); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
243 defIndex++; |
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 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
246 foundDef.getParameters().add(spec); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
247 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
248 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
249 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
250 return typeDefs; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
251 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
252 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
253 protected static class TypeDef { |
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 private final TypeMirror[] types; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
256 private final String name; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
257 private final List<ParameterSpec> parameters = new ArrayList<>(); |
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 public TypeDef(TypeMirror[] types, String name) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
260 this.types = types; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
261 this.name = name; |
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 List<ParameterSpec> getParameters() { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
265 return parameters; |
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 public TypeMirror[] getTypes() { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
269 return types; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
270 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
271 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
272 public String getName() { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
273 return name; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
274 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
275 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
276 |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
277 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
|
278 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
|
279 |
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 b.append(" "); |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
281 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
|
282 |
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 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
|
284 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
|
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 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
|
288 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
|
289 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
|
290 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
|
291 } |
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 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
|
293 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
|
294 } |
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 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
296 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
|
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 (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
|
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 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
|
303 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
|
304 } |
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 |
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
|
306 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
|
307 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
|
308 } |
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
|
309 |
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
|
310 } |
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
|
311 |
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
|
312 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
|
313 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
314 if (!typeDefs.isEmpty()) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
315 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
|
316 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
317 String lineSep = ""; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
318 for (TypeDef def : typeDefs) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
319 b.append(lineSep); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
320 b.append(" <").append(def.getName()).append(">"); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
321 b.append(" = {"); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
322 String separator = ""; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
323 for (TypeMirror type : def.getTypes()) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
324 b.append(separator).append(Utils.getSimpleName(type)); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
325 separator = ", "; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
326 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
327 b.append("}"); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
328 lineSep = "\n"; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
329 |
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
|
330 } |
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
|
331 } |
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
|
332 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
|
333 } |
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
|
334 |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
335 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
|
336 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
|
337 if (spec.getAllowedTypes().length > 1) { |
7679
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
338 TypeDef foundTypeDef = null; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
339 for (TypeDef typeDef : typeDefs) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
340 if (typeDef.getParameters().contains(spec)) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
341 foundTypeDef = typeDef; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
342 break; |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
343 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
344 } |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
345 if (foundTypeDef != null) { |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
346 builder.append("<" + foundTypeDef.getName() + ">"); |
5f3cba05c2fa
Cleanup and improved error messages.
Christian Humer <christian.humer@gmail.com>
parents:
7530
diff
changeset
|
347 } |
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
|
348 } 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
|
349 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
|
350 } 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
|
351 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
|
352 } |
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
|
353 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
|
354 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
|
355 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
|
356 } |
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
|
357 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
|
358 } |
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
|
359 |
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
|
360 } |