diff options
| author | Bradley Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-09-08 12:05:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-09-08 12:05:28 -0400 |
| commit | 9bdcac7e8724b9c9276bceb4b9f39b65469a693e (patch) | |
| tree | 12695e37725b68fc32c0cee82be23ebe44c348e4 /src/server/analysis.odin | |
| parent | 4c445789e81d53f7de8153513686bbb79ecb78e8 (diff) | |
| parent | 38f27472e9baf7b856dc1ff61c50b19e9b07816c (diff) | |
Merge pull request #983 from BradLewis/feat/improve-semantic-types
Feat/improve semantic types
Diffstat (limited to 'src/server/analysis.odin')
| -rw-r--r-- | src/server/analysis.odin | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 5985fea..1b50468 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1387,7 +1387,8 @@ resolve_selector_expression :: proc(ast_context: ^AstContext, node: ^ast.Selecto set_ast_package_from_node_scoped(ast_context, s.types[i]) ast_context.field_name = node.field^ ok := internal_resolve_type_expression(ast_context, s.types[i], &symbol) - symbol.type = .Variable + symbol.type = .Field + symbol.flags |= {.Mutable} return symbol, ok } } @@ -1396,7 +1397,8 @@ resolve_selector_expression :: proc(ast_context: ^AstContext, node: ^ast.Selecto if node.field != nil && name == node.field.name { ast_context.field_name = node.field^ ok := internal_resolve_type_expression(ast_context, s.types[i], &symbol) - symbol.type = .Variable + symbol.type = .Field + symbol.flags |= {.Mutable} return symbol, ok } } @@ -1682,7 +1684,7 @@ resolve_local_identifier :: proc(ast_context: ^AstContext, node: ast.Ident, loca case ^ast.Basic_Lit: return_symbol, ok = resolve_basic_lit(ast_context, v^) return_symbol.name = node.name - return_symbol.type = local.variable ? .Variable : .Constant + return_symbol.type = .Mutable in local.flags ? .Variable : .Constant case ^ast.Binary_Expr: return_symbol, ok = resolve_binary_expression(ast_context, v) case: @@ -1698,8 +1700,12 @@ resolve_local_identifier :: proc(ast_context: ^AstContext, node: ast.Ident, loca return_symbol.flags |= {.Parameter} } - if local.variable { + if .Mutable in local.flags { return_symbol.type = .Variable + return_symbol.flags |= {.Mutable} + } + if .Variable in local.flags { + return_symbol.flags |= {.Variable} } return_symbol.flags |= {.Local} @@ -1733,7 +1739,7 @@ resolve_global_identifier :: proc(ast_context: ^AstContext, node: ast.Ident, glo } if ok = internal_resolve_type_expression(ast_context, v.expr, &return_symbol); ok { - return_types := get_proc_return_types(ast_context, return_symbol, v, global.mutable) + return_types := get_proc_return_types(ast_context, return_symbol, v, .Mutable in global.flags) if len(return_types) > 0 { ok = internal_resolve_type_expression(ast_context, return_types[0], &return_symbol) } @@ -1799,7 +1805,7 @@ resolve_global_identifier :: proc(ast_context: ^AstContext, node: ast.Ident, glo case ^ast.Basic_Lit: return_symbol, ok = resolve_basic_lit(ast_context, v^) return_symbol.name = node.name - return_symbol.type = global.mutable ? .Variable : .Constant + return_symbol.type = .Mutable in global.flags ? .Variable : .Constant case: ok = internal_resolve_type_expression(ast_context, global.expr, &return_symbol) } @@ -1809,8 +1815,13 @@ resolve_global_identifier :: proc(ast_context: ^AstContext, node: ast.Ident, glo return_symbol.flags |= {.Distinct} } - if global.mutable { + if .Mutable in global.flags { return_symbol.type = .Variable + return_symbol.flags |= {.Mutable} + } + + if .Variable in global.flags { + return_symbol.flags |= {.Variable} } if global.docs != nil { @@ -2637,6 +2648,7 @@ resolve_container_allocator_location :: proc(ast_context: ^AstContext, container for name, i in v.names { if name == "allocator" { symbol.range = v.ranges[i] + symbol.type = .Field return symbol, true } } @@ -2683,18 +2695,21 @@ resolve_symbol_selector :: proc( for name, i in v.names { if strings.compare(name, field) == 0 { symbol.range = v.ranges[i] + symbol.type = .EnumMember } } case SymbolStructValue: for name, i in v.names { if strings.compare(name, field) == 0 { symbol.range = v.ranges[i] + symbol.type = .Field } } case SymbolBitFieldValue: for name, i in v.names { if strings.compare(name, field) == 0 { symbol.range = v.ranges[i] + symbol.type = .Field } } case SymbolPackageValue: |