From cd68969115f19b09aeb72923426e722725ba9451 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 30 Nov 2015 22:53:37 -0700 Subject: closer to multiple files working --- src/analyze.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/analyze.cpp') diff --git a/src/analyze.cpp b/src/analyze.cpp index 131bc22e52..37c3950ac2 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -9,6 +9,7 @@ #include "semantic_info.hpp" #include "error.hpp" #include "zig_llvm.hpp" +#include "os.hpp" static void add_node_error(CodeGen *g, AstNode *node, Buf *msg) { g->errors.add_one(); @@ -212,7 +213,7 @@ static void preview_function_declarations(CodeGen *g, ImportTableEntry *import, } break; case NodeTypeUse: - zig_panic("TODO use"); + // nothing to do here break; case NodeTypeDirective: case NodeTypeParamDecl: @@ -383,9 +384,16 @@ static void analyze_top_level_declaration(CodeGen *g, AstNode *node) { case NodeTypeRootExportDecl: case NodeTypeExternBlock: - case NodeTypeUse: // already looked at these in the preview pass break; + case NodeTypeUse: + for (int i = 0; i < node->data.use.directives->length; i += 1) { + AstNode *directive_node = node->data.use.directives->at(i); + Buf *name = &directive_node->data.directive.name; + add_node_error(g, directive_node, + buf_sprintf("invalid directive: '%s'", buf_ptr(name))); + } + break; case NodeTypeDirective: case NodeTypeParamDecl: case NodeTypeFnProto: @@ -429,7 +437,14 @@ static void analyze_root(CodeGen *g, ImportTableEntry *import, AstNode *node) { } } -void semantic_analyze(CodeGen *g, ImportTableEntry *import_table_entry) { - analyze_root(g, import_table_entry, import_table_entry->root); -} +void semantic_analyze(CodeGen *g) { + auto it = g->import_table.entry_iterator(); + for (;;) { + auto *entry = it.next(); + if (!entry) + break; + ImportTableEntry *import = entry->value; + analyze_root(g, import, import->root); + } +} -- cgit v1.2.3