/** * Uses the provided language to find a meta-object of a value, if any. The meta-object * represents a description of the object, reveals it's kind and it's features. Some * information that a meta-object might define includes the base object's type, interface, * class, methods, attributes, etc. When no meta-object is known, <code>null</code> is * returned. For the best results, use the {@link #findLanguage(java.lang.Object) value's * language}, if any. * * @param language a language * @param value a value to find the meta-object of, must be an interop type (i.e. either * implementing TruffleObject or be a primitive value) * @return the meta-object, or <code>null</code> * @see #findLanguage(java.lang.Object) * @since 0.27 */ public Object findMetaObject(LanguageInfo language, Object value) { AccessorInstrumentHandler.interopAccess().checkInteropType(value); final TruffleLanguage.Env env = AccessorInstrumentHandler.engineAccess().getEnvForInstrument(language); return AccessorInstrumentHandler.langAccess().findMetaObject(env, value); }
/** * Uses the provided language to find a meta-object of a value, if any. The meta-object * represents a description of the object, reveals it's kind and it's features. Some * information that a meta-object might define includes the base object's type, interface, * class, methods, attributes, etc. When no meta-object is known, <code>null</code> is * returned. For the best results, use the {@link #findLanguage(java.lang.Object) value's * language}, if any. * * @param language a language * @param value a value to find the meta-object of, must be an interop type (i.e. either * implementing TruffleObject or be a primitive value) * @return the meta-object, or <code>null</code> * @see #findLanguage(java.lang.Object) * @since 0.27 */ public Object findMetaObject(LanguageInfo language, Object value) { AccessorInstrumentHandler.interopAccess().checkInteropType(value); final TruffleLanguage.Env env = AccessorInstrumentHandler.engineAccess().getEnvForInstrument(language); Object metaObject = AccessorInstrumentHandler.langAccess().findMetaObject(env, value); assert checkNullOrInterop(metaObject); return metaObject; }
/** * Uses the provided language to find a source location where a value is declared, if any. * For the best results, use the {@link #findLanguage(java.lang.Object) value's language}, * if any. * * @param language a language * @param value a value to get the source location for, must be an interop type (i.e. either * implementing TruffleObject or be a primitive value) * @return a source location of the object, or <code>null</code> * @see #findLanguage(java.lang.Object) * @since 0.27 */ public SourceSection findSourceLocation(LanguageInfo language, Object value) { AccessorInstrumentHandler.interopAccess().checkInteropType(value); final TruffleLanguage.Env env = AccessorInstrumentHandler.engineAccess().getEnvForInstrument(language); return AccessorInstrumentHandler.langAccess().findSourceLocation(env, value); }
/** * Uses the provided language to print a string representation of this value. The behavior * of this method is undefined if a type unknown to the language is passed as a value. * * @param language a language * @param value a known value of that language, must be an interop type (i.e. either * implementing TruffleObject or be a primitive value) * @return a human readable string representation of the value. * @see #findLanguage(java.lang.Object) * @since 0.27 */ public String toString(LanguageInfo language, Object value) { AccessorInstrumentHandler.interopAccess().checkInteropType(value); final TruffleLanguage.Env env = AccessorInstrumentHandler.engineAccess().getEnvForInstrument(language); return AccessorInstrumentHandler.langAccess().toStringIfVisible(env, value, false); }
/** * Uses the provided language to find a source location where a value is declared, if any. * For the best results, use the {@link #findLanguage(java.lang.Object) value's language}, * if any. * * @param language a language * @param value a value to get the source location for, must be an interop type (i.e. either * implementing TruffleObject or be a primitive value) * @return a source location of the object, or <code>null</code> * @see #findLanguage(java.lang.Object) * @since 0.27 */ public SourceSection findSourceLocation(LanguageInfo language, Object value) { AccessorInstrumentHandler.interopAccess().checkInteropType(value); final TruffleLanguage.Env env = AccessorInstrumentHandler.engineAccess().getEnvForInstrument(language); return AccessorInstrumentHandler.langAccess().findSourceLocation(env, value); }
/** * Uses the provided language to print a string representation of this value. The behavior * of this method is undefined if a type unknown to the language is passed as a value. * * @param language a language * @param value a known value of that language, must be an interop type (i.e. either * implementing TruffleObject or be a primitive value) * @return a human readable string representation of the value. * @see #findLanguage(java.lang.Object) * @since 0.27 */ public String toString(LanguageInfo language, Object value) { AccessorInstrumentHandler.interopAccess().checkInteropType(value); final TruffleLanguage.Env env = AccessorInstrumentHandler.engineAccess().getEnvForInstrument(language); return AccessorInstrumentHandler.langAccess().toStringIfVisible(env, value, false); }
private boolean isNullOrInteropValue(Object result) { if (!(context.getInstrumentedNode() instanceof InstrumentableNode)) { // legacy support return true; } if (result == null) { return true; } AccessorInstrumentHandler.interopAccess().checkInteropType(result); return true; }
private boolean isNullOrInteropValue(Object result) { if (!(context.getInstrumentedNode() instanceof InstrumentableNode)) { // legacy support return true; } if (result == null) { return true; } AccessorInstrumentHandler.interopAccess().checkInteropType(result); return true; }
private boolean checkNullOrInterop(Object obj) { if (obj == null) { return true; } AccessorInstrumentHandler.interopAccess().checkInteropType(obj); return true; } }
private static boolean checkNullOrInterop(Object obj) { if (obj == null) { return true; } AccessorInstrumentHandler.interopAccess().checkInteropType(obj); return true; }