From 6805253515c587b9bd8dffbc21e6d1eb43e5bb81 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 Aids debugging IR. --- nac3core/src/codegen/stmt.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nac3core/src/codegen/stmt.rs b/nac3core/src/codegen/stmt.rs index b71a0719..47ba743e 100644 --- a/nac3core/src/codegen/stmt.rs +++ b/nac3core/src/codegen/stmt.rs @@ -193,7 +193,13 @@ pub fn gen_assign<'ctx, 'a, G: CodeGenerator>( } } _ => { - let ptr = generator.gen_store_target(ctx, target, Some("target.addr"))?; + let name = if let ExprKind::Name { id, .. } = &target.node { + format!("{}.addr", id.to_string()) + } else { + String::from("target.addr") + }; + let ptr = generator.gen_store_target(ctx, target, Some(name.as_str()))?; + if let ExprKind::Name { id, .. } = &target.node { let (_, static_value, counter) = ctx.var_assignment.get_mut(id).unwrap(); *counter += 1;