Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 14584:6189c1983cd3
Truffle: make Node#replace accept any CharSequence as reason
author | Andreas Woess <andreas.woess@jku.at> |
---|---|
date | Tue, 18 Mar 2014 13:14:53 +0100 |
parents | 6681b9eb3f4c |
children | a08b8694f556 |
comparison
equal
deleted
inserted
replaced
14583:2ec76bd5f309 | 14584:6189c1983cd3 |
---|---|
184 * | 184 * |
185 * @param newNode the new node that is the replacement | 185 * @param newNode the new node that is the replacement |
186 * @param reason a description of the reason for the replacement | 186 * @param reason a description of the reason for the replacement |
187 * @return the new node | 187 * @return the new node |
188 */ | 188 */ |
189 public final <T extends Node> T replace(T newNode, String reason) { | 189 public final <T extends Node> T replace(T newNode, CharSequence reason) { |
190 CompilerDirectives.transferToInterpreterAndInvalidate(); | 190 CompilerDirectives.transferToInterpreterAndInvalidate(); |
191 if (this.getParent() == null) { | 191 if (this.getParent() == null) { |
192 throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); | 192 throw new IllegalStateException("This node cannot be replaced, because it does not yet have a parent."); |
193 } | 193 } |
194 if (sourceSection != null && newNode.getSourceSection() == null) { | 194 if (sourceSection != null && newNode.getSourceSection() == null) { |
258 } | 258 } |
259 } | 259 } |
260 return false; | 260 return false; |
261 } | 261 } |
262 | 262 |
263 private void reportReplace(Node oldNode, Node newNode, String reason) { | 263 private void reportReplace(Node oldNode, Node newNode, CharSequence reason) { |
264 RootNode rootNode = getRootNode(); | 264 RootNode rootNode = getRootNode(); |
265 if (rootNode != null) { | 265 if (rootNode != null) { |
266 CallTarget target = rootNode.getCallTarget(); | 266 CallTarget target = rootNode.getCallTarget(); |
267 if (target instanceof ReplaceObserver) { | 267 if (target instanceof ReplaceObserver) { |
268 ((ReplaceObserver) target).nodeReplaced(oldNode, newNode, reason); | 268 ((ReplaceObserver) target).nodeReplaced(oldNode, newNode, reason); |
275 * node is rewritten. This method is invoked before the actual replace has happened. | 275 * node is rewritten. This method is invoked before the actual replace has happened. |
276 * | 276 * |
277 * @param newNode the replacement node | 277 * @param newNode the replacement node |
278 * @param reason the reason the replace supplied | 278 * @param reason the reason the replace supplied |
279 */ | 279 */ |
280 protected void onReplace(Node newNode, String reason) { | 280 protected void onReplace(Node newNode, CharSequence reason) { |
281 if (TruffleOptions.TraceRewrites) { | 281 if (TruffleOptions.TraceRewrites) { |
282 traceRewrite(newNode, reason); | 282 traceRewrite(newNode, reason); |
283 } | 283 } |
284 } | 284 } |
285 | 285 |
286 private void traceRewrite(Node newNode, String reason) { | 286 private void traceRewrite(Node newNode, CharSequence reason) { |
287 | 287 |
288 if (TruffleOptions.TraceRewritesFilterFromCost != null) { | 288 if (TruffleOptions.TraceRewritesFilterFromCost != null) { |
289 if (filterByKind(this, TruffleOptions.TraceRewritesFilterFromCost)) { | 289 if (filterByKind(this, TruffleOptions.TraceRewritesFilterFromCost)) { |
290 return; | 290 return; |
291 } | 291 } |