|
|
|
@ -358,12 +358,19 @@ public class CodeGenImpl extends CodeGenBase
|
|
|
|
|
@Override
|
|
|
|
|
public Register analyze(UnaryExpr node)
|
|
|
|
|
{
|
|
|
|
|
node.operand.dispatch(this);
|
|
|
|
|
if(node.operator.equals("-"))
|
|
|
|
|
{
|
|
|
|
|
if(node.operator.equals("-") && node.getInferredType().equals(Type.INT_TYPE))
|
|
|
|
|
{
|
|
|
|
|
node.operand.dispatch(this);
|
|
|
|
|
backend.emitLI(Register.T0, -1, "Set value of Register T0 to -1");
|
|
|
|
|
backend.emitMUL(Register.A0, Register.A0, Register.T0, "Multiply by -1");
|
|
|
|
|
}
|
|
|
|
|
else if(node.operator.equals("not") && node.getInferredType().equals(Type.BOOL_TYPE))
|
|
|
|
|
{
|
|
|
|
|
node.operand.dispatch(this);
|
|
|
|
|
backend.emitSEQZ(Register.T0, Register.A0, "Not operation on Register A0");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return null;
|
|
|
|
|
return Register.A0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|