Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/template/MethodSpec.java @ 13527:25ecb47a6d0e
Truffle-DSL: Added support for references to child arrays in @ShortCircuit;
Introduced new layer NodeExecutionData to the implementation model which is in between NodeChildData and the actual parameters..
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Tue, 07 Jan 2014 12:22:47 +0100 |
parents | 2b9fcffd6f36 |
children | e8ef44830b50 |
comparison
equal
deleted
inserted
replaced
13483:37ec2cabf397 | 13527:25ecb47a6d0e |
---|---|
25 import java.util.*; | 25 import java.util.*; |
26 | 26 |
27 import javax.lang.model.type.*; | 27 import javax.lang.model.type.*; |
28 | 28 |
29 import com.oracle.truffle.dsl.processor.*; | 29 import com.oracle.truffle.dsl.processor.*; |
30 import com.oracle.truffle.dsl.processor.node.NodeChildData.*; | |
31 | 30 |
32 public class MethodSpec { | 31 public class MethodSpec { |
33 | 32 |
34 private final List<TypeMirror> implicitRequiredTypes = new ArrayList<>(); | 33 private final List<TypeMirror> implicitRequiredTypes = new ArrayList<>(); |
35 | 34 |
36 private final ParameterSpec returnType; | 35 private final ParameterSpec returnType; |
37 private final List<ParameterSpec> optional = new ArrayList<>(); | 36 private final List<ParameterSpec> optional = new ArrayList<>(); |
38 private final List<ParameterSpec> required = new ArrayList<>(); | 37 private final List<ParameterSpec> required = new ArrayList<>(); |
39 | 38 |
40 private int minimumRequiredArguments; | 39 private boolean ignoreAdditionalParameters; |
41 private boolean variableRequiredArguments; | 40 private boolean ignoreAdditionalSpecifications; |
41 private boolean variableRequiredParameters; | |
42 | |
42 private List<TypeDef> typeDefinitions; | 43 private List<TypeDef> typeDefinitions; |
43 | 44 |
44 public MethodSpec(ParameterSpec returnType) { | 45 public MethodSpec(ParameterSpec returnType) { |
45 this.returnType = returnType; | 46 this.returnType = returnType; |
46 } | 47 } |
47 | 48 |
48 public void setMinimumRequiredArguments(int minimumRequiredArguments) { | 49 public void setVariableRequiredParameters(boolean variableRequiredParameters) { |
49 this.minimumRequiredArguments = minimumRequiredArguments; | 50 this.variableRequiredParameters = variableRequiredParameters; |
50 } | 51 } |
51 | 52 |
52 public int getMinimumRequiredArguments() { | 53 public boolean isVariableRequiredParameters() { |
53 return minimumRequiredArguments; | 54 return variableRequiredParameters; |
54 } | |
55 | |
56 public void setVariableRequiredArguments(boolean variableArguments) { | |
57 this.variableRequiredArguments = variableArguments; | |
58 } | |
59 | |
60 public boolean isVariableRequiredArguments() { | |
61 return variableRequiredArguments; | |
62 } | 55 } |
63 | 56 |
64 public void addImplicitRequiredType(TypeMirror type) { | 57 public void addImplicitRequiredType(TypeMirror type) { |
65 this.implicitRequiredTypes.add(type); | 58 this.implicitRequiredTypes.add(type); |
59 } | |
60 | |
61 public void setIgnoreAdditionalParameters(boolean ignoreAdditionalParameter) { | |
62 this.ignoreAdditionalParameters = ignoreAdditionalParameter; | |
63 } | |
64 | |
65 public boolean isIgnoreAdditionalParameters() { | |
66 return ignoreAdditionalParameters; | |
66 } | 67 } |
67 | 68 |
68 public void addOptional(ParameterSpec spec) { | 69 public void addOptional(ParameterSpec spec) { |
69 optional.add(spec); | 70 optional.add(spec); |
70 } | 71 } |
156 b.append(createTypeSignature(optionalSpec, false)); | 157 b.append(createTypeSignature(optionalSpec, false)); |
157 b.append("]"); | 158 b.append("]"); |
158 sep = ", "; | 159 sep = ", "; |
159 } | 160 } |
160 | 161 |
161 for (ParameterSpec requiredSpec : getRequired()) { | 162 for (int i = 0; i < getRequired().size(); i++) { |
163 ParameterSpec requiredSpec = getRequired().get(i); | |
162 b.append(sep); | 164 b.append(sep); |
163 if (requiredSpec.getCardinality() == Cardinality.MANY) { | 165 |
164 b.append("{"); | 166 if (isVariableRequiredParameters() && i == getRequired().size() - 1) { |
167 b.append(("{")); | |
165 } | 168 } |
166 b.append(createTypeSignature(requiredSpec, false)); | 169 b.append(createTypeSignature(requiredSpec, false)); |
167 if (requiredSpec.getCardinality() == Cardinality.MANY) { | 170 if (isVariableRequiredParameters() && i == getRequired().size() - 1) { |
168 b.append("}"); | 171 b.append(("}")); |
169 } | 172 } |
173 | |
170 sep = ", "; | 174 sep = ", "; |
171 } | 175 } |
172 | 176 |
173 b.append(")"); | 177 b.append(")"); |
174 | 178 |
232 public String getName() { | 236 public String getName() { |
233 return name; | 237 return name; |
234 } | 238 } |
235 } | 239 } |
236 | 240 |
241 public void setIgnoreAdditionalSpecifications(boolean ignoreAdditoinalSpecifications) { | |
242 this.ignoreAdditionalSpecifications = ignoreAdditoinalSpecifications; | |
243 } | |
244 | |
245 public boolean isIgnoreAdditionalSpecifications() { | |
246 return ignoreAdditionalSpecifications; | |
247 } | |
248 | |
237 } | 249 } |