diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-07-24 02:59:51 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-07-24 02:59:51 -0400 |
| commit | e220812f2f0fe2becd570308971f98e0290835db (patch) | |
| tree | d80b9a51b13322603dfe31eedbf7b357c627eed4 /src/analyze.cpp | |
| parent | 19ee4957502c704312646f75544e968b618aa807 (diff) | |
| download | zig-e220812f2f0fe2becd570308971f98e0290835db.tar.gz zig-e220812f2f0fe2becd570308971f98e0290835db.zip | |
implement local variables in async functions
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index fe86c613f3..957e61b198 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -1911,11 +1911,32 @@ static Error resolve_coro_frame(CodeGen *g, ZigType *frame_type) { } else { param_name = buf_sprintf("arg%" ZIG_PRI_usize "", arg_i); } - ZigType *param_type = param_info[arg_i].type; + ZigType *param_type = param_info->type; field_names.append(buf_ptr(param_name)); field_types.append(param_type); } + for (size_t alloca_i = 0; alloca_i < fn->alloca_gen_list.length; alloca_i += 1) { + IrInstructionAllocaGen *instruction = fn->alloca_gen_list.at(alloca_i); + ZigType *ptr_type = instruction->base.value.type; + assert(ptr_type->id == ZigTypeIdPointer); + ZigType *child_type = ptr_type->data.pointer.child_type; + if (!type_has_bits(child_type)) + continue; + if (instruction->base.ref_count == 0) + continue; + if (instruction->base.value.special != ConstValSpecialRuntime) { + if (const_ptr_pointee(nullptr, g, &instruction->base.value, nullptr)->special != + ConstValSpecialRuntime) + { + continue; + } + } + field_names.append(instruction->name_hint); + field_types.append(child_type); + } + + assert(field_names.length == field_types.length); frame_type->data.frame.locals_struct = get_struct_type(g, buf_ptr(&frame_type->name), field_names.items, field_types.items, field_names.length); |
