From b3c4681508350b087c5ed90969d8b214a3ec9f04 Mon Sep 17 00:00:00 2001 From: Lee Date: Sun, 7 Jul 2024 22:47:18 +0800 Subject: [PATCH] Update assignment expression logic for array subscripting --- src/qbe_ir_generator.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/qbe_ir_generator.cpp b/src/qbe_ir_generator.cpp index 9c6770cb..b3ad2728 100644 --- a/src/qbe_ir_generator.cpp +++ b/src/qbe_ir_generator.cpp @@ -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(assign_expr.lhs.get())) { + dynamic_cast(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 {