Mercurial > hg > truffle
comparison 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 |
comparison
equal
deleted
inserted
replaced
11544:e5b5a5cb0ac7 | 11545:2fb276f5e3e9 |
---|---|
47 | 47 |
48 public enum ExecutionKind { | 48 public enum ExecutionKind { |
49 DEFAULT, SHORT_CIRCUIT | 49 DEFAULT, SHORT_CIRCUIT |
50 } | 50 } |
51 | 51 |
52 private final NodeData parent; | |
52 private final Element sourceElement; | 53 private final Element sourceElement; |
53 private final AnnotationMirror sourceAnnotationMirror; | 54 private final AnnotationMirror sourceAnnotationMirror; |
54 | 55 |
55 private final String name; | 56 private final String name; |
56 private final TypeMirror type; | 57 private final TypeMirror type; |
62 | 63 |
63 private List<NodeChildData> executeWith = Collections.emptyList(); | 64 private List<NodeChildData> executeWith = Collections.emptyList(); |
64 | 65 |
65 private NodeData nodeData; | 66 private NodeData nodeData; |
66 | 67 |
67 public NodeChildData(Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, TypeMirror originalNodeType, Element accessElement, Cardinality cardinality, | 68 public NodeChildData(NodeData parent, Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, TypeMirror originalNodeType, Element accessElement, |
68 ExecutionKind executionKind) { | 69 Cardinality cardinality, ExecutionKind executionKind) { |
70 this.parent = parent; | |
69 this.sourceElement = sourceElement; | 71 this.sourceElement = sourceElement; |
70 this.sourceAnnotationMirror = sourceMirror; | 72 this.sourceAnnotationMirror = sourceMirror; |
71 this.name = name; | 73 this.name = name; |
72 this.type = nodeType; | 74 this.type = nodeType; |
73 this.originalType = originalNodeType; | 75 this.originalType = originalNodeType; |
80 return executeWith; | 82 return executeWith; |
81 } | 83 } |
82 | 84 |
83 void setExecuteWith(List<NodeChildData> executeWith) { | 85 void setExecuteWith(List<NodeChildData> executeWith) { |
84 this.executeWith = executeWith; | 86 this.executeWith = executeWith; |
87 } | |
88 | |
89 public boolean needsImplicitCast(ProcessorContext context) { | |
90 if (!parent.needsRewrites(context)) { | |
91 return false; | |
92 } | |
93 | |
94 boolean used = false; | |
95 SpecializationData generic = parent.getGenericSpecialization(); | |
96 for (ActualParameter param : generic.getParameters()) { | |
97 if (!param.getSpecification().isSignature()) { | |
98 continue; | |
99 } | |
100 NodeChildData child = parent.findChild(param.getSpecification().getName()); | |
101 if (child == this) { | |
102 used = true; | |
103 break; | |
104 } | |
105 } | |
106 | |
107 if (!used) { | |
108 return false; | |
109 } | |
110 | |
111 return getNodeData().getTypeSystem().getImplicitCasts() != null && !getNodeData().getTypeSystem().getImplicitCasts().isEmpty(); | |
85 } | 112 } |
86 | 113 |
87 public ExecutableTypeData findExecutableType(ProcessorContext context, TypeData targetType) { | 114 public ExecutableTypeData findExecutableType(ProcessorContext context, TypeData targetType) { |
88 ExecutableTypeData executableType = nodeData.findExecutableType(targetType, getExecuteWith().size()); | 115 ExecutableTypeData executableType = nodeData.findExecutableType(targetType, getExecuteWith().size()); |
89 if (executableType == null) { | 116 if (executableType == null) { |