use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class SuspendedEvent method isEvalRootStackFrame.
static boolean isEvalRootStackFrame(DebuggerSession session, FrameInstance instance) {
CallTarget target = instance.getCallTarget();
RootNode root = null;
if (target instanceof RootCallTarget) {
root = ((RootCallTarget) target).getRootNode();
}
if (root != null && session.getDebugger().getEnv().isEngineRoot(root)) {
return true;
}
return false;
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class ContextLookupTest method invalidLookup.
@Test
public void invalidLookup() throws Exception {
LanguageLookupContext context = new LanguageLookupContext(null);
PolyglotEngine vm = createBuilder().config(LanguageLookup.MIME_TYPE, "channel", context).build();
vm.getLanguages().get(LanguageLookup.MIME_TYPE).getGlobalObject();
try {
LanguageLookup.getContext();
fail();
} catch (IllegalStateException e) {
}
try {
LanguageLookup.getLanguage();
fail();
} catch (IllegalStateException e) {
}
RootNode root = new RootNode(context.language) {
@Override
public Object execute(VirtualFrame frame) {
return null;
}
};
try {
root.getCurrentContext(LanguageLookup.class);
fail();
} catch (IllegalStateException e) {
}
try {
// using an exposed context reference outside of PE does not work
context.language.sharedChannelRef.get();
fail();
} catch (IllegalStateException e) {
}
try {
// but you can create context references outside
context.language.getContextReference();
} catch (IllegalStateException e) {
}
try {
// creating a context reference in the constructor does not work
context.language.getContextReference().get();
fail();
} catch (IllegalStateException e) {
// illegal state expected. context not yet initialized
}
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class JavaInterop method convertToJavaObject.
@CompilerDirectives.TruffleBoundary
@SuppressWarnings("unchecked")
private static <T> T convertToJavaObject(Class<T> type, TruffleObject foreignObject) {
RootNode root = new TemporaryConvertRoot(ToJavaNode.create(), foreignObject, type);
Object convertedValue = Truffle.getRuntime().createCallTarget(root).call();
return (T) convertedValue;
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class ProxySPITestLanguage method parse.
@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
Object result = "null result";
if (runinside != null) {
try {
result = runinside.apply(getContext().env);
} finally {
runinside = null;
}
}
if (result == null) {
result = "null result";
}
final Object finalResult = result;
return Truffle.getRuntime().createCallTarget(new RootNode(this) {
@Override
public Object execute(VirtualFrame frame) {
return finalResult;
}
});
}
use of com.oracle.truffle.api.nodes.RootNode in project graal by oracle.
the class ContextAPITestLanguage method parse.
@Override
protected CallTarget parse(ParsingRequest request) throws Exception {
Object result = "null result";
if (runinside != null) {
try {
result = runinside.apply(getContext().env);
} finally {
runinside = null;
}
}
if (result == null) {
result = "null result";
}
final Object finalResult = result;
return Truffle.getRuntime().createCallTarget(new RootNode(this) {
@Override
public Object execute(VirtualFrame frame) {
return finalResult;
}
});
}
Aggregations