From 572b9d1b3fd3afa9f34e649bd0110abb01571b1c Mon Sep 17 00:00:00 2001 From: gingerBill Date: Sat, 6 Mar 2021 16:11:01 +0000 Subject: Fix `context` bug with `deferred_*` attributes which caused a new `context` to be created every time --- src/ir.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index 1ca7b4cd4..300b5b3af 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -1594,34 +1594,33 @@ irValue *ir_emit_struct_ep(irProcedure *proc, irValue *s, i32 index); -irDefer ir_add_defer_node(irProcedure *proc, isize scope_index, Ast *stmt) { +void ir_add_defer_node(irProcedure *proc, isize scope_index, Ast *stmt) { irDefer d = {irDefer_Node}; d.scope_index = scope_index; d.context_stack_count = proc->context_stack.count; d.block = proc->curr_block; d.stmt = stmt; array_add(&proc->defer_stmts, d); - return d; } -irDefer ir_add_defer_instr(irProcedure *proc, isize scope_index, irValue *instr) { +void ir_add_defer_instr(irProcedure *proc, isize scope_index, irValue *instr) { irDefer d = {irDefer_Instr}; d.scope_index = proc->scope_index; + d.context_stack_count = proc->context_stack.count; d.block = proc->curr_block; d.instr = instr; // NOTE(bill): It will make a copy everytime it is called array_add(&proc->defer_stmts, d); - return d; } -irDefer ir_add_defer_proc(irProcedure *proc, isize scope_index, irValue *deferred, Array const &result_as_args) { +void ir_add_defer_proc(irProcedure *proc, isize scope_index, irValue *deferred, Array const &result_as_args) { irDefer d = {irDefer_Proc}; d.scope_index = proc->scope_index; + d.context_stack_count = proc->context_stack.count; d.block = proc->curr_block; d.proc.deferred = deferred; d.proc.result_as_args = result_as_args; array_add(&proc->defer_stmts, d); - return d; } irValue *ir_add_module_constant(irModule *m, Type *type, ExactValue value); -- cgit v1.2.3