use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SuspendableLocationFinder method findNearestBound.
private static SourceSection findNearestBound(Source source, Set<Class<? extends Tag>> elementTags, int line, int column, SuspendAnchor anchor, TruffleInstrument.Env env) {
int offset = source.getLineStartOffset(line);
if (column > 0) {
offset += column - 1;
}
NearestSections sectionsCollector = new NearestSections(elementTags, (column <= 0) ? line : 0, offset, anchor);
// All SourceSections of the Source are loaded already when the source was executed
env.getInstrumenter().attachLoadSourceSectionListener(SourceSectionFilter.newBuilder().sourceIs(source).build(), sectionsCollector, true).dispose();
SourceSection section = sectionsCollector.getExactSection();
if (section != null) {
return section;
}
InstrumentableNode contextNode = sectionsCollector.getContainsNode();
if (contextNode == null) {
contextNode = sectionsCollector.getNextNode();
}
if (contextNode == null) {
contextNode = sectionsCollector.getPreviousNode();
}
if (contextNode == null) {
return null;
}
Node node = contextNode.findNearestNodeAt(offset, elementTags);
if (node == null) {
return null;
}
return node.getSourceSection();
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class SubstrateNodeIterator method next.
@Override
public Node next() {
Node result = next;
if (result == null) {
throw new NoSuchElementException();
}
computeNext();
return result;
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class CachedTest method testChildrenAdoption5.
@Test
public void testChildrenAdoption5() {
ChildrenAdoption5 root = createNode(ChildrenAdoption5Factory.getInstance(), false);
Node child = new ValueNode();
root.execute(child);
Assert.assertTrue(hasParent(root, child));
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class CachedTest method testChildrenAdoption2.
@Test
public void testChildrenAdoption2() {
ChildrenAdoption2 root = createNode(ChildrenAdoption2Factory.getInstance(), false);
Node child = new ValueNode();
root.execute(child);
root.adoptChildren();
Assert.assertTrue(hasParent(root, child));
}
use of com.oracle.truffle.api.nodes.Node in project graal by oracle.
the class CachedTest method testChildrenAdoption6.
@Test
public void testChildrenAdoption6() {
ChildrenAdoption6 root = createNode(ChildrenAdoption6Factory.getInstance(), false);
Node child = new ValueNode();
root.execute(child);
Assert.assertTrue(hasParent(root, child));
}
Aggregations