use of com.oracle.truffle.api.frame.VirtualFrame in project graal by oracle.
the class StackTraceTest method testFrameAccess.
@Test
public void testFrameAccess() {
CallTarget callTarget = createCallTarget(new TestCallWithCallTargetNode(null));
CallTarget indirect = createCallTarget(new TestCallWithIndirectTargetNode(callTarget));
CallTarget direct = createCallTarget(new TestCallWithDirectTargetNode(indirect));
CallTarget test = createCallTarget(new TestCallNode(null) {
@Override
Object execute(VirtualFrame frame) {
Truffle.getRuntime().iterateFrames(new FrameInstanceVisitor<Object>() {
@SuppressWarnings("deprecation")
public Object visitFrame(FrameInstance frameInstance) {
Assert.assertNull(frameInstance.getFrame(FrameAccess.NONE));
Frame readOnlyFrame = frameInstance.getFrame(FrameAccess.READ_ONLY);
FrameSlot slot = readOnlyFrame.getFrameDescriptor().findFrameSlot("demo");
Assert.assertEquals(42, readOnlyFrame.getValue(slot));
Frame readWriteFrame = frameInstance.getFrame(FrameAccess.READ_WRITE);
Assert.assertEquals(42, readWriteFrame.getValue(slot));
readWriteFrame.setObject(slot, 43);
Frame materializedFrame = frameInstance.getFrame(FrameAccess.MATERIALIZE);
Assert.assertEquals(43, materializedFrame.getValue(slot));
materializedFrame.setObject(slot, 44);
Assert.assertEquals(44, readOnlyFrame.getValue(slot));
Assert.assertEquals(44, readWriteFrame.getValue(slot));
return null;
}
});
return null;
}
});
findTestCallNode(callTarget).setNext(test);
direct.call();
}
use of com.oracle.truffle.api.frame.VirtualFrame 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();
}
use of com.oracle.truffle.api.frame.VirtualFrame in project TrufflePascal by Aspect26.
the class UnitLexicalScope method createInitializationBlock.
@Override
BlockNode createInitializationBlock() {
VirtualFrame unitFrame = PascalLanguage.INSTANCE.createUnitFrame(this.getName(), this.getFrameDescriptor());
List<StatementNode> initializationNodes = this.generateInitializationNodes(unitFrame);
initializationNodes.addAll(this.scopeInitializationNodes);
return new BlockNode(initializationNodes.toArray(new StatementNode[initializationNodes.size()]));
}
Aggregations