diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-09-30 20:12:00 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-09-30 20:12:00 -0400 |
| commit | 633781e31dedaa27d9692d56f6cf073931ca311a (patch) | |
| tree | 64f05abeb6225a8c45164a073afe02bb2af47ec0 /src/analyze.cpp | |
| parent | 4e2fa2d15be248c29051a58995e38caa0b1de0a5 (diff) | |
| download | zig-633781e31dedaa27d9692d56f6cf073931ca311a.tar.gz zig-633781e31dedaa27d9692d56f6cf073931ca311a.zip | |
empty function compiles successfully with IR
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index c76e546188..e153703121 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -11,6 +11,7 @@ #include "error.hpp" #include "eval.hpp" #include "ir.hpp" +#include "ir_print.hpp" #include "os.hpp" #include "parseh.hpp" #include "parser.hpp" @@ -54,7 +55,7 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry); static void resolve_use_decl(CodeGen *g, AstNode *node); static void preview_use_decl(CodeGen *g, AstNode *node); -static AstNode *first_executing_node(AstNode *node) { +AstNode *first_executing_node(AstNode *node) { switch (node->type) { case NodeTypeFnCallExpr: return first_executing_node(node->data.fn_call_expr.fn_ref_expr); @@ -2381,18 +2382,6 @@ static VariableTableEntry *find_variable(CodeGen *g, BlockContext *orig_context, return nullptr; } -static LabelTableEntry *find_label(CodeGen *g, BlockContext *orig_context, Buf *name) { - BlockContext *context = orig_context; - while (context && context->fn_entry) { - auto entry = context->label_table.maybe_get(name); - if (entry) { - return entry->value; - } - context = context->parent; - } - return nullptr; -} - static TypeEnumField *find_enum_type_field(TypeTableEntry *enum_type, Buf *name) { for (uint32_t i = 0; i < enum_type->data.enumeration.src_field_count; i += 1) { TypeEnumField *type_enum_field = &enum_type->data.enumeration.fields[i]; @@ -7098,14 +7087,19 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) { buf_sprintf("byvalue types not yet supported on extern function return values")); } - IrBasicBlock *entry_basic_block = ir_gen(g, node, expected_type); - if (!entry_basic_block) { + IrInstruction *result = ir_gen_fn(g, fn_table_entry); + if (result == g->invalid_instruction) { fn_proto_node->data.fn_proto.skip = true; fn_table_entry->anal_state = FnAnalStateSkipped; return; } - TypeTableEntry *block_return_type = ir_analyze(g, node, entry_basic_block, expected_type); + if (g->verbose) { + fprintf(stderr, "fn %s {\n", buf_ptr(&fn_table_entry->symbol_name)); + ir_print(stderr, &fn_table_entry->ir_executable, 4); + fprintf(stderr, "}\n"); + } + TypeTableEntry *block_return_type = ir_analyze(g, &fn_table_entry->ir_executable, expected_type); node->data.fn_def.implicit_return_type = block_return_type; fn_table_entry->anal_state = FnAnalStateComplete; |
