diff options
| author | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-09 21:29:50 +0200 |
|---|---|---|
| committer | Daniel Gavin <danielgavin5@hotmail.com> | 2022-07-09 21:29:50 +0200 |
| commit | ec8bb7ab5a7aaabd1d8cbd159639b9f29ad4b8e6 (patch) | |
| tree | 0bbf01d1f7160569112bbdefddde26f07c1690b5 | |
| parent | 22617323ab40d28480541527957f76697e308d2c (diff) | |
more fixes
| -rw-r--r-- | src/server/analysis.odin | 2 | ||||
| -rw-r--r-- | src/server/build.odin | 11 | ||||
| -rw-r--r-- | src/server/collector.odin | 2 | ||||
| -rw-r--r-- | src/server/completion.odin | 33 | ||||
| -rw-r--r-- | src/server/requests.odin | 18 | ||||
| -rw-r--r-- | tests/builtin/builtin.odin | 81 | ||||
| -rw-r--r-- | tests/builtin/intrinsics.odin | 0 |
7 files changed, 107 insertions, 40 deletions
diff --git a/src/server/analysis.odin b/src/server/analysis.odin index aabaf79..9d61ae9 100644 --- a/src/server/analysis.odin +++ b/src/server/analysis.odin @@ -1034,6 +1034,8 @@ resolve_type_expression :: proc(ast_context: ^AstContext, node: ^ast.Expr) -> (S case SymbolPackageValue: ast_context.current_package = selector.pkg + try_build_package(ast_context.current_package) + if v.field != nil { return resolve_symbol_return(ast_context, lookup(v.field.name, selector.pkg)) } else { diff --git a/src/server/build.odin b/src/server/build.odin index a903b3d..7fd26d1 100644 --- a/src/server/build.odin +++ b/src/server/build.odin @@ -106,17 +106,14 @@ try_build_package :: proc(pkg_name: string) { } } -/* - -evict_old_build_packages :: proc() { - -} -*/ - setup_index :: proc() { build_cache.loaded_pkgs = make(map[string]PackageCacheInfo, 50, context.allocator) symbol_collection := make_symbol_collection(context.allocator, &common.config) indexer.index = make_memory_index(symbol_collection) + + dir_exe := path.dir(os.args[0]) + + try_build_package(path.join(dir_exe, "builtin")) } free_index :: proc() { diff --git a/src/server/collector.odin b/src/server/collector.odin index 469c748..e5c5bcb 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -371,7 +371,7 @@ collect_symbols :: proc(collection: ^SymbolCollection, file: ast.File, uri: stri symbol.name = get_index_unique_string(collection, name) symbol.type = token_type symbol.doc = common.get_doc(expr.docs, collection.allocator) - + if expr.builtin || strings.contains(uri, "builtin.odin") { symbol.pkg = "$builtin" } else if strings.contains(uri, "intrinsics.odin") { diff --git a/src/server/completion.odin b/src/server/completion.odin index 3de9ee9..786db8d 100644 --- a/src/server/completion.odin +++ b/src/server/completion.odin @@ -799,18 +799,18 @@ get_implicit_completion :: proc(ast_context: ^AstContext, position_context: ^Doc } } -CombinedResult :: struct { - score: f32, - snippet: Snippet_Info, - name: string, - type: SymbolType, - doc: string, - pkg: string, - signature: string, - flags: SymbolFlags, -} - get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^DocumentPositionContext, list: ^CompletionList) { + CombinedResult :: struct { + score: f32, + snippet: Snippet_Info, + name: string, + type: SymbolType, + doc: string, + pkg: string, + signature: string, + flags: SymbolFlags, + } + items := make([dynamic]CompletionItem, context.temp_allocator) list.isIncomplete = true @@ -1001,21 +1001,10 @@ get_identifier_completion :: proc(ast_context: ^AstContext, position_context: ^D } } - for f in combined { - //log.error(f.name, " ") - } - - //log.error("sorting done \n") - slice.sort_by(combined[:], proc(i, j: CombinedResult) -> bool { return j.score < i.score }) - for f in combined { - //log.error(f.name, " ") - } - - //hard code for now top_results := combined[0:(min(50, len(combined)))] diff --git a/src/server/requests.odin b/src/server/requests.odin index 6e6fdc3..c9d9a8d 100644 --- a/src/server/requests.odin +++ b/src/server/requests.odin @@ -418,9 +418,6 @@ request_initialize :: proc (params: json.Value, id: RequestId, config: ^common.C } } - if ok := "" in config.collections; !ok { - config.collections[""] = strings.clone(uri.path) - } } else { log.errorf("Failed to unmarshal %v", file) } @@ -826,22 +823,23 @@ notification_did_save :: proc (params: json.Value, id: RequestId, config: ^commo if !ok { log.errorf("error in parse file for indexing %v", fullpath) } - /* - for k, v in &indexer.dynamic_index.collection.packages { + + corrected_uri := common.create_uri(fullpath, context.temp_allocator) + + for k, v in &indexer.index.collection.packages { for k2, v2 in &v { - if v2.uri == uri.uri { - free_symbol(v2, context.allocator) + if corrected_uri.uri == v2.uri { + free_symbol(v2, indexer.index.collection.allocator) v[k2] = {} } } } - if ret := collect_symbols(&indexer.dynamic_index.collection, file, uri.uri); ret != .None { + if ret := collect_symbols(&indexer.index.collection, file, corrected_uri.uri); ret != .None { log.errorf("failed to collect symbols on save %v", ret) } - indexer.dynamic_uri_owned[uri.uri] = true - */ + check(uri, writer, config) return .None diff --git a/tests/builtin/builtin.odin b/tests/builtin/builtin.odin new file mode 100644 index 0000000..8a7c773 --- /dev/null +++ b/tests/builtin/builtin.odin @@ -0,0 +1,81 @@ +package ols_builtin + +// Procedures +@builtin len :: proc(array: Array_Type) -> int --- +@builtin cap :: proc(array: Array_Type) -> int --- + +size_of :: proc($T: typeid) -> int --- +@builtin align_of :: proc($T: typeid) -> int --- +@builtin offset_of :: proc($T: typeid) -> uintptr --- +@builtin type_of :: proc(x: expr) -> type --- +@builtin type_info_of :: proc($T: typeid) -> ^runtime.Type_Info --- +@builtin typeid_of :: proc($T: typeid) -> typeid --- + +@builtin swizzle :: proc(x: [N]T, indices: ..int) -> [len(indices)]T --- + +complex :: proc(real, imag: Float) -> Complex_Type --- +quaternion :: proc(real, imag, jmag, kmag: Float) -> Quaternion_Type --- +real :: proc(value: Complex_Or_Quaternion) -> Float --- +imag :: proc(value: Complex_Or_Quaternion) -> Float --- +jmag :: proc(value: Quaternion) -> Float --- +kmag :: proc(value: Quaternion) -> Float --- +conj :: proc(value: Complex_Or_Quaternion) -> Complex_Or_Quaternion --- + +@builtin min :: proc(values: ..T) -> T --- +@builtin max :: proc(values: ..T) -> T --- +@builtin abs :: proc(value: T) -> T --- +@builtin clamp :: proc(value, minimum, maximum: T) -> T --- + +/* + This is interally from the compiler +*/ + +Odin_OS_Type :: enum int { + Unknown, + Windows, + Darwin, + Linux, + Essence, + FreeBSD, + WASI, + JS, + Freestanding, +} + +@builtin +ODIN_OS: Odin_OS_Type + +Odin_Arch_Type :: enum int { + Unknown, + amd64, + i386, + arm64, + wasm32, + wasm64, +} + +@builtin +ODIN_ARCH: Odin_Arch_Type + +Odin_Build_Mode_Type :: enum int { + Executable, + Dynamic, + Object, + Assembly, + LLVM_IR, +} + +@builtin +ODIN_BUILD_MODE: Odin_Build_Mode_Type + +Odin_Endian_Type :: enum int { + Unknown, + Little, + Big, +} + +@builtin +ODIN_ENDIAN: Odin_Endian_Type + +@builtin +ODIN_DEBUG: bool
\ No newline at end of file diff --git a/tests/builtin/intrinsics.odin b/tests/builtin/intrinsics.odin new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/builtin/intrinsics.odin |