comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeChildData.java @ 9287:8e3a1635cc9e

Implemented @NodeChild(executeWith={...}).
author Christian Humer <christian.humer@gmail.com>
date Wed, 24 Apr 2013 21:50:03 +0200
parents 6d92fdf1c999
children 746fa60be266
comparison
equal deleted inserted replaced
9286:39f08ef7b5d8 9287:8e3a1635cc9e
20 * or visit www.oracle.com if you need additional information or have any 20 * or visit www.oracle.com if you need additional information or have any
21 * questions. 21 * questions.
22 */ 22 */
23 package com.oracle.truffle.codegen.processor.node; 23 package com.oracle.truffle.codegen.processor.node;
24 24
25 import java.util.*;
26
25 import javax.lang.model.element.*; 27 import javax.lang.model.element.*;
26 import javax.lang.model.type.*; 28 import javax.lang.model.type.*;
27 29
30 import com.oracle.truffle.codegen.processor.*;
28 import com.oracle.truffle.codegen.processor.template.*; 31 import com.oracle.truffle.codegen.processor.template.*;
32 import com.oracle.truffle.codegen.processor.typesystem.*;
29 33
30 public class NodeChildData extends MessageContainer { 34 public class NodeChildData extends MessageContainer {
31 35
32 public enum Cardinality { 36 public enum Cardinality {
33 ONE, MANY; 37 ONE, MANY;
52 private final TypeMirror type; 56 private final TypeMirror type;
53 private final Element accessElement; 57 private final Element accessElement;
54 58
55 private final Cardinality cardinality; 59 private final Cardinality cardinality;
56 private final ExecutionKind executionKind; 60 private final ExecutionKind executionKind;
61
62 private List<NodeChildData> executeWith = Collections.emptyList();
63
57 private NodeData nodeData; 64 private NodeData nodeData;
58 65
59 public NodeChildData(Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, Element accessElement, Cardinality cardinality, ExecutionKind executionKind) { 66 public NodeChildData(Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, Element accessElement, Cardinality cardinality, ExecutionKind executionKind) {
60 this.sourceElement = sourceElement; 67 this.sourceElement = sourceElement;
61 this.sourceAnnotationMirror = sourceMirror; 68 this.sourceAnnotationMirror = sourceMirror;
62 this.name = name; 69 this.name = name;
63 this.type = nodeType; 70 this.type = nodeType;
64 this.accessElement = accessElement; 71 this.accessElement = accessElement;
65 this.cardinality = cardinality; 72 this.cardinality = cardinality;
66 this.executionKind = executionKind; 73 this.executionKind = executionKind;
74 }
75
76 public List<NodeChildData> getExecuteWith() {
77 return executeWith;
78 }
79
80 void setExecuteWith(List<NodeChildData> executeWith) {
81 this.executeWith = executeWith;
82 }
83
84 public ExecutableTypeData findExecutableType(ProcessorContext context, TypeData targetType) {
85 ExecutableTypeData executableType = nodeData.findExecutableType(targetType, getExecuteWith().size());
86 if (executableType == null) {
87 executableType = findAnyGenericExecutableType(context);
88 }
89 return executableType;
90 }
91
92 public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) {
93 return nodeData.findGenericExecutableTypes(context, getExecuteWith().size());
94 }
95
96 public ExecutableTypeData findAnyGenericExecutableType(ProcessorContext context) {
97 return nodeData.findAnyGenericExecutableType(context, getExecuteWith().size());
98 }
99
100 public List<ExecutableTypeData> findExecutableTypes() {
101 return nodeData.getExecutableTypes(getExecuteWith().size());
67 } 102 }
68 103
69 @Override 104 @Override
70 public Element getMessageElement() { 105 public Element getMessageElement() {
71 return sourceElement; 106 return sourceElement;