gecko-dev/js/js2/java/BitwiseNode.java

36 lines
774 B
Java
Raw Normal View History

1999-05-20 00:14:26 +00:00
class BitwiseNode extends BinaryNode {
BitwiseNode(String aOp, ExpressionNode aLeft, ExpressionNode aRight)
{
super(aOp, aLeft, aRight);
}
void eval(Environment theEnv)
{
left.eval(theEnv);
JSInteger lV = theEnv.theStack.pop().toJSInteger();
right.eval(theEnv);
1999-05-20 00:14:26 +00:00
if (op == "&")
lV.and(theEnv);
1999-05-20 00:14:26 +00:00
else
if (op == "|")
lV.or(theEnv);
1999-05-20 00:14:26 +00:00
else
if (op == "^")
lV.xor(theEnv);
1999-05-20 00:14:26 +00:00
else
if (op == "<<")
lV.shr(theEnv);
1999-05-20 00:14:26 +00:00
else
if (op == ">>")
lV.shl(theEnv);
1999-05-20 00:14:26 +00:00
else
if (op == ">>>")
lV.ushl(theEnv);
1999-05-20 00:14:26 +00:00
else
System.out.println("missing bitwise op " + op);
}
}