Fixed IndexExpr

master
Apoorva Ranade 4 years ago
parent 3ef2df7136
commit 1944e1dad5

@ -547,8 +547,12 @@ public class CodeGenImpl extends CodeGenBase
} }
else else
{ {
backend.emitSW(reg, Register.FP, -sp_off*wordSize, "Store value to b stored");
incSp(1);
Register ret = target.dispatch(this); Register ret = target.dispatch(this);
backend.emitSW(T1, ret, 0, "Set list element"); sp_off--;
backend.emitLW(reg, Register.FP, -sp_off*wordSize, "Load value to b stored");
backend.emitSW(reg, ret, 0, "Set list element");
} }
} }
//} //}
@ -1139,8 +1143,9 @@ public class CodeGenImpl extends CodeGenBase
backend.emitADDI(index, index, 4, "Compute list element offset in words"); backend.emitADDI(index, index, 4, "Compute list element offset in words");
backend.emitLI(temp, wordSize, "Word size in bytes"); backend.emitLI(temp, wordSize, "Word size in bytes");
backend.emitMUL(index, index, temp, "Compute list element offset in bytes"); backend.emitMUL(index, index, temp, "Compute list element offset in bytes");
backend.emitADD(index, vacantReg, index, "Pointer to list element"); backend.emitADD(vacantReg, vacantReg, index, "Pointer to list element");
backend.emitLW(Register.A0, index, 0, "Set list element"); backend.emitMV(temp,vacantReg,"Copy Result");
backend.emitLW(A0, vacantReg, 0, "Load list element");
} }
else else
{ {
@ -1165,10 +1170,11 @@ public class CodeGenImpl extends CodeGenBase
backend.emitLI(T1, 1, "str size"); backend.emitLI(T1, 1, "str size");
backend.emitSW(T1, vacantReg, 3*wordSize, "len"); backend.emitSW(T1, vacantReg, 3*wordSize, "len");
backend.emitSW(T0, vacantReg, 4*wordSize, "ch"); backend.emitSW(T0, vacantReg, 4*wordSize, "ch");
backend.emitMV(temp,vacantReg,"Copy Result");
} }
freeRegister(tmpHandle); freeRegister(tmpHandle);
-- sp_off; -- sp_off;
return vacantReg; return temp;
} }
public Register analyze(MemberExpr node) public Register analyze(MemberExpr node)

Loading…
Cancel
Save