diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-01-11 23:21:57 +0100 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-01-11 23:21:57 +0100 |
| commit | 3f3eb27677088d86cd7e0331f98385d497d0966a (patch) | |
| tree | 1f3fc486ea5f8b2da3603fd9b0cca9dcf9572fa2 /src/common | |
| parent | 04e2312b458d0448bf39bd94a1770c0710c8f255 (diff) | |
simplified how variables are decided
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/ast.odin | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/ast.odin b/src/common/ast.odin index ff6f7e2..0bc789f 100644 --- a/src/common/ast.odin +++ b/src/common/ast.odin @@ -75,6 +75,25 @@ GlobalExpr :: struct { package_private: bool, } + +unwrap_pointer :: proc(expr: ^ast.Expr) -> (ast.Ident, bool) { + expr := expr; + for expr != nil { + if pointer, ok := expr.derived.(ast.Pointer_Type); ok { + expr = pointer.elem; + } else { + break; + } + } + + if expr != nil { + ident, ok := expr.derived.(ast.Ident); + return ident, ok; + } + + return {}, false; +} + 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 { |