Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/parser/SpecializationGroup.java @ 19282:ae81dd154fb6
Truffle-DSL: remove old DSL layout; Make new layout the default.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 22 Jan 2015 20:44:24 +0100 |
parents | a665483c3881 |
children | 08aa0372dad4 |
comparison
equal
deleted
inserted
replaced
19281:92880b0f7fed | 19282:ae81dd154fb6 |
---|---|
24 | 24 |
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.*; | |
30 import com.oracle.truffle.dsl.processor.java.*; | 29 import com.oracle.truffle.dsl.processor.java.*; |
31 import com.oracle.truffle.dsl.processor.model.*; | 30 import com.oracle.truffle.dsl.processor.model.*; |
32 import com.oracle.truffle.dsl.processor.model.TemplateMethod.TypeSignature; | 31 import com.oracle.truffle.dsl.processor.model.TemplateMethod.TypeSignature; |
33 | 32 |
34 /** | 33 /** |
77 collectedGuards.addAll(typeGuards); | 76 collectedGuards.addAll(typeGuards); |
78 if (parent != null) { | 77 if (parent != null) { |
79 collectedGuards.addAll(parent.getAllGuards()); | 78 collectedGuards.addAll(parent.getAllGuards()); |
80 } | 79 } |
81 return collectedGuards; | 80 return collectedGuards; |
82 } | |
83 | |
84 public TypeGuard findTypeGuard(int signatureIndex) { | |
85 for (TypeGuard guard : typeGuards) { | |
86 if (guard.getSignatureIndex() == signatureIndex) { | |
87 return guard; | |
88 } | |
89 } | |
90 return null; | |
91 } | 81 } |
92 | 82 |
93 public List<GuardExpression> findElseConnectableGuards() { | 83 public List<GuardExpression> findElseConnectableGuards() { |
94 if (!getTypeGuards().isEmpty() || !getAssumptions().isEmpty()) { | 84 if (!getTypeGuards().isEmpty() || !getAssumptions().isEmpty()) { |
95 return Collections.emptyList(); | 85 return Collections.emptyList(); |
421 public TypeData getType() { | 411 public TypeData getType() { |
422 return type; | 412 return type; |
423 } | 413 } |
424 } | 414 } |
425 | 415 |
426 public boolean isTypeGuardUsedInAnyGuardBelow(ProcessorContext context, SpecializationData source, TypeGuard typeGuard) { | |
427 NodeExecutionData execution = source.getNode().getChildExecutions().get(typeGuard.getSignatureIndex()); | |
428 | |
429 for (GuardExpression guard : guards) { | |
430 List<Parameter> guardParameters = guard.getResolvedGuard().findByExecutionData(execution); | |
431 Parameter sourceParameter = source.getSignatureParameter(typeGuard.getSignatureIndex()); | |
432 for (Parameter guardParameter : guardParameters) { | |
433 if (sourceParameter.getTypeSystemType().needsCastTo(guardParameter.getType())) { | |
434 return true; | |
435 } | |
436 } | |
437 } | |
438 | |
439 for (SpecializationGroup group : getChildren()) { | |
440 if (group.isTypeGuardUsedInAnyGuardBelow(context, source, typeGuard)) { | |
441 return true; | |
442 } | |
443 } | |
444 | |
445 return false; | |
446 } | |
447 | |
448 } | 416 } |