本文整理了Java中com.oracle.truffle.api.nodes.Node.replace()
方法的一些代码示例,展示了Node.replace()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.replace()
方法的具体详情如下:
包路径:com.oracle.truffle.api.nodes.Node
类名称: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
/**
* Replaces this node with another node. If there is a source section (see
* {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
*
* @param newNode the new node that is the replacement
* @return the new node
*/
public final <T extends Node> T replace(T newNode) {
return replace(newNode, "");
}
代码示例来源:origin: com.oracle.truffle/truffle-api
/**
* Replaces this node with another node. If there is a source section (see
* {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
*
* @param newNode the new node that is the replacement
* @return the new node
* @since 0.8 or earlier
*/
public final <T extends Node> T replace(T newNode) {
return replace(newNode, "");
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
/**
* Replaces this node with another node. If there is a source section (see
* {@link #getSourceSection()}) associated with this node, it is transferred to the new node.
*
* @param newNode the new node that is the replacement
* @return the new node
* @since 0.8 or earlier
*/
public final <T extends Node> T replace(T newNode) {
return replace(newNode, "");
}
代码示例来源:origin: com.oracle/truffle
public T call() {
Node prev = getPrevious(uninitialized);
if (prev == null) {
newNode.adoptChildren0(uninitialized, null);
return uninitialized.replace(newNode, "Uninitialized monomorphic");
} else {
return appendPolymorphic(uninitialized, newNode);
}
}
});
代码示例来源:origin: com.oracle/truffle
public T call() {
assert newNode != null;
if (getNext(thisNode) != null || getPrevious(thisNode) != null) {
// already polymorphic -> append
return appendPolymorphic(findUninitialized(thisNode), newNode);
} else if (includes(thisNode, newNode)) {
// included -> remains monomorphic
newNode.adoptChildren0(thisNode, null);
return thisNode.replace(newNode, message);
} else {
// goto polymorphic
return null;
}
}
});
代码示例来源:origin: com.oracle.truffle/truffle-api
@SuppressWarnings("unchecked")
private Node materializeSyntaxNodes(Node instrumentableNode, SourceSection sourceSection) {
if (instrumentableNode instanceof InstrumentableNode) {
InstrumentableNode currentNode = (InstrumentableNode) instrumentableNode;
assert currentNode.isInstrumentable();
Set<Class<? extends Tag>> materializeTags = (Set<Class<? extends Tag>>) (materializeLimitedTags == null ? providedTags : materializeLimitedTags);
InstrumentableNode materializedNode = currentNode.materializeInstrumentableNodes(materializeTags);
if (currentNode != materializedNode) {
if (!(materializedNode instanceof Node)) {
throw new IllegalStateException("The returned materialized syntax node is not a Truffle Node.");
}
if (((Node) materializedNode).getParent() != null) {
throw new IllegalStateException("The returned materialized syntax node is already adopted.");
}
SourceSection newSourceSection = ((Node) materializedNode).getSourceSection();
if (!Objects.equals(sourceSection, newSourceSection)) {
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,
newSourceSection));
}
return ((Node) currentNode).replace((Node) materializedNode);
}
}
return instrumentableNode;
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
@SuppressWarnings("unchecked")
private Node materializeSyntaxNodes(Node instrumentableNode, SourceSection sourceSection) {
if (instrumentableNode instanceof InstrumentableNode) {
InstrumentableNode currentNode = (InstrumentableNode) instrumentableNode;
assert currentNode.isInstrumentable();
Set<Class<? extends Tag>> materializeTags = (Set<Class<? extends Tag>>) (materializeLimitedTags == null ? providedTags : materializeLimitedTags);
InstrumentableNode materializedNode = currentNode.materializeInstrumentableNodes(materializeTags);
if (currentNode != materializedNode) {
if (!(materializedNode instanceof Node)) {
throw new IllegalStateException("The returned materialized syntax node is not a Truffle Node.");
}
if (((Node) materializedNode).getParent() != null) {
throw new IllegalStateException("The returned materialized syntax node is already adopted.");
}
SourceSection newSourceSection = ((Node) materializedNode).getSourceSection();
if (!Objects.equals(sourceSection, newSourceSection)) {
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,
newSourceSection));
}
return ((Node) currentNode).replace((Node) materializedNode);
}
}
return instrumentableNode;
}
代码示例来源:origin: org.graalvm.truffle/truffle-api
node.replace(wrapperNode, "Insert instrumentation wrapper node.");
代码示例来源:origin: com.oracle.truffle/truffle-api
originalNode.replace(wrapperNode, "Insert instrumentation wrapper node.");
代码示例来源:origin: org.graalvm.truffle/truffle-api
@SuppressWarnings("deprecation")
static void removeWrapper(ProbeNode node) {
if (TRACE) {
trace("Remove wrapper for %s%n", node.getContext().getInstrumentedSourceSection());
}
com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode wrapperNode = node.findWrapper();
((Node) wrapperNode).replace(wrapperNode.getDelegateNode());
}
代码示例来源:origin: com.oracle.truffle/truffle-api
@SuppressWarnings("deprecation")
static void removeWrapper(ProbeNode node) {
if (TRACE) {
trace("Remove wrapper for %s%n", node.getContext().getInstrumentedSourceSection());
}
com.oracle.truffle.api.instrumentation.InstrumentableFactory.WrapperNode wrapperNode = node.findWrapper();
((Node) wrapperNode).replace(wrapperNode.getDelegateNode());
}
代码示例来源:origin: com.oracle/truffle
private static <T extends Node & DSLNode> T appendPolymorphic(Node uninitialized, T newNode) {
Class<?>[] includes = newNode.getMetadata0().getIncludes();
Node cur = getPrevious(uninitialized);
Node prev = uninitialized;
int depth = 0;
Class<?>[] types = null;
while (cur != null) {
if (containsClass(includes, cur)) {
cur.replace(prev, "Included in other specialization");
cur = prev;
} else {
depth++;
types = mergeTypes((DSLNode) cur, types);
}
prev = cur;
cur = getPrevious(cur);
}
assert prev.getCost() == NodeCost.POLYMORPHIC;
updateSourceSection(prev, newNode);
if (depth <= 1) {
newNode.adoptChildren0(prev, null);
return prev.replace(newNode, "Polymorphic to monomorphic.");
} else {
newNode.adoptChildren0(null, uninitialized);
((DSLNode) prev).updateTypes0(mergeTypes(newNode, types));
return uninitialized.replace(newNode, "Appended polymorphic");
}
}
代码示例来源:origin: com.oracle/truffle
public T call() {
assert getNext(oldNode) == null;
assert getPrevious(oldNode) == null;
assert newNodeDSL != null;
Node uninitialized = (Node) uninitializedDSL;
Node newNode = (Node) newNodeDSL;
polymorphic.adoptChildren0(oldNode, (Node) currentCopy);
updateSourceSection(oldNode, uninitialized);
// new specialization
updateSourceSection(oldNode, newNode);
newNodeDSL.adoptChildren0(null, uninitialized);
currentCopy.adoptChildren0(null, newNode);
oldNode.replace(polymorphic, message);
assert newNode != null ? currentCopy.getNext0() == newNode : currentCopy.getNext0() == uninitialized;
assert uninitializedDSL.getNext0() == null;
return polymorphic;
}
});
代码示例来源:origin: com.oracle/truffle
this.replace(wrapperNode);
内容来源于网络,如有侵权,请联系作者删除!