use of flash.tools.debugger.expression.ValueExp in project intellij-plugins by JetBrains.
the class DebugCLI method shouldBreak.
/**
* Determines if the given BreakAction requests a halt given the file
* line and optionally a conditional to evaluate.'
*/
boolean shouldBreak(BreakAction a, int fileId, int line) {
boolean should = a.isEnabled();
ValueExp exp = a.getCondition();
if (// halt request fires true
should && exp != null && !m_requestHalt) {
// evaluate it then update our boolean
try {
EvaluationResult result = evalExpression(exp, false);
if (result != null)
should = ECMA.toBoolean(result.context.toValue(result.value));
} catch (NullPointerException npe) {
} catch (NumberFormatException nfe) {
}
}
return should;
}
use of flash.tools.debugger.expression.ValueExp in project intellij-plugins by JetBrains.
the class DebugCLI method doCondition.
/**
* Apply or remove conditions to a breakpoint.
*/
void doCondition() throws IOException {
try {
// must have a breakpoint number
int id = nextIntToken();
// get the breakpoint
int at = breakpointIndexOf(id);
BreakAction a = breakpointAt(at);
// no more parms means to clear it
if (hasMoreTokens()) {
// now just pull the commands as they come while not end
String line = restOfLine();
// build an expression and attach it to the breakpoint
ValueExp exp = parseExpression(line);
// warn about the assignment!
if (//$NON-NLS-1$
exp.containsAssignment() && !yesNoQuery(getLocalizationManager().getLocalizedTextString("askExpressionContainsAssignment")))
//$NON-NLS-1$
throw new IllegalAccessException("=");
a.setCondition(exp, line);
} else {
// clear it
a.clearCondition();
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("breakpointNumber", Integer.toString(id));
//$NON-NLS-1$
out(getLocalizationManager().getLocalizedTextString("breakpointNowUnconditional", args));
}
} catch (IllegalAccessException iae) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("breakpointNotChanged"));
} catch (IndexOutOfBoundsException iob) {
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("breakpointNumber", m_currentToken);
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("noBreakpointNumber", args));
} catch (NumberFormatException nfe) {
Map<String, Object> args = new HashMap<String, Object>();
//$NON-NLS-1$
args.put("token", m_currentToken);
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("badBreakpointNumber", args));
} catch (NullPointerException npe) {
//$NON-NLS-1$
err(getLocalizationManager().getLocalizedTextString("commandFailed"));
}
}
use of flash.tools.debugger.expression.ValueExp 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"));
}
}
Aggregations