Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/serial/PostOrderDeserializer.java @ 20129:5b7db8941fd7
Truffle: make NodeClass and NodeField a top-level class.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Thu, 02 Apr 2015 01:22:41 +0200 |
parents | 6ba170cb6f53 |
children | 8dc73c226c63 |
comparison
equal
deleted
inserted
replaced
20128:7ad60a16bbb0 | 20129:5b7db8941fd7 |
---|---|
28 import java.util.*; | 28 import java.util.*; |
29 | 29 |
30 import sun.misc.*; | 30 import sun.misc.*; |
31 | 31 |
32 import com.oracle.truffle.api.nodes.*; | 32 import com.oracle.truffle.api.nodes.*; |
33 import com.oracle.truffle.api.nodes.NodeUtil.NodeClass; | 33 import com.oracle.truffle.api.nodes.NodeFieldAccessor.NodeFieldKind; |
34 import com.oracle.truffle.api.nodes.NodeUtil.NodeField; | |
35 import com.oracle.truffle.api.nodes.NodeUtil.NodeFieldKind; | |
36 import com.oracle.truffle.api.source.*; | 34 import com.oracle.truffle.api.source.*; |
37 | 35 |
38 /** | 36 /** |
39 * Experimental API. May change without notice. | 37 * Experimental API. May change without notice. |
40 */ | 38 */ |
146 throw new RuntimeException("Class is not a truffle node " + nodeClass); | 144 throw new RuntimeException("Class is not a truffle node " + nodeClass); |
147 } | 145 } |
148 | 146 |
149 Node node = (Node) object; | 147 Node node = (Node) object; |
150 | 148 |
151 NodeField[] nodeFields = NodeClass.get(nodeClass).getFields(); | 149 NodeFieldAccessor[] nodeFields = NodeClass.get(nodeClass).getFields(); |
152 deserializeChildrenFields(node, nodeFields); | 150 deserializeChildrenFields(node, nodeFields); |
153 deserializeChildFields(node, nodeFields); | 151 deserializeChildFields(node, nodeFields); |
154 deserializeDataFields(buffer, node, nodeFields); | 152 deserializeDataFields(buffer, node, nodeFields); |
155 | 153 |
156 return node; | 154 return node; |
157 } | 155 } |
158 | 156 |
159 private void deserializeDataFields(VariableLengthIntBuffer buffer, Node nodeInstance, NodeField[] nodeFields) throws UnsupportedConstantPoolTypeException { | 157 private void deserializeDataFields(VariableLengthIntBuffer buffer, Node nodeInstance, NodeFieldAccessor[] nodeFields) throws UnsupportedConstantPoolTypeException { |
160 for (int i = 0; i < nodeFields.length; i++) { | 158 for (int i = 0; i < nodeFields.length; i++) { |
161 NodeField field = nodeFields[i]; | 159 NodeFieldAccessor field = nodeFields[i]; |
162 if (field.getKind() == NodeFieldKind.DATA) { | 160 if (field.getKind() == NodeFieldKind.DATA) { |
163 Class<?> fieldClass = field.getType(); | 161 Class<?> fieldClass = field.getType(); |
164 long offset = field.getOffset(); | 162 long offset = field.getOffset(); |
165 | 163 |
166 // source sections are not serialized | 164 // source sections are not serialized |
237 } else { | 235 } else { |
238 unsafe.putObject(nodeInstance, offset, null); | 236 unsafe.putObject(nodeInstance, offset, null); |
239 } | 237 } |
240 } | 238 } |
241 | 239 |
242 private void deserializeChildFields(Node parent, NodeField[] nodeFields) { | 240 private void deserializeChildFields(Node parent, NodeFieldAccessor[] nodeFields) { |
243 for (int i = nodeFields.length - 1; i >= 0; i--) { | 241 for (int i = nodeFields.length - 1; i >= 0; i--) { |
244 NodeField field = nodeFields[i]; | 242 NodeFieldAccessor field = nodeFields[i]; |
245 if (field.getKind() == NodeFieldKind.CHILD) { | 243 if (field.getKind() == NodeFieldKind.CHILD) { |
246 unsafe.putObject(parent, field.getOffset(), popNode(parent, field.getType())); | 244 unsafe.putObject(parent, field.getOffset(), popNode(parent, field.getType())); |
247 } | 245 } |
248 } | 246 } |
249 } | 247 } |
250 | 248 |
251 private void deserializeChildrenFields(Node parent, NodeField[] nodeFields) { | 249 private void deserializeChildrenFields(Node parent, NodeFieldAccessor[] nodeFields) { |
252 for (int i = nodeFields.length - 1; i >= 0; i--) { | 250 for (int i = nodeFields.length - 1; i >= 0; i--) { |
253 NodeField field = nodeFields[i]; | 251 NodeFieldAccessor field = nodeFields[i]; |
254 if (field.getKind() == NodeFieldKind.CHILDREN) { | 252 if (field.getKind() == NodeFieldKind.CHILDREN) { |
255 unsafe.putObject(parent, field.getOffset(), popArray(parent, field.getType())); | 253 unsafe.putObject(parent, field.getOffset(), popArray(parent, field.getType())); |
256 } | 254 } |
257 } | 255 } |
258 } | 256 } |