mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-02 20:58:15 +00:00
Remove dead code
This commit is contained in:
+28
-66
@@ -2352,41 +2352,6 @@ void add_import_dependency_node(Checker *c, AstNode *decl, Map<ImportGraphNode *
|
|||||||
}
|
}
|
||||||
case_end;
|
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);
|
case_ast_node(ws, WhenStmt, decl);
|
||||||
if (ws->body != nullptr) {
|
if (ws->body != nullptr) {
|
||||||
auto stmts = ws->body->BlockStmt.stmts;
|
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;
|
String path = start->package->fullpath;
|
||||||
HashKey key = hash_string(path);
|
HashKey key = hash_string(path);
|
||||||
Scope **found = map_get(&c->package_scopes, key);
|
Scope **found = map_get(&c->package_scopes, key);
|
||||||
// if (found) {
|
if (found) {
|
||||||
// AstPackage *p = (*found)->package;
|
AstPackage *p = (*found)->package;
|
||||||
// GB_ASSERT(p != nullptr);
|
GB_ASSERT(p != nullptr);
|
||||||
|
|
||||||
// for_array(i, f->imports_and_exports) {
|
for_array(i, p->files.entries) {
|
||||||
// Scope *s = nullptr;
|
AstFile *f = p->files.entries[i].value;
|
||||||
// AstNode *decl = f->imports_and_exports[i];
|
for_array(j, f->imports) {
|
||||||
// /* if (decl->kind == AstNode_ExportDecl) {
|
Scope *s = nullptr;
|
||||||
// s = decl->ExportDecl.file->scope;
|
AstNode *decl = f->imports[j];
|
||||||
// } else */
|
if (decl->kind == AstNode_ImportDecl) {
|
||||||
// if (decl->kind == AstNode_ImportDecl) {
|
s = decl->ImportDecl.package->scope;
|
||||||
// if (!decl->ImportDecl.is_using) {
|
} else {
|
||||||
// // continue;
|
continue;
|
||||||
// }
|
}
|
||||||
// s = decl->ImportDecl.package->scope;
|
GB_ASSERT(s != nullptr && s->is_package);
|
||||||
// } else {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// GB_ASSERT(s != nullptr);
|
|
||||||
|
|
||||||
// ImportPathItem item = {s, decl};
|
ImportPathItem item = {s, decl};
|
||||||
// if (s == end) {
|
if (s == end) {
|
||||||
// auto path = array_make<ImportPathItem>(heap_allocator());
|
auto path = array_make<ImportPathItem>(heap_allocator());
|
||||||
// array_add(&path, item);
|
array_add(&path, item);
|
||||||
// return path;
|
return path;
|
||||||
// }
|
}
|
||||||
// auto next_path = find_import_path(c, s, end, visited);
|
auto next_path = find_import_path(c, s, end, visited);
|
||||||
// if (next_path.count > 0) {
|
if (next_path.count > 0) {
|
||||||
// array_add(&next_path, item);
|
array_add(&next_path, item);
|
||||||
// return next_path;
|
return next_path;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
return empty_path;
|
return empty_path;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+5
-38
@@ -61,7 +61,6 @@ Token ast_node_token(AstNode *node) {
|
|||||||
|
|
||||||
case AstNode_ValueDecl: return ast_node_token(node->ValueDecl.names[0]);
|
case AstNode_ValueDecl: return ast_node_token(node->ValueDecl.names[0]);
|
||||||
case AstNode_ImportDecl: return node->ImportDecl.token;
|
case AstNode_ImportDecl: return node->ImportDecl.token;
|
||||||
// case AstNode_ExportDecl: return node->ExportDecl.token;
|
|
||||||
case AstNode_ForeignImportDecl: return node->ForeignImportDecl.token;
|
case AstNode_ForeignImportDecl: return node->ForeignImportDecl.token;
|
||||||
|
|
||||||
case AstNode_ForeignBlockDecl: return node->ForeignBlockDecl.token;
|
case AstNode_ForeignBlockDecl: return node->ForeignBlockDecl.token;
|
||||||
@@ -1011,16 +1010,6 @@ AstNode *ast_import_decl(AstFile *f, Token token, bool is_using, Token relpath,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// AstNode *ast_export_decl(AstFile *f, Token token, Token relpath,
|
|
||||||
// CommentGroup docs, CommentGroup comment) {
|
|
||||||
// AstNode *result = make_ast_node(f, AstNode_ExportDecl);
|
|
||||||
// result->ExportDecl.token = token;
|
|
||||||
// result->ExportDecl.relpath = relpath;
|
|
||||||
// result->ExportDecl.docs = docs;
|
|
||||||
// result->ExportDecl.comment = comment;
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
|
|
||||||
AstNode *ast_foreign_import_decl(AstFile *f, Token token, Token filepath, Token library_name,
|
AstNode *ast_foreign_import_decl(AstFile *f, Token token, Token filepath, Token library_name,
|
||||||
CommentGroup docs, CommentGroup comment) {
|
CommentGroup docs, CommentGroup comment) {
|
||||||
AstNode *result = make_ast_node(f, AstNode_ForeignImportDecl);
|
AstNode *result = make_ast_node(f, AstNode_ForeignImportDecl);
|
||||||
@@ -1319,7 +1308,6 @@ bool is_semicolon_optional_for_node(AstFile *f, AstNode *s) {
|
|||||||
return s->ProcLit.body != nullptr;
|
return s->ProcLit.body != nullptr;
|
||||||
|
|
||||||
case AstNode_ImportDecl:
|
case AstNode_ImportDecl:
|
||||||
// case AstNode_ExportDecl:
|
|
||||||
case AstNode_ForeignImportDecl:
|
case AstNode_ForeignImportDecl:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
@@ -3481,7 +3469,7 @@ AstNode *parse_import_decl(AstFile *f, ImportDeclKind kind) {
|
|||||||
s = ast_bad_decl(f, import_name, file_path);
|
s = ast_bad_decl(f, import_name, file_path);
|
||||||
} else {
|
} else {
|
||||||
s = ast_import_decl(f, token, is_using, file_path, import_name, docs, f->line_comment);
|
s = ast_import_decl(f, token, is_using, file_path, import_name, docs, f->line_comment);
|
||||||
array_add(&f->imports_and_exports, s);
|
array_add(&f->imports, s);
|
||||||
}
|
}
|
||||||
expect_semicolon(f, s);
|
expect_semicolon(f, s);
|
||||||
return s;
|
return s;
|
||||||
@@ -3642,13 +3630,7 @@ AstNode *parse_stmt(AstFile *f) {
|
|||||||
import_decl->ImportDecl.using_in_list = list;
|
import_decl->ImportDecl.using_in_list = list;
|
||||||
}
|
}
|
||||||
return import_decl;
|
return import_decl;
|
||||||
} /* else if (f->curr_token.kind == Token_export) {
|
}
|
||||||
AstNode *export_decl = parse_export_decl(f);
|
|
||||||
if (export_decl->kind == AstNode_ExportDecl) {
|
|
||||||
export_decl->ExportDecl.using_in_list = list;
|
|
||||||
}
|
|
||||||
return export_decl;
|
|
||||||
} */
|
|
||||||
|
|
||||||
AstNode *expr = parse_expr(f, true);
|
AstNode *expr = parse_expr(f, true);
|
||||||
expect_semicolon(f, expr);
|
expect_semicolon(f, expr);
|
||||||
@@ -3873,7 +3855,7 @@ ParseFileError init_ast_file(AstFile *f, String fullpath, TokenPos *err_pos) {
|
|||||||
arena_size *= 2*f->tokens.count;
|
arena_size *= 2*f->tokens.count;
|
||||||
gb_arena_init_from_allocator(&f->arena, heap_allocator(), arena_size);
|
gb_arena_init_from_allocator(&f->arena, heap_allocator(), arena_size);
|
||||||
array_init(&f->comments, heap_allocator());
|
array_init(&f->comments, heap_allocator());
|
||||||
array_init(&f->imports_and_exports, heap_allocator());
|
array_init(&f->imports, heap_allocator());
|
||||||
|
|
||||||
f->curr_proc = nullptr;
|
f->curr_proc = nullptr;
|
||||||
|
|
||||||
@@ -3885,7 +3867,7 @@ void destroy_ast_file(AstFile *f) {
|
|||||||
gb_arena_free(&f->arena);
|
gb_arena_free(&f->arena);
|
||||||
array_free(&f->tokens);
|
array_free(&f->tokens);
|
||||||
array_free(&f->comments);
|
array_free(&f->comments);
|
||||||
array_free(&f->imports_and_exports);
|
array_free(&f->imports);
|
||||||
gb_free(heap_allocator(), f->tokenizer.fullpath.text);
|
gb_free(heap_allocator(), f->tokenizer.fullpath.text);
|
||||||
destroy_tokenizer(&f->tokenizer);
|
destroy_tokenizer(&f->tokenizer);
|
||||||
}
|
}
|
||||||
@@ -4098,22 +4080,7 @@ void parse_setup_file_decls(Parser *p, AstFile *f, String base_dir, Array<AstNod
|
|||||||
|
|
||||||
id->fullpath = import_path;
|
id->fullpath = import_path;
|
||||||
try_add_import_path(p, import_path, original_string, ast_node_token(node).pos);
|
try_add_import_path(p, import_path, original_string, ast_node_token(node).pos);
|
||||||
} /* else if (node->kind == AstNode_ExportDecl) {
|
} else if (node->kind == AstNode_ForeignImportDecl) {
|
||||||
ast_node(ed, ExportDecl, node);
|
|
||||||
|
|
||||||
String original_string = ed->relpath.string;
|
|
||||||
String export_path = {};
|
|
||||||
bool ok = determine_path_from_string(p, node, base_dir, original_string, &export_path);
|
|
||||||
if (!ok) {
|
|
||||||
decls[i] = ast_bad_decl(f, ed->relpath, ed->relpath);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
export_path = string_trim_whitespace(export_path);
|
|
||||||
|
|
||||||
ed->fullpath = export_path;
|
|
||||||
try_add_import_path(p, export_path, original_string, ast_node_token(node).pos);
|
|
||||||
} */else if (node->kind == AstNode_ForeignImportDecl) {
|
|
||||||
ast_node(fl, ForeignImportDecl, node);
|
ast_node(fl, ForeignImportDecl, node);
|
||||||
|
|
||||||
String file_str = fl->filepath.string;
|
String file_str = fl->filepath.string;
|
||||||
|
|||||||
+1
-11
@@ -64,7 +64,7 @@ struct AstFile {
|
|||||||
isize when_level;
|
isize when_level;
|
||||||
|
|
||||||
Array<AstNode *> decls;
|
Array<AstNode *> decls;
|
||||||
Array<AstNode *> imports_and_exports; // 'import' 'using import' 'export'
|
Array<AstNode *> imports; // 'import' 'using import'
|
||||||
|
|
||||||
|
|
||||||
AstNode * curr_proc;
|
AstNode * curr_proc;
|
||||||
@@ -368,16 +368,6 @@ AST_NODE_KIND(_DeclBegin, "", struct {}) \
|
|||||||
bool is_using; \
|
bool is_using; \
|
||||||
bool been_handled; \
|
bool been_handled; \
|
||||||
}) \
|
}) \
|
||||||
/* AST_NODE_KIND(ExportDecl, "export declaration", struct { \
|
|
||||||
AstFile *file; \
|
|
||||||
Token token; \
|
|
||||||
Token relpath; \
|
|
||||||
String fullpath; \
|
|
||||||
Array<AstNode *> using_in_list; \
|
|
||||||
CommentGroup docs; \
|
|
||||||
CommentGroup comment; \
|
|
||||||
bool been_handled; \
|
|
||||||
}) */ \
|
|
||||||
AST_NODE_KIND(ForeignImportDecl, "foreign import declaration", struct { \
|
AST_NODE_KIND(ForeignImportDecl, "foreign import declaration", struct { \
|
||||||
Token token; \
|
Token token; \
|
||||||
Token filepath; \
|
Token filepath; \
|
||||||
|
|||||||
Reference in New Issue
Block a user