Skip to content

Commit

Permalink
Update assignment expression logic for array subscripting
Browse files Browse the repository at this point in the history
  • Loading branch information
leewei05 committed Jul 7, 2024
1 parent dcff243 commit b3c4681
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/qbe_ir_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,10 @@ void QbeIrGenerator::Visit(const SimpleAssignmentExprNode& assign_expr) {
// Global array subscripting will return the target address instead of the
// address of `id`.
if (assign_expr.lhs->is_global &&
!dynamic_cast<ArrSubExprNode*>(assign_expr.lhs.get())) {
dynamic_cast<ArrSubExprNode*>(assign_expr.lhs.get())) {
WriteInstr_("storew {}, {}", FuncScopeTemp{rhs_num},
FuncScopeTemp{reg_num_to_id_num.at(lhs_num)});
} else if (assign_expr.lhs->is_global) {
WriteInstr_("storew {}, {}", FuncScopeTemp{rhs_num},
user_defined::GlobalPointer{reg_num_to_id.at(lhs_num)});
} else {
Expand Down

0 comments on commit b3c4681

Please sign in to comment.