forked from M-Labs/nac3
nac3core: fix assignment
This commit is contained in:
parent
a022005183
commit
096f4b03c0
|
@ -42,15 +42,18 @@ pub fn gen_store_target<'ctx, 'a, G: CodeGenerator>(
|
||||||
// very similar to gen_expr, but we don't do an extra load at the end
|
// very similar to gen_expr, but we don't do an extra load at the end
|
||||||
// and we flatten nested tuples
|
// and we flatten nested tuples
|
||||||
Ok(match &pattern.node {
|
Ok(match &pattern.node {
|
||||||
ExprKind::Name { id, .. } => {
|
ExprKind::Name { id, .. } => match ctx.var_assignment.get(id) {
|
||||||
ctx.var_assignment.get(id).map(|v| Ok(v.0) as Result<_, String>).unwrap_or_else(
|
None => {
|
||||||
|| {
|
let ptr_ty = ctx.get_llvm_type(generator, pattern.custom.unwrap());
|
||||||
let ptr_ty = ctx.get_llvm_type(generator, pattern.custom.unwrap());
|
let ptr = generator.gen_var_alloc(ctx, ptr_ty)?;
|
||||||
let ptr = generator.gen_var_alloc(ctx, ptr_ty)?;
|
ctx.var_assignment.insert(*id, (ptr, None, 0));
|
||||||
ctx.var_assignment.insert(*id, (ptr, None, 0));
|
ptr
|
||||||
Ok(ptr)
|
}
|
||||||
},
|
Some(v) => {
|
||||||
)?
|
let (ptr, counter) = (v.0, v.2);
|
||||||
|
ctx.var_assignment.insert(*id, (ptr, None, counter));
|
||||||
|
ptr
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ExprKind::Attribute { value, attr, .. } => {
|
ExprKind::Attribute { value, attr, .. } => {
|
||||||
let index = ctx.get_attr_index(value.custom.unwrap(), *attr);
|
let index = ctx.get_attr_index(value.custom.unwrap(), *attr);
|
||||||
|
|
Loading…
Reference in New Issue