Mozilla/mozilla/js/js2/java/ArithmeticNode.java
rogerl%netscape.com 13a12a7a0e Switch to new JSValue hierarchy.
Added logical/bitwise ops.


git-svn-id: svn://10.0.0.236/trunk@32350 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-20 00:13:38 +00:00

31 lines
871 B
Java

class ArithmeticNode extends BinaryNode {
ArithmeticNode(String aOp, ExpressionNode aLeft, ExpressionNode aRight)
{
super(aOp, aLeft, aRight);
}
void eval(Environment theEnv)
{
super.eval(theEnv);
double dR = theEnv.theStack.pop().d;
double dL = theEnv.theStack.pop().d;
if (op == "+")
theEnv.theStack.push(new StackValue(dL + dR));
else
if (op == "-")
theEnv.theStack.push(new StackValue(dL - dR));
else
if (op == "*")
theEnv.theStack.push(new StackValue(dL * dR));
else
if (op == "/")
theEnv.theStack.push(new StackValue(dL / dR));
else
if (op == "%")
theEnv.theStack.push(new StackValue(dL % dR));
else
System.out.println("missing arithmetic op " + op);
}
}