mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-02 07:05:24 +00:00
40 lines
1009 B
Java
40 lines
1009 B
Java
class LogicalNode extends BinaryNode {
|
|
|
|
LogicalNode(String aOp, ExpressionNode aLeft, ExpressionNode aRight)
|
|
{
|
|
super(aOp, aLeft, aRight);
|
|
}
|
|
|
|
JSValue eval(Environment theEnv)
|
|
{
|
|
JSBoolean b = left.eval(theEnv).toJSBoolean(theEnv);
|
|
if (op == "&&") {
|
|
if (b.isFalse())
|
|
return b;
|
|
else {
|
|
b = right.eval(theEnv).toJSBoolean(theEnv);
|
|
if (b.isFalse())
|
|
return b;
|
|
else
|
|
return JSBoolean.JSTrue;
|
|
}
|
|
}
|
|
if (op == "||") {
|
|
if (b.isTrue())
|
|
return b;
|
|
else {
|
|
b = right.eval(theEnv).toJSBoolean(theEnv);
|
|
if (b.isTrue())
|
|
return b;
|
|
else
|
|
return JSBoolean.JSFalse;
|
|
}
|
|
}
|
|
else {
|
|
System.out.println("missing logical op " + op);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
}
|