use of flash.tools.debugger.Variable in project intellij-plugins by JetBrains.
the class DebugCLI method dumpTree.
/**
* Traverse the given variables dumping any Movieclips we find that
* contain a member called 'member'
* @throws NotConnectedException
* @throws NoResponseException
* @throws NotSuspendedException
*/
void dumpTree(Map tree, List e, String name, Value result, String member) throws NotSuspendedException, NoResponseException, NotConnectedException {
// name for this variable
if (name == null)
//$NON-NLS-1$
name = "";
// have we seen it already
if (tree.containsKey(result))
return;
// place it
tree.put(result, name);
// first iterate over our members looking for 'member'
Value proto = result;
boolean done = false;
while (!done && proto != null) {
Variable[] members = proto.getMembers(m_session);
proto = null;
// see if we find one called 'member'
for (int i = 0; i < members.length; i++) {
Variable m = members[i];
String memName = m.getName();
if (memName.equals(member) && !tree.containsKey(m)) {
e.add(name);
e.add(result);
e.add(m);
//$NON-NLS-1$
tree.put(m, name + "." + memName);
done = true;
} else if (//$NON-NLS-1$
memName.equals("__proto__"))
proto = members[i].getValue();
}
}
// now traverse other mcs recursively
done = false;
proto = result;
while (!done && proto != null) {
Variable[] members = proto.getMembers(m_session);
proto = null;
// see if we find an mc
for (int i = 0; i < members.length; i++) {
Variable m = members[i];
String memName = m.getName();
// if our type is NOT object or movieclip then we are done
if (m.getValue().getType() != VariableType.OBJECT && m.getValue().getType() != VariableType.MOVIECLIP)
;
else if (m.getValue().getId() != Value.UNKNOWN_ID)
dumpTree(tree, e, name, m.getValue(), member);
else if (//$NON-NLS-1$
memName.equals("__proto__")) {
proto = m.getValue();
// name = name + ".__proto__";
}
}
}
}
use of flash.tools.debugger.Variable in project intellij-plugins by JetBrains.
the class DebugCLI method doInfoVariables.
void doInfoVariables() throws PlayerDebugException {
waitTilHalted();
// dump a set of locals
StringBuilder sb = new StringBuilder();
// use our expression cache formatting routine
try {
Variable[] vars = m_session.getVariableList();
for (int i = 0; i < vars.length; i++) {
Variable v = vars[i];
// all non-local and non-arg variables
if (!v.isAttributeSet(VariableAttribute.IS_LOCAL) && !v.isAttributeSet(VariableAttribute.IS_ARGUMENT)) {
ExpressionCache.appendVariable(sb, vars[i]);
sb.append(m_newline);
}
}
} catch (NullPointerException npe) {
//$NON-NLS-1$
sb.append(getLocalizationManager().getLocalizedTextString("noVariables"));
}
out(sb.toString());
}
use of flash.tools.debugger.Variable in project intellij-plugins by JetBrains.
the class DebugCLI method doPrint.
void doPrint() throws NotConnectedException {
// waitTilHalted();
try {
Object result = null;
boolean isLookupMembers = false;
if (!hasMoreTokens()) {
try {
// attempt to get the last result
//$NON-NLS-1$
result = m_exprCache.get("$");
} catch (ArrayIndexOutOfBoundsException aib) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("commandHistoryIsEmpty"));
throw new NullPointerException();
}
} else {
// pull the rest of the line
String s = restOfLine();
// first parse it, then attempt to evaluate the expression
ValueExp expr = parseExpression(s);
// make sure no assignment
if (expr.containsAssignment())
throw new IllegalAccessException();
result = evalExpression(expr).value;
isLookupMembers = expr.isLookupMembers();
}
/* it worked, add it to the list */
int which = m_exprCache.add(result);
/* dump the output */
StringBuilder sb = new StringBuilder();
sb.append('$');
sb.append(which);
//$NON-NLS-1$
sb.append(" = ");
if (result instanceof Variable)
result = ((Variable) result).getValue();
if (result instanceof InternalProperty)
sb.append(((InternalProperty) result).valueOf());
else if (isLookupMembers)
sb.append(result);
else
ExpressionCache.appendVariableValue(sb, result);
out(sb.toString());
m_repeatLine = m_currentLine;
} catch (ArrayIndexOutOfBoundsException aio) {
// $n not in range 0..size
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("number", aio.getMessage());
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("historyHasNotReached", args));
} catch (IllegalAccessException iae) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("noSideEffectsAllowed"));
} catch (NoSuchVariableException nsv) {
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("variable", nsv.getMessage());
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("variableUnknown", args));
} catch (NullPointerException npe) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("couldNotEvaluate"));
}
}
use of flash.tools.debugger.Variable in project intellij-plugins by JetBrains.
the class DebugCLI method doInfoLocals.
void doInfoLocals() throws PlayerDebugException {
waitTilHalted();
// dump a set of locals
StringBuilder sb = new StringBuilder();
// use our expression cache formatting routine
try {
// get the variables from the requested frame
int num = propertyGet(DISPLAY_FRAME_NUMBER);
Frame[] ar = m_session.getFrames();
Frame ctx = ar[num];
Variable[] vars = ctx.getLocals(m_session);
for (int i = 0; i < vars.length; i++) {
Variable v = vars[i];
// see if variable is local
if (v.isAttributeSet(VariableAttribute.IS_LOCAL)) {
ExpressionCache.appendVariable(sb, v);
sb.append(m_newline);
}
}
} catch (NullPointerException npe) {
//$NON-NLS-1$
sb.append(getLocalizationManager().getLocalizedTextString("noLocals"));
} catch (ArrayIndexOutOfBoundsException aix) {
//$NON-NLS-1$
sb.append(getLocalizationManager().getLocalizedTextString("notInValidFrame"));
}
out(sb.toString());
}
Aggregations