1999-04-27 16:22:20 +00:00
|
|
|
class RelationalNode extends BinaryNode {
|
|
|
|
|
|
|
|
RelationalNode(String aOp, ExpressionNode aLeft, ExpressionNode aRight)
|
|
|
|
{
|
|
|
|
super(aOp, aLeft, aRight);
|
|
|
|
}
|
1999-05-07 22:07:22 +00: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) ? 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");
|
|
|
|
}
|
1999-04-27 16:22:20 +00:00
|
|
|
}
|