use of com.oracle.truffle.tools.chromeinspector.types.Scope in project graal by oracle.
the class TruffleDebugger method createScope.
private Scope createScope(String scopeType, DebugScope dscope) {
RemoteObject scopeVars = new RemoteObject(dscope);
context.getRemoteObjectsHandler().register(scopeVars);
return new Scope(scopeType, scopeVars, dscope.getName(), null, null);
}
use of com.oracle.truffle.tools.chromeinspector.types.Scope in project graal by oracle.
the class TruffleDebugger method createCallFrames.
private CallFrame[] createCallFrames(Iterable<DebugStackFrame> frames) {
List<CallFrame> cfs = new ArrayList<>();
int depth = 0;
for (DebugStackFrame frame : frames) {
SourceSection sourceSection = frame.getSourceSection();
if (sourceSection == null) {
continue;
}
if (frame.isInternal()) {
continue;
}
Source source = sourceSection.getSource();
if (source.isInternal()) {
// should not be, double-check
continue;
}
slh.assureLoaded(source);
Script script = slh.getScript(slh.getScriptId(source));
List<Scope> scopes = new ArrayList<>();
DebugScope dscope;
try {
dscope = frame.getScope();
} catch (Exception ex) {
PrintWriter err = context.getErr();
if (err != null) {
err.println("getScope() has caused " + ex);
ex.printStackTrace(err);
}
dscope = null;
}
String scopeType = "block";
boolean wasFunction = false;
SourceSection functionSourceSection = null;
while (dscope != null) {
if (wasFunction) {
scopeType = "closure";
} else if (dscope.isFunctionScope()) {
scopeType = "local";
functionSourceSection = dscope.getSourceSection();
wasFunction = true;
}
if (dscope.isFunctionScope() || dscope.getDeclaredValues().iterator().hasNext()) {
// provide only scopes that have some variables
scopes.add(createScope(scopeType, dscope));
}
dscope = getParent(dscope);
}
try {
dscope = ds.getTopScope(source.getLanguage());
} catch (Exception ex) {
PrintWriter err = context.getErr();
if (err != null) {
err.println("getTopScope() has caused " + ex);
ex.printStackTrace(err);
}
}
while (dscope != null) {
if (dscope.getDeclaredValues().iterator().hasNext()) {
// provide only scopes that have some variables
scopes.add(createScope("global", dscope));
}
dscope = getParent(dscope);
}
CallFrame cf = new CallFrame(frame, depth++, script, sourceSection, functionSourceSection, null, scopes.toArray(new Scope[scopes.size()]));
cfs.add(cf);
}
return cfs.toArray(new CallFrame[cfs.size()]);
}
Aggregations