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());
}
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));
}
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();
}
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);
}
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;
}
}
Aggregations