Mercurial > hg > graal-compiler
diff graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeChildData.java @ 11545:2fb276f5e3e9
Truffle-DSL: implemented implicit casts.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Fri, 06 Sep 2013 16:16:40 +0200 |
parents | 79041ab43660 |
children | 25ecb47a6d0e |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeChildData.java Fri Sep 06 16:11:15 2013 +0200 +++ b/graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeChildData.java Fri Sep 06 16:16:40 2013 +0200 @@ -49,6 +49,7 @@ DEFAULT, SHORT_CIRCUIT } + private final NodeData parent; private final Element sourceElement; private final AnnotationMirror sourceAnnotationMirror; @@ -64,8 +65,9 @@ private NodeData nodeData; - public NodeChildData(Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, TypeMirror originalNodeType, Element accessElement, Cardinality cardinality, - ExecutionKind executionKind) { + public NodeChildData(NodeData parent, Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, TypeMirror originalNodeType, Element accessElement, + Cardinality cardinality, ExecutionKind executionKind) { + this.parent = parent; this.sourceElement = sourceElement; this.sourceAnnotationMirror = sourceMirror; this.name = name; @@ -84,6 +86,31 @@ this.executeWith = executeWith; } + public boolean needsImplicitCast(ProcessorContext context) { + if (!parent.needsRewrites(context)) { + return false; + } + + boolean used = false; + SpecializationData generic = parent.getGenericSpecialization(); + for (ActualParameter param : generic.getParameters()) { + if (!param.getSpecification().isSignature()) { + continue; + } + NodeChildData child = parent.findChild(param.getSpecification().getName()); + if (child == this) { + used = true; + break; + } + } + + if (!used) { + return false; + } + + return getNodeData().getTypeSystem().getImplicitCasts() != null && !getNodeData().getTypeSystem().getImplicitCasts().isEmpty(); + } + public ExecutableTypeData findExecutableType(ProcessorContext context, TypeData targetType) { ExecutableTypeData executableType = nodeData.findExecutableType(targetType, getExecuteWith().size()); if (executableType == null) {