Mercurial > hg > graal-jvmci-8
changeset 10846:e87d56a51047
Truffle: add Node.isReplaceable()
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Mon, 22 Jul 2013 18:07:53 +0200 |
parents | e9248ebb1d79 |
children | 669e3105804d |
files | graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java |
diffstat | 1 files changed, 16 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Mon Jul 22 17:29:48 2013 +0200 +++ b/graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java Mon Jul 22 18:07:53 2013 +0200 @@ -188,6 +188,22 @@ } /** + * Checks if this node is properly adopted by a parent and can be replaced. + * + * @return {@code true} if it is safe to replace this node. + */ + public final boolean isReplaceable() { + if (getParent() != null) { + for (Node sibling : getParent().getChildren()) { + if (sibling == this) { + return true; + } + } + } + return false; + } + + /** * Intended to be implemented by subclasses of {@link Node} to receive a notification when the * node is rewritten. This method is invoked before the actual replace has happened. *