use of com.oracle.truffle.api.frame.FrameInstance in project graal by oracle.
the class StackTraceTest method testStackTraversal.
@Test
public void testStackTraversal() {
CallTarget callTarget = createCallTarget(new TestCallWithCallTargetNode(null));
CallTarget indirect = createCallTarget(new TestCallWithIndirectTargetNode(callTarget));
CallTarget direct = createCallTarget(new TestCallWithDirectTargetNode(indirect));
CallTarget test = createCallTarget(new TestCallNode(null) {
int visitCount = 0;
@Override
Object execute(VirtualFrame frame) {
Object result = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Object>() {
public Object visitFrame(FrameInstance frameInstance) {
visitCount++;
return "foobar";
}
});
Assert.assertEquals(1, visitCount);
Assert.assertEquals("foobar", result);
visitCount = 0;
result = Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Object>() {
public Object visitFrame(FrameInstance frameInstance) {
visitCount++;
if (visitCount == 2) {
return "foobar";
} else {
// continue traversing
return null;
}
}
});
Assert.assertEquals(2, visitCount);
Assert.assertEquals("foobar", result);
return null;
}
});
findTestCallNode(callTarget).setNext(test);
direct.call();
}
Aggregations