Mercurial > hg > graal-jvmci-8
annotate graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.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 | 3cc5fb59916e |
children |
rev | line source |
---|---|
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
1 /* |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
4 * |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
8 * |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
13 * accompanied this code). |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
14 * |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
18 * |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
21 * questions. |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
22 */ |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
23 package com.oracle.truffle.codegen.processor.node; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
24 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
25 import java.util.*; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
26 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import javax.lang.model.element.*; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
28 import javax.lang.model.type.*; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
30 import com.oracle.truffle.codegen.processor.*; |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
31 import com.oracle.truffle.codegen.processor.node.NodeChildData.ExecutionKind; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 import com.oracle.truffle.codegen.processor.template.*; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 import com.oracle.truffle.codegen.processor.typesystem.*; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 public class NodeData extends Template { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
37 private final String nodeId; |
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
|
38 private NodeData declaringNode; |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
39 private List<NodeData> declaredNodes = new ArrayList<>(); |
10591
3cc5fb59916e
Truffle-DSL: Renamed @NodeClass to @NodeContainer. splitByMethodName is not an option anymore and is always enabled if a @NodeContainer is used.
Christian Humer <christian.humer@gmail.com>
parents:
10446
diff
changeset
|
40 private boolean nodeContainer; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
41 |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
42 private TypeSystemData typeSystem; |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
43 private List<NodeChildData> children; |
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
|
44 private List<NodeFieldData> fields; |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
45 private TypeMirror nodeType; |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
46 private ParameterSpec instanceParameterSpec; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 |
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
|
48 private List<SpecializationData> specializations; |
10596
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
49 private List<SpecializationData> polymorphicSpecializations; |
8242
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
50 private List<SpecializationListenerData> specializationListeners; |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
51 private Map<Integer, List<ExecutableTypeData>> executableTypes; |
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
|
52 private List<ShortCircuitData> shortCircuits; |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
53 private List<String> assumptions; |
10446
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
54 private List<CreateCastData> casts; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 |
10596
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
56 private int polymorphicDepth = -1; |
9779
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
57 private String shortName; |
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
58 |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
59 public NodeData(TypeElement type, String id) { |
8248
c4c3f50fa9c2
Fixes for codegen builtins support.
Christian Humer <christian.humer@gmail.com>
parents:
8245
diff
changeset
|
60 super(type, null, null); |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
61 this.nodeId = id; |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
62 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
63 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
64 public NodeData(NodeData splitSource, String templateMethodName, String nodeId) { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
65 super(splitSource.getTemplateType(), templateMethodName, null); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
66 this.nodeId = nodeId; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
67 this.declaringNode = splitSource.declaringNode; |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
68 this.declaredNodes = splitSource.declaredNodes; |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
69 this.typeSystem = splitSource.typeSystem; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
70 this.nodeType = splitSource.nodeType; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
71 this.specializations = splitSource.specializations; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
72 this.specializationListeners = splitSource.specializationListeners; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
73 this.executableTypes = splitSource.executableTypes; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
74 this.shortCircuits = splitSource.shortCircuits; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
75 this.fields = splitSource.fields; |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
76 this.children = splitSource.children; |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
77 this.assumptions = splitSource.assumptions; |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
78 } |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
79 |
10596
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
80 public int getPolymorphicDepth() { |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
81 return polymorphicDepth; |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
82 } |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
83 |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
84 void setPolymorphicDepth(int polymorphicDepth) { |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
85 this.polymorphicDepth = polymorphicDepth; |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
86 } |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
87 |
10446
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
88 public List<CreateCastData> getCasts() { |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
89 return casts; |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
90 } |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
91 |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
92 void setCasts(List<CreateCastData> casts) { |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
93 this.casts = casts; |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
94 } |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
95 |
9779
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
96 void setShortName(String shortName) { |
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
97 this.shortName = shortName; |
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
98 } |
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
99 |
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
100 public String getShortName() { |
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
101 return shortName; |
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
102 } |
0e4db5ee0695
Added support for the kind field in @NodeInfo for the source code generation.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
103 |
10591
3cc5fb59916e
Truffle-DSL: Renamed @NodeClass to @NodeContainer. splitByMethodName is not an option anymore and is always enabled if a @NodeContainer is used.
Christian Humer <christian.humer@gmail.com>
parents:
10446
diff
changeset
|
104 public boolean isNodeContainer() { |
3cc5fb59916e
Truffle-DSL: Renamed @NodeClass to @NodeContainer. splitByMethodName is not an option anymore and is always enabled if a @NodeContainer is used.
Christian Humer <christian.humer@gmail.com>
parents:
10446
diff
changeset
|
105 return nodeContainer; |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
106 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
107 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
108 void setTypeSystem(TypeSystemData typeSystem) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
109 this.typeSystem = typeSystem; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
110 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
111 |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
112 void setFields(List<NodeFieldData> fields) { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
113 this.fields = fields; |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
114 } |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
115 |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
116 public List<NodeFieldData> getFields() { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
117 return fields; |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
118 } |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
119 |
10591
3cc5fb59916e
Truffle-DSL: Renamed @NodeClass to @NodeContainer. splitByMethodName is not an option anymore and is always enabled if a @NodeContainer is used.
Christian Humer <christian.humer@gmail.com>
parents:
10446
diff
changeset
|
120 void setNodeContainer(boolean splitByMethodName) { |
3cc5fb59916e
Truffle-DSL: Renamed @NodeClass to @NodeContainer. splitByMethodName is not an option anymore and is always enabled if a @NodeContainer is used.
Christian Humer <christian.humer@gmail.com>
parents:
10446
diff
changeset
|
121 this.nodeContainer = splitByMethodName; |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
122 } |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
123 |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
124 @Override |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
125 protected List<MessageContainer> findChildContainers() { |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
126 List<MessageContainer> containerChildren = new ArrayList<>(); |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
127 if (declaredNodes != null) { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
128 containerChildren.addAll(declaredNodes); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
129 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
130 if (typeSystem != null) { |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
131 containerChildren.add(typeSystem); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
132 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
133 if (specializations != null) { |
8315 | 134 for (MessageContainer specialization : specializations) { |
135 if (specialization.getMessageElement() != null) { | |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
136 containerChildren.add(specialization); |
8315 | 137 } |
138 } | |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
139 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
140 if (specializationListeners != null) { |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
141 containerChildren.addAll(specializationListeners); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
142 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
143 if (executableTypes != null) { |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
144 containerChildren.addAll(getExecutableTypes()); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
145 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
146 if (shortCircuits != null) { |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
147 containerChildren.addAll(shortCircuits); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
148 } |
9227
6d92fdf1c999
Fixes several minor issues.
Christian Humer <christian.humer@gmail.com>
parents:
9224
diff
changeset
|
149 if (children != null) { |
6d92fdf1c999
Fixes several minor issues.
Christian Humer <christian.humer@gmail.com>
parents:
9224
diff
changeset
|
150 containerChildren.addAll(children); |
6d92fdf1c999
Fixes several minor issues.
Christian Humer <christian.humer@gmail.com>
parents:
9224
diff
changeset
|
151 } |
6d92fdf1c999
Fixes several minor issues.
Christian Humer <christian.humer@gmail.com>
parents:
9224
diff
changeset
|
152 if (fields != null) { |
6d92fdf1c999
Fixes several minor issues.
Christian Humer <christian.humer@gmail.com>
parents:
9224
diff
changeset
|
153 containerChildren.addAll(fields); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
154 } |
10446
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
155 if (casts != null) { |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
156 containerChildren.addAll(casts); |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
157 } |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
158 return containerChildren; |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
159 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
160 |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
161 public ParameterSpec getInstanceParameterSpec() { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
162 return instanceParameterSpec; |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
163 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
164 |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
165 public void setInstanceParameterSpec(ParameterSpec instanceParameter) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
166 this.instanceParameterSpec = instanceParameter; |
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 |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
169 public String getNodeId() { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
170 return nodeId; |
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 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
173 public TypeMirror getNodeType() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
174 if (nodeType != null) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
175 return nodeType; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
176 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
177 return getTemplateType().asType(); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
178 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
179 |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
180 void setAssumptions(List<String> assumptions) { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
181 this.assumptions = assumptions; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
182 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
183 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
184 public List<String> getAssumptions() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
185 return assumptions; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
186 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
187 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
188 public boolean needsFactory() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
189 if (specializations == null) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
190 return false; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
191 } |
9224
b69312e4eceb
Minor fix for private template types.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
192 if (getTemplateType().getModifiers().contains(Modifier.PRIVATE)) { |
b69312e4eceb
Minor fix for private template types.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
193 return false; |
b69312e4eceb
Minor fix for private template types.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
194 } |
b69312e4eceb
Minor fix for private template types.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
195 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
196 boolean noSpecialization = true; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
197 for (SpecializationData specialization : specializations) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
198 noSpecialization = noSpecialization && specialization.isGeneric() || specialization.isUninitialized(); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
199 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
200 return !noSpecialization; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
201 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
202 |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7855
diff
changeset
|
203 public boolean supportsFrame() { |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
204 if (executableTypes != null) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
205 for (ExecutableTypeData execType : getExecutableTypes(-1)) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
206 if (execType.findParameter("frameValue") == null) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
207 return false; |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
208 } |
8237
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7855
diff
changeset
|
209 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7855
diff
changeset
|
210 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7855
diff
changeset
|
211 return true; |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7855
diff
changeset
|
212 } |
6b74ffe38183
Implemented support for executing nodes in @Children fields.
Christian Humer <christian.humer@gmail.com>
parents:
7855
diff
changeset
|
213 |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
214 public List<NodeData> getNodeDeclaringChildren() { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
215 List<NodeData> nodeChildren = new ArrayList<>(); |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
216 for (NodeData child : getDeclaredNodes()) { |
7855
6e4fb0ccebb1
Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
7794
diff
changeset
|
217 if (child.needsFactory()) { |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
218 nodeChildren.add(child); |
7855
6e4fb0ccebb1
Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
7794
diff
changeset
|
219 } |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
220 nodeChildren.addAll(child.getNodeDeclaringChildren()); |
7855
6e4fb0ccebb1
Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
7794
diff
changeset
|
221 } |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
222 return nodeChildren; |
7855
6e4fb0ccebb1
Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
7794
diff
changeset
|
223 } |
6e4fb0ccebb1
Generated factories implement the new NodeFactory interface.
Christian Humer <christian.humer@gmail.com>
parents:
7794
diff
changeset
|
224 |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
225 void setDeclaredNodes(List<NodeData> declaredChildren) { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
226 this.declaredNodes = declaredChildren; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
227 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
228 for (NodeData child : declaredChildren) { |
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
|
229 child.declaringNode = this; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
230 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
231 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
232 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
233 public NodeData getParent() { |
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
|
234 return declaringNode; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
235 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
236 |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
237 public List<NodeData> getDeclaredNodes() { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
238 return declaredNodes; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
239 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
240 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
241 public void setNodeType(TypeMirror nodeType) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
242 this.nodeType = nodeType; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
243 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
244 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
245 public List<TemplateMethod> getAllTemplateMethods() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
246 List<TemplateMethod> methods = new ArrayList<>(); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
247 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
248 for (SpecializationData specialization : getSpecializations()) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
249 methods.add(specialization); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
250 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
251 |
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
|
252 methods.addAll(getSpecializationListeners()); |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
253 methods.addAll(getExecutableTypes()); |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
254 methods.addAll(getShortCircuits()); |
10446
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
255 if (getCasts() != null) { |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
256 methods.addAll(getCasts()); |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
257 } |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
258 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
259 return methods; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
260 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
261 |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
262 public ExecutableTypeData findGenericExecutableType(ProcessorContext context, TypeData type, int evaluatedCount) { |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
263 List<ExecutableTypeData> types = findGenericExecutableTypes(context, evaluatedCount); |
7794
b891ec348f8a
Made the usage of generic types more flexible for short circuits and generic specializations.
Christian Humer <christian.humer@gmail.com>
parents:
7754
diff
changeset
|
264 for (ExecutableTypeData availableType : types) { |
b891ec348f8a
Made the usage of generic types more flexible for short circuits and generic specializations.
Christian Humer <christian.humer@gmail.com>
parents:
7754
diff
changeset
|
265 if (Utils.typeEquals(availableType.getType().getBoxedType(), type.getBoxedType())) { |
b891ec348f8a
Made the usage of generic types more flexible for short circuits and generic specializations.
Christian Humer <christian.humer@gmail.com>
parents:
7754
diff
changeset
|
266 return availableType; |
7752
388848bbe03d
Fixed resolve of generic execute type.
Christian Humer <christian.humer@gmail.com>
parents:
7679
diff
changeset
|
267 } |
388848bbe03d
Fixed resolve of generic execute type.
Christian Humer <christian.humer@gmail.com>
parents:
7679
diff
changeset
|
268 } |
7794
b891ec348f8a
Made the usage of generic types more flexible for short circuits and generic specializations.
Christian Humer <christian.humer@gmail.com>
parents:
7754
diff
changeset
|
269 return null; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
270 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
271 |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
272 public ExecutableTypeData findAnyGenericExecutableType(ProcessorContext context, int evaluatedCount) { |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
273 List<ExecutableTypeData> types = findGenericExecutableTypes(context, evaluatedCount); |
8279
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
274 for (ExecutableTypeData type : types) { |
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
275 if (type.getType().isGeneric()) { |
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
276 return type; |
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
277 } |
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
278 } |
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
279 |
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
280 for (ExecutableTypeData type : types) { |
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
281 if (!type.getType().isVoid()) { |
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
282 return type; |
cc83fc474fd5
Fixed unsupported generic generation which could also take void as a type.
Christian Humer <christian.humer@gmail.com>
parents:
8252
diff
changeset
|
283 } |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8248
diff
changeset
|
284 } |
10596
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
285 |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
286 for (ExecutableTypeData type : types) { |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
287 return type; |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
288 } |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8248
diff
changeset
|
289 return null; |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8248
diff
changeset
|
290 } |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8248
diff
changeset
|
291 |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
292 public List<ExecutableTypeData> getExecutableTypes(int evaluatedCount) { |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
293 if (executableTypes == null) { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
294 return Collections.emptyList(); |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
295 } |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
296 if (evaluatedCount == -1) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
297 List<ExecutableTypeData> typeData = new ArrayList<>(); |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
298 for (int currentEvaluationCount : executableTypes.keySet()) { |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
299 typeData.addAll(executableTypes.get(currentEvaluationCount)); |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
300 } |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
301 return typeData; |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
302 } else { |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
303 List<ExecutableTypeData> types = executableTypes.get(evaluatedCount); |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
304 if (types == null) { |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
305 return Collections.emptyList(); |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
306 } |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
307 return types; |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
308 } |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
309 } |
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
310 |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
311 public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context, int evaluatedCount) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
312 List<ExecutableTypeData> types = new ArrayList<>(); |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
313 for (ExecutableTypeData type : getExecutableTypes(evaluatedCount)) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
314 if (!type.hasUnexpectedValue(context)) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
315 types.add(type); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
316 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
317 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
318 return types; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
319 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
320 |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
321 public ExecutableTypeData findExecutableType(TypeData prmitiveType, int evaluatedCount) { |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
322 for (ExecutableTypeData type : getExecutableTypes(evaluatedCount)) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
323 if (Utils.typeEquals(type.getType().getPrimitiveType(), prmitiveType.getPrimitiveType())) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
324 return type; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
325 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
326 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
327 return null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
328 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
329 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
330 public SpecializationData findUniqueSpecialization(TypeData type) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
331 SpecializationData result = null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
332 for (SpecializationData specialization : specializations) { |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
333 if (specialization.getReturnType().getTypeSystemType() == type) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
334 if (result != null) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
335 // Result not unique; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
336 return null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
337 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
338 result = specialization; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
339 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
340 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
341 return result; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
342 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
343 |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
344 public NodeChildData[] filterFields(ExecutionKind usage) { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
345 List<NodeChildData> filteredFields = new ArrayList<>(); |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
346 for (NodeChildData field : getChildren()) { |
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
|
347 if (usage == null || field.getExecutionKind() == usage) { |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
348 filteredFields.add(field); |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
349 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
350 } |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
351 return filteredFields.toArray(new NodeChildData[filteredFields.size()]); |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
352 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
353 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
354 public boolean needsRewrites(ProcessorContext context) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
355 boolean needsRewrites = false; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
356 |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8248
diff
changeset
|
357 for (SpecializationData specialization : getSpecializations()) { |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8248
diff
changeset
|
358 if (specialization.hasRewrite(context)) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
359 needsRewrites = true; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
360 break; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
361 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
362 } |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
363 return needsRewrites || getSpecializations().size() > 1; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
364 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
365 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
366 public SpecializationData getGenericSpecialization() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
367 for (SpecializationData specialization : specializations) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
368 if (specialization.isGeneric()) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
369 return specialization; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
370 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
371 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
372 return null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
373 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
374 |
10596
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
375 public SpecializationData getUninitializedSpecialization() { |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
376 for (SpecializationData specialization : specializations) { |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
377 if (specialization.isUninitialized()) { |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
378 return specialization; |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
379 } |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
380 } |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
381 return null; |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
382 } |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
383 |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8315
diff
changeset
|
384 @Override |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
385 public TypeSystemData getTypeSystem() { |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
386 return typeSystem; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
387 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
388 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
389 public String dump() { |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
390 return dump(0); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
391 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
392 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
393 private String dump(int level) { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
394 String indent = ""; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
395 for (int i = 0; i < level; i++) { |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
396 indent += " "; |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
397 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
398 StringBuilder builder = new StringBuilder(); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
399 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
400 builder.append(String.format("%s%s {", indent, toString())); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
401 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
402 dumpProperty(builder, indent, "templateClass", Utils.getQualifiedName(getTemplateType())); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
403 dumpProperty(builder, indent, "typeSystem", getTypeSystem()); |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
404 dumpProperty(builder, indent, "fields", getChildren()); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
405 dumpProperty(builder, indent, "executableTypes", getExecutableTypes()); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
406 dumpProperty(builder, indent, "specializations", getSpecializations()); |
10596
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
407 dumpProperty(builder, indent, "polymorphicDepth", getPolymorphicDepth()); |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
408 dumpProperty(builder, indent, "polymorphic", getPolymorphicSpecializations()); |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9227
diff
changeset
|
409 dumpProperty(builder, indent, "assumptions", getAssumptions()); |
10446
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
410 dumpProperty(builder, indent, "casts", getCasts()); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
411 dumpProperty(builder, indent, "messages", collectMessages()); |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
412 if (getDeclaredNodes().size() > 0) { |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
413 builder.append(String.format("\n%s children = [", indent)); |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
414 for (NodeData node : getDeclaredNodes()) { |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
415 builder.append("\n"); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
416 builder.append(node.dump(level + 1)); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
417 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
418 builder.append(String.format("\n%s ]", indent)); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
419 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
420 builder.append(String.format("%s}", indent)); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
421 return builder.toString(); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
422 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
423 |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
424 private static void dumpProperty(StringBuilder b, String indent, String propertyName, Object value) { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
425 if (value instanceof List) { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
426 List<?> list = (List<?>) value; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
427 if (!list.isEmpty()) { |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
428 b.append(String.format("\n%s %s = %s", indent, propertyName, dumpList(indent, (List<?>) value))); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
429 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
430 } else { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
431 if (value != null) { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
432 b.append(String.format("\n%s %s = %s", indent, propertyName, value)); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
433 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
434 } |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
435 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
436 |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
437 private static String dumpList(String indent, List<?> array) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
438 if (array == null) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
439 return "null"; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
440 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
441 |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
442 if (array.isEmpty()) { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
443 return "[]"; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
444 } else if (array.size() == 1) { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
445 return "[" + array.get(0).toString() + "]"; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
446 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
447 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
448 StringBuilder b = new StringBuilder(); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
449 b.append("["); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
450 for (Object object : array) { |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
451 b.append("\n "); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
452 b.append(indent); |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
453 b.append(object); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
454 b.append(", "); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
455 } |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
456 b.append("\n ").append(indent).append("]"); |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
457 return b.toString(); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
458 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
459 |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
460 public NodeChildData findChild(String name) { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
461 for (NodeChildData field : getChildren()) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
462 if (field.getName().equals(name)) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
463 return field; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
464 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
465 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
466 return null; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
467 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
468 |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
469 public List<NodeChildData> getChildren() { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
470 return children; |
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
|
471 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
472 |
9220
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
473 void setChildren(List<NodeChildData> fields) { |
97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
Christian Humer <christian.humer@gmail.com>
parents:
9217
diff
changeset
|
474 this.children = fields; |
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
|
475 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
476 |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
477 public List<SpecializationData> getSpecializations() { |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
478 return getSpecializations(false); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
479 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
480 |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
481 public List<SpecializationData> getSpecializations(boolean userDefinedOnly) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
482 if (userDefinedOnly) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
483 List<SpecializationData> specs = new ArrayList<>(); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
484 for (SpecializationData spec : specializations) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
485 if (spec.getMethod() != null) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
486 specs.add(spec); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
487 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
488 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
489 return specs; |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
490 } else { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
491 return specializations; |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
492 } |
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
|
493 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
494 |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
495 public List<SpecializationListenerData> getSpecializationListeners() { |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
496 return specializationListeners; |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
497 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
498 |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
499 public List<ExecutableTypeData> getExecutableTypes() { |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
500 return getExecutableTypes(-1); |
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
|
501 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
502 |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
503 public List<ShortCircuitData> getShortCircuits() { |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
504 return shortCircuits; |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
505 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
506 |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
507 void setSpecializations(List<SpecializationData> specializations) { |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
508 this.specializations = specializations; |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
509 if (this.specializations != null) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
510 for (SpecializationData specialization : specializations) { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
511 specialization.setNode(this); |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
512 } |
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
|
513 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
514 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
515 |
10596
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
516 void setPolymorphicSpecializations(List<SpecializationData> polymorphicSpecializations) { |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
517 this.polymorphicSpecializations = polymorphicSpecializations; |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
518 } |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
519 |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
520 public List<SpecializationData> getPolymorphicSpecializations() { |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
521 return polymorphicSpecializations; |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
522 } |
f43eb2f1bbbc
Truffle-DSL: code-generation of polymorphic caching
Christian Humer <christian.humer@gmail.com>
parents:
10591
diff
changeset
|
523 |
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
|
524 void setSpecializationListeners(List<SpecializationListenerData> specializationListeners) { |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
525 this.specializationListeners = specializationListeners; |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
526 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
527 |
9217
61ba6fc21ba4
Sourcegen can now generate execute methods of signature execute(frame, evaluatedValue).
Christian Humer <christian.humer@gmail.com>
parents:
9216
diff
changeset
|
528 void setExecutableTypes(Map<Integer, List<ExecutableTypeData>> executableTypes) { |
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
|
529 this.executableTypes = executableTypes; |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
530 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
531 |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
532 void setShortCircuits(List<ShortCircuitData> shortCircuits) { |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
533 this.shortCircuits = shortCircuits; |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
534 } |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
8237
diff
changeset
|
535 |
8245
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
536 @Override |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
537 public String toString() { |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
538 return getClass().getSimpleName() + "[" + getNodeId() + "]"; |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
539 } |
703c09f8640c
Implemented support for @NodeClass annotation to support builtins.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
540 |
10446
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
541 public CreateCastData findCast(String name) { |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
542 if (getCasts() != null) { |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
543 for (CreateCastData cast : getCasts()) { |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
544 if (cast.getChildNames().contains(name)) { |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
545 return cast; |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
546 } |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
547 } |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
548 } |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
549 return null; |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
550 } |
746fa60be266
Implemented CreateCast annotation for easier insertion of casts.
Christian Humer <christian.humer@gmail.com>
parents:
9779
diff
changeset
|
551 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
552 } |