Search in sources :

Example 56 with CallTarget

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();
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) Source(com.oracle.truffle.api.source.Source) TruffleObject(com.oracle.truffle.api.interop.TruffleObject)

Example 57 with CallTarget

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);
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) RootNode(com.oracle.truffle.api.nodes.RootNode) Node(com.oracle.truffle.api.nodes.Node)

Example 58 with CallTarget

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());
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) TruffleObject(com.oracle.truffle.api.interop.TruffleObject) Test(org.junit.Test)

Example 59 with CallTarget

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);
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget) TruffleObject(com.oracle.truffle.api.interop.TruffleObject)

Example 60 with CallTarget

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;
}
Also used : CallTarget(com.oracle.truffle.api.CallTarget)

Aggregations

CallTarget (com.oracle.truffle.api.CallTarget)128 Test (org.junit.Test)102 TestHelper.createCallTarget (com.oracle.truffle.api.dsl.test.TestHelper.createCallTarget)50 RootCallTarget (com.oracle.truffle.api.RootCallTarget)26 RootNode (com.oracle.truffle.api.nodes.RootNode)17 TruffleRuntime (com.oracle.truffle.api.TruffleRuntime)15 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)10 UnsupportedSpecializationException (com.oracle.truffle.api.dsl.UnsupportedSpecializationException)9 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)9 Node (com.oracle.truffle.api.nodes.Node)9 OptimizedCallTarget (org.graalvm.compiler.truffle.runtime.OptimizedCallTarget)9 TruffleContext (com.oracle.truffle.api.TruffleContext)6 LanguageContext (com.oracle.truffle.api.test.polyglot.LanguageSPITestLanguage.LanguageContext)6 Context (org.graalvm.polyglot.Context)6 Theory (org.junit.experimental.theories.Theory)6 TruffleException (com.oracle.truffle.api.TruffleException)5 UnknownIdentifierException (com.oracle.truffle.api.interop.UnknownIdentifierException)5 UnsupportedMessageException (com.oracle.truffle.api.interop.UnsupportedMessageException)5 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)5 Source (com.oracle.truffle.api.source.Source)5