Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeChildData.java @ 16759:23415229349b
Truffle-DSL: new package structure.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 11 Aug 2014 15:57:14 +0200 |
parents | graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/node/NodeChildData.java@8db6e76cb658 |
children | a069a87b9a02 |
comparison
equal
deleted
inserted
replaced
16758:c5f8eeb3cbc8 | 16759:23415229349b |
---|---|
1 /* | |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 package com.oracle.truffle.dsl.processor.model; | |
24 | |
25 import java.util.*; | |
26 | |
27 import javax.lang.model.element.*; | |
28 import javax.lang.model.type.*; | |
29 | |
30 import com.oracle.truffle.dsl.processor.*; | |
31 | |
32 public class NodeChildData extends MessageContainer { | |
33 | |
34 public enum Cardinality { | |
35 ONE, | |
36 MANY; | |
37 | |
38 public boolean isMany() { | |
39 return this == MANY; | |
40 } | |
41 | |
42 public boolean isOne() { | |
43 return this == ONE; | |
44 } | |
45 } | |
46 | |
47 private final Element sourceElement; | |
48 private final AnnotationMirror sourceAnnotationMirror; | |
49 private final String name; | |
50 private final TypeMirror type; | |
51 private final TypeMirror originalType; | |
52 private final Element accessElement; | |
53 private final Cardinality cardinality; | |
54 | |
55 private List<NodeChildData> executeWith = Collections.emptyList(); | |
56 | |
57 private NodeData childNode; | |
58 | |
59 public NodeChildData(Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, TypeMirror originalNodeType, Element accessElement, Cardinality cardinality) { | |
60 this.sourceElement = sourceElement; | |
61 this.sourceAnnotationMirror = sourceMirror; | |
62 this.name = name; | |
63 this.type = nodeType; | |
64 this.originalType = originalNodeType; | |
65 this.accessElement = accessElement; | |
66 this.cardinality = cardinality; | |
67 } | |
68 | |
69 public List<NodeChildData> getExecuteWith() { | |
70 return executeWith; | |
71 } | |
72 | |
73 public void setExecuteWith(List<NodeChildData> executeWith) { | |
74 this.executeWith = executeWith; | |
75 } | |
76 | |
77 public ExecutableTypeData findExecutableType(ProcessorContext context, TypeData targetType) { | |
78 ExecutableTypeData executableType = childNode.findExecutableType(targetType, getExecuteWith().size()); | |
79 if (executableType == null) { | |
80 executableType = findAnyGenericExecutableType(context); | |
81 } | |
82 return executableType; | |
83 } | |
84 | |
85 public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) { | |
86 return childNode.findGenericExecutableTypes(context, getExecuteWith().size()); | |
87 } | |
88 | |
89 public ExecutableTypeData findAnyGenericExecutableType(ProcessorContext context) { | |
90 return childNode.findAnyGenericExecutableType(context, getExecuteWith().size()); | |
91 } | |
92 | |
93 public TypeMirror getOriginalType() { | |
94 return originalType; | |
95 } | |
96 | |
97 @Override | |
98 public Element getMessageElement() { | |
99 return sourceElement; | |
100 } | |
101 | |
102 @Override | |
103 public AnnotationMirror getMessageAnnotation() { | |
104 return sourceAnnotationMirror; | |
105 } | |
106 | |
107 public void setNode(NodeData nodeData) { | |
108 this.childNode = nodeData; | |
109 if (nodeData != null) { | |
110 getMessages().addAll(nodeData.collectMessages()); | |
111 } | |
112 } | |
113 | |
114 public Element getAccessElement() { | |
115 return accessElement; | |
116 } | |
117 | |
118 public TypeMirror getNodeType() { | |
119 return type; | |
120 } | |
121 | |
122 public Cardinality getCardinality() { | |
123 return cardinality; | |
124 } | |
125 | |
126 public NodeData getNodeData() { | |
127 return childNode; | |
128 } | |
129 | |
130 public String getName() { | |
131 return name; | |
132 } | |
133 | |
134 @Override | |
135 public String toString() { | |
136 return "NodeFieldData[name=" + getName() + ", kind=" + cardinality + ", node=" + getNodeData() + "]"; | |
137 } | |
138 | |
139 } |