mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-05 16:46:26 +00:00
35 lines
974 B
Java
35 lines
974 B
Java
class BitwiseNode extends BinaryNode {
|
|
|
|
BitwiseNode(String aOp, ExpressionNode aLeft, ExpressionNode aRight)
|
|
{
|
|
super(aOp, aLeft, aRight);
|
|
}
|
|
|
|
void eval(Environment theEnv)
|
|
{
|
|
super.eval(theEnv);
|
|
int iR = (int)(theEnv.theStack.pop().d);
|
|
int iL = (int)(theEnv.theStack.pop().d);
|
|
if (op == "&")
|
|
theEnv.theStack.push(new StackValue(iL & iR));
|
|
else
|
|
if (op == "|")
|
|
theEnv.theStack.push(new StackValue(iL | iR));
|
|
else
|
|
if (op == "^")
|
|
theEnv.theStack.push(new StackValue(iL ^ iR));
|
|
else
|
|
if (op == "<<")
|
|
theEnv.theStack.push(new StackValue(iL << iR));
|
|
else
|
|
if (op == ">>")
|
|
theEnv.theStack.push(new StackValue(iL >> iR));
|
|
else
|
|
if (op == ">>>")
|
|
theEnv.theStack.push(new StackValue(iL >>> iR));
|
|
else
|
|
System.out.println("missing bitwise op " + op);
|
|
}
|
|
|
|
}
|