fix the scoping problem: variables in an outer scope were not included in the stack
This commit is contained in:
@@ -477,8 +477,12 @@ public class DebugStackState extends StackState implements DebugRequestListener
|
|||||||
|
|
||||||
Vector variables = new Vector();
|
Vector variables = new Vector();
|
||||||
Hashtable variablesSeen = new Hashtable();
|
Hashtable variablesSeen = new Hashtable();
|
||||||
addVariables(variables, variablesSeen, index);
|
Proto p = calls[index].closure.p;
|
||||||
|
for (int i = index; i >= 0; i--) {
|
||||||
|
if (i == index || isInScope(p, calls[i])) {
|
||||||
|
addVariables(variables, variablesSeen, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
Variable[] result = new Variable[variables.size()];
|
Variable[] result = new Variable[variables.size()];
|
||||||
for (int i = 0; i < variables.size(); i++) {
|
for (int i = 0; i < variables.size(); i++) {
|
||||||
result[i] = (Variable) variables.elementAt(i);
|
result[i] = (Variable) variables.elementAt(i);
|
||||||
@@ -487,6 +491,19 @@ public class DebugStackState extends StackState implements DebugRequestListener
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isInScope(Proto p, CallInfo ci) {
|
||||||
|
Proto[] enclosingProtos = ci.closure.p.p;
|
||||||
|
boolean bFound = false;
|
||||||
|
for (int i = 0; enclosingProtos!= null && i < enclosingProtos.length; i++) {
|
||||||
|
if (enclosingProtos[i] == p) {
|
||||||
|
bFound = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bFound;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the visible globals to the current VM.
|
* Returns the visible globals to the current VM.
|
||||||
* @return the visible globals.
|
* @return the visible globals.
|
||||||
|
|||||||
Reference in New Issue
Block a user