Mercurial > hg > graal-compiler
annotate graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/SpecializationData.java @ 9417:ffa27c3058e9
minor simplifications for writing compiled stubs
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Mon, 29 Apr 2013 21:18:37 +0200 |
parents | e6251a86e8e3 |
children | 746fa60be266 |
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, 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 |
8242
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
7847
diff
changeset
|
25 import java.util.*; |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
7847
diff
changeset
|
26 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
27 import com.oracle.truffle.api.codegen.*; |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
28 import com.oracle.truffle.codegen.processor.*; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
29 import com.oracle.truffle.codegen.processor.template.*; |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
30 import com.oracle.truffle.codegen.processor.typesystem.*; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
31 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
32 public class SpecializationData extends TemplateMethod { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
33 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
34 private final int order; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
35 private final boolean generic; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
36 private final boolean uninitialized; |
8243
d81ff782fa1a
Removed @SpecializationThrows from codegen API. Replaced it by a simplier version in @Specialization.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
37 private final List<SpecializationThrowsData> exceptions; |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
38 private List<String> guardDefinitions = Collections.emptyList(); |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
39 private List<GuardData> guards = Collections.emptyList(); |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
40 private List<ShortCircuitData> shortCircuits; |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
41 private List<String> assumptions = Collections.emptyList(); |
7751
ef1b41ea0a90
Implemented an option to turn off generated generic generation using specializations in @Generic.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
42 private boolean useSpecializationsForGeneric = true; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
43 private NodeData node; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
44 |
8243
d81ff782fa1a
Removed @SpecializationThrows from codegen API. Replaced it by a simplier version in @Specialization.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
45 public SpecializationData(TemplateMethod template, int order, List<SpecializationThrowsData> exceptions) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
46 super(template); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
47 this.order = order; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
48 this.generic = false; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
49 this.uninitialized = false; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
50 this.exceptions = exceptions; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
51 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
52 for (SpecializationThrowsData exception : exceptions) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
53 exception.setSpecialization(this); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
54 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
55 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
56 |
8256 | 57 public SpecializationData(TemplateMethod template, boolean generic, boolean uninitialized) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
58 super(template); |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
59 this.order = Specialization.DEFAULT_ORDER; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
60 this.generic = generic; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
61 this.uninitialized = uninitialized; |
8243
d81ff782fa1a
Removed @SpecializationThrows from codegen API. Replaced it by a simplier version in @Specialization.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
62 this.exceptions = Collections.emptyList(); |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
63 } |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
64 |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
65 @Override |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
66 protected List<MessageContainer> findChildContainers() { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
67 List<MessageContainer> sinks = new ArrayList<>(); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
68 if (exceptions != null) { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
69 sinks.addAll(exceptions); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
70 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
71 if (guards != null) { |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
72 sinks.addAll(guards); |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
73 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
74 return sinks; |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
75 } |
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
76 |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
77 public boolean hasRewrite(ProcessorContext context) { |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
78 if (!getExceptions().isEmpty()) { |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
79 return true; |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
80 } |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
81 if (!getGuards().isEmpty()) { |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
82 return true; |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
83 } |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
84 if (!getAssumptions().isEmpty()) { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
85 return true; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
86 } |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
87 for (ActualParameter parameter : getParameters()) { |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
88 NodeChildData child = getNode().findChild(parameter.getSpecification().getName()); |
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
89 if (child == null) { |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
90 continue; |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
91 } |
9287
8e3a1635cc9e
Implemented @NodeChild(executeWith={...}).
Christian Humer <christian.humer@gmail.com>
parents:
9279
diff
changeset
|
92 ExecutableTypeData type = child.findExecutableType(context, parameter.getTypeSystemType()); |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
93 if (type.hasUnexpectedValue(context)) { |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
94 return true; |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
95 } |
9305
e6251a86e8e3
Fixed some minor bugs in executeWith supprt.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
96 if (type.getReturnType().getTypeSystemType().needsCastTo(context, parameter.getTypeSystemType())) { |
e6251a86e8e3
Fixed some minor bugs in executeWith supprt.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
97 return true; |
e6251a86e8e3
Fixed some minor bugs in executeWith supprt.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
98 } |
e6251a86e8e3
Fixed some minor bugs in executeWith supprt.
Christian Humer <christian.humer@gmail.com>
parents:
9287
diff
changeset
|
99 |
8251
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
100 } |
cb70ed101b5f
Added automatic generation of generic specialization which throws unsupported operation if reached.
Christian Humer <christian.humer@gmail.com>
parents:
8243
diff
changeset
|
101 return false; |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
102 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
103 |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
104 @Override |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
105 public int compareBySignature(TemplateMethod other) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
106 if (this == other) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
107 return 0; |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
108 } else if (!(other instanceof SpecializationData)) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
109 return super.compareBySignature(other); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
110 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
111 |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
112 SpecializationData m2 = (SpecializationData) other; |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
113 |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
114 if (getOrder() != Specialization.DEFAULT_ORDER && m2.getOrder() != Specialization.DEFAULT_ORDER) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
115 return getOrder() - m2.getOrder(); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
116 } else if (isUninitialized() ^ m2.isUninitialized()) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
117 return isUninitialized() ? -1 : 1; |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
118 } else if (isGeneric() ^ m2.isGeneric()) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
119 return isGeneric() ? 1 : -1; |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
120 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
121 |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
122 if (getTemplate() != m2.getTemplate()) { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
123 throw new UnsupportedOperationException("Cannot compare two specializations with different templates."); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
124 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
125 |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
126 return super.compareBySignature(m2); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
127 } |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
128 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
129 public NodeData getNode() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
130 return node; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
131 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
132 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
133 public void setNode(NodeData node) { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
134 this.node = node; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
135 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
136 |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
137 public void setGuards(List<GuardData> guards) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
138 this.guards = guards; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
139 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
140 |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
141 public void setGuardDefinitions(List<String> guardDefinitions) { |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
142 this.guardDefinitions = guardDefinitions; |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
143 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
144 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
145 public int getOrder() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
146 return order; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
147 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
148 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
149 public boolean isGeneric() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
150 return generic; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
151 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
152 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
153 public boolean isUninitialized() { |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
154 return uninitialized; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
155 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
156 |
8243
d81ff782fa1a
Removed @SpecializationThrows from codegen API. Replaced it by a simplier version in @Specialization.
Christian Humer <christian.humer@gmail.com>
parents:
8242
diff
changeset
|
157 public List<SpecializationThrowsData> getExceptions() { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
158 return exceptions; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
159 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
160 |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
161 public List<String> getGuardDefinitions() { |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
162 return guardDefinitions; |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
163 } |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
164 |
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
165 public List<GuardData> getGuards() { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
166 return guards; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
167 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
168 |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
169 public void setShortCircuits(List<ShortCircuitData> shortCircuits) { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
170 this.shortCircuits = shortCircuits; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
171 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
172 |
8252
0905d796944a
Refactored codegen error model to make error redirection a lot easier.
Christian Humer <christian.humer@gmail.com>
parents:
8251
diff
changeset
|
173 public List<ShortCircuitData> getShortCircuits() { |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
174 return shortCircuits; |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
175 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
176 |
7751
ef1b41ea0a90
Implemented an option to turn off generated generic generation using specializations in @Generic.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
177 void setUseSpecializationsForGeneric(boolean useSpecializationsForGeneric) { |
ef1b41ea0a90
Implemented an option to turn off generated generic generation using specializations in @Generic.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
178 this.useSpecializationsForGeneric = useSpecializationsForGeneric; |
ef1b41ea0a90
Implemented an option to turn off generated generic generation using specializations in @Generic.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
179 } |
ef1b41ea0a90
Implemented an option to turn off generated generic generation using specializations in @Generic.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
180 |
ef1b41ea0a90
Implemented an option to turn off generated generic generation using specializations in @Generic.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
181 public boolean isUseSpecializationsForGeneric() { |
ef1b41ea0a90
Implemented an option to turn off generated generic generation using specializations in @Generic.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
182 return useSpecializationsForGeneric; |
ef1b41ea0a90
Implemented an option to turn off generated generic generation using specializations in @Generic.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
183 } |
ef1b41ea0a90
Implemented an option to turn off generated generic generation using specializations in @Generic.
Christian Humer <christian.humer@gmail.com>
parents:
7502
diff
changeset
|
184 |
9279
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
185 public List<String> getAssumptions() { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
186 return assumptions; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
187 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
188 |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
189 void setAssumptions(List<String> assumptions) { |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
190 this.assumptions = assumptions; |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
191 } |
2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
Christian Humer <christian.humer@gmail.com>
parents:
9220
diff
changeset
|
192 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
193 public SpecializationData findNextSpecialization() { |
8242
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
7847
diff
changeset
|
194 List<SpecializationData> specializations = node.getSpecializations(); |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
7847
diff
changeset
|
195 for (int i = 0; i < specializations.size() - 1; i++) { |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
7847
diff
changeset
|
196 if (specializations.get(i) == this) { |
ac4e8c16ffdf
Added new codegen api classes NodeId, NodeClass to codegen along with some refactorings.
Christian Humer <christian.humer@gmail.com>
parents:
7847
diff
changeset
|
197 return specializations.get(i + 1); |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
198 } |
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 null; |
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 |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
203 public boolean hasDynamicGuards() { |
8592
a80bf36c6a1e
Refactor to shared template method signature comparison.
Christian Humer <christian.humer@gmail.com>
parents:
8310
diff
changeset
|
204 return !getGuards().isEmpty(); |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
205 } |
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
206 |
8595
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
207 @Override |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
208 public String toString() { |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
209 return String.format("%s [id = %s, method = %s, guards = %s]", getClass().getSimpleName(), getId(), getMethod(), getGuards()); |
8a1115c92271
Implemented codegen guard definitions can now omit unused parameters.
Christian Humer <christian.humer@gmail.com>
parents:
8592
diff
changeset
|
210 } |
8662
5eeade940236
Fixed user generic signature must not match generated generic signature.
Christian Humer <christian.humer@gmail.com>
parents:
8595
diff
changeset
|
211 |
7502
6343a09b2ec1
Codegen operation generation is inferred from the node type hierarchy.
Christian Humer <christian.humer@gmail.com>
parents:
diff
changeset
|
212 } |