Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethod.java @ 9848:a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 03 Jun 2013 20:28:50 +0200 |
parents | 8e3a1635cc9e |
children | f43eb2f1bbbc |
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.*; |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
31 import com.oracle.truffle.codegen.processor.typesystem.*; |
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
|
32 |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
33 /** |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
34 * Note: this class has a natural ordering that is inconsistent with equals. |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
35 */ |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
36 public class TemplateMethod extends MessageContainer implements Comparable<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
|
37 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
38 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
|
39 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
|
40 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
|
41 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
|
42 private final AnnotationMirror markerAnnotation; |
8662
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
43 private ActualParameter returnType; |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
44 private 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
|
45 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
46 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
|
47 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
|
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.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
|
50 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
|
51 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
|
52 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
|
53 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
|
54 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
|
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 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
|
57 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
|
58 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
|
59 } |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
60 } |
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
|
61 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
62 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
63 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
|
64 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
|
65 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
|
66 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
67 |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
68 public void setParameters(List<ActualParameter> parameters) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
69 this.parameters = parameters; |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
70 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
71 |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
72 @Override |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
73 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
|
74 return method; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
75 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
76 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
77 @Override |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
78 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
|
79 return markerAnnotation; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
80 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
81 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
82 @Override |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
83 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
|
84 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
|
85 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
86 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
87 public void setId(String id) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
88 this.id = id; |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
89 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
90 |
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
|
91 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
|
92 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
|
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 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
95 public Template getTemplate() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
96 return template; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
7291
diff
changeset
|
97 } |
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
|
98 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
99 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
|
100 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
|
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 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
|
104 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
|
105 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 |
8662
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
107 public void replaceParameter(String localName, ActualParameter newParameter) { |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
108 if (returnType.getLocalName().equals(localName)) { |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
109 returnType = newParameter; |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
110 returnType.setMethod(this); |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
111 } |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
112 |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
113 for (ListIterator<ActualParameter> iterator = parameters.listIterator(); iterator.hasNext();) { |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
114 ActualParameter parameter = iterator.next(); |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
115 if (parameter.getLocalName().equals(localName)) { |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
116 iterator.set(newParameter); |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
117 newParameter.setMethod(this); |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
118 } |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
119 } |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
120 } |
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
121 |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
122 public List<ActualParameter> getRequiredParameters() { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
123 List<ActualParameter> requiredParameters = new ArrayList<>(); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
124 for (ActualParameter parameter : getParameters()) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
125 if (getSpecification().getRequired().contains(parameter.getSpecification())) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
126 requiredParameters.add(parameter); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
127 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
128 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
129 return requiredParameters; |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
130 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
131 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
132 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
|
133 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
|
134 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 |
9848
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
136 public List<ActualParameter> findParameters(ParameterSpec spec) { |
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
137 List<ActualParameter> foundParameters = new ArrayList<>(); |
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
138 for (ActualParameter param : getReturnTypeAndParameters()) { |
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
139 if (param.getSpecification().equals(spec)) { |
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
140 foundParameters.add(param); |
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
141 } |
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
142 } |
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
143 return foundParameters; |
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
144 } |
a5d3e0973e83
Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
145 |
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
|
146 public ActualParameter findParameter(String valueName) { |
8662
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
147 for (ActualParameter param : getReturnTypeAndParameters()) { |
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
|
148 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
|
149 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
|
150 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
151 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 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
|
153 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
154 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
155 public List<ActualParameter> getReturnTypeAndParameters() { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
156 List<ActualParameter> allParameters = new ArrayList<>(getParameters().size() + 1); |
9208
9dfefdee8f3f
Fixed getting signature if returnType is null.
Christian Humer <christian.humer@gmail.com>
parents:
8662
diff
changeset
|
157 if (getReturnType() != null) { |
9dfefdee8f3f
Fixed getting signature if returnType is null.
Christian Humer <christian.humer@gmail.com>
parents:
8662
diff
changeset
|
158 allParameters.add(getReturnType()); |
9dfefdee8f3f
Fixed getting signature if returnType is null.
Christian Humer <christian.humer@gmail.com>
parents:
8662
diff
changeset
|
159 } |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
160 allParameters.addAll(getParameters()); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
161 return Collections.unmodifiableList(allParameters); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
162 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
163 |
9227
6d92fdf1c999
Fixes several minor issues.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
164 public boolean canBeAccessedByInstanceOf(ProcessorContext context, TypeMirror type) { |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
165 TypeMirror methodType = Utils.findNearestEnclosingType(getMethod()).asType(); |
9227
6d92fdf1c999
Fixes several minor issues.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
166 return Utils.isAssignable(context, type, methodType) || Utils.isAssignable(context, methodType, type); |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
167 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
168 |
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
|
169 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
|
170 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
|
171 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
172 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
173 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
|
174 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
|
175 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
|
176 } else { |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8245
diff
changeset
|
177 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
|
178 } |
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
|
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 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation 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 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
|
182 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
|
183 } |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
184 |
a748e4d44694
Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
185 @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
|
186 public String toString() { |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
187 return String.format("%s [id = %s, method = %s]", getClass().getSimpleName(), getId(), 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
|
188 } |
7847
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
189 |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
190 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
|
191 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
|
192 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
|
193 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
|
194 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
|
195 } |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
196 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
|
197 } |
06a7cd6aaf00
Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
198 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
|
199 } |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
200 |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
201 public TypeData getReturnSignature() { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
202 return getReturnType().getTypeSystemType(); |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
203 } |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
204 |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
205 public List<TypeData> getSignature() { |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
206 List<TypeData> types = new ArrayList<>(); |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
207 for (ActualParameter parameter : getParameters()) { |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
208 if (!parameter.getSpecification().isSignature()) { |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
209 continue; |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
210 } |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
211 TypeData typeData = parameter.getTypeSystemType(); |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
212 if (typeData != null) { |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
213 types.add(typeData); |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
214 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
215 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
216 return types; |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
217 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
218 |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
219 public List<ActualParameter> getSignatureParameters() { |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
220 List<ActualParameter> types = new ArrayList<>(); |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
221 for (ActualParameter parameter : getParameters()) { |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
222 if (!parameter.getSpecification().isSignature()) { |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
223 continue; |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
224 } |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
225 types.add(parameter); |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
226 } |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
227 return types; |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
228 } |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
229 |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
230 @Override |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
231 public int compareTo(TemplateMethod o) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
232 if (this == o) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
233 return 0; |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
234 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
235 |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
236 int compare = compareBySignature(o); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
237 if (compare == 0) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
238 // if signature sorting failed sort by id |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
239 compare = getId().compareTo(o.getId()); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
240 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
241 if (compare == 0) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
242 // if still no difference sort by enclosing type name |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
243 TypeElement enclosingType1 = Utils.findNearestEnclosingType(getMethod()); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
244 TypeElement enclosingType2 = Utils.findNearestEnclosingType(o.getMethod()); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
245 compare = enclosingType1.getQualifiedName().toString().compareTo(enclosingType2.getQualifiedName().toString()); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
246 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
247 return compare; |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
248 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
249 |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
250 public List<ActualParameter> getParametersAfter(ActualParameter genericParameter) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
251 boolean found = false; |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
252 List<ActualParameter> foundParameters = new ArrayList<>(); |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
253 for (ActualParameter param : getParameters()) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
254 if (param.getLocalName().equals(genericParameter.getLocalName())) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
255 found = true; |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
256 } else if (found) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
257 foundParameters.add(param); |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
258 } |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
259 } |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
260 return foundParameters; |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
261 } |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
262 |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
263 public int compareBySignature(TemplateMethod compareMethod) { |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
264 TypeSystemData typeSystem = getTemplate().getTypeSystem(); |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
265 if (typeSystem != compareMethod.getTemplate().getTypeSystem()) { |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
266 throw new IllegalStateException("Cannot compare two methods with different type systems."); |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
267 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
268 |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
269 List<TypeData> signature1 = getSignature(); |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
270 List<TypeData> signature2 = compareMethod.getSignature(); |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
271 if (signature1.size() != signature2.size()) { |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
272 return signature2.size() - signature1.size(); |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
273 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
274 |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
275 int result = 0; |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
276 for (int i = 0; i < signature1.size(); i++) { |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
277 int typeResult = compareActualParameter(typeSystem, signature1.get(i), signature2.get(i)); |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
278 if (result == 0) { |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
279 result = typeResult; |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
280 } else if (typeResult != 0 && Math.signum(result) != Math.signum(typeResult)) { |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
281 // We cannot define an order. |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
282 return 0; |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
283 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
284 } |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
285 if (result == 0) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
286 TypeData returnSignature1 = getReturnSignature(); |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
287 TypeData returnSignature2 = compareMethod.getReturnSignature(); |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
288 |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
289 result = compareActualParameter(typeSystem, returnSignature1, returnSignature2); |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9208
diff
changeset
|
290 } |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
291 |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
292 return result; |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
293 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
294 |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
295 private static int compareActualParameter(TypeSystemData typeSystem, TypeData t1, TypeData t2) { |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
296 int index1 = typeSystem.findType(t1); |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
297 int index2 = typeSystem.findType(t2); |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
298 return index1 - index2; |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
299 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
300 |
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
|
301 } |