diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2025-06-25 17:48:04 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2025-06-25 17:48:04 +0200 |
| commit | 344eea71fbf1863106bc051dbae11534e7dcca74 (patch) | |
| tree | afb93528027d91d2c7febe2b1334f964db8f402e /src/server | |
| parent | 312a15dd5752e8c90b57ea4911e5fb29525deee1 (diff) | |
Improve use of runtime procedures without importing the actual package.
Diffstat (limited to 'src/server')
| -rw-r--r-- | src/server/analysis.odin | 12 | ||||
| -rw-r--r-- | src/server/build.odin | 2 | ||||
| -rw-r--r-- | src/server/indexer.odin | 14 | ||||
| -rw-r--r-- | src/server/requests.odin | 5 |
4 files changed, 19 insertions, 14 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index 2990fe3..c485a43 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1445,6 +1445,17 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide } } + //This could also be the runtime package, which is not required to be imported, but itself is used with selector expression in runtime functions: `my_runtime_proc :proc(a: runtime.*)` + if node.name == "runtime" { + symbol := Symbol { + type = .Package, + pkg = indexer.runtime_package, + value = SymbolPackageValue{}, + } + + return symbol, true + } + if global, ok := ast_context.globals[node.name]; ast_context.current_package == ast_context.document_package && ok { is_distinct := false @@ -1601,7 +1612,6 @@ internal_resolve_type_identifier :: proc(ast_context: ^AstContext, node: ast.Ide } for u in ast_context.usings { - //TODO(Daniel, make into a map, not really required for performance but looks nicer) for imp in ast_context.imports { if strings.compare(imp.base, u) == 0 { if symbol, ok := lookup(node.name, imp.name); ok { diff --git a/src/server/build.odin b/src/server/build.odin index d3b8572..d4d0b90 100644 --- a/src/server/build.odin +++ b/src/server/build.odin @@ -278,7 +278,7 @@ setup_index :: proc() { builtin_path := path.join({dir_exe, "builtin"}, context.temp_allocator) if !os.exists(builtin_path) { - log.error("Failed to find the builtin folder at %v", builtin_path) + log.errorf("Failed to find the builtin folder at %v", builtin_path) } try_build_package(builtin_path) diff --git a/src/server/indexer.odin b/src/server/indexer.odin index b7a3bf1..0a161aa 100644 --- a/src/server/indexer.odin +++ b/src/server/indexer.odin @@ -1,14 +1,15 @@ package server -import "core:odin/ast" import "core:fmt" -import "core:strings" import "core:log" +import "core:odin/ast" import "core:slice" +import "core:strings" Indexer :: struct { builtin_packages: [dynamic]string, + runtime_package: string, index: MemoryIndex, } @@ -24,14 +25,7 @@ clear_index_cache :: proc() { memory_index_clear_cache(&indexer.index) } -lookup :: proc( - name: string, - pkg: string, - loc := #caller_location, -) -> ( - Symbol, - bool, -) { +lookup :: proc(name: string, pkg: string, loc := #caller_location) -> (Symbol, bool) { if name == "" { return {}, false } diff --git a/src/server/requests.odin b/src/server/requests.odin index aef44f6..92bd8aa 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -722,8 +722,9 @@ request_initialize :: proc( Add runtime package */ - if core, ok := config.collections["base"]; ok { - append(&indexer.builtin_packages, path.join({core, "runtime"})) + if base, ok := config.collections["base"]; ok { + indexer.runtime_package = path.join({base, "runtime"}) + append(&indexer.builtin_packages, indexer.runtime_package) } file_resolve_cache.files = make(map[string]FileResolve, 200) |