diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-27 10:59:39 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-27 10:59:39 +0100 |
| commit | 116e98b37891091841976d1c70ec1fb39c439d8a (patch) | |
| tree | 38be4a443bde7e40037c65a82cf08c5ab756f574 /src/parser.cpp | |
| parent | ae25787f48f4190a90428228c22faf6ae22d7365 (diff) | |
Improve default scope size
Diffstat (limited to 'src/parser.cpp')
| -rw-r--r-- | src/parser.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/parser.cpp b/src/parser.cpp index fcc8078f7..f1f348ff4 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -5261,6 +5261,28 @@ String dir_from_path(String path) { return base_dir; } +isize calc_decl_count(Ast *decl) { + isize count = 0; + switch (decl->kind) { + case Ast_BlockStmt: + for_array(i, decl->BlockStmt.stmts) { + count += calc_decl_count(decl->BlockStmt.stmts.data[i]); + } + break; + case Ast_ValueDecl: + count = decl->ValueDecl.names.count; + break; + case Ast_ForeignBlockDecl: + count = calc_decl_count(decl->ForeignBlockDecl.body); + break; + case Ast_ImportDecl: + case Ast_ForeignImportDecl: + count = 1; + break; + } + return count; +} + bool parse_file(Parser *p, AstFile *f) { if (f->tokens.count == 0) { return true; @@ -5346,6 +5368,8 @@ bool parse_file(Parser *p, AstFile *f) { stmt->ExprStmt.expr->kind == Ast_ProcLit) { syntax_error(stmt, "Procedure literal evaluated but not used"); } + + f->total_file_decl_count += calc_decl_count(stmt); } } |