diff --git a/lab3-4/codegen.cc b/lab3-4/codegen.cc index c517e2c4270cebf234a7bb06fa0db7310ce092e9..a49b68265f38f3674f39b3b18251ffd777455ef8 100644 --- a/lab3-4/codegen.cc +++ b/lab3-4/codegen.cc @@ -1257,11 +1257,15 @@ void Quad::print_c(ostream& o) << setw(8) << "=" << setw(8) << sym1; break; - case aassign: - o << setw(8) << "aassign " - << setw(8) << sym1 - << setw(8) << int1 - << setw(8) << sym3; + case aassign: { + ::string itVar = sym1->id + "_" + ::string(int1); + o << setw(8) << "for(int " << itVar << " = 0 ;" + << setw(8) << itVar << "<" << int1 << ";" + << setw(8) << itVar << "++;)" //Increment & close for loop. + /*Assign the array*/ + << setw(8) << sym3 << "[" << itVar << "]" << "=" + << setw(8) << sym1 << "[" << itVar << "];"; + } break; case hcf: o << setw(8) << "exit(-1)";