Mozilla/mozilla/js/js2/java/ArithmeticNode.java
rogerl%netscape.com b307b926e7 Latest changes
git-svn-id: svn://10.0.0.236/trunk@30777 18797224-902f-48f8-a5cc-f745e15eee43
1999-05-07 22:07:22 +00:00

22 lines
586 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
System.out.println("missing arithmetic op " + op);
}
}