Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethod.java @ 8310:89006c76f737
Final fields of base node can be optionally passed to builtin specialization method. And a few fixes.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 15 Mar 2013 21:18:33 +0100 |
parents | 0905d796944a |
children | a80bf36c6a1e |
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 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
25 import java.util.*; |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
26 |
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
|
27 import javax.lang.model.element.*; |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
28 import javax.lang.model.type.*; |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
29 |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
30 import com.oracle.truffle.codegen.processor.*; |
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
|
31 |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
32 public class TemplateMethod extends MessageContainer { |
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 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
34 private String id; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
35 private final 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
|
36 private final MethodSpec specification; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 private final ExecutableElement 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
|
38 private final AnnotationMirror markerAnnotation; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 ActualParameter returnType; |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
40 private final List<ActualParameter> parameters; |
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
|
41 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
42 public TemplateMethod(String id, Template template, MethodSpec specification, ExecutableElement method, AnnotationMirror markerAnnotation, ActualParameter returnType, |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
43 List<ActualParameter> parameters) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
44 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
|
45 this.specification = specification; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 this.method = 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
|
47 this.markerAnnotation = markerAnnotation; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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.returnType = returnType; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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.parameters = parameters; |
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
|
50 this.id = id; |
7847
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
51 |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
52 if (parameters != null) { |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
53 for (ActualParameter param : parameters) { |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
54 param.setMethod(this); |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
55 } |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
56 } |
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
|
57 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 public TemplateMethod(TemplateMethod method) { |
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
|
60 this(method.id, method.template, method.specification, method.method, method.markerAnnotation, method.returnType, method.parameters); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
61 getMessages().addAll(method.getMessages()); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
62 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
63 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
64 @Override |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
65 public Element getMessageElement() { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
66 return method; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
67 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
68 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
69 @Override |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
70 public AnnotationMirror getMessageAnnotation() { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
71 return markerAnnotation; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
72 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
73 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
74 @Override |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
75 protected List<MessageContainer> findChildContainers() { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
76 return Collections.emptyList(); |
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
|
77 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
78 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
79 public void setId(String id) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
80 this.id = id; |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
81 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
82 |
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
|
83 public String getId() { |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
84 return id; |
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
|
85 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
86 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
87 public Template getTemplate() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
88 return template; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
89 } |
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
|
90 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 public MethodSpec getSpecification() { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 return specification; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
93 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
94 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
95 public ActualParameter 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
|
96 return returnType; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
97 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
98 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
99 public List<ActualParameter> getParameters() { |
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
|
100 return parameters; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
101 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 public ActualParameter findParameter(String valueName) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
104 for (ActualParameter param : getParameters()) { |
8310
89006c76f737
Final fields of base node can be optionally passed to builtin specialization method. And a few fixes.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
105 if (param.getLocalName().equals(valueName)) { |
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
|
106 return param; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
107 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
108 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 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
|
110 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
112 public List<ActualParameter> getReturnTypeAndParameters() { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
113 List<ActualParameter> allParameters = new ArrayList<>(getParameters().size() + 1); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
114 allParameters.add(getReturnType()); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
115 allParameters.addAll(getParameters()); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
116 return Collections.unmodifiableList(allParameters); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
117 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
118 |
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 public ActualParameter findParameter(ParameterSpec spec) { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 for (ActualParameter param : getParameters()) { |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
121 if (param.getSpecification().getName().equals(spec.getName())) { |
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
|
122 return param; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
124 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 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
|
126 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
128 public boolean canBeAccessedByInstanceOf(TypeMirror type) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
129 TypeMirror methodType = Utils.findNearestEnclosingType(getMethod()).asType(); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
130 return Utils.isAssignable(type, methodType) || Utils.isAssignable(methodType, type); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
131 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
132 |
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
|
133 public ExecutableElement getMethod() { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 return 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
|
135 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
136 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 public String getMethodName() { |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8245
diff
changeset
|
138 if (getMethod() != null) { |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8245
diff
changeset
|
139 return getMethod().getSimpleName().toString(); |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8245
diff
changeset
|
140 } else { |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8245
diff
changeset
|
141 return "$synthetic"; |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8245
diff
changeset
|
142 } |
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
|
143 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
144 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
145 public AnnotationMirror getMarkerAnnotation() { |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
146 return markerAnnotation; |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
147 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
148 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
149 @Override |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
150 public String toString() { |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
151 return "id = " + getId() + ", " + getClass().getSimpleName() + " [method = " + getMethod() + "]"; |
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
|
152 } |
7847
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
153 |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
154 public ActualParameter getPreviousParam(ActualParameter searchParam) { |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
155 ActualParameter prev = null; |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
156 for (ActualParameter param : getParameters()) { |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
157 if (param == searchParam) { |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
158 return prev; |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
159 } |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
160 prev = param; |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
161 } |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
162 return prev; |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
163 } |
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
|
164 } |