This commit is contained in:
rogerl@netscape.com
1999-05-20 00:14:26 +00:00
parent 07a6670f46
commit 5eeb873cfa
8 changed files with 189 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
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);
}
}