use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class LoadNFILibraryTest method eval.
private static TruffleObject eval(String format, Object... args) {
Source source = Source.newBuilder(String.format(format, args)).name("LoadLibraryTest").mimeType("application/x-native").build();
CallTarget target = runWithPolyglot.getTruffleTestEnv().parse(source);
return (TruffleObject) target.call();
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class JavaInteropTest method message.
static Object message(final Message m, TruffleObject receiver, Object... arr) {
Node n = m.createNode();
CallTarget callTarget = Truffle.getRuntime().createCallTarget(new TemporaryRoot(n, receiver));
return callTarget.call(arr);
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class JavaInteropNullTest method testNullArg.
@Test
public void testNullArg() {
TruffleObject callback = JavaInterop.asTruffleFunction(StringCallback.class, (obj) -> {
Assert.assertNull(obj);
});
CallTarget target = Truffle.getRuntime().createCallTarget(new TestRootNode(callback));
target.call(new TestNull());
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class PolyglotEngine method evalImpl.
private Value evalImpl(final Language l, final Source source) {
assert checkThread();
ComputeInExecutor<Object> compute = new ComputeInExecutor<Object>(executor()) {
@Override
protected Object compute() {
CallTarget evalTarget = l.parserCache.get(source);
if (evalTarget == null) {
evalTarget = PolyglotRootNode.createEval(PolyglotEngine.this, l, source);
l.parserCache.put(source, evalTarget);
}
return evalTarget.call();
}
};
compute.perform();
return new ExecutorValue(l, compute);
}
use of com.oracle.truffle.api.CallTarget in project graal by oracle.
the class PolyglotLanguageContext method parseCached.
CallTarget parseCached(com.oracle.truffle.api.source.Source source) throws AssertionError {
CallTarget target = sourceCache.get(source);
if (target == null) {
ensureInitialized(null);
target = LANGUAGE.parse(requireEnv(), source, null);
if (target == null) {
throw new AssertionError(String.format("Parsing resulted in a null CallTarget for %s.", source));
}
sourceCache.put(source, target);
}
return target;
}
Aggregations