Improve default scope size

This commit is contained in:
gingerBill
2021-07-27 10:59:39 +01:00
parent ae25787f48
commit 116e98b378
6 changed files with 51 additions and 8 deletions

View File

@@ -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);
}
}