comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeData.java @ 18776:c0fb70634640

Truffle-DSL: support for frame types Frame, MaterializedFrame. Added validation for frame type consistency. Some refactorings along the way.
author Christian Humer <christian.humer@gmail.com>
date Mon, 05 Jan 2015 01:31:08 +0100
parents a665483c3881
children 941761f6b736
comparison
equal deleted inserted replaced
18775:a069a87b9a02 18776:c0fb70634640
52 private Map<Integer, List<ExecutableTypeData>> executableTypes; 52 private Map<Integer, List<ExecutableTypeData>> executableTypes;
53 53
54 private final NodeExecutionData thisExecution; 54 private final NodeExecutionData thisExecution;
55 private final boolean generateFactory; 55 private final boolean generateFactory;
56 56
57 public NodeData(ProcessorContext context, TypeElement type, String shortName, TypeSystemData typeSystem, List<NodeChildData> children, List<NodeExecutionData> executions, 57 private TypeMirror frameType;
58 List<NodeFieldData> fields, List<String> assumptions, boolean generateFactory) { 58
59 public NodeData(ProcessorContext context, TypeElement type, String shortName, TypeSystemData typeSystem, boolean generateFactory) {
59 super(context, type, null); 60 super(context, type, null);
60 this.nodeId = type.getSimpleName().toString(); 61 this.nodeId = ElementUtils.getSimpleName(type);
61 this.shortName = shortName; 62 this.shortName = shortName;
62 this.typeSystem = typeSystem; 63 this.typeSystem = typeSystem;
63 this.fields = fields; 64 this.fields = new ArrayList<>();
64 this.children = children; 65 this.children = new ArrayList<>();
65 this.childExecutions = executions; 66 this.childExecutions = new ArrayList<>();
66 this.assumptions = assumptions; 67 this.assumptions = new ArrayList<>();
67 this.thisExecution = new NodeExecutionData(new NodeChildData(null, null, "this", getNodeType(), getNodeType(), null, Cardinality.ONE), -1, false); 68 this.thisExecution = new NodeExecutionData(new NodeChildData(null, null, "this", getNodeType(), getNodeType(), null, Cardinality.ONE), -1, false);
68 this.thisExecution.getChild().setNode(this); 69 this.thisExecution.getChild().setNode(this);
69 this.generateFactory = generateFactory; 70 this.generateFactory = generateFactory;
70 } 71 }
71 72
72 public NodeData(ProcessorContext context, TypeElement type) { 73 public NodeData(ProcessorContext context, TypeElement type) {
73 this(context, type, null, null, null, null, null, null, false); 74 this(context, type, null, null, false);
74 } 75 }
75 76
76 public boolean isGenerateFactory() { 77 public boolean isGenerateFactory() {
77 return generateFactory; 78 return generateFactory;
78 } 79 }
85 SpecializationData generic = getGenericSpecialization(); 86 SpecializationData generic = getGenericSpecialization();
86 if (generic != null) { 87 if (generic != null) {
87 return generic.isReachable(); 88 return generic.isReachable();
88 } 89 }
89 return false; 90 return false;
91 }
92
93 public void setFrameType(TypeMirror frameType) {
94 this.frameType = frameType;
95 }
96
97 public TypeMirror getFrameType() {
98 return frameType;
90 } 99 }
91 100
92 public void addEnclosedNode(NodeData node) { 101 public void addEnclosedNode(NodeData node) {
93 this.enclosingNodes.add(node); 102 this.enclosingNodes.add(node);
94 node.declaringNode = this; 103 node.declaringNode = this;
132 return getSpecializations().get(0).getSignatureSize(); 141 return getSpecializations().get(0).getSignatureSize();
133 } 142 }
134 return 0; 143 return 0;
135 } 144 }
136 145
137 public boolean isFrameUsedByAnyGuard(ProcessorContext context) { 146 public boolean isFrameUsedByAnyGuard() {
138 for (SpecializationData specialization : specializations) { 147 for (SpecializationData specialization : specializations) {
139 if (!specialization.isReachable()) { 148 if (!specialization.isReachable()) {
140 continue; 149 continue;
141 } 150 }
142 if (specialization.isFrameUsedByGuard(context)) { 151 if (specialization.isFrameUsedByGuard()) {
143 return true; 152 return true;
144 } 153 }
145 } 154 }
146 return false; 155 return false;
147 } 156 }