diff --git a/src/main/java/chocopy/pa3/CodeGenImpl.java b/src/main/java/chocopy/pa3/CodeGenImpl.java index 7376ce0..5d21ca2 100644 --- a/src/main/java/chocopy/pa3/CodeGenImpl.java +++ b/src/main/java/chocopy/pa3/CodeGenImpl.java @@ -739,9 +739,25 @@ public class CodeGenImpl extends CodeGenBase sp_off -= 2; backend.emitADDI(SP, FP, -sp_off*wordSize, "restore sp"); } + if(operator.equals("!=")) + { + incSp(2); + backend.emitSW(node.left.dispatch(this), FP, (1 - sp_off) *wordSize, "Push argument 0 from last."); + backend.emitSW(node.right.dispatch(this), FP, ( - sp_off) *wordSize, "Push argument 1 from last."); + backend.emitADDI(SP, FP, -sp_off * wordSize, "Set SP to last argument."); + backend.emitJAL(strneqlLabel, "Invoke method:strneql"); + sp_off -= 2; + backend.emitADDI(SP, FP, -sp_off*wordSize, "restore sp"); + } else if(operator.equals("+")) { - + incSp(2); + backend.emitSW(node.left.dispatch(this), FP, (1 - sp_off) *wordSize, "Push argument 0 from last."); + backend.emitSW(node.right.dispatch(this), FP, ( - sp_off) *wordSize, "Push argument 1 from last."); + backend.emitADDI(SP, FP, -sp_off * wordSize, "Set SP to last argument."); + backend.emitJAL(concatLabel, "Invoke method:concat"); + sp_off -= 2; + backend.emitADDI(SP, FP, -sp_off*wordSize, "restore sp"); } else backend.emitJAL(errorNI, "Operator not implemented for String operands");