Mozilla/mozilla/js/js2/java/LogicalNode.java
rogerl%netscape.com 7448fc1fe9 Moved from stack to inline execution.
git-svn-id: svn://10.0.0.236/trunk@33132 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-28 19:00:48 +00:00

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;
}
}
}