com.oracle.truffle.api.nodes.Node.replace()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(618)

本文整理了Java中com.oracle.truffle.api.nodes.Node.replace()方法的一些代码示例,展示了Node.replace()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.replace()方法的具体详情如下:
包路径:com.oracle.truffle.api.nodes.Node
类名称:Node
方法名:replace

Node.replace介绍

[英]Replaces this node with another node. If there is a source section (see #getSourceSection()) associated with this node, it is transferred to the new node.
[中]将此节点替换为另一个节点。如果存在与此节点关联的源节(请参见#getSourceSection()),则会将其传输到新节点。

代码示例

代码示例来源:origin: com.oracle/truffle

  1. /**
  2. * Replaces this node with another node. If there is a source section (see
  3. * {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
  4. *
  5. * @param newNode the new node that is the replacement
  6. * @return the new node
  7. */
  8. public final <T extends Node> T replace(T newNode) {
  9. return replace(newNode, "");
  10. }

代码示例来源:origin: com.oracle.truffle/truffle-api

  1. /**
  2. * Replaces this node with another node. If there is a source section (see
  3. * {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
  4. *
  5. * @param newNode the new node that is the replacement
  6. * @return the new node
  7. * @since 0.8 or earlier
  8. */
  9. public final <T extends Node> T replace(T newNode) {
  10. return replace(newNode, "");
  11. }

代码示例来源:origin: org.graalvm.truffle/truffle-api

  1. /**
  2. * Replaces this node with another node. If there is a source section (see
  3. * {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
  4. *
  5. * @param newNode the new node that is the replacement
  6. * @return the new node
  7. * @since 0.8 or earlier
  8. */
  9. public final <T extends Node> T replace(T newNode) {
  10. return replace(newNode, "");
  11. }

代码示例来源:origin: com.oracle/truffle

  1. public T call() {
  2. Node prev = getPrevious(uninitialized);
  3. if (prev == null) {
  4. newNode.adoptChildren0(uninitialized, null);
  5. return uninitialized.replace(newNode, "Uninitialized monomorphic");
  6. } else {
  7. return appendPolymorphic(uninitialized, newNode);
  8. }
  9. }
  10. });

代码示例来源:origin: com.oracle/truffle

  1. public T call() {
  2. assert newNode != null;
  3. if (getNext(thisNode) != null || getPrevious(thisNode) != null) {
  4. // already polymorphic -> append
  5. return appendPolymorphic(findUninitialized(thisNode), newNode);
  6. } else if (includes(thisNode, newNode)) {
  7. // included -> remains monomorphic
  8. newNode.adoptChildren0(thisNode, null);
  9. return thisNode.replace(newNode, message);
  10. } else {
  11. // goto polymorphic
  12. return null;
  13. }
  14. }
  15. });

代码示例来源:origin: com.oracle.truffle/truffle-api

  1. @SuppressWarnings("unchecked")
  2. private Node materializeSyntaxNodes(Node instrumentableNode, SourceSection sourceSection) {
  3. if (instrumentableNode instanceof InstrumentableNode) {
  4. InstrumentableNode currentNode = (InstrumentableNode) instrumentableNode;
  5. assert currentNode.isInstrumentable();
  6. Set<Class<? extends Tag>> materializeTags = (Set<Class<? extends Tag>>) (materializeLimitedTags == null ? providedTags : materializeLimitedTags);
  7. InstrumentableNode materializedNode = currentNode.materializeInstrumentableNodes(materializeTags);
  8. if (currentNode != materializedNode) {
  9. if (!(materializedNode instanceof Node)) {
  10. throw new IllegalStateException("The returned materialized syntax node is not a Truffle Node.");
  11. }
  12. if (((Node) materializedNode).getParent() != null) {
  13. throw new IllegalStateException("The returned materialized syntax node is already adopted.");
  14. }
  15. SourceSection newSourceSection = ((Node) materializedNode).getSourceSection();
  16. if (!Objects.equals(sourceSection, newSourceSection)) {
  17. throw new IllegalStateException(String.format("The source section of the materialized syntax node must match the source section of the original node. %s != %s.", sourceSection,
  18. newSourceSection));
  19. }
  20. return ((Node) currentNode).replace((Node) materializedNode);
  21. }
  22. }
  23. return instrumentableNode;
  24. }

