Search in sources :

Example 81 with Node

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();
}
Also used : InstrumentableNode(com.oracle.truffle.api.instrumentation.InstrumentableNode) Node(com.oracle.truffle.api.nodes.Node) InstrumentableNode(com.oracle.truffle.api.instrumentation.InstrumentableNode) SourceSection(com.oracle.truffle.api.source.SourceSection)

Example 82 with Node

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;
}
Also used : Node(com.oracle.truffle.api.nodes.Node) NoSuchElementException(java.util.NoSuchElementException)

Example 83 with Node

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));
}
Also used : ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Node(com.oracle.truffle.api.nodes.Node) TestHelper.createNode(com.oracle.truffle.api.dsl.test.TestHelper.createNode) ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Test(org.junit.Test)

Example 84 with Node

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));
}
Also used : ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Node(com.oracle.truffle.api.nodes.Node) TestHelper.createNode(com.oracle.truffle.api.dsl.test.TestHelper.createNode) ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Test(org.junit.Test)

Example 85 with Node

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));
}
Also used : ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Node(com.oracle.truffle.api.nodes.Node) TestHelper.createNode(com.oracle.truffle.api.dsl.test.TestHelper.createNode) ValueNode(com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode) Test(org.junit.Test)

Aggregations

Node (com.oracle.truffle.api.nodes.Node)101 RootNode (com.oracle.truffle.api.nodes.RootNode)65 Test (org.junit.Test)46 InstrumentableNode (com.oracle.truffle.api.instrumentation.InstrumentableNode)21 ProbeNode (com.oracle.truffle.api.instrumentation.ProbeNode)21 Source (com.oracle.truffle.api.source.Source)16 NodeVisitor (com.oracle.truffle.api.nodes.NodeVisitor)11 CallTarget (com.oracle.truffle.api.CallTarget)9 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)9 DirectCallNode (com.oracle.truffle.api.nodes.DirectCallNode)8 WrapperNode (com.oracle.truffle.api.instrumentation.InstrumentableNode.WrapperNode)7 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)6 SourceSection (com.oracle.truffle.api.source.SourceSection)6 TestHelper.createNode (com.oracle.truffle.api.dsl.test.TestHelper.createNode)5 ValueNode (com.oracle.truffle.api.dsl.test.TypeSystemTest.ValueNode)5 SLEvalRootNode (com.oracle.truffle.sl.nodes.SLEvalRootNode)5 SLStatementNode (com.oracle.truffle.sl.nodes.SLStatementNode)5 SLBlockNode (com.oracle.truffle.sl.nodes.controlflow.SLBlockNode)5 LinkedHashMap (java.util.LinkedHashMap)5 TruffleInstrument (com.oracle.truffle.api.instrumentation.TruffleInstrument)4