Switching to JSValue throughout. Implementing operators per base type.
git-svn-id: svn://10.0.0.236/trunk@32415 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -7,23 +7,24 @@ class ArithmeticNode extends BinaryNode {
|
||||
|
||||
void eval(Environment theEnv)
|
||||
{
|
||||
super.eval(theEnv);
|
||||
double dR = theEnv.theStack.pop().d;
|
||||
double dL = theEnv.theStack.pop().d;
|
||||
left.eval(theEnv);
|
||||
JSValue lV = theEnv.theStack.pop();
|
||||
right.eval(theEnv);
|
||||
|
||||
if (op == "+")
|
||||
theEnv.theStack.push(new StackValue(dL + dR));
|
||||
lV.add(theEnv);
|
||||
else
|
||||
if (op == "-")
|
||||
theEnv.theStack.push(new StackValue(dL - dR));
|
||||
lV.subtract(theEnv);
|
||||
else
|
||||
if (op == "*")
|
||||
theEnv.theStack.push(new StackValue(dL * dR));
|
||||
lV.multiply(theEnv);
|
||||
else
|
||||
if (op == "/")
|
||||
theEnv.theStack.push(new StackValue(dL / dR));
|
||||
lV.divide(theEnv);
|
||||
else
|
||||
if (op == "%")
|
||||
theEnv.theStack.push(new StackValue(dL % dR));
|
||||
lV.remainder(theEnv);
|
||||
else
|
||||
System.out.println("missing arithmetic op " + op);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user