@CompilerDirectives.TruffleBoundary private static void initializeMessageClass(String message) throws IllegalArgumentException { try { ClassLoader l = Message.class.getClassLoader(); if (l == null) { l = ClassLoader.getSystemClassLoader(); } Class.forName(message, false, l).newInstance(); } catch (Exception ex) { throw new IllegalArgumentException("Cannot find message for " + message, ex); } }
@TruffleBoundary private void doEnter() { SteppingStrategy steppingStrategy = strategyMap.get(Thread.currentThread()); if (steppingStrategy != null) { steppingStrategy.notifyCallEntry(); } }
/** * Delegate method for {@link DynamicObject#toString()}. * * @since 0.8 or earlier */ @TruffleBoundary public String toString(DynamicObject object) { return "DynamicObject<" + this.toString() + ">@" + Integer.toHexString(hashCode(object)); }
@TruffleBoundary public Object access(ArgumentsArrayObject argsArr, int index, Object value) { try { argsArr.args[index] = value; return value; } catch (IndexOutOfBoundsException ioob) { throw UnknownIdentifierException.raise(Integer.toString(index)); } } }
@TruffleBoundary public Object access(ArgumentsArrayObject argsArr, int index, Object value) { try { argsArr.args[index] = value; return value; } catch (IndexOutOfBoundsException ioob) { throw UnknownIdentifierException.raise(Integer.toString(index)); } } }
@Override @TruffleBoundary public boolean isDouble(FrameSlot slot) { return delegate.isDouble(slot); } }
@Override @TruffleBoundary public boolean isBoolean(FrameSlot slot) { return delegate.isBoolean(slot); }
@Override @TruffleBoundary public boolean isObject(FrameSlot slot) { return delegate.isObject(slot); }
@Override @TruffleBoundary public void setBoolean(FrameSlot slot, boolean value) { throw newReadonlyAssertionError(); }
@Override @TruffleBoundary public void setByte(FrameSlot slot, byte value) { throw newReadonlyAssertionError(); }
@TruffleBoundary private static ClassCastException newInvalidKeyTypeException(Type targetType) { String message = "Unsupported Map key type: " + targetType; return newClassCastException(message); }
/** @since 0.33 */ @TruffleBoundary public void invalidate(String message) { Assumption newAssumption = Truffle.getRuntime().createAssumption(name); Assumption oldAssumption = ASSUMPTION_UPDATER.getAndSet(this, newAssumption); oldAssumption.invalidate(message); }
@TruffleBoundary private void doReturn(MaterializedFrame frame, Object result) { SteppingStrategy steppingStrategy = strategyMap.get(Thread.currentThread()); if (steppingStrategy != null && steppingStrategy.isStopAfterCall()) { notifyCallback(this, frame, SuspendAnchor.AFTER, null, result, null); } }
@TruffleBoundary private void doStepAfter(MaterializedFrame frame, Object result) { SuspendAnchor anchor = SuspendAnchor.AFTER; SteppingStrategy steppingStrategy = getSteppingStrategy(Thread.currentThread()); if (steppingStrategy != null && steppingStrategy.isActiveOnStepTo(context, anchor)) { notifyCallback(this, frame, anchor, this, result, null); } }
@TruffleBoundary public Object access(JavaObject receiver, boolean includeInternal) { if (receiver.isNull()) { throw UnsupportedMessageException.raise(Message.KEYS); } String[] fields = TruffleOptions.AOT ? new String[0] : JavaInteropReflect.findUniquePublicMemberNames(receiver.getLookupClass(), receiver.isStaticClass(), includeInternal); return JavaObject.forObject(fields, receiver.languageContext); } }
@SuppressWarnings("unused") @TruffleBoundary @Specialization(guards = {"!receiver.isArray()", "!isList(receiver)"}) protected static Object notArray(JavaObject receiver, Number index) { throw UnsupportedMessageException.raise(Message.READ); }
@TruffleBoundary static RuntimeException invalidMapIdentifier(Object context, Object receiver, Type keyType, Type valueType, Object identifier) { if (identifier instanceof Number || identifier instanceof String) { throw newIllegalArgumentException( String.format("Invalid or unmodifiable value for identifier '%s' for Map<%s, %s> %s.", identifier, formatComponentType(keyType), formatComponentType(valueType), getValueInfo(context, receiver))); } else { throw newIllegalArgumentException( String.format("Illegal identifier type '%s' for Map<%s, %s> %s.", identifier == null ? "null" : identifier.getClass().getTypeName(), formatComponentType(keyType), formatComponentType(valueType), getValueInfo(context, receiver))); } }
@TruffleBoundary static RuntimeException listUnsupported(Object context, Object receiver, Type componentType, String operation) { String message = String.format("Unsupported operation %s for List<%s> %s.", operation, formatComponentType(componentType), getValueInfo(context, receiver)); throw newUnsupportedOperationException(message); }
@SuppressWarnings("unchecked") @TruffleBoundary @Specialization(guards = {"isMap(receiver)"}) protected Object doMapGeneric(JavaObject receiver, String name) { Map<String, Object> map = (Map<String, Object>) receiver.obj; if (!map.containsKey(name)) { throw UnknownIdentifierException.raise(name); } map.remove(name); return true; }
/** * Returns <code>true</code> if host access is generally allowed. If this method returns * <code>false</code> then {@link #lookupHostSymbol(String)} will always fail. * * @since 0.27 */ @TruffleBoundary public boolean isHostLookupAllowed() { return AccessAPI.engineAccess().isHostAccessAllowed(vmObject, this); }