Added is operator

master
Apoorva Ranade 4 years ago
parent 10cbb67c09
commit 874808ef98

@ -728,7 +728,17 @@ public class CodeGenImpl extends CodeGenBase
sp_off -= 2;
backend.emitADDI(SP, FP, -sp_off*wordSize, "restore sp");
}
// TODO: Implement "is" for objects
else if(operator.equals("is"))
{
node.right.dispatch(this);
backend.emitSW(Register.A0, Register.FP, -sp_off*wordSize, "Push on stack slot "+sp_off);
incSp(1);
node.left.dispatch(this);
sp_off--;
backend.emitLW(Register.T0, Register.FP, -sp_off*wordSize, "Pop stack slot "+sp_off);
backend.emitXOR(Register.A0, Register.A0, Register.T0, "Operator: is");
backend.emitSEQZ(Register.A0, Register.A0, "Result is True if XOR equals 0");
}
else
{
backend.emitJAL(errorNI, "Operator not implemented");

Loading…
Cancel
Save