Mercurial > hg > truffle
comparison graal/com.oracle.truffle.codegen.processor/src/com/oracle/truffle/codegen/processor/node/NodeChildData.java @ 9220:97ad6d3e7557
Codegen API changes. Executed child nodes are now defined using @NodeChildren instead of fields.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Sat, 20 Apr 2013 12:16:22 +0200 |
parents | |
children | 6d92fdf1c999 |
comparison
equal
deleted
inserted
replaced
9219:1964871a642d | 9220:97ad6d3e7557 |
---|---|
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.codegen.processor.node; | |
24 | |
25 import javax.lang.model.element.*; | |
26 import javax.lang.model.type.*; | |
27 | |
28 import com.oracle.truffle.codegen.processor.template.*; | |
29 | |
30 public class NodeChildData extends MessageContainer { | |
31 | |
32 public enum Cardinality { | |
33 ONE, MANY; | |
34 | |
35 public boolean isMany() { | |
36 return this == MANY; | |
37 } | |
38 | |
39 public boolean isOne() { | |
40 return this == ONE; | |
41 } | |
42 } | |
43 | |
44 public enum ExecutionKind { | |
45 DEFAULT, SHORT_CIRCUIT | |
46 } | |
47 | |
48 private final Element sourceElement; | |
49 private final AnnotationMirror sourceAnnotationMirror; | |
50 | |
51 private final String name; | |
52 private final TypeMirror type; | |
53 private final Element accessElement; | |
54 | |
55 private final Cardinality cardinality; | |
56 private final ExecutionKind executionKind; | |
57 private NodeData nodeData; | |
58 | |
59 public NodeChildData(Element sourceElement, AnnotationMirror sourceMirror, String name, TypeMirror nodeType, Element accessElement, Cardinality cardinality, ExecutionKind executionKind) { | |
60 this.sourceElement = sourceElement; | |
61 this.sourceAnnotationMirror = sourceMirror; | |
62 this.name = name; | |
63 this.type = nodeType; | |
64 this.accessElement = accessElement; | |
65 this.cardinality = cardinality; | |
66 this.executionKind = executionKind; | |
67 } | |
68 | |
69 @Override | |
70 public Element getMessageElement() { | |
71 return sourceElement; | |
72 } | |
73 | |
74 @Override | |
75 public AnnotationMirror getMessageAnnotation() { | |
76 return sourceAnnotationMirror; | |
77 } | |
78 | |
79 public boolean isShortCircuit() { | |
80 return executionKind == ExecutionKind.SHORT_CIRCUIT; | |
81 } | |
82 | |
83 void setNode(NodeData nodeData) { | |
84 this.nodeData = nodeData; | |
85 getMessages().addAll(nodeData.collectMessages()); | |
86 } | |
87 | |
88 public Element getAccessElement() { | |
89 return accessElement; | |
90 } | |
91 | |
92 public TypeMirror getNodeType() { | |
93 return type; | |
94 } | |
95 | |
96 public Cardinality getCardinality() { | |
97 return cardinality; | |
98 } | |
99 | |
100 public ExecutionKind getExecutionKind() { | |
101 return executionKind; | |
102 } | |
103 | |
104 public NodeData getNodeData() { | |
105 return nodeData; | |
106 } | |
107 | |
108 public String getName() { | |
109 return name; | |
110 } | |
111 | |
112 @Override | |
113 public String toString() { | |
114 return "NodeFieldData[name=" + getName() + ", kind=" + cardinality + ", execution=" + executionKind + ", node=" + getNodeData() + "]"; | |
115 } | |
116 | |
117 } |