Mercurial > hg > truffle
comparison truffle/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/NodeUtil.java @ 21966:5023b913e2ba
Help the partial evaluator / language developer by marking API methods as neverPartOfCompilation() when they are too complicated to be compiled.
author | Christian Wimmer <christian.wimmer@oracle.com> |
---|---|
date | Mon, 22 Jun 2015 10:16:27 -0700 |
parents | 9c8c0937da41 |
children | b2d1c8ff592a |
comparison
equal
deleted
inserted
replaced
21965:0103d237f6c3 | 21966:5023b913e2ba |
---|---|
129 public static <T extends Node> T cloneNode(T orig) { | 129 public static <T extends Node> T cloneNode(T orig) { |
130 return (T) orig.deepCopy(); | 130 return (T) orig.deepCopy(); |
131 } | 131 } |
132 | 132 |
133 static Node deepCopyImpl(Node orig) { | 133 static Node deepCopyImpl(Node orig) { |
134 CompilerAsserts.neverPartOfCompilation(); | |
134 final Node clone = orig.copy(); | 135 final Node clone = orig.copy(); |
135 NodeClass nodeClass = clone.getNodeClass(); | 136 NodeClass nodeClass = clone.getNodeClass(); |
136 | 137 |
137 nodeClass.getParentField().putObject(clone, null); | 138 nodeClass.getParentField().putObject(clone, null); |
138 | 139 |
166 } | 167 } |
167 return clone; | 168 return clone; |
168 } | 169 } |
169 | 170 |
170 public static List<Node> findNodeChildren(Node node) { | 171 public static List<Node> findNodeChildren(Node node) { |
172 CompilerAsserts.neverPartOfCompilation(); | |
171 List<Node> nodes = new ArrayList<>(); | 173 List<Node> nodes = new ArrayList<>(); |
172 NodeClass nodeClass = node.getNodeClass(); | 174 NodeClass nodeClass = node.getNodeClass(); |
173 | 175 |
174 for (NodeFieldAccessor nodeField : nodeClass.getChildFields()) { | 176 for (NodeFieldAccessor nodeField : nodeClass.getChildFields()) { |
175 Object child = nodeField.getObject(node); | 177 Object child = nodeField.getObject(node); |
195 oldNode.replaceHelper(newNode, reason); | 197 oldNode.replaceHelper(newNode, reason); |
196 return newNode; | 198 return newNode; |
197 } | 199 } |
198 | 200 |
199 public static boolean replaceChild(Node parent, Node oldChild, Node newChild) { | 201 public static boolean replaceChild(Node parent, Node oldChild, Node newChild) { |
202 CompilerAsserts.neverPartOfCompilation(); | |
200 NodeClass nodeClass = parent.getNodeClass(); | 203 NodeClass nodeClass = parent.getNodeClass(); |
201 | 204 |
202 for (NodeFieldAccessor nodeField : nodeClass.getChildFields()) { | 205 for (NodeFieldAccessor nodeField : nodeClass.getChildFields()) { |
203 if (nodeField.getObject(parent) == oldChild) { | 206 if (nodeField.getObject(parent) == oldChild) { |
204 assert assertAssignable(nodeField, newChild); | 207 assert assertAssignable(nodeField, newChild); |
299 * Executes a closure for every non-null child of the parent node. | 302 * Executes a closure for every non-null child of the parent node. |
300 * | 303 * |
301 * @return {@code true} if all children were visited, {@code false} otherwise | 304 * @return {@code true} if all children were visited, {@code false} otherwise |
302 */ | 305 */ |
303 public static boolean forEachChild(Node parent, NodeVisitor visitor) { | 306 public static boolean forEachChild(Node parent, NodeVisitor visitor) { |
307 CompilerAsserts.neverPartOfCompilation(); | |
304 Objects.requireNonNull(visitor); | 308 Objects.requireNonNull(visitor); |
305 NodeClass parentNodeClass = parent.getNodeClass(); | 309 NodeClass parentNodeClass = parent.getNodeClass(); |
306 | 310 |
307 for (NodeFieldAccessor field : parentNodeClass.getChildFields()) { | 311 for (NodeFieldAccessor field : parentNodeClass.getChildFields()) { |
308 Object child = field.getObject(parent); | 312 Object child = field.getObject(parent); |