gecko-dev/js/js2/java/ArithmeticNode.java
1999-05-28 19:00:48 +00:00

33 lines
794 B
Java

class ArithmeticNode extends BinaryNode {
ArithmeticNode(String aOp, ExpressionNode aLeft, ExpressionNode aRight)
{
super(aOp, aLeft, aRight);
}
JSValue eval(Environment theEnv)
{
JSValue lV = left.eval(theEnv);
JSValue rV = right.eval(theEnv);
if (op == "+")
return lV.add(theEnv, rV);
else
if (op == "-")
return lV.subtract(theEnv, rV);
else
if (op == "*")
return lV.multiply(theEnv, rV);
else
if (op == "/")
return lV.divide(theEnv, rV);
else
if (op == "%")
return lV.remainder(theEnv, rV);
else {
System.out.println("missing arithmetic op " + op);
return null;
}
}
}