diff options
| author | DanielGavin <danielgavin5@hotmail.com> | 2024-06-04 19:45:21 +0200 |
|---|---|---|
| committer | DanielGavin <danielgavin5@hotmail.com> | 2024-06-04 19:45:21 +0200 |
| commit | 6c82924d0a56ca6868e89ba2559a0bf9ca07c16b (patch) | |
| tree | 7263c9c3912978f68898fa85be6786436965c7b1 | |
| parent | ef77d6ab12be2c6d47ff33c3e7a04884c915e97d (diff) | |
Start fixing memory leaks on tests.
| -rw-r--r-- | build.bat | 4 | ||||
| -rw-r--r-- | builtin/intrinsics.odin | 376 | ||||
| -rw-r--r-- | src/common/util_windows.odin | 36 | ||||
| -rw-r--r-- | src/server/build.odin | 7 | ||||
| -rw-r--r-- | src/server/collector.odin | 5 | ||||
| -rw-r--r-- | src/server/documents.odin | 3 | ||||
| -rw-r--r-- | src/server/symbol.odin | 3 | ||||
| -rw-r--r-- | src/testing/testing.odin | 83 | ||||
| -rw-r--r-- | tests/completions_test.odin | 50 | ||||
| -rw-r--r-- | tests/hover_test.odin | 4 | ||||
| -rw-r--r-- | tests/objc_test.odin | 8 | ||||
| -rw-r--r-- | tests/signatures_test.odin | 8 |
12 files changed, 349 insertions, 238 deletions
@@ -12,9 +12,9 @@ if "%1" == "CI" ( call "tools/odinfmt/tests.bat"
if %errorlevel% neq 0 exit /b 1
) else if "%1" == "test" (
- odin test tests -collection:src=src -debug
+ odin test tests -collection:src=src -debug -define:ODIN_TEST_THREADS=1
) else if "%1" == "single_test" (
- odin test tests -collection:src=src -test-name:%2
+ odin test tests -collection:src=src -define:ODIN_TEST_NAMES=%2 -debug
) else if "%1" == "debug" (
odin build src\ -show-timings -collection:src=src -microarch:native -out:ols.exe -o:minimal -no-bounds-check -use-separate-modules -debug
) else (
diff --git a/builtin/intrinsics.odin b/builtin/intrinsics.odin index 4007cad..46678f2 100644 --- a/builtin/intrinsics.odin +++ b/builtin/intrinsics.odin @@ -4,61 +4,67 @@ package ols_builtin is_package_imported :: proc(package_name: string) -> bool --- // Types -soa_struct :: proc($N: int, $T: typeid) -> type/#soa[N]T +soa_struct :: proc($N: int, $T: typeid) -> type / #soa[N]T // Volatile -volatile_load :: proc(dst: ^$T) -> T --- +volatile_load :: proc(dst: ^$T) -> T --- volatile_store :: proc(dst: ^$T, val: T) --- -non_temporal_load :: proc(dst: ^$T) -> T --- -non_temporal_store :: proc(dst: ^$T, val: T) --- +non_temporal_load :: proc(dst: ^$T) -> T --- +non_temporal_store :: proc(dst: ^$T, val: T) --- // Trapping debug_trap :: proc() --- -trap :: proc() -> ! --- +trap :: proc() -> ! --- // Instructions -alloca :: proc(size, align: int) -> [^]u8 --- -cpu_relax :: proc() --- +alloca :: proc(size, align: int) -> [^]u8 --- +cpu_relax :: proc() --- read_cycle_counter :: proc() -> i64 --- -count_ones :: proc(x: $T) -> T where type_is_integer(T) || type_is_simd_vector(T) --- -count_zeros :: proc(x: $T) -> T where type_is_integer(T) || type_is_simd_vector(T) --- -count_trailing_zeros :: proc(x: $T) -> T where type_is_integer(T) || type_is_simd_vector(T) --- -count_leading_zeros :: proc(x: $T) -> T where type_is_integer(T) || type_is_simd_vector(T) --- -reverse_bits :: proc(x: $T) -> T where type_is_integer(T) || type_is_simd_vector(T) --- -byte_swap :: proc(x: $T) -> T where type_is_integer(T) || type_is_float(T) --- +count_ones :: proc(x: $T) -> T --- +count_zeros :: proc(x: $T) -> T --- +count_trailing_zeros :: proc(x: $T) -> T --- +count_leading_zeros :: proc(x: $T) -> T --- +reverse_bits :: proc(x: $T) -> T --- +byte_swap :: proc(x: $T) -> T --- overflow_add :: proc(lhs, rhs: $T) -> (T, bool) #optional_ok --- overflow_sub :: proc(lhs, rhs: $T) -> (T, bool) #optional_ok --- overflow_mul :: proc(lhs, rhs: $T) -> (T, bool) #optional_ok --- -sqrt :: proc(x: $T) -> T where type_is_float(T) || (type_is_simd_vector(T) && type_is_float(type_elem_type(T))) --- +sqrt :: proc(x: $T) -> T --- -fused_mul_add :: proc(a, b, c: $T) -> T where type_is_float(T) || (type_is_simd_vector(T) && type_is_float(type_elem_type(T))) --- +fused_mul_add :: proc(a, b, c: $T) -> T --- -mem_copy :: proc(dst, src: rawptr, len: int) --- +mem_copy :: proc(dst, src: rawptr, len: int) --- mem_copy_non_overlapping :: proc(dst, src: rawptr, len: int) --- -mem_zero :: proc(ptr: rawptr, len: int) --- -mem_zero_volatile :: proc(ptr: rawptr, len: int) --- +mem_zero :: proc(ptr: rawptr, len: int) --- +mem_zero_volatile :: proc(ptr: rawptr, len: int) --- // prefer [^]T operations if possible ptr_offset :: proc(ptr: ^$T, offset: int) -> ^T --- -ptr_sub :: proc(a, b: ^$T) -> int --- - -unaligned_load :: proc(src: ^$T) -> T --- -unaligned_store :: proc(dst: ^$T, val: T) -> T --- - -fixed_point_mul :: proc(lhs, rhs: $T, #const scale: uint) -> T where type_is_integer(T) --- -fixed_point_div :: proc(lhs, rhs: $T, #const scale: uint) -> T where type_is_integer(T) --- -fixed_point_mul_sat :: proc(lhs, rhs: $T, #const scale: uint) -> T where type_is_integer(T) --- -fixed_point_div_sat :: proc(lhs, rhs: $T, #const scale: uint) -> T where type_is_integer(T) --- - -prefetch_read_instruction :: proc(address: rawptr, #const locality: i32 /* 0..=3 */) --- -prefetch_read_data :: proc(address: rawptr, #const locality: i32 /* 0..=3 */) --- -prefetch_write_instruction :: proc(address: rawptr, #const locality: i32 /* 0..=3 */) --- -prefetch_write_data :: proc(address: rawptr, #const locality: i32 /* 0..=3 */) --- +ptr_sub :: proc(a, b: ^$T) -> int --- + +unaligned_load :: proc(src: ^$T) -> T --- +unaligned_store :: proc(dst: ^$T, val: T) -> T --- + +fixed_point_mul :: proc(lhs, rhs: $T, scale: uint) -> T --- +fixed_point_div :: proc(lhs, rhs: $T, scale: uint) -> T --- +fixed_point_mul_sat :: proc(lhs, rhs: $T, scale: uint) -> T --- +fixed_point_div_sat :: proc(lhs, rhs: $T, scale: uint) -> T --- + +prefetch_read_instruction :: proc( + address: rawptr, + locality: i32, +) --- /* 0..=3 */ +prefetch_read_data :: proc(address: rawptr, locality: i32) --- /* 0..=3 */ +prefetch_write_instruction :: proc( + address: rawptr, + locality: i32, +) --- /* 0..=3 */ +prefetch_write_data :: proc(address: rawptr, locality: i32) --- /* 0..=3 */ // Compiler Hints expect :: proc(val, expected_val: T) -> T --- @@ -82,32 +88,86 @@ atomic_type_is_lock_free :: proc($T: typeid) -> bool --- atomic_thread_fence :: proc(order: Atomic_Memory_Order) --- atomic_signal_fence :: proc(order: Atomic_Memory_Order) --- -atomic_store :: proc(dst: ^$T, val: T) --- +atomic_store :: proc(dst: ^$T, val: T) --- atomic_store_explicit :: proc(dst: ^$T, val: T, order: Atomic_Memory_Order) --- -atomic_load :: proc(dst: ^$T) -> T --- -atomic_load_explicit :: proc(dst: ^$T, order: Atomic_Memory_Order) -> T --- +atomic_load :: proc(dst: ^$T) -> T --- +atomic_load_explicit :: proc(dst: ^$T, order: Atomic_Memory_Order) -> T --- // fetch then operator -atomic_add :: proc(dst: ^$T, val: T) -> T --- -atomic_add_explicit :: proc(dst: ^$T, val: T, order: Atomic_Memory_Order) -> T --- -atomic_sub :: proc(dst: ^$T, val: T) -> T --- -atomic_sub_explicit :: proc(dst: ^$T, val: T, order: Atomic_Memory_Order) -> T --- -atomic_and :: proc(dst: ^$T, val: T) -> T --- -atomic_and_explicit :: proc(dst: ^$T, val: T, order: Atomic_Memory_Order) -> T --- -atomic_nand :: proc(dst: ^$T, val: T) -> T --- -atomic_nand_explicit :: proc(dst: ^$T, val: T, order: Atomic_Memory_Order) -> T --- -atomic_or :: proc(dst: ^$T, val: T) -> T --- -atomic_or_explicit :: proc(dst: ^$T, val: T, order: Atomic_Memory_Order) -> T --- -atomic_xor :: proc(dst: ^$T, val: T) -> T --- -atomic_xor_explicit :: proc(dst: ^$T, val: T, order: Atomic_Memory_Order) -> T --- -atomic_exchange :: proc(dst: ^$T, val: T) -> T --- -atomic_exchange_explicit :: proc(dst: ^$T, val: T, order: Atomic_Memory_Order) -> T --- - -atomic_compare_exchange_strong :: proc(dst: ^$T, old, new: T) -> (T, bool) #optional_ok --- -atomic_compare_exchange_strong_explicit :: proc(dst: ^$T, old, new: T, success, failure: Atomic_Memory_Order) -> (T, bool) #optional_ok --- -atomic_compare_exchange_weak :: proc(dst: ^$T, old, new: T) -> (T, bool) #optional_ok --- -atomic_compare_exchange_weak_explicit :: proc(dst: ^$T, old, new: T, success, failure: Atomic_Memory_Order) -> (T, bool) #optional_ok --- +atomic_add :: proc(dst: ^$T, val: T) -> T --- +atomic_add_explicit :: proc( + dst: ^$T, + val: T, + order: Atomic_Memory_Order, +) -> T --- +atomic_sub :: proc(dst: ^$T, val: T) -> T --- +atomic_sub_explicit :: proc( + dst: ^$T, + val: T, + order: Atomic_Memory_Order, +) -> T --- +atomic_and :: proc(dst: ^$T, val: T) -> T --- +atomic_and_explicit :: proc( + dst: ^$T, + val: T, + order: Atomic_Memory_Order, +) -> T --- +atomic_nand :: proc(dst: ^$T, val: T) -> T --- +atomic_nand_explicit :: proc( + dst: ^$T, + val: T, + order: Atomic_Memory_Order, +) -> T --- +atomic_or :: proc(dst: ^$T, val: T) -> T --- +atomic_or_explicit :: proc( + dst: ^$T, + val: T, + order: Atomic_Memory_Order, +) -> T --- +atomic_xor :: proc(dst: ^$T, val: T) -> T --- +atomic_xor_explicit :: proc( + dst: ^$T, + val: T, + order: Atomic_Memory_Order, +) -> T --- +atomic_exchange :: proc(dst: ^$T, val: T) -> T --- +atomic_exchange_explicit :: proc( + dst: ^$T, + val: T, + order: Atomic_Memory_Order, +) -> T --- + +atomic_compare_exchange_strong :: proc( + dst: ^$T, + old, new: T, +) -> ( + T, + bool, +) #optional_ok --- +atomic_compare_exchange_strong_explicit :: proc( + dst: ^$T, + old, new: T, + success, failure: Atomic_Memory_Order, +) -> ( + T, + bool, +) #optional_ok --- +atomic_compare_exchange_weak :: proc( + dst: ^$T, + old, new: T, +) -> ( + T, + bool, +) #optional_ok --- +atomic_compare_exchange_weak_explicit :: proc( + dst: ^$T, + old, new: T, + success, failure: Atomic_Memory_Order, +) -> ( + T, + bool, +) #optional_ok --- // Constant type tests @@ -116,83 +176,94 @@ type_base_type :: proc($T: typeid) -> type --- type_core_type :: proc($T: typeid) -> type --- type_elem_type :: proc($T: typeid) -> type --- -type_is_boolean :: proc($T: typeid) -> bool --- -type_is_integer :: proc($T: typeid) -> bool --- -type_is_rune :: proc($T: typeid) -> bool --- -type_is_float :: proc($T: typeid) -> bool --- -type_is_complex :: proc($T: typeid) -> bool --- +type_is_boolean :: proc($T: typeid) -> bool --- +type_is_integer :: proc($T: typeid) -> bool --- +type_is_rune :: proc($T: typeid) -> bool --- +type_is_float :: proc($T: typeid) -> bool --- +type_is_complex :: proc($T: typeid) -> bool --- type_is_quaternion :: proc($T: typeid) -> bool --- -type_is_string :: proc($T: typeid) -> bool --- -type_is_typeid :: proc($T: typeid) -> bool --- -type_is_any :: proc($T: typeid) -> bool --- - -type_is_endian_platform :: proc($T: typeid) -> bool --- -type_is_endian_little :: proc($T: typeid) -> bool --- -type_is_endian_big :: proc($T: typeid) -> bool --- -type_is_unsigned :: proc($T: typeid) -> bool --- -type_is_numeric :: proc($T: typeid) -> bool --- -type_is_ordered :: proc($T: typeid) -> bool --- -type_is_ordered_numeric :: proc($T: typeid) -> bool --- -type_is_indexable :: proc($T: typeid) -> bool --- -type_is_sliceable :: proc($T: typeid) -> bool --- -type_is_comparable :: proc($T: typeid) -> bool --- -type_is_simple_compare :: proc($T: typeid) -> bool --- // easily compared using memcmp (== and !=) -type_is_dereferenceable :: proc($T: typeid) -> bool --- -type_is_valid_map_key :: proc($T: typeid) -> bool --- +type_is_string :: proc($T: typeid) -> bool --- +type_is_typeid :: proc($T: typeid) -> bool --- +type_is_any :: proc($T: typeid) -> bool --- + +type_is_endian_platform :: proc($T: typeid) -> bool --- +type_is_endian_little :: proc($T: typeid) -> bool --- +type_is_endian_big :: proc($T: typeid) -> bool --- +type_is_unsigned :: proc($T: typeid) -> bool --- +type_is_numeric :: proc($T: typeid) -> bool --- +type_is_ordered :: proc($T: typeid) -> bool --- +type_is_ordered_numeric :: proc($T: typeid) -> bool --- +type_is_indexable :: proc($T: typeid) -> bool --- +type_is_sliceable :: proc($T: typeid) -> bool --- +type_is_comparable :: proc($T: typeid) -> bool --- +type_is_simple_compare :: proc($T: typeid) -> bool --- // easily compared using memcmp (== and !=) +type_is_dereferenceable :: proc($T: typeid) -> bool --- +type_is_valid_map_key :: proc($T: typeid) -> bool --- type_is_valid_matrix_elements :: proc($T: typeid) -> bool --- -type_is_named :: proc($T: typeid) -> bool --- -type_is_pointer :: proc($T: typeid) -> bool --- -type_is_multi_pointer :: proc($T: typeid) -> bool --- -type_is_array :: proc($T: typeid) -> bool --- +type_is_named :: proc($T: typeid) -> bool --- +type_is_pointer :: proc($T: typeid) -> bool --- +type_is_multi_pointer :: proc($T: typeid) -> bool --- +type_is_array :: proc($T: typeid) -> bool --- type_is_enumerated_array :: proc($T: typeid) -> bool --- -type_is_slice :: proc($T: typeid) -> bool --- -type_is_dynamic_array :: proc($T: typeid) -> bool --- -type_is_map :: proc($T: typeid) -> bool --- -type_is_struct :: proc($T: typeid) -> bool --- -type_is_union :: proc($T: typeid) -> bool --- -type_is_enum :: proc($T: typeid) -> bool --- -type_is_proc :: proc($T: typeid) -> bool --- -type_is_bit_set :: proc($T: typeid) -> bool --- -type_is_simd_vector :: proc($T: typeid) -> bool --- -type_is_matrix :: proc($T: typeid) -> bool --- +type_is_slice :: proc($T: typeid) -> bool --- +type_is_dynamic_array :: proc($T: typeid) -> bool --- +type_is_map :: proc($T: typeid) -> bool --- +type_is_struct :: proc($T: typeid) -> bool --- +type_is_union :: proc($T: typeid) -> bool --- +type_is_enum :: proc($T: typeid) -> bool --- +type_is_proc :: proc($T: typeid) -> bool --- +type_is_bit_set :: proc($T: typeid) -> bool --- +type_is_simd_vector :: proc($T: typeid) -> bool --- +type_is_matrix :: proc($T: typeid) -> bool --- type_has_nil :: proc($T: typeid) -> bool --- type_is_specialization_of :: proc($T, $S: typeid) -> bool --- -type_is_variant_of :: proc($U, $V: typeid) -> bool where type_is_union(U) --- +type_is_variant_of :: proc($U, $V: typeid) -> bool --- type_has_field :: proc($T: typeid, $name: string) -> bool --- type_field_type :: proc($T: typeid, $name: string) -> typeid --- -type_proc_parameter_count :: proc($T: typeid) -> int where type_is_proc(T) --- -type_proc_return_count :: proc($T: typeid) -> int where type_is_proc(T) --- +type_proc_parameter_count :: proc($T: typeid) -> int --- +type_proc_return_count :: proc($T: typeid) -> int --- -type_proc_parameter_type :: proc($T: typeid, index: int) -> typeid where type_is_proc(T) --- -type_proc_return_type :: proc($T: typeid, index: int) -> typeid where type_is_proc(T) --- +type_proc_parameter_type :: proc($T: typeid, index: int) -> typeid --- +type_proc_return_type :: proc($T: typeid, index: int) -> typeid --- -type_struct_field_count :: proc($T: typeid) -> int where type_is_struct(T) --- +type_struct_field_count :: proc($T: typeid) -> int --- type_polymorphic_record_parameter_count :: proc($T: typeid) -> typeid --- -type_polymorphic_record_parameter_value :: proc($T: typeid, index: int) -> $V --- +type_polymorphic_record_parameter_value :: proc( + $T: typeid, + index: int, +) -> $V --- -type_is_specialized_polymorphic_record :: proc($T: typeid) -> bool --- +type_is_specialized_polymorphic_record :: proc($T: typeid) -> bool --- type_is_unspecialized_polymorphic_record :: proc($T: typeid) -> bool --- type_is_subtype_of :: proc($T, $U: typeid) -> bool --- type_field_index_of :: proc($T: typeid, $name: string) -> uintptr --- -type_equal_proc :: proc($T: typeid) -> (equal: proc "contextless" (rawptr, rawptr) -> bool) where type_is_comparable(T) --- -type_hasher_proc :: proc($T: typeid) -> (hasher: proc "contextless" (data: rawptr, seed: uintptr) -> uintptr) where type_is_comparable(T) --- +type_equal_proc :: proc( + $T: typeid, +) -> ( + equal: proc "contextless" (_: rawptr, _: rawptr) -> bool +) --- +type_hasher_proc :: proc( + $T: typeid, +) -> ( + hasher: proc "contextless" (data: rawptr, seed: uintptr) -> uintptr +) --- constant_utf16_cstring :: proc($literal: string) -> [^]u16 --- // SIMD related -simd_add :: proc(a, b: #simd[N]T) -> #simd[N]T --- -simd_sub :: proc(a, b: #simd[N]T) -> #simd[N]T --- -simd_mul :: proc(a, b: #simd[N]T) -> #simd[N]T --- -simd_div :: proc(a, b: #simd[N]T) -> #simd[N]T where type_is_float(T) --- +simd_add :: proc(a, b: #simd[N]T) -> #simd[N]T --- +simd_sub :: proc(a, b: #simd[N]T) -> #simd[N]T --- +simd_mul :: proc(a, b: #simd[N]T) -> #simd[N]T --- +simd_div :: proc(a, b: #simd[N]T) -> #simd[N]T --- // Keeps Odin's Behaviour // (x << y) if y <= mask else 0 @@ -201,23 +272,29 @@ simd_shr :: proc(a: #simd[N]T, b: #simd[N]Unsigned_Integer) -> #simd[N]T --- // Similar to C's Behaviour // x << (y & mask) -simd_shl_masked :: proc(a: #simd[N]T, b: #simd[N]Unsigned_Integer) -> #simd[N]T --- -simd_shr_masked :: proc(a: #simd[N]T, b: #simd[N]Unsigned_Integer) -> #simd[N]T --- +simd_shl_masked :: proc( + a: #simd[N]T, + b: #simd[N]Unsigned_Integer, +) -> #simd[N]T --- +simd_shr_masked :: proc( + a: #simd[N]T, + b: #simd[N]Unsigned_Integer, +) -> #simd[N]T --- simd_add_sat :: proc(a, b: #simd[N]T) -> #simd[N]T --- simd_sub_sat :: proc(a, b: #simd[N]T) -> #simd[N]T --- -simd_and :: proc(a, b: #simd[N]T) -> #simd[N]T --- -simd_or :: proc(a, b: #simd[N]T) -> #simd[N]T --- -simd_xor :: proc(a, b: #simd[N]T) -> #simd[N]T --- +simd_and :: proc(a, b: #simd[N]T) -> #simd[N]T --- +simd_or :: proc(a, b: #simd[N]T) -> #simd[N]T --- +simd_xor :: proc(a, b: #simd[N]T) -> #simd[N]T --- simd_and_not :: proc(a, b: #simd[N]T) -> #simd[N]T --- -simd_neg :: proc(a: #simd[N]T) -> #simd[N]T --- +simd_neg :: proc(a: #simd[N]T) -> #simd[N]T --- simd_abs :: proc(a: #simd[N]T) -> #simd[N]T --- -simd_min :: proc(a, b: #simd[N]T) -> #simd[N]T --- -simd_max :: proc(a, b: #simd[N]T) -> #simd[N]T --- +simd_min :: proc(a, b: #simd[N]T) -> #simd[N]T --- +simd_max :: proc(a, b: #simd[N]T) -> #simd[N]T --- simd_clamp :: proc(v, min, max: #simd[N]T) -> #simd[N]T --- // Return an unsigned integer of the same size as the input type @@ -237,34 +314,40 @@ simd_replace :: proc(a: #simd[N]T, idx: uint, elem: T) -> #simd[N]T --- simd_reduce_add_ordered :: proc(a: #simd[N]T) -> T --- simd_reduce_mul_ordered :: proc(a: #simd[N]T) -> T --- -simd_reduce_min :: proc(a: #simd[N]T) -> T --- -simd_reduce_max :: proc(a: #simd[N]T) -> T --- -simd_reduce_and :: proc(a: #simd[N]T) -> T --- -simd_reduce_or :: proc(a: #simd[N]T) -> T --- -simd_reduce_xor :: proc(a: #simd[N]T) -> T --- - -simd_shuffle :: proc(a, b: #simd[N]T, indices: ..int) -> #simd[len(indices)]T --- -simd_select :: proc(cond: #simd[N]boolean_or_integer, true, false: #simd[N]T) -> #simd[N]T --- +simd_reduce_min :: proc(a: #simd[N]T) -> T --- +simd_reduce_max :: proc(a: #simd[N]T) -> T --- +simd_reduce_and :: proc(a: #simd[N]T) -> T --- +simd_reduce_or :: proc(a: #simd[N]T) -> T --- +simd_reduce_xor :: proc(a: #simd[N]T) -> T --- + +simd_shuffle :: proc( + a, b: #simd[N]T, + indices: ..int, +) -> #simd[len(indices)]T --- +simd_select :: proc( + cond: #simd[N]boolean_or_integer, + true, false: #simd[N]T, +) -> #simd[N]T --- // Lane-wise operations -simd_ceil :: proc(a: #simd[N]any_float) -> #simd[N]any_float --- -simd_floor :: proc(a: #simd[N]any_float) -> #simd[N]any_float --- -simd_trunc :: proc(a: #simd[N]any_float) -> #simd[N]any_float --- +simd_ceil :: proc(a: #simd[N]any_float) -> #simd[N]any_float --- +simd_floor :: proc(a: #simd[N]any_float) -> #simd[N]any_float --- +simd_trunc :: proc(a: #simd[N]any_float) -> #simd[N]any_float --- // rounding to the nearest integral value; if two values are equally near, rounds to the even one simd_nearest :: proc(a: #simd[N]any_float) -> #simd[N]any_float --- -simd_to_bits :: proc(v: #simd[N]T) -> #simd[N]Integer where size_of(T) == size_of(Integer), type_is_unsigned(Integer) --- +simd_to_bits :: proc(v: #simd[N]T) -> #simd[N]Integer --- // equivalent a swizzle with descending indices, e.g. reserve(a, 3, 2, 1, 0) simd_reverse :: proc(a: #simd[N]T) -> #simd[N]T --- -simd_rotate_left :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T --- +simd_rotate_left :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T --- simd_rotate_right :: proc(a: #simd[N]T, $offset: int) -> #simd[N]T --- // WASM targets only wasm_memory_grow :: proc(index, delta: uintptr) -> int --- -wasm_memory_size :: proc(index: uintptr) -> int --- +wasm_memory_size :: proc(index: uintptr) -> int --- // `timeout_ns` is maximum number of nanoseconds the calling thread will be blocked for // A negative value will be blocked forever @@ -272,30 +355,43 @@ wasm_memory_size :: proc(index: uintptr) -> int --- // 0 - indicates that the thread blocked and then was woken up // 1 - the loaded value from `ptr` did not match `expected`, the thread did not block // 2 - the thread blocked, but the timeout -wasm_memory_atomic_wait32 :: proc(ptr: ^u32, expected: u32, timeout_ns: i64) -> u32 --- -wasm_memory_atomic_notify32 :: proc(ptr: ^u32, waiters: u32) -> (waiters_woken_up: u32) --- +wasm_memory_atomic_wait32 :: proc( + ptr: ^u32, + expected: u32, + timeout_ns: i64, +) -> u32 --- +wasm_memory_atomic_notify32 :: proc( + ptr: ^u32, + waiters: u32, +) -> ( + waiters_woken_up: u32 +) --- // x86 Targets (i386, amd64) -x86_cpuid :: proc(ax, cx: u32) -> (eax, ebc, ecx, edx: u32) --- +x86_cpuid :: proc(ax, cx: u32) -> (eax, ebc, ecx, edx: u32) --- x86_xgetbv :: proc(cx: u32) -> (eax, edx: u32) --- // Darwin targets only -objc_object :: struct{} -objc_selector :: struct{} -objc_class :: struct{} -objc_id :: ^objc_object -objc_SEL :: ^objc_selector +objc_object :: struct {} +objc_selector :: struct {} +objc_class :: struct {} +objc_id :: ^objc_object +objc_SEL :: ^objc_selector objc_Class :: ^objc_class -objc_find_selector :: proc($name: string) -> objc_SEL --- -objc_register_selector :: proc($name: string) -> objc_SEL --- -objc_find_class :: proc($name: string) -> objc_Class --- -objc_register_class :: proc($name: string) -> objc_Class --- +objc_find_selector :: proc($name: string) -> objc_SEL --- +objc_register_selector :: proc($name: string) -> objc_SEL --- +objc_find_class :: proc($name: string) -> objc_Class --- +objc_register_class :: proc($name: string) -> objc_Class --- -valgrind_client_request :: proc(default: uintptr, request: uintptr, a0, a1, a2, a3, a4: uintptr) -> uintptr --- +valgrind_client_request :: proc( + default: uintptr, + request: uintptr, + a0, a1, a2, a3, a4: uintptr, +) -> uintptr --- // Internal compiler use only -__entry_point :: proc() ---
\ No newline at end of file +__entry_point :: proc() --- diff --git a/src/common/util_windows.odin b/src/common/util_windows.odin index 1626529..71fe3e2 100644 --- a/src/common/util_windows.odin +++ b/src/common/util_windows.odin @@ -1,9 +1,9 @@ package common -import "core:strings" -import "core:mem" import "core:fmt" import "core:log" +import "core:mem" +import "core:strings" import win32 "core:sys/windows" @@ -36,8 +36,14 @@ get_case_sensitive_path :: proc( ) if (file == win32.INVALID_HANDLE) { - log.errorf("Failed on get_case_sensitive_path(%v) at %v", path, location) - log_last_error() + when !ODIN_TEST { + log.errorf( + "Failed on get_case_sensitive_path(%v) at %v", + path, + location, + ) + log_last_error() + } return path } @@ -113,17 +119,17 @@ run_executable :: proc( startup_info.dwFlags |= win32.STARTF_USESTDHANDLES if !win32.CreateProcessW( - nil, - &win32.utf8_to_utf16(command)[0], - nil, - nil, - true, - 0, - nil, - nil, - &startup_info, - &process_info, - ) { + nil, + &win32.utf8_to_utf16(command)[0], + nil, + nil, + true, + 0, + nil, + nil, + &startup_info, + &process_info, + ) { return 0, false, stdout[0:] } diff --git a/src/server/build.odin b/src/server/build.odin index aca1796..d9e052a 100644 --- a/src/server/build.odin +++ b/src/server/build.odin @@ -160,7 +160,10 @@ setup_index :: proc() { ) indexer.index = make_memory_index(symbol_collection) - dir_exe, ok := filepath.abs(path.dir(os.args[0], context.temp_allocator)) + dir_exe, ok := filepath.abs( + path.dir(os.args[0], context.temp_allocator), + context.temp_allocator, + ) if !ok { log.error( @@ -169,7 +172,7 @@ setup_index :: proc() { return } - try_build_package(path.join({dir_exe, "builtin"})) + try_build_package(path.join({dir_exe, "builtin"}, context.temp_allocator)) } free_index :: proc() { diff --git a/src/server/collector.odin b/src/server/collector.odin index e86fa92..eecf2ed 100644 --- a/src/server/collector.odin +++ b/src/server/collector.odin @@ -94,6 +94,11 @@ delete_symbol_collection :: proc(collection: SymbolCollection) { } for k, v in collection.packages { + for k2, v2 in v.methods { + delete(v2) + } + delete(v.methods) + delete(v.objc_structs) delete(v.symbols) } diff --git a/src/server/documents.odin b/src/server/documents.odin index d78a0d2..b874082 100644 --- a/src/server/documents.odin +++ b/src/server/documents.odin @@ -318,6 +318,7 @@ document_close :: proc(uri_string: string) -> common.Error { common.delete_uri(document.uri) delete(document.text) + delete(document.package_name) document.used_text = 0 @@ -500,7 +501,7 @@ parse_imports :: proc(document: ^Document, config: ^common.Config) { import_: Package import_.original = imp.fullpath import_.name = path.join( - elems = { + elems = { document.package_name, imp.fullpath[1:len(imp.fullpath) - 1], }, diff --git a/src/server/symbol.odin b/src/server/symbol.odin index 39708d9..d46cf99 100644 --- a/src/server/symbol.odin +++ b/src/server/symbol.odin @@ -176,7 +176,7 @@ SymbolType :: enum { Struct = 22, Type_Function = 23, Union = 7, - Type = 8, //For maps, arrays, slices, dyn arrays, matrixes, etc + Type = 8, //For maps, arrays, slices, dyn arrays, matrixes, etc Unresolved = 1, //Use text if not being able to resolve it. } @@ -223,6 +223,7 @@ free_symbol :: proc(symbol: Symbol, allocator: mem.Allocator) { common.free_ast(v.group, allocator) case SymbolEnumValue: delete(v.names, allocator) + delete(v.ranges, allocator) case SymbolUnionValue: common.free_ast(v.types, allocator) case SymbolBitSetValue: diff --git a/src/testing/testing.odin b/src/testing/testing.odin index 9f67ff0..fb8c034 100644 --- a/src/testing/testing.odin +++ b/src/testing/testing.odin @@ -1,6 +1,7 @@ package ols_testing import "core:fmt" +import "core:log" import "core:mem" import "core:odin/ast" import "core:odin/parser" @@ -27,7 +28,7 @@ Source :: struct { @(private) setup :: proc(src: ^Source) { - src.main = strings.clone(src.main) + src.main = strings.clone(src.main, context.temp_allocator) src.document = new(server.Document, context.temp_allocator) src.document.uri = common.create_uri( "test/test.odin", @@ -36,7 +37,10 @@ setup :: proc(src: ^Source) { src.document.client_owned = true src.document.text = transmute([]u8)src.main src.document.used_text = len(src.document.text) - src.document.allocator = new(common.Scratch_Allocator) + src.document.allocator = new( + common.Scratch_Allocator, + context.temp_allocator, + ) src.document.package_name = "test" common.scratch_allocator_init( @@ -78,12 +82,9 @@ setup :: proc(src: ^Source) { server.document_refresh(src.document, &src.config, nil) - /* - There is a lot code here that is used in the real code, then i'd like to see. - */ - - for src_pkg in src.packages { + context.allocator = common.scratch_allocator(src.document.allocator) + uri := common.create_uri( fmt.aprintf("test/%v/package.odin", src_pkg.pkg), context.temp_allocator, @@ -99,7 +100,7 @@ setup :: proc(src: ^Source) { dir := filepath.base(filepath.dir(fullpath, context.temp_allocator)) - pkg := new(ast.Package) + pkg := new(ast.Package, context.temp_allocator) pkg.kind = .Normal pkg.fullpath = fullpath pkg.name = dir @@ -133,8 +134,20 @@ setup :: proc(src: ^Source) { @(private) teardown :: proc(src: ^Source) { + //A lot of these deletes are managed by other systems in ols, but to simplify it, we just delete them here in tests. + server.free_index() server.indexer.index = {} + + delete(src.document.package_name) + + for k, v in server.build_cache.loaded_pkgs { + delete(k) + } + + delete(server.build_cache.loaded_pkgs) + + common.scratch_allocator_destroy(src.document.allocator) } expect_signature_labels :: proc( @@ -148,18 +161,17 @@ expect_signature_labels :: proc( help, ok := server.get_signature_information(src.document, src.position) if !ok { - testing.error(t, "Failed get_signature_information") + log.error("Failed get_signature_information") } if len(expect_labels) == 0 && len(help.signatures) > 0 { - testing.errorf( - t, + log.errorf( "Expected empty signature label, but received %v", help.signatures, ) } - flags := make([]int, len(expect_labels)) + flags := make([]int, len(expect_labels), context.temp_allocator) for expect_label, i in expect_labels { for signature, j in help.signatures { @@ -171,8 +183,7 @@ expect_signature_labels :: proc( for flag, i in flags { if flag != 1 { - testing.errorf( - t, + log.errorf( "Expected signature label %v, but received %v", expect_labels[i], help.signatures, @@ -193,8 +204,7 @@ expect_signature_parameter_position :: proc( help, ok := server.get_signature_information(src.document, src.position) if help.activeParameter != position { - testing.errorf( - t, + log.errorf( "expected parameter position %v, but received %v", position, help.activeParameter, @@ -222,18 +232,17 @@ expect_completion_labels :: proc( ) if !ok { - testing.error(t, "Failed get_completion_list") + log.error("Failed get_completion_list") } if len(expect_labels) == 0 && len(completion_list.items) > 0 { - testing.errorf( - t, + log.errorf( "Expected empty completion label, but received %v", completion_list.items, ) } - flags := make([]int, len(expect_labels)) + flags := make([]int, len(expect_labels), context.temp_allocator) for expect_label, i in expect_labels { for completion, j in completion_list.items { @@ -245,8 +254,7 @@ expect_completion_labels :: proc( for flag, i in flags { if flag != 1 { - testing.errorf( - t, + log.errorf( "Expected completion detail %v, but received %v", expect_labels[i], completion_list.items, @@ -275,18 +283,17 @@ expect_completion_details :: proc( ) if !ok { - testing.error(t, "Failed get_completion_list") + log.error("Failed get_completion_list") } if len(expect_details) == 0 && len(completion_list.items) > 0 { - testing.errorf( - t, + log.errorf( "Expected empty completion label, but received %v", completion_list.items, ) } - flags := make([]int, len(expect_details)) + flags := make([]int, len(expect_details), context.temp_allocator) for expect_detail, i in expect_details { for completion, j in completion_list.items { @@ -298,8 +305,7 @@ expect_completion_details :: proc( for flag, i in flags { if flag != 1 { - testing.errorf( - t, + log.errorf( "Expected completion label %v, but received %v", expect_details[i], completion_list.items, @@ -319,20 +325,18 @@ expect_hover :: proc( hover, _, ok := server.get_hover_information(src.document, src.position) if !ok { - testing.error(t, "Failed get_hover_information") + log.error(t, "Failed get_hover_information") } if expect_hover_string == "" && hover.contents.value != "" { - testing.errorf( - t, + log.errorf( "Expected empty hover string, but received %v", hover.contents.value, ) } if !strings.contains(hover.contents.value, expect_hover_string) { - testing.errorf( - t, + log.errorf( "Expected hover string %v, but received %v", expect_hover_string, hover.contents.value, @@ -351,18 +355,14 @@ expect_definition_locations :: proc( locations, ok := server.get_definition_location(src.document, src.position) if !ok { - testing.error(t, "Failed get_definition_location") + log.error("Failed get_definition_location") } if len(expect_locations) == 0 && len(locations) > 0 { - testing.errorf( - t, - "Expected empty locations, but received %v", - locations, - ) + log.errorf("Expected empty locations, but received %v", locations) } - flags := make([]int, len(expect_locations)) + flags := make([]int, len(expect_locations), context.temp_allocator) for expect_location, i in expect_locations { for location, j in locations { @@ -374,8 +374,7 @@ expect_definition_locations :: proc( for flag, i in flags { if flag != 1 { - testing.errorf( - t, + log.errorf( "Expected location %v, but received %v", expect_locations[i].range, locations, diff --git a/tests/completions_test.odin b/tests/completions_test.odin index 4084c16..d74de1b 100644 --- a/tests/completions_test.odin +++ b/tests/completions_test.odin @@ -345,7 +345,7 @@ ast_completion_selector_on_indexed_array :: proc(t: ^testing.T) { @(test) index_package_completion :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -593,7 +593,7 @@ ast_swizzle_resolve_one_component_struct_completion :: proc(t: ^testing.T) { @(test) ast_for_in_for_from_different_package :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -872,7 +872,7 @@ ast_completion_in_between_struct :: proc(t: ^testing.T) { @(test) ast_overload_with_any_int_index_completion :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -916,7 +916,7 @@ ast_overload_with_any_int_index_completion :: proc(t: ^testing.T) { @(test) ast_package_procedure_completion :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1041,7 +1041,7 @@ ast_basic_value_binary_completion :: proc(t: ^testing.T) { @(test) ast_file_private_completion :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1070,7 +1070,7 @@ ast_file_private_completion :: proc(t: ^testing.T) { @(test) ast_non_mutable_variable_struct_completion :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1098,7 +1098,7 @@ ast_non_mutable_variable_struct_completion :: proc(t: ^testing.T) { @(test) ast_mutable_variable_struct_completion :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1130,9 +1130,9 @@ ast_out_of_block_scope_completion :: proc(t: ^testing.T) { main = `package main main :: proc() { { - aabb := 2 + zzaabb := 2 } - aab{*} + zzaab{*} } `, } @@ -1458,7 +1458,7 @@ ast_maybe_array :: proc(t: ^testing.T) { @(test) ast_maybe_index_completion :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1584,7 +1584,7 @@ ast_overload_with_procedure_return :: proc(t: ^testing.T) { @(test) ast_index_proc_parameter_completion :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1697,7 +1697,7 @@ ast_enum_complete :: proc(t: ^testing.T) { @(test) ast_comp_lit_with_all_symbols_indexed_enum_implicit :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1735,7 +1735,7 @@ ast_comp_lit_with_all_symbols_indexed_enum_implicit :: proc(t: ^testing.T) { @(test) ast_package_uppercase_test :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1777,7 +1777,7 @@ ast_package_uppercase_test :: proc(t: ^testing.T) { @(test) ast_index_enum_infer :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1809,7 +1809,7 @@ ast_index_enum_infer :: proc(t: ^testing.T) { @(test) ast_index_enum_infer_call_expr :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -1967,7 +1967,7 @@ ast_switch_completion_for_maybe_enum :: proc(t: ^testing.T) { @(test) ast_union_with_type_from_different_package :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -2130,7 +2130,7 @@ ast_completion_on_call_expr :: proc(t: ^testing.T) { @(test) ast_completion_struct_with_same_name_in_pkg :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -2168,7 +2168,7 @@ ast_completion_struct_with_same_name_in_pkg :: proc(t: ^testing.T) { @(test) ast_completion_method_with_type :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -2201,7 +2201,7 @@ ast_completion_method_with_type :: proc(t: ^testing.T) { @(test) ast_implicit_bitset_value_decl_from_package :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -2237,7 +2237,7 @@ ast_implicit_bitset_value_decl_from_package :: proc(t: ^testing.T) { @(test) ast_private_proc_ignore :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -2269,7 +2269,7 @@ ast_private_proc_ignore :: proc(t: ^testing.T) { @(test) ast_bitset_assignment_diff_pkg :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -2602,7 +2602,7 @@ ast_completion_comp_lit_in_proc :: proc(t: ^testing.T) { @(test) ast_completion_infer_bitset_package :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -2668,7 +2668,7 @@ ast_simple_bit_field_completion :: proc(t: ^testing.T) { @(test) ast_generics_function_with_struct_same_pkg :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -2719,7 +2719,7 @@ ast_generics_function_with_struct_same_pkg :: proc(t: ^testing.T) { @(test) ast_generics_function_with_struct_diff_pkg :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -2770,7 +2770,7 @@ ast_generics_function_with_struct_diff_pkg :: proc(t: ^testing.T) { @(test) ast_generics_function_with_comp_lit_struct :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, diff --git a/tests/hover_test.odin b/tests/hover_test.odin index 1cee1dc..22403a0 100644 --- a/tests/hover_test.odin +++ b/tests/hover_test.odin @@ -58,7 +58,7 @@ ast_hover_parameter :: proc(t: ^testing.T) { @(test) ast_hover_external_package_parameter :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -88,7 +88,7 @@ ast_hover_external_package_parameter :: proc(t: ^testing.T) { @(test) ast_hover_procedure_package_parameter :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, diff --git a/tests/objc_test.odin b/tests/objc_test.odin index 760d193..9c69afb 100644 --- a/tests/objc_test.odin +++ b/tests/objc_test.odin @@ -8,7 +8,7 @@ import test "src:testing" @(test) objc_return_type_with_selector_expression :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -49,7 +49,7 @@ objc_return_type_with_selector_expression :: proc(t: ^testing.T) { @(test) objc_return_type_with_selector_expression_2 :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -98,7 +98,7 @@ objc_return_type_with_selector_expression_2 :: proc(t: ^testing.T) { @(test) objc_hover_chained_selector :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -147,7 +147,7 @@ objc_hover_chained_selector :: proc(t: ^testing.T) { @(test) objc_implicit_enum_completion :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, diff --git a/tests/signatures_test.odin b/tests/signatures_test.odin index 66b1b01..32e5e17 100644 --- a/tests/signatures_test.odin +++ b/tests/signatures_test.odin @@ -210,7 +210,7 @@ ast_proc_group_signature_empty_call :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - { + { "test.int_function: proc(a: int)", "test.bool_function: proc(a: bool)", }, @@ -237,7 +237,7 @@ ast_proc_signature_generic :: proc(t: ^testing.T) { test.expect_signature_labels( t, &source, - { + { "test.clone_array: proc(array: $A/[]^$T, allocator: mem.Allocator, unique_strings: ^map[string]string) -> A", }, ) @@ -354,7 +354,7 @@ ast_proc_group_signature_struct :: proc(t: ^testing.T) { @(test) index_simple_signature :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, @@ -464,7 +464,7 @@ ast_signature_global_variable_pointer :: proc(t: ^testing.T) { @(test) index_variable_pointer_signature :: proc(t: ^testing.T) { - packages := make([dynamic]test.Package) + packages := make([dynamic]test.Package, context.temp_allocator) append( &packages, |