Search in sources :

Example 1 with ExportMessage

use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.

the class RegexObject method invokeMember.

@ExportMessage
Object invokeMember(String member, Object[] args, @Cached ToLongNode toLongNode, @Cached InvokeCacheNode invokeCache) throws UnknownIdentifierException, ArityException, UnsupportedTypeException, UnsupportedMessageException {
    if (args.length != 2) {
        CompilerDirectives.transferToInterpreterAndInvalidate();
        throw ArityException.create(2, 2, args.length);
    }
    Object input = args[0];
    long fromIndex = toLongNode.execute(args[1]);
    if (fromIndex > Integer.MAX_VALUE) {
        return RegexResult.getNoMatchInstance();
    }
    return invokeCache.execute(member, this, input, (int) fromIndex, source.getEncoding());
}
Also used : TruffleObject(com.oracle.truffle.api.interop.TruffleObject) ExportMessage(com.oracle.truffle.api.library.ExportMessage)

Example 2 with ExportMessage

use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.

the class DefaultNodeExports method hasScope.

@TruffleBoundary
@ExportMessage
@SuppressWarnings("unused")
static boolean hasScope(Node node, Frame frame) {
    RootNode root = node.getRootNode();
    TruffleLanguage<?> language = InteropAccessor.NODES.getLanguage(root);
    return language != null && (node == root || InteropAccessor.ACCESSOR.instrumentSupport().isInstrumentable(node));
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) ExportMessage(com.oracle.truffle.api.library.ExportMessage) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 3 with ExportMessage

use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.

the class DefaultNodeExports method getScope.

@TruffleBoundary
@ExportMessage
@SuppressWarnings({ "unchecked", "unused" })
static Object getScope(Node node, Frame frame, boolean nodeEnter) throws UnsupportedMessageException {
    RootNode root = node.getRootNode();
    TruffleLanguage<?> language = InteropAccessor.NODES.getLanguage(root);
    if (language != null && (node == root || InteropAccessor.ACCESSOR.instrumentSupport().isInstrumentable(node))) {
        return createDefaultScope(root, frame, (Class<? extends TruffleLanguage<?>>) language.getClass());
    }
    throw UnsupportedMessageException.create();
}
Also used : RootNode(com.oracle.truffle.api.nodes.RootNode) ExportMessage(com.oracle.truffle.api.library.ExportMessage) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 4 with ExportMessage

use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.

the class PolyglotBindings method writeMember.

@ExportMessage
@TruffleBoundary
void writeMember(String member, Object value) {
    Value v = (languageContext != null) ? languageContext.asValue(value) : context.asValue(value);
    getBindings().put(member, v);
}
Also used : Value(org.graalvm.polyglot.Value) ExportMessage(com.oracle.truffle.api.library.ExportMessage) TruffleBoundary(com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)

Example 5 with ExportMessage

use of com.oracle.truffle.api.library.ExportMessage in project graal by oracle.

the class CommonPointerLibraries method isMemberReadable.

@ExportMessage
static boolean isMemberReadable(LLVMPointerImpl receiver, String ident, @Shared("isObject") @Cached ConditionProfile isObject) {
    if (isObject.profile(receiver.getExportType() instanceof LLVMInteropType.Clazz)) {
        LLVMInteropType.Clazz clazz = (LLVMInteropType.Clazz) receiver.getExportType();
        LLVMInteropType.StructMember member = clazz.findMember(ident);
        if (member == null) {
            LLVMInteropType.Method method = clazz.findMethod(ident);
            return method != null;
        }
        return member != null;
    } else if (isObject.profile(receiver.getExportType() instanceof LLVMInteropType.Struct)) {
        LLVMInteropType.Struct struct = (LLVMInteropType.Struct) receiver.getExportType();
        LLVMInteropType.StructMember member = struct.findMember(ident);
        return member != null;
    } else {
        return false;
    }
}
Also used : Clazz(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType.Clazz) Clazz(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType.Clazz) LLVMInteropType(com.oracle.truffle.llvm.runtime.interop.access.LLVMInteropType) ExportMessage(com.oracle.truffle.api.library.ExportMessage)

Aggregations

ExportMessage (com.oracle.truffle.api.library.ExportMessage)68 TruffleBoundary (com.oracle.truffle.api.CompilerDirectives.TruffleBoundary)24 Meta (com.oracle.truffle.espresso.meta.Meta)24 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)16 Method (com.oracle.truffle.espresso.impl.Method)13 ByteBuffer (java.nio.ByteBuffer)10 ByteOrder (java.nio.ByteOrder)10 Klass (com.oracle.truffle.espresso.impl.Klass)8 ObjectKlass (com.oracle.truffle.espresso.impl.ObjectKlass)8 StaticObject (com.oracle.truffle.espresso.runtime.StaticObject)8 Value (org.graalvm.polyglot.Value)8 ProxyObject (org.graalvm.polyglot.proxy.ProxyObject)8 ArityException (com.oracle.truffle.api.interop.ArityException)7 UnsupportedTypeException (com.oracle.truffle.api.interop.UnsupportedTypeException)7 ProxyNativeObject (org.graalvm.polyglot.proxy.ProxyNativeObject)7 ArrayKlass (com.oracle.truffle.espresso.impl.ArrayKlass)6 ReadOnlyBufferException (java.nio.ReadOnlyBufferException)5 InteropLibrary (com.oracle.truffle.api.interop.InteropLibrary)4 Field (com.oracle.truffle.espresso.impl.Field)4 ProxyHashMap (org.graalvm.polyglot.proxy.ProxyHashMap)4