Search in sources :

Example 11 with LanguageInfo

use of com.oracle.truffle.api.nodes.LanguageInfo in project graal by oracle.

the class DebugContext method evaluate.

/**
 * Evaluate the given code in this context.
 *
 * @param code the code to evaluate
 * @param languageId the language to evaluate the code in
 * @return result of the evaluation
 * @since 0.30
 */
public DebugValue evaluate(String code, String languageId) {
    assert code != null;
    Object prevContext = context.enter();
    try {
        Debugger debugger = executionLifecycle.getDebugger();
        CallTarget target = debugger.getEnv().parse(Source.newBuilder(code).language(languageId).name("eval").build());
        Object result = target.call();
        LanguageInfo languageInfo = debugger.getEnv().getLanguages().get(languageId);
        return new DebugValue.HeapValue(debugger, languageInfo, null, result);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    } finally {
        context.leave(prevContext);
    }
}
Also used : LanguageInfo(com.oracle.truffle.api.nodes.LanguageInfo) CallTarget(com.oracle.truffle.api.CallTarget) IOException(java.io.IOException)

Example 12 with LanguageInfo

use of com.oracle.truffle.api.nodes.LanguageInfo in project graal by oracle.

the class DebugValue method getSourceLocation.

/**
 * 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;
    }
}
Also used : TruffleInstrument(com.oracle.truffle.api.instrumentation.TruffleInstrument) LanguageInfo(com.oracle.truffle.api.nodes.LanguageInfo) TruffleObject(com.oracle.truffle.api.interop.TruffleObject)

Example 13 with LanguageInfo

use of com.oracle.truffle.api.nodes.LanguageInfo in project graal by oracle.

the class DebugValue method getMetaObject.

/**
 * 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;
}
Also used : TruffleInstrument(com.oracle.truffle.api.instrumentation.TruffleInstrument) LanguageInfo(com.oracle.truffle.api.nodes.LanguageInfo) TruffleObject(com.oracle.truffle.api.interop.TruffleObject)

Example 14 with LanguageInfo

use of com.oracle.truffle.api.nodes.LanguageInfo in project graal by oracle.

the class DebuggerSessionSnippets method getTopScope.

/**
 * Returns a language top scope. The top scopes have global validity and unlike
 * {@link DebugStackFrame#getScope()} have no relation to the suspended location.
 *
 * @since 0.30
 */
public DebugScope getTopScope(String languageId) {
    LanguageInfo info = debugger.getEnv().getLanguages().get(languageId);
    if (info == null) {
        return null;
    }
    Iterable<Scope> scopes = debugger.getEnv().findTopScopes(languageId);
    Iterator<Scope> it = scopes.iterator();
    if (!it.hasNext()) {
        return null;
    }
    return new DebugScope(it.next(), it, debugger, info);
}
Also used : LanguageInfo(com.oracle.truffle.api.nodes.LanguageInfo) Scope(com.oracle.truffle.api.Scope)

Aggregations

LanguageInfo (com.oracle.truffle.api.nodes.LanguageInfo)14 RootNode (com.oracle.truffle.api.nodes.RootNode)6 TruffleLanguage (com.oracle.truffle.api.TruffleLanguage)3 TruffleInstrument (com.oracle.truffle.api.instrumentation.TruffleInstrument)3 TruffleObject (com.oracle.truffle.api.interop.TruffleObject)3 Node (com.oracle.truffle.api.nodes.Node)3 Test (org.junit.Test)3 Env (com.oracle.truffle.api.TruffleLanguage.Env)2 DebugValue (com.oracle.truffle.api.debug.DebugValue)2 IOException (java.io.IOException)2 Source (org.graalvm.polyglot.Source)2 CallTarget (com.oracle.truffle.api.CallTarget)1 InstrumentInfo (com.oracle.truffle.api.InstrumentInfo)1 Scope (com.oracle.truffle.api.Scope)1 Breakpoint (com.oracle.truffle.api.debug.Breakpoint)1 DebugStackFrame (com.oracle.truffle.api.debug.DebugStackFrame)1 HeapValue (com.oracle.truffle.api.debug.DebugValue.HeapValue)1 DebuggerSession (com.oracle.truffle.api.debug.DebuggerSession)1 SuspendedEvent (com.oracle.truffle.api.debug.SuspendedEvent)1 VirtualFrame (com.oracle.truffle.api.frame.VirtualFrame)1