New.
git-svn-id: svn://10.0.0.236/trunk@32351 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
40
mozilla/js/js2/java/LogicalNode.java
Normal file
40
mozilla/js/js2/java/LogicalNode.java
Normal file
@@ -0,0 +1,40 @@
|
||||
class LogicalNode extends BinaryNode {
|
||||
|
||||
LogicalNode(String aOp, ExpressionNode aLeft, ExpressionNode aRight)
|
||||
{
|
||||
super(aOp, aLeft, aRight);
|
||||
}
|
||||
|
||||
void eval(Environment theEnv)
|
||||
{
|
||||
left.eval(theEnv);
|
||||
double d = theEnv.theStack.pop().d;
|
||||
if (op == "&&") {
|
||||
if (d == 0.0)
|
||||
theEnv.theStack.push(new StackValue(0));
|
||||
else {
|
||||
right.eval(theEnv);
|
||||
d = theEnv.theStack.pop().d;
|
||||
if (d == 0.0)
|
||||
theEnv.theStack.push(new StackValue(0));
|
||||
else
|
||||
theEnv.theStack.push(new StackValue(1));
|
||||
}
|
||||
}
|
||||
if (op == "||") {
|
||||
if (d != 0.0)
|
||||
theEnv.theStack.push(new StackValue(1));
|
||||
else {
|
||||
right.eval(theEnv);
|
||||
d = theEnv.theStack.pop().d;
|
||||
if (d != 0.0)
|
||||
theEnv.theStack.push(new StackValue(1));
|
||||
else
|
||||
theEnv.theStack.push(new StackValue(0));
|
||||
}
|
||||
}
|
||||
else
|
||||
System.out.println("missing logical op " + op);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user