comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeChildData.java @ 13528:5a0c694ef735

Truffle-DSL: Removed API classes NodeId, NodeContainer and SpecializationListener.
author Christian Humer <christian.humer@gmail.com>
date Tue, 07 Jan 2014 18:52:32 +0100
parents 25ecb47a6d0e
children 8db6e76cb658
comparison
equal deleted inserted replaced
13527:25ecb47a6d0e 13528:5a0c694ef735
43 public boolean isOne() { 43 public boolean isOne() {
44 return this == ONE; 44 return this == ONE;
45 } 45 }
46 } 46 }
47 47
48 private final NodeData parent; 48 private NodeData parentNode;
49 private final Element sourceElement; 49 private final Element sourceElement;
50 private final AnnotationMirror sourceAnnotationMirror; 50 private final AnnotationMirror sourceAnnotationMirror;
51
52 private final String name; 51 private final String name;
53 private final TypeMirror type; 52 private final TypeMirror type;
54 private final TypeMirror originalType; 53 private final TypeMirror originalType;
55 private final Element accessElement; 54 private final Element accessElement;
56
57 private final Cardinality cardinality; 55 private final Cardinality cardinality;
58 56
59 private List<NodeChildData> executeWith = Collections.emptyList(); 57 private List<NodeChildData> executeWith = Collections.emptyList();
60 58
61 private NodeData nodeData; 59 private NodeData childNode;
62 60
63 public NodeChildData(NodeData parent, Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, TypeMirror originalNodeType, Element accessElement, 61 public NodeChildData(Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, TypeMirror originalNodeType, Element accessElement, Cardinality cardinality) {
64 Cardinality cardinality) {
65 this.parent = parent;
66 this.sourceElement = sourceElement; 62 this.sourceElement = sourceElement;
67 this.sourceAnnotationMirror = sourceMirror; 63 this.sourceAnnotationMirror = sourceMirror;
68 this.name = name; 64 this.name = name;
69 this.type = nodeType; 65 this.type = nodeType;
70 this.originalType = originalNodeType; 66 this.originalType = originalNodeType;
71 this.accessElement = accessElement; 67 this.accessElement = accessElement;
72 this.cardinality = cardinality; 68 this.cardinality = cardinality;
69 }
70
71 void setParentNode(NodeData parentNode) {
72 this.parentNode = parentNode;
73 } 73 }
74 74
75 public List<NodeChildData> getExecuteWith() { 75 public List<NodeChildData> getExecuteWith() {
76 return executeWith; 76 return executeWith;
77 } 77 }
79 void setExecuteWith(List<NodeChildData> executeWith) { 79 void setExecuteWith(List<NodeChildData> executeWith) {
80 this.executeWith = executeWith; 80 this.executeWith = executeWith;
81 } 81 }
82 82
83 public boolean needsImplicitCast(ProcessorContext context) { 83 public boolean needsImplicitCast(ProcessorContext context) {
84 if (!parent.needsRewrites(context)) { 84 if (!parentNode.needsRewrites(context)) {
85 return false; 85 return false;
86 } 86 }
87 87
88 boolean used = false; 88 boolean used = false;
89 for (NodeExecutionData execution : parent.getChildExecutions()) { 89 for (NodeExecutionData execution : parentNode.getChildExecutions()) {
90 if (execution.getChild() == this) { 90 if (execution.getChild() == this) {
91 used = true; 91 used = true;
92 break; 92 break;
93 } 93 }
94 } 94 }
98 98
99 return getNodeData().getTypeSystem().getImplicitCasts() != null && !getNodeData().getTypeSystem().getImplicitCasts().isEmpty(); 99 return getNodeData().getTypeSystem().getImplicitCasts() != null && !getNodeData().getTypeSystem().getImplicitCasts().isEmpty();
100 } 100 }
101 101
102 public ExecutableTypeData findExecutableType(ProcessorContext context, TypeData targetType) { 102 public ExecutableTypeData findExecutableType(ProcessorContext context, TypeData targetType) {
103 ExecutableTypeData executableType = nodeData.findExecutableType(targetType, getExecuteWith().size()); 103 ExecutableTypeData executableType = childNode.findExecutableType(targetType, getExecuteWith().size());
104 if (executableType == null) { 104 if (executableType == null) {
105 executableType = findAnyGenericExecutableType(context); 105 executableType = findAnyGenericExecutableType(context);
106 } 106 }
107 return executableType; 107 return executableType;
108 } 108 }
109 109
110 public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) { 110 public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) {
111 return nodeData.findGenericExecutableTypes(context, getExecuteWith().size()); 111 return childNode.findGenericExecutableTypes(context, getExecuteWith().size());
112 } 112 }
113 113
114 public ExecutableTypeData findAnyGenericExecutableType(ProcessorContext context) { 114 public ExecutableTypeData findAnyGenericExecutableType(ProcessorContext context) {
115 return nodeData.findAnyGenericExecutableType(context, getExecuteWith().size()); 115 return childNode.findAnyGenericExecutableType(context, getExecuteWith().size());
116 } 116 }
117 117
118 public List<ExecutableTypeData> findExecutableTypes() { 118 public List<ExecutableTypeData> findExecutableTypes() {
119 return nodeData.getExecutableTypes(getExecuteWith().size()); 119 return childNode.getExecutableTypes(getExecuteWith().size());
120 } 120 }
121 121
122 public TypeMirror getOriginalType() { 122 public TypeMirror getOriginalType() {
123 return originalType; 123 return originalType;
124 } 124 }
132 public AnnotationMirror getMessageAnnotation() { 132 public AnnotationMirror getMessageAnnotation() {
133 return sourceAnnotationMirror; 133 return sourceAnnotationMirror;
134 } 134 }
135 135
136 void setNode(NodeData nodeData) { 136 void setNode(NodeData nodeData) {
137 this.nodeData = nodeData; 137 this.childNode = nodeData;
138 if (nodeData != null) { 138 if (nodeData != null) {
139 getMessages().addAll(nodeData.collectMessages()); 139 getMessages().addAll(nodeData.collectMessages());
140 } 140 }
141 } 141 }
142 142
151 public Cardinality getCardinality() { 151 public Cardinality getCardinality() {
152 return cardinality; 152 return cardinality;
153 } 153 }
154 154
155 public NodeData getNodeData() { 155 public NodeData getNodeData() {
156 return nodeData; 156 return childNode;
157 } 157 }
158 158
159 public String getName() { 159 public String getName() {
160 return name; 160 return name;
161 } 161 }