core: Use AST var name for IR name

Aids debugging IR.
This commit is contained in:
David Mak 2023-09-05 15:15:47 +08:00
parent 19915bac79
commit 6805253515
1 changed files with 7 additions and 1 deletions

View File

@ -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;