Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeChildData.java @ 21951:9c8c0937da41
Moving all sources into truffle subdirectory
author | Jaroslav Tulach <jaroslav.tulach@oracle.com> |
---|---|
date | Wed, 17 Jun 2015 10:58:08 +0200 |
parents | graal/com.oracle.truffle.dsl.processor/src/com/oracle/truffle/dsl/processor/model/NodeChildData.java@18c0f02fa4d2 |
children | dc83cc1f94f2 |
comparison
equal
deleted
inserted
replaced
21950:2a5011c7e641 | 21951:9c8c0937da41 |
---|---|
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<NodeExecutionData> 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<NodeExecutionData> getExecuteWith() { | |
70 return executeWith; | |
71 } | |
72 | |
73 public void setExecuteWith(List<NodeExecutionData> executeWith) { | |
74 this.executeWith = executeWith; | |
75 } | |
76 | |
77 public ExecutableTypeData findExecutableType(TypeMirror targetType) { | |
78 return childNode.findExecutableType(targetType, getExecuteWith().size()); | |
79 } | |
80 | |
81 public List<ExecutableTypeData> findGenericExecutableTypes(ProcessorContext context) { | |
82 return childNode.findGenericExecutableTypes(context, getExecuteWith().size()); | |
83 } | |
84 | |
85 public ExecutableTypeData findAnyGenericExecutableType(ProcessorContext context) { | |
86 return childNode.findAnyGenericExecutableType(context, getExecuteWith().size()); | |
87 } | |
88 | |
89 public TypeMirror getOriginalType() { | |
90 return originalType; | |
91 } | |
92 | |
93 @Override | |
94 public Element getMessageElement() { | |
95 return sourceElement; | |
96 } | |
97 | |
98 @Override | |
99 public AnnotationMirror getMessageAnnotation() { | |
100 return sourceAnnotationMirror; | |
101 } | |
102 | |
103 public void setNode(NodeData nodeData) { | |
104 this.childNode = nodeData; | |
105 if (nodeData != null) { | |
106 getMessages().addAll(nodeData.collectMessages()); | |
107 } | |
108 } | |
109 | |
110 public Element getAccessElement() { | |
111 return accessElement; | |
112 } | |
113 | |
114 public TypeMirror getNodeType() { | |
115 return type; | |
116 } | |
117 | |
118 public Cardinality getCardinality() { | |
119 return cardinality; | |
120 } | |
121 | |
122 public NodeData getNodeData() { | |
123 return childNode; | |
124 } | |
125 | |
126 public String getName() { | |
127 return name; | |
128 } | |
129 | |
130 @Override | |
131 public String toString() { | |
132 return "NodeFieldData[name=" + getName() + ", kind=" + cardinality + ", node=" + getNodeData() + "]"; | |
133 } | |
134 | |
135 } |