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);
}
}
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;
}
}
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;
}
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);
}
Aggregations