From be5775bbd529d269ab01cf773b219ad67f3afeb3 Mon Sep 17 00:00:00 2001 From: David Mak Date: Tue, 5 Sep 2023 15:15:47 +0800 Subject: [PATCH] core: Use AST var name for IR name --- nac3core/src/codegen/stmt.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nac3core/src/codegen/stmt.rs b/nac3core/src/codegen/stmt.rs index a2f7c02..85ec390 100644 --- a/nac3core/src/codegen/stmt.rs +++ b/nac3core/src/codegen/stmt.rs @@ -193,7 +193,12 @@ pub fn gen_assign<'ctx, 'a, G: CodeGenerator>( } } _ => { - let ptr = generator.gen_store_target(ctx, target)?; + let ptr = if let ExprKind::Name { id, .. } = &target.node { + generator.gen_store_target_named(ctx, target, format!("{}.addr", id.to_string()).as_str())? + } else { + generator.gen_store_target(ctx, target)? + }; + if let ExprKind::Name { id, .. } = &target.node { let (_, static_value, counter) = ctx.var_assignment.get_mut(id).unwrap(); *counter += 1;