aboutsummaryrefslogtreecommitdiff
path: root/src/analyze.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-09-30 02:21:21 -0400
committerAndrew Kelley <superjoe30@gmail.com>2016-09-30 02:21:21 -0400
commit4e2fa2d15be248c29051a58995e38caa0b1de0a5 (patch)
treeb8f27f8f3157b1897cf796c6b0241dafacbfd7b0 /src/analyze.cpp
parent0562111b0208d94852928f4bc7a7f2b8e335366f (diff)
downloadzig-4e2fa2d15be248c29051a58995e38caa0b1de0a5.tar.gz
zig-4e2fa2d15be248c29051a58995e38caa0b1de0a5.zip
*WIP*
Diffstat (limited to 'src/analyze.cpp')
-rw-r--r--src/analyze.cpp50
1 files changed, 13 insertions, 37 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp
index 21f82c68ec..c76e546188 100644
--- a/src/analyze.cpp
+++ b/src/analyze.cpp
@@ -6,14 +6,15 @@
*/
#include "analyze.hpp"
-#include "parser.hpp"
+#include "ast_render.hpp"
+#include "config.h"
#include "error.hpp"
-#include "zig_llvm.hpp"
+#include "eval.hpp"
+#include "ir.hpp"
#include "os.hpp"
#include "parseh.hpp"
-#include "config.h"
-#include "ast_render.hpp"
-#include "eval.hpp"
+#include "parser.hpp"
+#include "zig_llvm.hpp"
static TypeTableEntry *analyze_expression(CodeGen *g, ImportTableEntry *import, BlockContext *context,
TypeTableEntry *expected_type, AstNode *node);
@@ -6880,22 +6881,6 @@ static TypeTableEntry *analyze_goto_pass1(CodeGen *g, ImportTableEntry *import,
return g->builtin_types.entry_unreachable;
}
-static void analyze_goto_pass2(CodeGen *g, ImportTableEntry *import, AstNode *node) {
- assert(node->type == NodeTypeGoto);
- Buf *label_name = node->data.goto_expr.name;
- BlockContext *context = node->block_context;
- assert(context);
- LabelTableEntry *label = find_label(g, context, label_name);
-
- if (!label) {
- add_node_error(g, node, buf_sprintf("no label in scope named '%s'", buf_ptr(label_name)));
- return;
- }
-
- label->used = true;
- node->data.goto_expr.label_entry = label;
-}
-
static TypeTableEntry *analyze_expression_pointer_only(CodeGen *g, ImportTableEntry *import,
BlockContext *context, TypeTableEntry *expected_type, AstNode *node, bool pointer_only)
{
@@ -7113,24 +7098,15 @@ static void analyze_fn_body(CodeGen *g, FnTableEntry *fn_table_entry) {
buf_sprintf("byvalue types not yet supported on extern function return values"));
}
- TypeTableEntry *block_return_type = analyze_expression(g, import, context, expected_type, node->data.fn_def.body);
-
- node->data.fn_def.implicit_return_type = block_return_type;
-
- for (size_t i = 0; i < fn_table_entry->goto_list.length; i += 1) {
- AstNode *goto_node = fn_table_entry->goto_list.at(i);
- assert(goto_node->type == NodeTypeGoto);
- analyze_goto_pass2(g, import, goto_node);
+ IrBasicBlock *entry_basic_block = ir_gen(g, node, expected_type);
+ if (!entry_basic_block) {
+ 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);
- for (size_t i = 0; i < fn_table_entry->all_labels.length; i += 1) {
- LabelTableEntry *label = fn_table_entry->all_labels.at(i);
- if (!label->used) {
- add_node_error(g, label->decl_node,
- buf_sprintf("label '%s' defined but not used",
- buf_ptr(label->decl_node->data.label.name)));
- }
- }
+ node->data.fn_def.implicit_return_type = block_return_type;
fn_table_entry->anal_state = FnAnalStateComplete;
}