/** * Returns a debug value that presents itself as seen by the provided language. The language * affects the output of {@link #as(java.lang.Class)}, {@link #getMetaObject()} and * {@link #getSourceLocation()}. Properties, array elements and other attributes are not * affected by a language. The {@link #getOriginalLanguage() original language} of the returned * value remains the same as of this value. * * @param language a language to get the value representation of * @return the value as represented in the language * @since 0.27 */ public final DebugValue asInLanguage(LanguageInfo language) { if (preferredLanguage == language) { return this; } return createAsInLanguage(language); }
/** * 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); }
final LanguageInfo resolveLanguage() { LanguageInfo languageInfo; if (preferredLanguage != null) { languageInfo = preferredLanguage; } else if (getScope() != null && getScope().getLanguage() != null) { languageInfo = getScope().getLanguage(); } else { languageInfo = getOriginalLanguage(); } return languageInfo; }
/** * 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); } }
/** * Returns <code>true</code> if this value represents an array, <code>false</code> otherwise. * * @throws DebugException when guest language code throws an exception * @since 0.19 */ public final boolean isArray() throws DebugException { if (!isReadable()) { return false; } Object value = get(); if (value instanceof TruffleObject) { TruffleObject to = (TruffleObject) value; return ObjectStructures.isArray(getDebugger().getMessageNodes(), to); } else { return false; } }
@Override public void set(DebugValue expression) { value = expression.get(); }
private ValuePropertiesCollection getVariables() { verifyValidState(); if (variables == null) { Object variablesObj = scope.getVariables(); variables = DebugValue.getProperties(variablesObj, debugger, getLanguage(), this); } return variables; }
String name = nextVar.getName(); if (!names.contains(name)) { names.add(name);
/** * Returns <code>true</code> if this value represents an array, <code>false</code> otherwise. * * @since 0.19 */ public final boolean isArray() { if (!isReadable()) { return false; } Object value = get(); if (value instanceof TruffleObject) { TruffleObject to = (TruffleObject) value; return ObjectStructures.isArray(getDebugger().getMessageNodes(), to); } else { return false; } }
@Override public DebugValue set(int index, DebugValue value) { DebugValue old = get(index); list.set(index, value.get()); return old; }
final LanguageInfo resolveLanguage() { LanguageInfo languageInfo; if (preferredLanguage != null) { languageInfo = preferredLanguage; } else if (getScope() != null && getScope().getLanguage() != null) { languageInfo = getScope().getLanguage(); } else { languageInfo = getOriginalLanguage(); } return languageInfo; }
private ValuePropertiesCollection getVariables() { verifyValidState(); try { if (variables == null) { Object variablesObj = scope.getVariables(); variables = DebugValue.getProperties(variablesObj, session, getLanguage(), this); } } catch (ThreadDeath td) { throw td; } catch (Throwable ex) { throw new DebugException(session, ex, language, null, true, null); } return variables; }
String name = nextVar.getName(); if (!names.contains(name)) { names.add(name);
/** * 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; } }
/** * Get the original language that created the value, if any. This method will return * <code>null</code> for values representing a primitive value, or objects that are not * associated with any language. * * @return the language, or <code>null</code> when no language can be identified as the creator * of the value. * @throws DebugException when guest language code throws an exception * @since 0.27 */ public final LanguageInfo getOriginalLanguage() throws DebugException { if (!isReadable()) { return null; } Object obj = get(); if (obj == null) { return null; } return getDebugger().getEnv().findLanguage(obj); }
@Override public void set(DebugValue value) { checkValid(); property.setValue(value.get()); }
/** * Get arguments of this scope. If this scope is a {@link #isFunctionScope() function} scope, * function arguments are returned. * <p> * This method is not thread-safe and will throw an {@link IllegalStateException} if called on * another thread than it was created with. * * @return an iterable of arguments, or <code>null</code> when this scope does not have a * concept of arguments. * @since 0.26 */ public Iterable<DebugValue> getArguments() { verifyValidState(); Object argumentsObj = scope.getArguments(); Iterable<DebugValue> arguments = null; if (argumentsObj != null && argumentsObj instanceof TruffleObject) { TruffleObject argsTO = (TruffleObject) argumentsObj; arguments = DebugValue.getProperties(argumentsObj, debugger, getLanguage(), this); if (arguments == null && ObjectStructures.isArray(debugger.getMessageNodes(), argsTO)) { List<Object> array = ObjectStructures.asList(debugger.getMessageNodes(), argsTO); arguments = new ValueInteropList(debugger, getLanguage(), array); } } return arguments; }
/** * Returns a debug value that presents itself as seen by the provided language. The language * affects the output of {@link #as(java.lang.Class)}, {@link #getMetaObject()} and * {@link #getSourceLocation()}. Properties, array elements and other attributes are not * affected by a language. The {@link #getOriginalLanguage() original language} of the returned * value remains the same as of this value. * * @param language a language to get the value representation of * @return the value as represented in the language * @since 0.27 */ public final DebugValue asInLanguage(LanguageInfo language) { if (preferredLanguage == language) { return this; } return createAsInLanguage(language); }