代码示例来源:origin: org.graalvm.truffle/truffle-api

  1. @SuppressWarnings("unchecked")
  2. private Node materializeSyntaxNodes(Node instrumentableNode, SourceSection sourceSection) {
  3. if (instrumentableNode instanceof InstrumentableNode) {
  4. InstrumentableNode currentNode = (InstrumentableNode) instrumentableNode;
  5. assert currentNode.isInstrumentable();
  6. Set<Class<? extends Tag>> materializeTags = (Set<Class<? extends Tag>>) (materializeLimitedTags == null ? providedTags : materializeLimitedTags);
  7. InstrumentableNode materializedNode = currentNode.materializeInstrumentableNodes(materializeTags);
  8. if (currentNode != materializedNode) {
  9. if (!(materializedNode instanceof Node)) {
  10. throw new IllegalStateException("The returned materialized syntax node is not a Truffle Node.");
  11. }
  12. if (((Node) materializedNode).getParent() != null) {
  13. throw new IllegalStateException("The returned materialized syntax node is already adopted.");
  14. }
  15. SourceSection newSourceSection = ((Node) materializedNode).getSourceSection();
  16. if (!Objects.equals(sourceSection, newSourceSection)) {
  17. throw new IllegalStateException(String.format("The source section of the materialized syntax node must match the source section of the original node. %s != %s.", sourceSection,
  18. newSourceSection));
  19. }
  20. return ((Node) currentNode).replace((Node) materializedNode);
  21. }
  22. }
  23. return instrumentableNode;
  24. }

代码示例来源:origin: org.graalvm.truffle/truffle-api

  1. node.replace(wrapperNode, "Insert instrumentation wrapper node.");

代码示例来源:origin: com.oracle.truffle/truffle-api

  1. originalNode.replace(wrapperNode, "Insert instrumentation wrapper node.");

代码示例来源:origin: org.graalvm.truffle/truffle-api

  1. @SuppressWarnings("deprecation")
  2. static void removeWrapper(ProbeNode node) {
  3. if (TRACE) {
  4. trace("Remove wrapper for %s%n", node.getContext().getInstrumentedSourceSection());
  5. }
  6. com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode wrapperNode = node.findWrapper();
  7. ((Node) wrapperNode).replace(wrapperNode.getDelegateNode());
  8. }

代码示例来源:origin: com.oracle.truffle/truffle-api

  1. @SuppressWarnings("deprecation")
  2. static void removeWrapper(ProbeNode node) {
  3. if (TRACE) {
  4. trace("Remove wrapper for %s%n", node.getContext().getInstrumentedSourceSection());
  5. }
  6. com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode wrapperNode = node.findWrapper();
  7. ((Node) wrapperNode).replace(wrapperNode.getDelegateNode());
  8. }

代码示例来源:origin: com.oracle/truffle

  1. private static <T extends Node & DSLNode> T appendPolymorphic(Node uninitialized, T newNode) {
  2. Class<?>[] includes = newNode.getMetadata0().getIncludes();
  3. Node cur = getPrevious(uninitialized);
  4. Node prev = uninitialized;
  5. int depth = 0;
  6. Class<?>[] types = null;
  7. while (cur != null) {
  8. if (containsClass(includes, cur)) {
  9. cur.replace(prev, "Included in other specialization");
  10. cur = prev;
  11. } else {
  12. depth++;
  13. types = mergeTypes((DSLNode) cur, types);
  14. }
  15. prev = cur;
  16. cur = getPrevious(cur);
  17. }
  18. assert prev.getCost() == NodeCost.POLYMORPHIC;
  19. updateSourceSection(prev, newNode);
  20. if (depth <= 1) {
  21. newNode.adoptChildren0(prev, null);
  22. return prev.replace(newNode, "Polymorphic to monomorphic.");
  23. } else {
  24. newNode.adoptChildren0(null, uninitialized);
  25. ((DSLNode) prev).updateTypes0(mergeTypes(newNode, types));
  26. return uninitialized.replace(newNode, "Appended polymorphic");
  27. }
  28. }

代码示例来源:origin: com.oracle/truffle

  1. public T call() {
  2. assert getNext(oldNode) == null;
  3. assert getPrevious(oldNode) == null;
  4. assert newNodeDSL != null;
  5. Node uninitialized = (Node) uninitializedDSL;
  6. Node newNode = (Node) newNodeDSL;
  7. polymorphic.adoptChildren0(oldNode, (Node) currentCopy);
  8. updateSourceSection(oldNode, uninitialized);
  9. // new specialization
  10. updateSourceSection(oldNode, newNode);
  11. newNodeDSL.adoptChildren0(null, uninitialized);
  12. currentCopy.adoptChildren0(null, newNode);
  13. oldNode.replace(polymorphic, message);
  14. assert newNode != null ? currentCopy.getNext0() == newNode : currentCopy.getNext0() == uninitialized;
  15. assert uninitializedDSL.getNext0() == null;
  16. return polymorphic;
  17. }
  18. });

代码示例来源:origin: com.oracle/truffle

  1. this.replace(wrapperNode);

相关文章