gecko-dev/js/js2/java/RelationalNode.java
rogerl%netscape.com 8cf3d6ffe7 Latest changes
1999-05-07 22:07:22 +00:00

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");
}
}