use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class FrameSlotTypeSpecializationTest method test.
@Test
public void test() {
TruffleRuntime runtime = Truffle.getRuntime();
FrameDescriptor frameDescriptor = new FrameDescriptor();
FrameSlot slot = frameDescriptor.addFrameSlot("localVar", FrameSlotKind.Int);
TestRootNode rootNode = new TestRootNode(frameDescriptor, new IntAssignLocal(slot, new StringTestChildNode()), new IntReadLocal(slot));
CallTarget target = runtime.createCallTarget(rootNode);
Assert.assertEquals(FrameSlotKind.Int, slot.getKind());
Object result = target.call();
Assert.assertEquals("42", result);
Assert.assertEquals(FrameSlotKind.Object, slot.getKind());
}
use of com.oracle.truffle.api.frame.FrameDescriptor in project graal by oracle.
the class FrameTest method test.
@Test
public void test() throws SecurityException, IllegalArgumentException {
TruffleRuntime runtime = Truffle.getRuntime();
FrameDescriptor frameDescriptor = new FrameDescriptor();
String varName = "localVar";
FrameSlot slot = frameDescriptor.addFrameSlot(varName, FrameSlotKind.Int);
TestRootNode rootNode = new TestRootNode(frameDescriptor, new AssignLocal(slot), new ReadLocal(slot));
CallTarget target = runtime.createCallTarget(rootNode);
Object result = target.call();
Assert.assertEquals(42, result);
frameDescriptor.removeFrameSlot(varName);
boolean slotMissing = false;
try {
result = target.call();
} catch (IllegalArgumentException iae) {
slotMissing = true;
}
Assert.assertTrue(slotMissing);
}
Aggregations