annotate graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/template/TemplateMethod.java @ 10596:f43eb2f1bbbc

Truffle-DSL: code-generation of polymorphic caching
author Christian Humer <christian.humer@gmail.com>
date Mon, 01 Jul 2013 20:32:20 +0200
parents a5d3e0973e83
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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;
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
53 this.parameters = new ArrayList<>();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
54 for (ActualParameter param : parameters) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
55 ActualParameter newParam = new ActualParameter(param);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
56 this.parameters.add(newParam);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
57 newParam.setMethod(this);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
58 }
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
59 this.id = 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
60 }
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation 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 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
63 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
64 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
65 }
0905d796944a Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents: 8251
diff changeset
66
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
67 public TemplateMethod(TemplateMethod method, ExecutableElement executable) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
68 this(method.id, method.template, method.specification, executable, method.markerAnnotation, method.returnType, method.parameters);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
69 getMessages().addAll(method.getMessages());
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
70 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
71
8595
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
72 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
73 this.parameters = parameters;
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
74 }
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
75
8252
0905d796944a Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents: 8251
diff changeset
76 @Override
0905d796944a Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents: 8251
diff changeset
77 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
78 return method;
0905d796944a Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents: 8251
diff changeset
79 }
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 @Override
0905d796944a Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents: 8251
diff changeset
82 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
83 return markerAnnotation;
0905d796944a Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents: 8251
diff changeset
84 }
0905d796944a Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents: 8251
diff changeset
85
0905d796944a Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents: 8251
diff changeset
86 @Override
0905d796944a Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents: 8251
diff changeset
87 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
88 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
89 }
ac4e8c16ffdf Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents: 8237
diff changeset
90
8245
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
91 public void setId(String id) {
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
92 this.id = id;
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
93 }
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
94
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
95 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
96 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
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
7502
6343a09b2ec1 Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents: 7291
diff changeset
99 public Template getTemplate() {
6343a09b2ec1 Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents: 7291
diff changeset
100 return template;
6343a09b2ec1 Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents: 7291
diff changeset
101 }
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
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 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
104 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
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
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation 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 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
108 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
109 }
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation 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
8662
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
111 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
112 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
113 returnType = newParameter;
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
114 returnType.setMethod(this);
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
115 }
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
116
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
117 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
118 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
119 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
120 iterator.set(newParameter);
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
121 newParameter.setMethod(this);
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
122 }
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
123 }
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
124 }
5eeade940236 Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents: 8595
diff changeset
125
8595
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
126 public List<ActualParameter> getRequiredParameters() {
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
127 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
128 for (ActualParameter parameter : getParameters()) {
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
129 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
130 requiredParameters.add(parameter);
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
131 }
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
132 }
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
133 return requiredParameters;
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
134 }
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
135
8245
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
136 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
137 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
138 }
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
139
9848
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
140 public List<ActualParameter> findParameters(ParameterSpec spec) {
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
141 List<ActualParameter> foundParameters = new ArrayList<>();
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
142 for (ActualParameter param : getReturnTypeAndParameters()) {
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
143 if (param.getSpecification().equals(spec)) {
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
144 foundParameters.add(param);
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
145 }
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
146 }
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
147 return foundParameters;
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
148 }
a5d3e0973e83 Fixed @Specialization#executeWith order was ignored.
Christian Humer <christian.humer@gmail.com>
parents: 9287
diff changeset
149
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
150 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
151 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
152 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
153 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
154 }
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
155 }
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
156 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
157 }
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
158
8245
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
159 public List<ActualParameter> getReturnTypeAndParameters() {
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
160 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
161 if (getReturnType() != null) {
9dfefdee8f3f Fixed getting signature if returnType is null.
Christian Humer <christian.humer@gmail.com>
parents: 8662
diff changeset
162 allParameters.add(getReturnType());
9dfefdee8f3f Fixed getting signature if returnType is null.
Christian Humer <christian.humer@gmail.com>
parents: 8662
diff changeset
163 }
8245
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
164 allParameters.addAll(getParameters());
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
165 return Collections.unmodifiableList(allParameters);
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
166 }
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
167
9227
6d92fdf1c999 Fixes several minor issues.
Christian Humer <christian.humer@gmail.com>
parents: 9217
diff changeset
168 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
169 TypeMirror methodType = Utils.findNearestEnclosingType(getMethod()).asType();
9227
6d92fdf1c999 Fixes several minor issues.
Christian Humer <christian.humer@gmail.com>
parents: 9217
diff changeset
170 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
171 }
703c09f8640c Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents: 8242
diff changeset
172
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
173 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
174 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
175 }
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
176
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
177 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
178 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
179 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
180 } else {
cb70ed101b5f Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents: 8245
diff changeset
181 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
182 }
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
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 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
186 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
187 }
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation 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
a748e4d44694 Truffle API to specify type-specalized Node classes; annotation processor for automatic code generation of the type-specialized Node classes during the build process
Christian Humer <christian.humer@gmail.com>
parents:
diff changeset
189 @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
190 public String toString() {
8595
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
191 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
192 }
7847
06a7cd6aaf00 Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents: 7502
diff changeset
193
06a7cd6aaf00 Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents: 7502
diff changeset
194 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
195 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
196 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
197 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
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 }
06a7cd6aaf00 Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents: 7502
diff changeset
200 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
201 }
06a7cd6aaf00 Casting is now done on demand using local variables for explicit guards.
Christian Humer <christian.humer@gmail.com>
parents: 7502
diff changeset
202 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
203 }
8592
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
204
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
205 public Signature getSignature() {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
206 Signature signature = new Signature();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
207 for (ActualParameter parameter : getReturnTypeAndParameters()) {
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) {
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
213 signature.types.add(typeData);
8592
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 }
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
216 return signature;
8592
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
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
219 public void updateSignature(Signature signature) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
220 assert signature.size() >= 1;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
221 int signatureIndex = 0;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
222 for (ActualParameter parameter : getReturnTypeAndParameters()) {
9287
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9227
diff changeset
223 if (!parameter.getSpecification().isSignature()) {
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9227
diff changeset
224 continue;
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9227
diff changeset
225 }
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
226 TypeData newType = signature.get(signatureIndex++);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
227 if (!parameter.getTypeSystemType().equals(newType)) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
228 replaceParameter(parameter.getLocalName(), new ActualParameter(parameter, newType));
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
229 }
9287
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9227
diff changeset
230 }
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9227
diff changeset
231 }
8e3a1635cc9e Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents: 9227
diff changeset
232
8595
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
233 @Override
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
234 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
235 if (this == o) {
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
236 return 0;
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
237 }
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
238
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
239 int compare = compareBySignature(o);
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
240 if (compare == 0) {
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
241 // 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
242 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
243 }
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
244 if (compare == 0) {
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
245 // 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
246 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
247 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
248 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
249 }
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
250 return compare;
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
251 }
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
252
9217
61ba6fc21ba4 Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents: 9208
diff changeset
253 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
254 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
255 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
256 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
257 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
258 found = true;
61ba6fc21ba4 Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents: 9208
diff changeset
259 } 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
260 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
261 }
61ba6fc21ba4 Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents: 9208
diff changeset
262 }
61ba6fc21ba4 Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents: 9208
diff changeset
263 return foundParameters;
61ba6fc21ba4 Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents: 9208
diff changeset
264 }
61ba6fc21ba4 Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents: 9208
diff changeset
265
8592
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
266 public int compareBySignature(TemplateMethod compareMethod) {
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
267 TypeSystemData typeSystem = getTemplate().getTypeSystem();
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
268 if (typeSystem != compareMethod.getTemplate().getTypeSystem()) {
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
269 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
270 }
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
271
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
272 Signature signature1 = getSignature();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
273 Signature signature2 = compareMethod.getSignature();
8592
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
274 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
275 return signature2.size() - signature1.size();
8592
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
276 }
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
277
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
278 int result = 0;
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
279 for (int i = 1; i < signature1.size(); i++) {
8592
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
280 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
281 if (result == 0) {
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
282 result = typeResult;
8595
8a1115c92271 Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents: 8592
diff changeset
283 } 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
284 // We cannot define an order.
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
285 return 0;
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
286 }
a80bf36c6a1e Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents: 8310
diff changeset
287 }
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
288 if (result == 0 && signature1.size() > 0) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
289 result = compareActualParameter(typeSystem, signature1.get(0), signature2.get(0));
9217
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
10596
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
301 public static class Signature implements Iterable<TypeData>, Comparable<Signature> {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
302
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
303 final List<TypeData> types;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
304
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
305 public Signature() {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
306 this.types = new ArrayList<>();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
307 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
308
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
309 public Signature(List<TypeData> signature) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
310 this.types = signature;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
311 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
312
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
313 @Override
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
314 public int hashCode() {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
315 return types.hashCode();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
316 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
317
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
318 public int compareTo(Signature o) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
319 if (o.size() != size()) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
320 return size() - o.size();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
321 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
322
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
323 int typeSum = 0;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
324 int otherTypeSum = 0;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
325 for (int i = 0; i < types.size(); i++) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
326 TypeData type = types.get(i);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
327 TypeData otherType = o.get(i);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
328 typeSum += type.isGeneric() ? 1 : 0;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
329 otherTypeSum += otherType.isGeneric() ? 1 : 0;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
330 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
331
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
332 return typeSum - otherTypeSum;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
333 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
334
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
335 public int size() {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
336 return types.size();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
337 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
338
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
339 public TypeData get(int index) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
340 return types.get(index);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
341 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
342
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
343 public Signature combine(Signature genericSignature, Signature other) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
344 assert types.size() == other.types.size();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
345 assert genericSignature.types.size() == other.types.size();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
346
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
347 if (this.equals(other)) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
348 return this;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
349 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
350
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
351 Signature signature = new Signature();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
352 for (int i = 0; i < types.size(); i++) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
353 TypeData type1 = types.get(i);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
354 TypeData type2 = other.types.get(i);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
355 if (type1.equals(type2)) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
356 signature.types.add(type1);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
357 } else {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
358 signature.types.add(genericSignature.types.get(i));
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
359 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
360 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
361 return signature;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
362 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
363
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
364 @Override
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
365 public boolean equals(Object obj) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
366 if (obj instanceof Signature) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
367 return ((Signature) obj).types.equals(types);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
368 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
369 return super.equals(obj);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
370 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
371
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
372 public Iterator<TypeData> iterator() {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
373 return types.iterator();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
374 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
375
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
376 @Override
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
377 public String toString() {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
378 return types.toString();
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
379 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
380
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
381 public boolean hasAnyParameterMatch(Signature other) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
382 for (int i = 1; i < types.size(); i++) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
383 TypeData type1 = types.get(i);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
384 TypeData type2 = other.types.get(i);
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
385 if (type1.equals(type2)) {
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
386 return true;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
387 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
388 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
389 return false;
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
390 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
391 }
f43eb2f1bbbc Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents: 9848
diff changeset
392
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
393 }