Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeData.java @ 9279:2a4b57f02fb4
Implemented basic support for assumptions for sourcecode generation.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Wed, 24 Apr 2013 17:44:15 +0200 |
parents | 6d92fdf1c999 |
children | 8e3a1635cc9e |
comparison
equal
deleted
inserted
replaced
9276:a9cfbe03d9c4 | 9279:2a4b57f02fb4 |
---|---|
47 | 47 |
48 private List<SpecializationData> specializations; | 48 private List<SpecializationData> specializations; |
49 private List<SpecializationListenerData> specializationListeners; | 49 private List<SpecializationListenerData> specializationListeners; |
50 private Map<Integer, List<ExecutableTypeData>> executableTypes; | 50 private Map<Integer, List<ExecutableTypeData>> executableTypes; |
51 private List<ShortCircuitData> shortCircuits; | 51 private List<ShortCircuitData> shortCircuits; |
52 private List<String> assumptions; | |
52 | 53 |
53 public NodeData(TypeElement type, String id) { | 54 public NodeData(TypeElement type, String id) { |
54 super(type, null, null); | 55 super(type, null, null); |
55 this.nodeId = id; | 56 this.nodeId = id; |
56 } | 57 } |
66 this.specializationListeners = splitSource.specializationListeners; | 67 this.specializationListeners = splitSource.specializationListeners; |
67 this.executableTypes = splitSource.executableTypes; | 68 this.executableTypes = splitSource.executableTypes; |
68 this.shortCircuits = splitSource.shortCircuits; | 69 this.shortCircuits = splitSource.shortCircuits; |
69 this.fields = splitSource.fields; | 70 this.fields = splitSource.fields; |
70 this.children = splitSource.children; | 71 this.children = splitSource.children; |
72 this.assumptions = splitSource.assumptions; | |
71 } | 73 } |
72 | 74 |
73 public boolean isSplitByMethodName() { | 75 public boolean isSplitByMethodName() { |
74 return splitByMethodName; | 76 return splitByMethodName; |
75 } | 77 } |
139 public TypeMirror getNodeType() { | 141 public TypeMirror getNodeType() { |
140 if (nodeType != null) { | 142 if (nodeType != null) { |
141 return nodeType; | 143 return nodeType; |
142 } | 144 } |
143 return getTemplateType().asType(); | 145 return getTemplateType().asType(); |
146 } | |
147 | |
148 void setAssumptions(List<String> assumptions) { | |
149 this.assumptions = assumptions; | |
150 } | |
151 | |
152 public List<String> getAssumptions() { | |
153 return assumptions; | |
144 } | 154 } |
145 | 155 |
146 public boolean needsFactory() { | 156 public boolean needsFactory() { |
147 if (specializations == null) { | 157 if (specializations == null) { |
148 return false; | 158 return false; |
239 } | 249 } |
240 return null; | 250 return null; |
241 } | 251 } |
242 | 252 |
243 public List<ExecutableTypeData> getExecutableTypes(int evaluatedCount) { | 253 public List<ExecutableTypeData> getExecutableTypes(int evaluatedCount) { |
254 if (executableTypes == null) { | |
255 return Collections.emptyList(); | |
256 } | |
244 if (evaluatedCount == -1) { | 257 if (evaluatedCount == -1) { |
245 List<ExecutableTypeData> typeData = new ArrayList<>(); | 258 List<ExecutableTypeData> typeData = new ArrayList<>(); |
246 for (int currentEvaluationCount : executableTypes.keySet()) { | 259 for (int currentEvaluationCount : executableTypes.keySet()) { |
247 typeData.addAll(executableTypes.get(currentEvaluationCount)); | 260 typeData.addAll(executableTypes.get(currentEvaluationCount)); |
248 } | 261 } |
302 if (specialization.hasRewrite(context)) { | 315 if (specialization.hasRewrite(context)) { |
303 needsRewrites = true; | 316 needsRewrites = true; |
304 break; | 317 break; |
305 } | 318 } |
306 } | 319 } |
307 return needsRewrites; | 320 return needsRewrites || getSpecializations().size() > 1; |
308 } | 321 } |
309 | 322 |
310 public SpecializationData getGenericSpecialization() { | 323 public SpecializationData getGenericSpecialization() { |
311 for (SpecializationData specialization : specializations) { | 324 for (SpecializationData specialization : specializations) { |
312 if (specialization.isGeneric()) { | 325 if (specialization.isGeneric()) { |
337 dumpProperty(builder, indent, "templateClass", Utils.getQualifiedName(getTemplateType())); | 350 dumpProperty(builder, indent, "templateClass", Utils.getQualifiedName(getTemplateType())); |
338 dumpProperty(builder, indent, "typeSystem", getTypeSystem()); | 351 dumpProperty(builder, indent, "typeSystem", getTypeSystem()); |
339 dumpProperty(builder, indent, "fields", getChildren()); | 352 dumpProperty(builder, indent, "fields", getChildren()); |
340 dumpProperty(builder, indent, "executableTypes", getExecutableTypes()); | 353 dumpProperty(builder, indent, "executableTypes", getExecutableTypes()); |
341 dumpProperty(builder, indent, "specializations", getSpecializations()); | 354 dumpProperty(builder, indent, "specializations", getSpecializations()); |
355 dumpProperty(builder, indent, "assumptions", getAssumptions()); | |
342 dumpProperty(builder, indent, "messages", collectMessages()); | 356 dumpProperty(builder, indent, "messages", collectMessages()); |
343 if (getDeclaredNodes().size() > 0) { | 357 if (getDeclaredNodes().size() > 0) { |
344 builder.append(String.format("\n%s children = [", indent)); | 358 builder.append(String.format("\n%s children = [", indent)); |
345 for (NodeData node : getDeclaredNodes()) { | 359 for (NodeData node : getDeclaredNodes()) { |
346 builder.append("\n"); | 360 builder.append("\n"); |