{
rhs = (DebuggerValue) node.rhs.evaluate(cx, this);
}
Context eeContext = eeContext(cx);
Session session = eeContext.getSession();
switch (node.op)
{
case Tokens.MULT_TOKEN:
{
// ECMA 11.5
double d1 = ECMA.toNumber(session, eeContext.toValue(lhs.debuggerValue));
double d2 = ECMA.toNumber(session, eeContext.toValue(rhs.debuggerValue));
return new DebuggerValue(new Double(d1 * d2));
}
case Tokens.DIV_TOKEN:
{
// ECMA 11.5
double d1 = ECMA.toNumber(session, eeContext.toValue(lhs.debuggerValue));
double d2 = ECMA.toNumber(session, eeContext.toValue(rhs.debuggerValue));
return new DebuggerValue(new Double(d1 / d2));
}
case Tokens.MODULUS_TOKEN:
{
// ECMA 11.5
double d1 = ECMA.toNumber(session, eeContext.toValue(lhs.debuggerValue));
double d2 = ECMA.toNumber(session, eeContext.toValue(rhs.debuggerValue));
return new DebuggerValue(new Double(d1 % d2));
}
case Tokens.PLUS_TOKEN:
{
// E4X 11.4.1 and ECMA 11.6.1
flash.tools.debugger.Value v1 = eeContext.toValue(lhs.debuggerValue);
flash.tools.debugger.Value v2 = eeContext.toValue(rhs.debuggerValue);
boolean isXMLConcat = false;
if (v1.getType() == VariableType.OBJECT && v2.getType() == VariableType.OBJECT)
{
String type1 = v1.getTypeName();
String type2 = v2.getTypeName();
int at;
at = type1.indexOf('@');
if (at != -1)
type1 = type1.substring(0, at);
at = type2.indexOf('@');
if (at != -1)
type2 = type2.substring(0, at);
if (type1.equals("XML") || type1.equals("XMLList")) //$NON-NLS-1$ //$NON-NLS-2$
if (type2.equals("XML") || type2.equals("XMLList")) //$NON-NLS-1$ //$NON-NLS-2$
isXMLConcat = true;
}
if (isXMLConcat)
{
try
{
flash.tools.debugger.Value xml1 = session.callFunction(v1, "toXMLString", new flash.tools.debugger.Value[0]); //$NON-NLS-1$
flash.tools.debugger.Value xml2 = session.callFunction(v2, "toXMLString", new flash.tools.debugger.Value[0]); //$NON-NLS-1$
String allXML = xml1.getValueAsString() + xml2.getValueAsString();
flash.tools.debugger.Value allXMLValue = DValue.forPrimitive(allXML);
flash.tools.debugger.Value retval = session.callConstructor("XMLList", new flash.tools.debugger.Value[] { allXMLValue }); //$NON-NLS-1$
return new DebuggerValue(retval);
}
catch (PlayerDebugException e)
{
throw new ExpressionEvaluatorException(e);
}
}
else
{
v1 = ECMA.toPrimitive(session, v1, null);
v2 = ECMA.toPrimitive(session, v2, null);
if (v1.getType() == VariableType.STRING || v2.getType() == VariableType.STRING)
{
return new DebuggerValue(ECMA.toString(session, v1) + ECMA.toString(session, v2));
}
else
{
return new DebuggerValue(new Double(ECMA.toNumber(session, v1) + ECMA.toNumber(session, v2)));
}
}
}
case Tokens.MINUS_TOKEN:
{
// ECMA 11.6.2
double d1 = ECMA.toNumber(session, eeContext.toValue(lhs.debuggerValue));
double d2 = ECMA.toNumber(session, eeContext.toValue(rhs.debuggerValue));
return new DebuggerValue(new Double(d1 - d2));
}
case Tokens.LEFTSHIFT_TOKEN:
{
// ECMA 11.7.1
int n1 = ECMA.toInt32(session, eeContext.toValue(lhs.debuggerValue));
int n2 = (int) (ECMA.toUint32(session, eeContext.toValue(rhs.debuggerValue)) & 0x1F);
return new DebuggerValue(new Double(n1 << n2));
}
case Tokens.RIGHTSHIFT_TOKEN:
{
// ECMA 11.7.1
int n1 = ECMA.toInt32(session, eeContext.toValue(lhs.debuggerValue));
int n2 = (int) (ECMA.toUint32(session, eeContext.toValue(rhs.debuggerValue)) & 0x1F);
return new DebuggerValue(new Double(n1 >> n2));
}
case Tokens.UNSIGNEDRIGHTSHIFT_TOKEN:
{
// ECMA 11.7.1
long n1 = ECMA.toUint32(session, eeContext.toValue(lhs.debuggerValue));
long n2 = (ECMA.toUint32(session, eeContext.toValue(rhs.debuggerValue)) & 0x1F);
return new DebuggerValue(new Double(n1 >>> n2));
}
case Tokens.LESSTHAN_TOKEN:
{
// ECMA 11.8.1
flash.tools.debugger.Value lessThan = ECMA.lessThan(session, eeContext.toValue(lhs.debuggerValue), eeContext
.toValue(rhs.debuggerValue));
boolean result;
if (lessThan.getType() == VariableType.UNDEFINED)
{
result = false;
}
else
{
result = ECMA.toBoolean(lessThan);
}
return new DebuggerValue(result);
}
case Tokens.GREATERTHAN_TOKEN:
{
// ECMA 11.8.2
flash.tools.debugger.Value greaterThan = ECMA.lessThan(session, eeContext.toValue(rhs.debuggerValue), eeContext
.toValue(lhs.debuggerValue));
boolean result;
if (greaterThan.getType() == VariableType.UNDEFINED)
{
result = false;
}
else
{
result = ECMA.toBoolean(greaterThan);
}
return new DebuggerValue(result);
}
case Tokens.LESSTHANOREQUALS_TOKEN:
{
// ECMA 11.8.3
flash.tools.debugger.Value lessThan = ECMA.lessThan(session, eeContext.toValue(rhs.debuggerValue), eeContext
.toValue(lhs.debuggerValue));
boolean result;
if (lessThan.getType() == VariableType.UNDEFINED)
{
result = false;
}
else
{
result = !ECMA.toBoolean(lessThan);
}
return new DebuggerValue(result);
}
case Tokens.GREATERTHANOREQUALS_TOKEN:
{
// ECMA 11.8.4
flash.tools.debugger.Value lessThan = ECMA.lessThan(session, eeContext.toValue(lhs.debuggerValue), eeContext
.toValue(rhs.debuggerValue));
boolean result;
if (lessThan.getType() == VariableType.UNDEFINED)
{
result = false;
}
else
{
result = !ECMA.toBoolean(lessThan);
}
return new DebuggerValue(result);
}
case Tokens.INSTANCEOF_TOKEN:
{
try {
return new DebuggerValue(session.evalInstanceof(eeContext.toValue(lhs.debuggerValue), eeContext.toValue(rhs.debuggerValue)));
} catch (PlayerDebugException e) {
throw new ExpressionEvaluatorException(e);
} catch (PlayerFaultException e) {
throw new ExpressionEvaluatorException(e);
}
}
case Tokens.IN_TOKEN:
{
try {
return new DebuggerValue(session.evalIn(eeContext.toValue(lhs.debuggerValue), eeContext.toValue(rhs.debuggerValue)));
} catch (PlayerDebugException e) {
throw new ExpressionEvaluatorException(e);
} catch (PlayerFaultException e) {
throw new ExpressionEvaluatorException(e);
}
}
case Tokens.IS_TOKEN:
{
try {
return new DebuggerValue(session.evalIs(eeContext.toValue(lhs.debuggerValue), eeContext.toValue(rhs.debuggerValue)));
} catch (PlayerDebugException e) {
throw new ExpressionEvaluatorException(e);
} catch (PlayerFaultException e) {
throw new ExpressionEvaluatorException(e);
}
}
case Tokens.AS_TOKEN:
{
try {
return new DebuggerValue(session.evalAs(eeContext.toValue(lhs.debuggerValue), eeContext.toValue(rhs.debuggerValue)));
} catch (PlayerDebugException e) {
throw new ExpressionEvaluatorException(e);
} catch (PlayerFaultException e) {
throw new ExpressionEvaluatorException(e);
}