diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2021-04-05 22:36:47 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2021-04-05 22:36:47 +0200 |
| commit | fe72ff5f06b0a39effaf306ef9f21fef17834ae3 (patch) | |
| tree | 47eb6e1eae4fdde7d4d13b24a8a392e7ca94f324 /src/common | |
| parent | afd020c9a4017c0bb5757fc65428923d208c107a (diff) | |
Don't index private procedures
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/ast.odin | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin index c798c1c..e85a261 100644 --- a/src/common/ast.odin +++ b/src/common/ast.odin @@ -34,8 +34,17 @@ GlobalExpr :: struct { docs: ^ast.Comment_Group, } -collect_value_decl :: proc(exprs: ^[dynamic]GlobalExpr, file: ast.File, stmt: ^ast.Node) { +collect_value_decl :: proc(exprs: ^[dynamic]GlobalExpr, file: ast.File, stmt: ^ast.Node, skip_private: bool) { if value_decl, ok := stmt.derived.(ast.Value_Decl); ok { + + for attribute in value_decl.attributes { + for elem in attribute.elems { + if ident, ok := elem.derived.(ast.Ident); ok && ident.name == "private" && skip_private { + return; + } + } + } + for name, i in value_decl.names { str := get_ast_node_string(name, file.src); @@ -50,14 +59,14 @@ collect_value_decl :: proc(exprs: ^[dynamic]GlobalExpr, file: ast.File, stmt: ^a } } -collect_globals :: proc(file: ast.File) -> []GlobalExpr { +collect_globals :: proc(file: ast.File, skip_private := false) -> []GlobalExpr { exprs := make([dynamic]GlobalExpr, context.temp_allocator); for decl in file.decls { if value_decl, ok := decl.derived.(ast.Value_Decl); ok { - collect_value_decl(&exprs, file, decl); + collect_value_decl(&exprs, file, decl, skip_private); } else if when_decl, ok := decl.derived.(ast.When_Stmt); ok { if when_decl.cond == nil { @@ -96,13 +105,13 @@ collect_globals :: proc(file: ast.File) -> []GlobalExpr { if block, ok := when_decl.body.derived.(ast.Block_Stmt); ok { for stmt in block.stmts { - collect_value_decl(&exprs, file, stmt); + collect_value_decl(&exprs, file, stmt, skip_private); } } } else if ident.name != "ODIN_OS" { if block, ok := when_decl.body.derived.(ast.Block_Stmt); ok { for stmt in block.stmts { - collect_value_decl(&exprs, file, stmt); + collect_value_decl(&exprs, file, stmt, skip_private); } } } @@ -112,7 +121,7 @@ collect_globals :: proc(file: ast.File) -> []GlobalExpr { else { if block, ok := when_decl.body.derived.(ast.Block_Stmt); ok { for stmt in block.stmts { - collect_value_decl(&exprs, file, stmt); + collect_value_decl(&exprs, file, stmt, skip_private); } } } @@ -124,7 +133,7 @@ collect_globals :: proc(file: ast.File) -> []GlobalExpr { if block, ok := foreign_decl.body.derived.(ast.Block_Stmt); ok { for stmt in block.stmts { - collect_value_decl(&exprs, file, stmt); + collect_value_decl(&exprs, file, stmt, skip_private); } } } |