diff options
| author | gingerBill <bill@gingerbill.org> | 2018-05-27 13:30:18 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2018-05-27 13:30:18 +0100 |
| commit | 307977d4cf6a2b0bd2004bd9facbab00d1e5cb57 (patch) | |
| tree | e32ce06f5c883da2f6cf371aad60709c83948785 /src/checker.cpp | |
| parent | 1beff539d7c3b3a9570684b9e619ff3c61ce9be8 (diff) | |
Remove dead code
Diffstat (limited to 'src/checker.cpp')
| -rw-r--r-- | src/checker.cpp | 98 |
1 files changed, 30 insertions, 68 deletions
diff --git a/src/checker.cpp b/src/checker.cpp index 9f9d8bebc..51689d027 100644 --- a/src/checker.cpp +++ b/src/checker.cpp @@ -2352,41 +2352,6 @@ void add_import_dependency_node(Checker *c, AstNode *decl, Map<ImportGraphNode * } case_end; - - // case_ast_node(ed, ExportDecl, decl); - // String path = ed->fullpath; - // HashKey key = hash_string(path); - // Scope **found = map_get(&c->file_scopes, key); - // if (found == nullptr) { - // for_array(scope_index, c->file_scopes.entries) { - // Scope *scope = c->file_scopes.entries[scope_index].value; - // gb_printf_err("%.*s\n", LIT(scope->file->tokenizer.fullpath)); - // } - // Token token = ast_node_token(decl); - // gb_printf_err("%.*s(%td:%td)\n", LIT(token.pos.file), token.pos.line, token.pos.column); - // GB_PANIC("Unable to find scope for file: %.*s", LIT(path)); - // } - // Scope *scope = *found; - // GB_ASSERT(scope != nullptr); - // ed->file = scope->file; - - // ImportGraphNode **found_node = nullptr; - // ImportGraphNode *m = nullptr; - // ImportGraphNode *n = nullptr; - - // found_node = map_get(M, hash_pointer(scope)); - // GB_ASSERT(found_node != nullptr); - // m = *found_node; - - // found_node = map_get(M, hash_pointer(parent_package_scope)); - // GB_ASSERT(found_node != nullptr); - // n = *found_node; - - // import_graph_node_set_add(&n->succ, m); - // import_graph_node_set_add(&m->pred, n); - // ptr_set_add(&m->scope->exported, n->scope); - // case_end; - case_ast_node(ws, WhenStmt, decl); if (ws->body != nullptr) { auto stmts = ws->body->BlockStmt.stmts; @@ -2474,39 +2439,36 @@ Array<ImportPathItem> find_import_path(Checker *c, Scope *start, Scope *end, Ptr String path = start->package->fullpath; HashKey key = hash_string(path); Scope **found = map_get(&c->package_scopes, key); - // if (found) { - // AstPackage *p = (*found)->package; - // GB_ASSERT(p != nullptr); - - // for_array(i, f->imports_and_exports) { - // Scope *s = nullptr; - // AstNode *decl = f->imports_and_exports[i]; - // /* if (decl->kind == AstNode_ExportDecl) { - // s = decl->ExportDecl.file->scope; - // } else */ - // if (decl->kind == AstNode_ImportDecl) { - // if (!decl->ImportDecl.is_using) { - // // continue; - // } - // s = decl->ImportDecl.package->scope; - // } else { - // continue; - // } - // GB_ASSERT(s != nullptr); - - // ImportPathItem item = {s, decl}; - // if (s == end) { - // auto path = array_make<ImportPathItem>(heap_allocator()); - // array_add(&path, item); - // return path; - // } - // auto next_path = find_import_path(c, s, end, visited); - // if (next_path.count > 0) { - // array_add(&next_path, item); - // return next_path; - // } - // } - // } + if (found) { + AstPackage *p = (*found)->package; + GB_ASSERT(p != nullptr); + + for_array(i, p->files.entries) { + AstFile *f = p->files.entries[i].value; + for_array(j, f->imports) { + Scope *s = nullptr; + AstNode *decl = f->imports[j]; + if (decl->kind == AstNode_ImportDecl) { + s = decl->ImportDecl.package->scope; + } else { + continue; + } + GB_ASSERT(s != nullptr && s->is_package); + + ImportPathItem item = {s, decl}; + if (s == end) { + auto path = array_make<ImportPathItem>(heap_allocator()); + array_add(&path, item); + return path; + } + auto next_path = find_import_path(c, s, end, visited); + if (next_path.count > 0) { + array_add(&next_path, item); + return next_path; + } + } + } + } return empty_path; } #endif |