/** * Provides properties representing an internal structure of this value. The returned collection * is not thread-safe. If the value is not {@link #isReadable() readable} then an * {@link IllegalStateException} is thrown. * * @return a collection of property values, or </code>null</code> when the value does not have * any concept of properties. * @since 0.19 */ public final Collection<DebugValue> getProperties() { if (!isReadable()) { throw new IllegalStateException("Value is not readable"); } Object value = get(); return getProperties(value, getDebugger(), resolveLanguage(), null); }
/** * Provides properties representing an internal structure of this value. The returned collection * is not thread-safe. If the value is not {@link #isReadable() readable} then an * {@link IllegalStateException} is thrown. * * @return a collection of property values, or </code>null</code> when the value does not have * any concept of properties. * @throws DebugException when guest language code throws an exception * @throws IllegalStateException if the value is not {@link #isReadable() readable} * @since 0.19 */ public final Collection<DebugValue> getProperties() throws DebugException { if (!isReadable()) { throw new IllegalStateException("Value is not readable"); } Object value = get(); try { return getProperties(value, getSession(), resolveLanguage(), null); } catch (ThreadDeath td) { throw td; } catch (Throwable ex) { throw new DebugException(getSession(), ex, resolveLanguage(), null, true, null); } }
/** * Get a source location where this value is declared, if any. * * @return a source location of the object, or <code>null</code> * @since 0.22 */ public final SourceSection getSourceLocation() { if (!isReadable()) { return null; } Object obj = get(); if (obj == null) { return null; } TruffleInstrument.Env env = getDebugger().getEnv(); LanguageInfo languageInfo = resolveLanguage(); if (languageInfo != null) { return env.findSourceLocation(languageInfo, obj); } else { return null; } }
/** * Returns <code>true</code> if this value can be executed (represents a guest language * function), else <code>false</code>. * * @since 1.0 */ public final boolean canExecute() throws DebugException { Object value = get(); if (value instanceof TruffleObject) { TruffleObject to = (TruffleObject) value; try { return ObjectStructures.canExecute(getDebugger().getMessageNodes(), to); } catch (ThreadDeath td) { throw td; } catch (Throwable ex) { throw new DebugException(getSession(), ex, resolveLanguage(), null, true, null); } } else { return false; } }
} else { Map.Entry<Object, Object> entry = new ObjectStructures.TruffleEntry(getDebugger().getMessageNodes(), object, name); return new DebugValue.PropertyValue(getSession(), resolveLanguage(), keyInfo, entry, null); throw new DebugException(getSession(), ex, resolveLanguage(), null, true, null);
/** * Provides array elements when this value represents an array. To test if this value represents * an array, check {@link #isArray()}. * * @return a list of array elements, or <code>null</code> when the value does not represent an * array. * @throws DebugException when guest language code throws an exception * @since 0.19 */ public final List<DebugValue> getArray() throws DebugException { if (!isReadable()) { return null; } List<DebugValue> arrayList = null; Object value = get(); if (value instanceof TruffleObject) { TruffleObject to = (TruffleObject) value; List<Object> array = ObjectStructures.asList(getDebugger().getMessageNodes(), to); if (array != null) { arrayList = new ValueInteropList(getSession(), resolveLanguage(), array); } } return arrayList; }
/** * Provides array elements when this value represents an array. To test if this value represents * an array, check {@link #isArray()}. * * @return a list of array elements, or <code>null</code> when the value does not represent an * array. * @since 0.19 */ public final List<DebugValue> getArray() { if (!isReadable()) { return null; } List<DebugValue> arrayList = null; Object value = get(); if (value instanceof TruffleObject) { TruffleObject to = (TruffleObject) value; List<Object> array = ObjectStructures.asList(getDebugger().getMessageNodes(), to); if (array != null) { arrayList = new ValueInteropList(getDebugger(), resolveLanguage(), array); } } return arrayList; }
/** * Get a meta-object of this value, if any. The meta-object represents a description of the * value, reveals it's kind and it's features. * * @return a value representing the meta-object, or <code>null</code> * @since 0.22 */ public final DebugValue getMetaObject() { if (!isReadable()) { return null; } Object obj = get(); if (obj == null) { return null; } TruffleInstrument.Env env = getDebugger().getEnv(); LanguageInfo languageInfo = resolveLanguage(); if (languageInfo != null) { obj = env.findMetaObject(languageInfo, obj); if (obj != null) { return new HeapValue(getDebugger(), languageInfo, null, obj); } } return null; }
/** * Get a source location where this value is declared, if any. * * @return a source location of the object, or <code>null</code> * @throws DebugException when guest language code throws an exception * @since 0.22 */ public final SourceSection getSourceLocation() throws DebugException { if (!isReadable()) { return null; } Object obj = get(); if (obj == null) { return null; } TruffleInstrument.Env env = getDebugger().getEnv(); LanguageInfo languageInfo = resolveLanguage(); if (languageInfo != null) { try { SourceSection location = env.findSourceLocation(languageInfo, obj); return getSession().resolveSection(location); } catch (ThreadDeath td) { throw td; } catch (Throwable ex) { throw new DebugException(getSession(), ex, languageInfo, null, true, null); } } else { return null; } }
LanguageInfo languageInfo = resolveLanguage(); if (languageInfo != null) { try {