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)
|
|
|
|
{
|
1999-05-20 21:16:11 +00:00
|
|
|
left.eval(theEnv);
|
1999-05-26 01:01:07 +00:00
|
|
|
JSInteger lV = theEnv.theStack.pop().toJSInteger(theEnv);
|
1999-05-20 21:16:11 +00:00
|
|
|
right.eval(theEnv);
|
|
|
|
|
1999-05-20 00:14:26 +00:00
|
|
|
if (op == "&")
|
1999-05-20 21:16:11 +00:00
|
|
|
lV.and(theEnv);
|
1999-05-20 00:14:26 +00:00
|
|
|
else
|
|
|
|
if (op == "|")
|
1999-05-20 21:16:11 +00:00
|
|
|
lV.or(theEnv);
|
1999-05-20 00:14:26 +00:00
|
|
|
else
|
|
|
|
if (op == "^")
|
1999-05-20 21:16:11 +00:00
|
|
|
lV.xor(theEnv);
|
1999-05-20 00:14:26 +00:00
|
|
|
else
|
|
|
|
if (op == "<<")
|
1999-05-20 21:16:11 +00:00
|
|
|
lV.shr(theEnv);
|
1999-05-20 00:14:26 +00:00
|
|
|
else
|
|
|
|
if (op == ">>")
|
1999-05-20 21:16:11 +00:00
|
|
|
lV.shl(theEnv);
|
1999-05-20 00:14:26 +00:00
|
|
|
else
|
|
|
|
if (op == ">>>")
|
1999-05-20 21:16:11 +00:00
|
|
|
lV.ushl(theEnv);
|
1999-05-20 00:14:26 +00:00
|
|
|
else
|
|
|
|
System.out.println("missing bitwise op " + op);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|