mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-01 14:45:29 +00:00
34 lines
1.0 KiB
Java
34 lines
1.0 KiB
Java
class RelationalNode extends BinaryNode {
|
|
|
|
RelationalNode(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) ? 1 : 0));
|
|
else
|
|
if (op == ">=")
|
|
theEnv.theStack.push(new StackValue((dL >= dR) ? 1 : 0));
|
|
else
|
|
if (op == "<")
|
|
theEnv.theStack.push(new StackValue((dL < dR) ? 1 : 0));
|
|
else
|
|
if (op == "<=")
|
|
theEnv.theStack.push(new StackValue((dL <= dR) ? 1 : 0));
|
|
else
|
|
if (op == "==")
|
|
theEnv.theStack.push(new StackValue((dL == dR) ? 1 : 0));
|
|
else
|
|
if (op == "!=")
|
|
theEnv.theStack.push(new StackValue((dL != dR) ? 1 : 0));
|
|
else
|
|
System.out.println("missing relational op");
|
|
}
|
|
}
|