comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeData.java @ 13527:25ecb47a6d0e

Truffle-DSL: Added support for references to child arrays in @ShortCircuit; Introduced new layer NodeExecutionData to the implementation model which is in between NodeChildData and the actual parameters..
author Christian Humer <christian.humer@gmail.com>
date Tue, 07 Jan 2014 12:22:47 +0100
parents 2b9fcffd6f36
children 5a0c694ef735
comparison
equal deleted inserted replaced
13483:37ec2cabf397 13527:25ecb47a6d0e
26 26
27 import javax.lang.model.element.*; 27 import javax.lang.model.element.*;
28 import javax.lang.model.type.*; 28 import javax.lang.model.type.*;
29 29
30 import com.oracle.truffle.dsl.processor.*; 30 import com.oracle.truffle.dsl.processor.*;
31 import com.oracle.truffle.dsl.processor.node.NodeChildData.*;
32 import com.oracle.truffle.dsl.processor.template.*; 31 import com.oracle.truffle.dsl.processor.template.*;
33 import com.oracle.truffle.dsl.processor.typesystem.*; 32 import com.oracle.truffle.dsl.processor.typesystem.*;
34 33
35 public class NodeData extends Template implements Comparable<NodeData> { 34 public class NodeData extends Template implements Comparable<NodeData> {
36 35
39 private List<NodeData> declaredNodes = new ArrayList<>(); 38 private List<NodeData> declaredNodes = new ArrayList<>();
40 private boolean nodeContainer; 39 private boolean nodeContainer;
41 40
42 private TypeSystemData typeSystem; 41 private TypeSystemData typeSystem;
43 private List<NodeChildData> children; 42 private List<NodeChildData> children;
43 private List<NodeExecutionData> childExecutions;
44 private List<NodeFieldData> fields; 44 private List<NodeFieldData> fields;
45 private TypeMirror nodeType; 45 private TypeMirror nodeType;
46 private ParameterSpec instanceParameterSpec; 46 private ParameterSpec instanceParameterSpec;
47 47
48 private List<SpecializationData> specializations; 48 private List<SpecializationData> specializations;
76 this.fields = splitSource.fields; 76 this.fields = splitSource.fields;
77 this.children = splitSource.children; 77 this.children = splitSource.children;
78 this.assumptions = splitSource.assumptions; 78 this.assumptions = splitSource.assumptions;
79 } 79 }
80 80
81 public List<NodeExecutionData> getChildExecutions() {
82 return childExecutions;
83 }
84
85 void setChildExecutions(List<NodeExecutionData> signature) {
86 this.childExecutions = signature;
87 }
88
81 public int getSignatureSize() { 89 public int getSignatureSize() {
82 if (getSpecializations() != null && !getSpecializations().isEmpty()) { 90 if (getSpecializations() != null && !getSpecializations().isEmpty()) {
83 return getSpecializations().get(0).getSignatureSize(); 91 return getSpecializations().get(0).getSignatureSize();
84 } 92 }
85 return 0; 93 return 0;
370 } 378 }
371 result = specialization; 379 result = specialization;
372 } 380 }
373 } 381 }
374 return result; 382 return result;
375 }
376
377 public NodeChildData[] filterFields(ExecutionKind usage) {
378 List<NodeChildData> filteredFields = new ArrayList<>();
379 for (NodeChildData field : getChildren()) {
380 if (usage == null || field.getExecutionKind() == usage) {
381 filteredFields.add(field);
382 }
383 }
384 return filteredFields.toArray(new NodeChildData[filteredFields.size()]);
385 } 383 }
386 384
387 public boolean needsRewrites(ProcessorContext context) { 385 public boolean needsRewrites(ProcessorContext context) {
388 boolean needsRewrites = false; 386 boolean needsRewrites = false;
389 387
488 } 486 }
489 b.append("\n ").append(indent).append("]"); 487 b.append("\n ").append(indent).append("]");
490 return b.toString(); 488 return b.toString();
491 } 489 }
492 490
491 public NodeExecutionData findExecution(String name) {
492 if (getChildExecutions() == null) {
493 return null;
494 }
495 for (NodeExecutionData execution : getChildExecutions()) {
496 if (execution.getName().equals(name)) {
497 return execution;
498 }
499 }
500 return null;
501 }
502
493 public NodeChildData findChild(String name) { 503 public NodeChildData findChild(String name) {
494 for (NodeChildData field : getChildren()) { 504 for (NodeChildData field : getChildren()) {
495 if (field.getName().equals(name)) { 505 if (field.getName().equals(name)) {
496 return field; 506 return field;
497 } 507 }
591 } 601 }
592 602
593 public int compareTo(NodeData o) { 603 public int compareTo(NodeData o) {
594 return getNodeId().compareTo(o.getNodeId()); 604 return getNodeId().compareTo(o.getNodeId());
595 } 605 }
606
596 } 607 }