comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 10846:e87d56a51047

Truffle: add Node.isReplaceable()
author Andreas Woess <andreas.woess@jku.at>
date Mon, 22 Jul 2013 18:07:53 +0200
parents 50f3f3958555
children 8c570011b86f
comparison
equal deleted inserted replaced
10845:e9248ebb1d79 10846:e87d56a51047
186 public final <T extends Node> T replace(T newNode) { 186 public final <T extends Node> T replace(T newNode) {
187 return replace(newNode, ""); 187 return replace(newNode, "");
188 } 188 }
189 189
190 /** 190 /**
191 * Checks if this node is properly adopted by a parent and can be replaced.
192 *
193 * @return {@code true} if it is safe to replace this node.
194 */
195 public final boolean isReplaceable() {
196 if (getParent() != null) {
197 for (Node sibling : getParent().getChildren()) {
198 if (sibling == this) {
199 return true;
200 }
201 }
202 }
203 return false;
204 }
205
206 /**
191 * Intended to be implemented by subclasses of {@link Node} to receive a notification when the 207 * Intended to be implemented by subclasses of {@link Node} to receive a notification when the
192 * node is rewritten. This method is invoked before the actual replace has happened. 208 * node is rewritten. This method is invoked before the actual replace has happened.
193 * 209 *
194 * @param newNode the replacement node 210 * @param newNode the replacement node
195 * @param reason the reason the replace supplied 211 * @param reason the reason the replace supplied