Added operators on Strings
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user