From a9a6f77a1f0a6e173d85fee42aec0a8d5e22a64d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 20 Oct 2016 01:13:39 -0400 Subject: add variable declaration initialization IR --- src/ir.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/ir.cpp') diff --git a/src/ir.cpp b/src/ir.cpp index 4d9eacb6c3..b70360f1ad 100644 --- a/src/ir.cpp +++ b/src/ir.cpp @@ -586,9 +586,6 @@ static VariableTableEntry *ir_add_local_var(IrBuilder *irb, AstNode *node, Buf * // TODO replace _anon with @anon and make sure all tests still pass buf_init_from_str(&variable_entry->name, "_anon"); } - if (node->block_context->fn_entry) { - node->block_context->fn_entry->variable_list.append(variable_entry); - } variable_entry->is_const = is_const; variable_entry->decl_node = node; @@ -2177,6 +2174,10 @@ static TypeTableEntry *ir_analyze_instruction_decl_var(IrAnalyze *ira, IrInstruc } ir_build_var_decl_from(&ira->new_irb, &decl_var_instruction->base, var, var_type, casted_init_value); + BlockContext *scope = decl_var_instruction->base.source_node->block_context; + if (scope->fn_entry) + scope->fn_entry->variable_list.append(var); + return ira->codegen->builtin_types.entry_void; } -- cgit v1.2.3