gecko-dev/js/js2/java/ArithmeticNode.java

22 строки
586 B
Java
Исходник Обычный вид История

1999-04-27 02:50:50 +04:00
class ArithmeticNode extends BinaryNode {
ArithmeticNode(String aOp, ExpressionNode aLeft, ExpressionNode aRight)
{
super(aOp, aLeft, aRight);
}
1999-05-08 02:07:22 +04:00
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);
}
1999-04-27 02:50:50 +04:00
}