comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeExecutionData.java @ 20938:18c0f02fa4d2

Truffle-DSL: make type systems optional.
author Christian Humer <christian.humer@gmail.com>
date Tue, 14 Apr 2015 15:12:48 +0200
parents 906367e494ca
children
comparison
equal deleted inserted replaced
20937:37ea76052733 20938:18c0f02fa4d2
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.dsl.processor.model; 23 package com.oracle.truffle.dsl.processor.model;
24 24
25 import java.util.*;
26
25 import javax.lang.model.type.*; 27 import javax.lang.model.type.*;
26 28
27 import com.oracle.truffle.dsl.processor.model.NodeChildData.Cardinality; 29 import com.oracle.truffle.dsl.processor.model.NodeChildData.Cardinality;
28 30
29 public class NodeExecutionData { 31 public class NodeExecutionData {
30 32
31 private final NodeChildData child; 33 private final NodeChildData child;
32 private final String name; 34 private final String name;
33 private final int index; 35 private final int index;
36 private final int childIndex;
34 private final boolean shortCircuit; 37 private final boolean shortCircuit;
38 private final List<TypeMirror> typeRestrictions = new ArrayList<>();
35 39
36 public NodeExecutionData(NodeChildData child, int index, boolean shortCircuit) { 40 public NodeExecutionData(NodeChildData child, int index, int childIndex, boolean shortCircuit) {
37 this.child = child; 41 this.child = child;
38 this.index = index; 42 this.index = index;
43 this.childIndex = childIndex;
39 this.shortCircuit = shortCircuit; 44 this.shortCircuit = shortCircuit;
40 this.name = createName(); 45 this.name = createName();
41 } 46 }
42 47
43 private String createName() { 48 private String createName() {
44 return createName(child.getName(), index); 49 return child != null ? createName(child.getName(), childIndex) : ("arg" + index);
50 }
51
52 public int getIndex() {
53 return index;
54 }
55
56 public List<TypeMirror> getTypeRestrictions() {
57 return typeRestrictions;
45 } 58 }
46 59
47 public TypeMirror getNodeType() { 60 public TypeMirror getNodeType() {
48 TypeMirror type; 61 TypeMirror type;
49 if (child.getCardinality() == Cardinality.MANY && child.getNodeType().getKind() == TypeKind.ARRAY) { 62 if (child.getCardinality() == Cardinality.MANY && child.getNodeType().getKind() == TypeKind.ARRAY) {
60 73
61 public NodeChildData getChild() { 74 public NodeChildData getChild() {
62 return child; 75 return child;
63 } 76 }
64 77
65 public int getIndex() { 78 public int getChildIndex() {
66 return index; 79 return childIndex;
67 } 80 }
68 81
69 public boolean isIndexed() { 82 public boolean isIndexed() {
70 return index > -1; 83 return childIndex > -1;
71 } 84 }
72 85
73 public boolean isShortCircuit() { 86 public boolean isShortCircuit() {
74 return shortCircuit; 87 return shortCircuit;
75 } 88 }
76 89
77 public String getIndexedName() { 90 public String getIndexedName() {
78 return createIndexedName(child, index); 91 return createIndexedName(child, childIndex);
79 } 92 }
80 93
81 public static String createIndexedName(NodeChildData child, int varArgsIndex) { 94 public static String createIndexedName(NodeChildData child, int varArgsIndex) {
82 String shortCircuitName = child.getName(); 95 String shortCircuitName = child.getName();
83 if (child.getCardinality().isMany()) { 96 if (child.getCardinality().isMany()) {