diff --git a/v.c b/v.c index 499f798..adf1a83 100644 --- a/v.c +++ b/v.c @@ -1,11 +1,11 @@ -#define V_COMMIT_HASH "32d7ae783" +#define V_COMMIT_HASH "5e8c4a3" #ifndef V_COMMIT_HASH - #define V_COMMIT_HASH "07cab64d1" + #define V_COMMIT_HASH "2a0b372" #endif #ifndef V_CURRENT_COMMIT_HASH - #define V_CURRENT_COMMIT_HASH "32d7ae7" + #define V_CURRENT_COMMIT_HASH "5e8c4a3" #endif // V comptime_definitions: @@ -993,7 +993,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; #endif -// added by module `builtin` +// added by module `builtin`, file: float.c.v:9: #if defined(__has_include) @@ -1011,7 +1011,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: os.c.v:3: #if defined(__has_include) @@ -1029,13 +1029,13 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: os.c.v:4: #include -// added by module `os` +// added by module `os`, file: os_nix.c.v:5: #if defined(__has_include) @@ -1053,7 +1053,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: os_nix.c.v:6: #if defined(__has_include) @@ -1071,7 +1071,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: os_nix.c.v:7: #if defined(__has_include) @@ -1089,7 +1089,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: os_nix.c.v:8: #if defined(__has_include) @@ -1107,7 +1107,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: os_nix.c.v:9: #if defined(__has_include) @@ -1125,7 +1125,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: os_nix.c.v:10: #if defined(__has_include) @@ -1144,7 +1144,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; #if !defined(__sun) && !defined(__HAIKU__) -// added by module `os` +// added by module `os`, file: os_nix.c.v:12: #if defined(__has_include) @@ -1163,7 +1163,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: signal.c.v:3: #if defined(__has_include) @@ -1181,7 +1181,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `time` +// added by module `time`, file: time.c.v:6: #if defined(__has_include) @@ -1199,7 +1199,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `time` +// added by module `time`, file: time_nix.c.v:6: #if defined(__has_include) @@ -1217,31 +1217,822 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `time` +// added by module `time`, file: time_nix.c.v:7: #include +#if defined(_WIN32) +// inserted by module `sync.stdatomic`, file: 1.declarations.c.v:8: +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef COMPAT_ATOMICS_WIN32_STDATOMIC_H +#define COMPAT_ATOMICS_WIN32_STDATOMIC_H -// added by module `sync.stdatomic` +#define WIN32_LEAN_AND_MEAN +#include +#include +#include -#if defined(__has_include) - -#if __has_include() -#include -#else -#error VERROR_MESSAGE Header file , needed for module `sync.stdatomic` was not found. Please install the corresponding development headers. +#ifdef __TINYC__ #endif -#else -#include +#define ATOMIC_FLAG_INIT 0 + +#define ATOMIC_VAR_INIT(value) (value) + +#define atomic_init(obj, value) \ + do \ + { \ + *(obj) = (value); \ + } while (0) + +#define kill_dependency(y) ((void)0) + +#define atomic_thread_fence(order) \ + MemoryBarrier(); + +#define atomic_signal_fence(order) \ + ((void)0) + +#define atomic_is_lock_free(obj) 0 + +typedef intptr_t atomic_flag; +typedef intptr_t atomic_bool; +typedef intptr_t atomic_char; +typedef intptr_t atomic_schar; +typedef intptr_t atomic_uchar; +typedef intptr_t atomic_short; +typedef intptr_t atomic_ushort; +typedef intptr_t atomic_int; +typedef intptr_t atomic_uint; +typedef intptr_t atomic_long; +typedef intptr_t atomic_ulong; +typedef intptr_t atomic_llong; +typedef intptr_t atomic_ullong; +typedef intptr_t atomic_wchar_t; +typedef intptr_t atomic_int_least8_t; +typedef intptr_t atomic_uint_least8_t; +typedef intptr_t atomic_int_least16_t; +typedef intptr_t atomic_uint_least16_t; +typedef intptr_t atomic_int_least32_t; +typedef intptr_t atomic_uint_least32_t; +typedef intptr_t atomic_int_least64_t; +typedef intptr_t atomic_uint_least64_t; +typedef intptr_t atomic_int_fast8_t; +typedef intptr_t atomic_uint_fast8_t; +typedef intptr_t atomic_int_fast16_t; +typedef intptr_t atomic_uint_fast16_t; +typedef intptr_t atomic_int_fast32_t; +typedef intptr_t atomic_uint_fast32_t; +typedef intptr_t atomic_int_fast64_t; +typedef intptr_t atomic_uint_fast64_t; +typedef intptr_t atomic_intptr_t; +typedef intptr_t atomic_uintptr_t; +typedef intptr_t atomic_size_t; +typedef intptr_t atomic_ptrdiff_t; +typedef intptr_t atomic_intmax_t; +typedef intptr_t atomic_uintmax_t; + +#ifdef __TINYC__ +/* + For TCC it is missing the x64 version of _InterlockedExchangeAdd64 so we + fake it (works the same) with InterlockedCompareExchange64 until it + succeeds +*/ +__CRT_INLINE LONGLONG _InterlockedExchangeAdd64(LONGLONG volatile *Addend, LONGLONG Value) +{ + LONGLONG Old; + do + { + Old = *Addend; + } while (InterlockedCompareExchange64(Addend, Old + Value, Old) != Old); + return Old; +} + +__CRT_INLINE LONG _InterlockedExchangeAdd(LONG volatile *Addend, LONG Value) +{ + LONG Old; + do + { + Old = *Addend; + } while (InterlockedCompareExchange(Addend, Old + Value, Old) != Old); + return Old; +} + +__CRT_INLINE SHORT _InterlockedExchangeAdd16(SHORT volatile *Addend, SHORT Value) +{ + SHORT Old; + do + { + Old = *Addend; + } while (InterlockedCompareExchange16(Addend, Old + Value, Old) != Old); + return Old; +} + +#define InterlockedIncrement64 _InterlockedExchangeAdd64 + #endif +#define atomic_store(object, desired) \ + do \ + { \ + *(object) = (desired); \ + MemoryBarrier(); \ + } while (0) + +#define atomic_store_explicit(object, desired, order) \ + atomic_store(object, desired) + +#define atomic_load(object) \ + (MemoryBarrier(), *(object)) + +#define atomic_load_explicit(object, order) \ + atomic_load(object) + +#define atomic_exchange(object, desired) \ + InterlockedExchangePointer(object, desired) + +#define atomic_exchange_explicit(object, desired, order) \ + atomic_exchange(object, desired) + +static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected, + intptr_t desired) +{ + intptr_t old = *expected; + *expected = (intptr_t)InterlockedCompareExchangePointer( + (PVOID *)object, (PVOID)desired, (PVOID)old); + return *expected == old; +} + +#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \ + atomic_compare_exchange_strong(object, expected, desired) + +#define atomic_compare_exchange_weak(object, expected, desired) \ + atomic_compare_exchange_strong(object, expected, desired) + +#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \ + atomic_compare_exchange_weak(object, expected, desired) + +#ifdef _WIN64 + +#define atomic_fetch_add(object, operand) \ + InterlockedExchangeAdd64(object, operand) + +#define atomic_fetch_sub(object, operand) \ + InterlockedExchangeAdd64(object, -(operand)) + +#define atomic_fetch_or(object, operand) \ + InterlockedOr64(object, operand) + +#define atomic_fetch_xor(object, operand) \ + InterlockedXor64(object, operand) + +#define atomic_fetch_and(object, operand) \ + InterlockedAnd64(object, operand) +#else +#define atomic_fetch_add(object, operand) \ + InterlockedExchangeAdd(object, operand) + +#define atomic_fetch_sub(object, operand) \ + InterlockedExchangeAdd(object, -(operand)) + +#define atomic_fetch_or(object, operand) \ + InterlockedOr(object, operand) + +#define atomic_fetch_xor(object, operand) \ + InterlockedXor(object, operand) + +#define atomic_fetch_and(object, operand) \ + InterlockedAnd(object, operand) +#endif /* _WIN64 */ + +/* specialized versions with explicit object size */ + +#define atomic_load_ptr atomic_load +#define atomic_store_ptr atomic_store +#define atomic_compare_exchange_weak_ptr atomic_compare_exchange_weak +#define atomic_compare_exchange_strong_ptr atomic_compare_exchange_strong +#define atomic_exchange_ptr atomic_exchange +#define atomic_fetch_add_ptr atomic_fetch_add +#define atomic_fetch_sub_ptr atomic_fetch_sub +#define atomic_fetch_and_ptr atomic_fetch_and +#define atomic_fetch_or_ptr atomic_fetch_or +#define atomic_fetch_xor_ptr atomic_fetch_xor + +static inline void atomic_store_u64(unsigned long long* object, unsigned long long desired) { + do { + *(object) = (desired); + MemoryBarrier(); + } while (0); +} + +static inline unsigned long long atomic_load_u64(unsigned long long* object) { + return (MemoryBarrier(), *(object)); +} + +#define atomic_exchange_u64(object, desired) \ + InterlockedExchange64(object, desired) + +static inline int atomic_compare_exchange_strong_u64(unsigned long long* object, unsigned long long* expected, + unsigned long long desired) +{ + unsigned long long old = *expected; + *expected = InterlockedCompareExchange64(object, desired, old); + return *expected == old; +} + +#define atomic_compare_exchange_weak_u64(object, expected, desired) \ + atomic_compare_exchange_strong_u64(object, expected, desired) + +#define atomic_fetch_add_u64(object, operand) \ + InterlockedExchangeAdd64(object, operand) + +#define atomic_fetch_sub_u64(object, operand) \ + InterlockedExchangeAdd64(object, -(operand)) + +#define atomic_fetch_or_u64(object, operand) \ + InterlockedOr64(object, operand) + +#define atomic_fetch_xor_u64(object, operand) \ + InterlockedXor64(object, operand) + +#define atomic_fetch_and_u64(object, operand) \ + InterlockedAnd64(object, operand) +static inline void atomic_store_u32(unsigned* object, unsigned desired) { + do { + *(object) = (desired); + MemoryBarrier(); + } while (0); +} -// added by module `term` +static inline unsigned atomic_load_u32(unsigned* object) { + return (MemoryBarrier(), *(object)); +} + +#define atomic_exchange_u32(object, desired) \ + InterlockedExchange(object, desired) + +static inline int atomic_compare_exchange_strong_u32(unsigned* object, unsigned* expected, + unsigned desired) +{ + unsigned old = *expected; + *expected = InterlockedCompareExchange(object, desired, old); + return *expected == old; +} + +#define atomic_compare_exchange_weak_u32(object, expected, desired) \ + atomic_compare_exchange_strong_u32(object, expected, desired) + +#define atomic_fetch_add_u32(object, operand) \ + InterlockedExchangeAdd(object, operand) + +#define atomic_fetch_sub_u32(object, operand) \ + InterlockedExchangeAdd(object, -(operand)) + +#define atomic_fetch_or_u32(object, operand) \ + InterlockedOr(object, operand) + +#define atomic_fetch_xor_u32(object, operand) \ + InterlockedXor(object, operand) + +#define atomic_fetch_and_u32(object, operand) \ + InterlockedAnd(object, operand) + + + +static inline void atomic_store_u16(unsigned short* object, unsigned short desired) { + do { + *(object) = (desired); + MemoryBarrier(); + } while (0); +} + +static inline unsigned short atomic_load_u16(unsigned short* object) { + return (MemoryBarrier(), *(object)); +} + +#define atomic_exchange_u16(object, desired) \ + InterlockedExchange16(object, desired) + +static inline int atomic_compare_exchange_strong_u16(unsigned short* object, unsigned short* expected, + unsigned short desired) +{ + unsigned short old = *expected; + *expected = InterlockedCompareExchange16(object, desired, old); + return *expected == old; +} + +#define atomic_compare_exchange_weak_u16(object, expected, desired) \ + atomic_compare_exchange_strong_u16(object, expected, desired) + +#define atomic_fetch_add_u16(object, operand) \ + InterlockedExchangeAdd16(object, operand) + +#define atomic_fetch_sub_u16(object, operand) \ + InterlockedExchangeAdd16(object, -(operand)) + +#define atomic_fetch_or_u16(object, operand) \ + InterlockedOr16(object, operand) + +#define atomic_fetch_xor_u16(object, operand) \ + InterlockedXor16(object, operand) + +#define atomic_fetch_and_u16(object, operand) \ + InterlockedAnd16(object, operand) + + + +#define atomic_fetch_add_explicit(object, operand, order) \ + atomic_fetch_add(object, operand) + +#define atomic_fetch_sub_explicit(object, operand, order) \ + atomic_fetch_sub(object, operand) + +#define atomic_fetch_or_explicit(object, operand, order) \ + atomic_fetch_or(object, operand) + +#define atomic_fetch_xor_explicit(object, operand, order) \ + atomic_fetch_xor(object, operand) + +#define atomic_fetch_and_explicit(object, operand, order) \ + atomic_fetch_and(object, operand) + +#define atomic_flag_test_and_set(object) \ + atomic_exchange(object, 1) + +#define atomic_flag_test_and_set_explicit(object, order) \ + atomic_flag_test_and_set(object) + +#define atomic_flag_clear(object) \ + atomic_store(object, 0) + +#define atomic_flag_clear_explicit(object, order) \ + atomic_flag_clear(object) + +#endif /* COMPAT_ATOMICS_WIN32_STDATOMIC_H */ + +#endif // $if defined(_WIN32) +#if 1 +// inserted by module `sync.stdatomic`, file: 1.declarations.c.v:11: +/* + Compability header for stdatomic.h that works for all compilers supported + by V. For TCC libatomic from the operating system is used + +*/ +#ifndef __ATOMIC_H +#define __ATOMIC_H + +#ifndef __cplusplus +// If C just use stdatomic.h +#ifndef __TINYC__ +#include +#endif +#else +// CPP wrapper for atomic operations that are compatible with C +#include "atomic_cpp.h" +#endif + +#ifdef __TINYC__ + +typedef volatile long long atomic_llong; +typedef volatile unsigned long long atomic_ullong; +typedef volatile uintptr_t atomic_uintptr_t; + +// use functions for 64, 32 and 8 bit from libatomic directly +// since tcc is not capible to use "generic" C functions +// there is no header file for libatomic so we provide function declarations here + +extern unsigned long long __atomic_load_8(unsigned long long* x, int mo); +extern void __atomic_store_8(unsigned long long* x, unsigned long long y, int mo); +extern _Bool __atomic_compare_exchange_8(unsigned long long* x, unsigned long long* expected, unsigned long long y, int mo, int mo2); +extern _Bool __atomic_compare_exchange_8(unsigned long long* x, unsigned long long* expected, unsigned long long y, int mo, int mo2); +extern unsigned long long __atomic_exchange_8(unsigned long long* x, unsigned long long y, int mo); +extern unsigned long long __atomic_fetch_add_8(unsigned long long* x, unsigned long long y, int mo); +extern unsigned long long __atomic_fetch_sub_8(unsigned long long* x, unsigned long long y, int mo); +extern unsigned long long __atomic_fetch_and_8(unsigned long long* x, unsigned long long y, int mo); +extern unsigned long long __atomic_fetch_or_8(unsigned long long* x, unsigned long long y, int mo); +extern unsigned long long __atomic_fetch_xor_8(unsigned long long* x, unsigned long long y, int mo); + +extern unsigned int __atomic_load_4(unsigned int* x, int mo); +extern void __atomic_store_4(unsigned int* x, unsigned int y, int mo); +extern _Bool __atomic_compare_exchange_4(unsigned int* x, unsigned int* expected, unsigned int y, int mo, int mo2); +extern _Bool __atomic_compare_exchange_4(unsigned int* x, unsigned int* expected, unsigned int y, int mo, int mo2); +extern unsigned int __atomic_exchange_4(unsigned int* x, unsigned int y, int mo); +extern unsigned int __atomic_fetch_add_4(unsigned int* x, unsigned int y, int mo); +extern unsigned int __atomic_fetch_sub_4(unsigned int* x, unsigned int y, int mo); +extern unsigned int __atomic_fetch_and_4(unsigned int* x, unsigned int y, int mo); +extern unsigned int __atomic_fetch_or_4(unsigned int* x, unsigned int y, int mo); +extern unsigned int __atomic_fetch_xor_4(unsigned int* x, unsigned int y, int mo); + +extern unsigned short __atomic_load_2(unsigned short* x, int mo); +extern void __atomic_store_2(unsigned short* x, unsigned short y, int mo); +extern _Bool __atomic_compare_exchange_2(unsigned short* x, unsigned short* expected, unsigned short y, int mo, int mo2); +extern _Bool __atomic_compare_exchange_2(unsigned short* x, unsigned short* expected, unsigned short y, int mo, int mo2); +extern unsigned short __atomic_exchange_2(unsigned short* x, unsigned short y, int mo); +extern unsigned short __atomic_fetch_add_2(unsigned short* x, unsigned short y, int mo); +extern unsigned short __atomic_fetch_sub_2(unsigned short* x, unsigned short y, int mo); +extern unsigned short __atomic_fetch_and_2(unsigned short* x, unsigned short y, int mo); +extern unsigned short __atomic_fetch_or_2(unsigned short* x, unsigned short y, int mo); +extern unsigned short __atomic_fetch_xor_2(unsigned short* x, unsigned short y, int mo); + +extern unsigned char __atomic_load_1(unsigned char* x, int mo); +extern void __atomic_store_1(unsigned char* x, unsigned char y, int mo); +extern _Bool __atomic_compare_exchange_1(unsigned char* x, unsigned char* expected, unsigned char y, int mo, int mo2); +extern _Bool __atomic_compare_exchange_1(unsigned char* x, unsigned char* expected, unsigned char y, int mo, int mo2); +extern unsigned char __atomic_exchange_1(unsigned char* x, unsigned char y, int mo); +extern unsigned char __atomic_fetch_add_1(unsigned char* x, unsigned char y, int mo); +extern unsigned char __atomic_fetch_sub_1(unsigned char* x, unsigned char y, int mo); +extern unsigned char __atomic_fetch_and_1(unsigned char* x, unsigned char y, int mo); +extern unsigned char __atomic_fetch_or_1(unsigned char* x, unsigned char y, int mo); +extern unsigned char __atomic_fetch_xor_1(unsigned char* x, unsigned char y, int mo); + +// The default functions should work with pointers so we have to decide based on pointer size +#if UINTPTR_MAX == 0xFFFFFFFF + +#define atomic_load_explicit __atomic_load_4 +#define atomic_store_explicit __atomic_store_4 +#define atomic_compare_exchange_weak_explicit __atomic_compare_exchange_4 +#define atomic_compare_exchange_strong_explicit __atomic_compare_exchange_4 +#define atomic_exchange_explicit __atomic_exchange_4 +#define atomic_fetch_add_explicit __atomic_fetch_add_4 +#define atomic_fetch_sub_explicit __atomic_sub_fetch_4 + +#else + +#define atomic_load_explicit __atomic_load_8 +#define atomic_store_explicit __atomic_store_8 +#define atomic_compare_exchange_weak_explicit __atomic_compare_exchange_8 +#define atomic_compare_exchange_strong_explicit __atomic_compare_exchange_8 +#define atomic_exchange_explicit __atomic_exchange_8 +#define atomic_fetch_add_explicit __atomic_fetch_add_8 +#define atomic_fetch_sub_explicit __atomic_sub_fetch_8 + +#endif + +// memory order policies - we use "sequentially consistent" by default + +#define memory_order_relaxed 0 +#define memory_order_consume 1 +#define memory_order_acquire 2 +#define memory_order_release 3 +#define memory_order_acq_rel 4 +#define memory_order_seq_cst 5 + +static inline void** atomic_load(void** x) { + return (void**)atomic_load_explicit((unsigned long long*)x, memory_order_seq_cst); +} +static inline void atomic_store(void** x, void* y) { + atomic_store_explicit((unsigned long long*)x, (uintptr_t)y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak(void** x, void** expected, void* y) { + return (int)atomic_compare_exchange_weak_explicit((unsigned long long*)x, (unsigned long long*)expected, (uintptr_t)y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong(void** x, void** expected, void* y) { + return (int)atomic_compare_exchange_strong_explicit((unsigned long long*)x, (unsigned long long*)expected, (uintptr_t)y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline uintptr_t atomic_exchange(void** x, void* y) { + return atomic_exchange_explicit((unsigned long long*)x, (uintptr_t)y, memory_order_seq_cst); +} +static inline uintptr_t atomic_fetch_add(uintptr_t* x, uintptr_t y) { + return atomic_fetch_add_explicit(x, y, memory_order_seq_cst); +} +static inline uintptr_t atomic_fetch_sub(uintptr_t* x, uintptr_t y) { + return atomic_fetch_sub_explicit(x, y, memory_order_seq_cst); +} +static inline uintptr_t atomic_fetch_and(uintptr_t* x, uintptr_t y) { + return atomic_fetch_and_explicit(x, y, memory_order_seq_cst); +} +static inline uintptr_t atomic_fetch_or(uintptr_t* x, uintptr_t y) { + return atomic_fetch_or_explicit(x, y, memory_order_seq_cst); +} +static inline uintptr_t atomic_fetch_xor(uintptr_t* x, uintptr_t y) { + return atomic_fetch_xor_explicit(x, y, memory_order_seq_cst); +} + +#define atomic_load_ptr atomic_load +#define atomic_store_ptr atomic_store +#define atomic_compare_exchange_weak_ptr atomic_compare_exchange_weak +#define atomic_compare_exchange_strong_ptr atomic_compare_exchange_strong +#define atomic_exchange_ptr atomic_exchange +#define atomic_fetch_add_ptr atomic_fetch_add +#define atomic_fetch_sub_ptr atomic_fetch_sub +#define atomic_fetch_and_ptr atomic_fetch_and +#define atomic_fetch_or_ptr atomic_fetch_or +#define atomic_fetch_xor_ptr atomic_fetch_xor + +// specialized versions for 64 bit + +static inline unsigned long long atomic_load_u64(unsigned long long* x) { + return __atomic_load_8(x, memory_order_seq_cst); +} +static inline void atomic_store_u64(unsigned long long* x, unsigned long long y) { + __atomic_store_8(x, y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak_u64(unsigned long long* x, unsigned long long* expected, unsigned long long y) { + return (int)__atomic_compare_exchange_8(x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong_u64(unsigned long long* x, unsigned long long* expected, unsigned long long y) { + return (int)__atomic_compare_exchange_8(x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline unsigned long long atomic_exchange_u64(unsigned long long* x, unsigned long long y) { + return __atomic_exchange_8(x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_add_u64(unsigned long long* x, unsigned long long y) { + return __atomic_fetch_add_8(x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_sub_u64(unsigned long long* x, unsigned long long y) { + return __atomic_fetch_sub_8(x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_and_u64(unsigned long long* x, unsigned long long y) { + return __atomic_fetch_and_8(x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_or_u64(unsigned long long* x, unsigned long long y) { + return __atomic_fetch_or_8(x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_xor_u64(unsigned long long* x, unsigned long long y) { + return __atomic_fetch_xor_8(x, y, memory_order_seq_cst); +} + +static inline unsigned atomic_load_u32(unsigned* x) { + return __atomic_load_4(x, memory_order_seq_cst); +} +static inline void atomic_store_u32(unsigned* x, unsigned y) { + __atomic_store_4(x, y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak_u32(unsigned* x, unsigned* expected, unsigned y) { + return (int)__atomic_compare_exchange_4(x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong_u32(unsigned* x, unsigned* expected, unsigned y) { + return (int)__atomic_compare_exchange_4(x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline unsigned atomic_exchange_u32(unsigned* x, unsigned y) { + return __atomic_exchange_4(x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_add_u32(unsigned* x, unsigned y) { + return __atomic_fetch_add_4(x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_sub_u32(unsigned* x, unsigned y) { + return __atomic_fetch_sub_4(x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_and_u32(unsigned* x, unsigned y) { + return __atomic_fetch_and_4(x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_or_u32(unsigned* x, unsigned y) { + return __atomic_fetch_or_4(x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_xor_u32(unsigned* x, unsigned y) { + return __atomic_fetch_xor_4(x, y, memory_order_seq_cst); +} + +static inline unsigned short atomic_load_u16(unsigned short* x) { + return __atomic_load_2(x, memory_order_seq_cst); +} +static inline void atomic_store_u16(void* x, unsigned short y) { + __atomic_store_2(x, y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak_u16(void* x, unsigned short* expected, unsigned short y) { + return (int)__atomic_compare_exchange_2(x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong_u16(unsigned short* x, unsigned short* expected, unsigned short y) { + return (int)__atomic_compare_exchange_2(x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline unsigned short atomic_exchange_u16(unsigned short* x, unsigned short y) { + return __atomic_exchange_2(x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_add_u16(unsigned short* x, unsigned short y) { + return __atomic_fetch_add_2(x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_sub_u16(unsigned short* x, unsigned short y) { + return __atomic_fetch_sub_2(x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_and_u16(unsigned short* x, unsigned short y) { + return __atomic_fetch_and_2(x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_or_u16(unsigned short* x, unsigned short y) { + return __atomic_fetch_or_2(x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_xor_u16(unsigned short* x, unsigned short y) { + return __atomic_fetch_xor_2(x, y, memory_order_seq_cst); +} + +static inline unsigned char atomic_load_byte(unsigned char* x) { + return __atomic_load_1(x, memory_order_seq_cst); +} +static inline void atomic_store_byte(unsigned char* x, unsigned char y) { + __atomic_store_1(x, y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak_byte(unsigned char* x, unsigned char* expected, unsigned char y) { + return __atomic_compare_exchange_1(x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong_byte(unsigned char* x, unsigned char* expected, unsigned char y) { + return __atomic_compare_exchange_1(x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline unsigned char atomic_exchange_byte(unsigned char* x, unsigned char y) { + return __atomic_exchange_1(x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_add_byte(unsigned char* x, unsigned char y) { + return __atomic_fetch_add_1(x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_sub_byte(unsigned char* x, unsigned char y) { + return __atomic_fetch_sub_1(x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_and_byte(unsigned char* x, unsigned char y) { + return __atomic_fetch_and_1(x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_or_byte(unsigned char* x, unsigned char y) { + return __atomic_fetch_or_1(x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_xor_byte(unsigned char* x, unsigned char y) { + return __atomic_fetch_xor_1(x, y, memory_order_seq_cst); +} + +#else + +// Since V might be confused with "generic" C functions either we provide special versions +// for gcc/clang, too +static inline unsigned long long atomic_load_u64(unsigned long long* x) { + return atomic_load_explicit((_Atomic (unsigned long long)*)x, memory_order_seq_cst); +} +static inline void atomic_store_u64(unsigned long long* x, unsigned long long y) { + atomic_store_explicit((_Atomic(unsigned long long)*)x, y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak_u64(unsigned long long* x, unsigned long long* expected, unsigned long long y) { + return (int)atomic_compare_exchange_weak_explicit((_Atomic(unsigned long long)*)x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong_u64(unsigned long long* x, unsigned long long* expected, unsigned long long y) { + return (int)atomic_compare_exchange_strong_explicit((_Atomic(unsigned long long)*)x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline unsigned long long atomic_exchange_u64(unsigned long long* x, unsigned long long y) { + return atomic_exchange_explicit((_Atomic(unsigned long long)*)x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_add_u64(unsigned long long* x, unsigned long long y) { + return atomic_fetch_add_explicit((_Atomic(unsigned long long)*)x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_sub_u64(unsigned long long* x, unsigned long long y) { + return atomic_fetch_sub_explicit((_Atomic(unsigned long long)*)x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_and_u64(unsigned long long* x, unsigned long long y) { + return atomic_fetch_and_explicit((_Atomic(unsigned long long)*)x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_or_u64(unsigned long long* x, unsigned long long y) { + return atomic_fetch_or_explicit((_Atomic(unsigned long long)*)x, y, memory_order_seq_cst); +} +static inline unsigned long long atomic_fetch_xor_u64(unsigned long long* x, unsigned long long y) { + return atomic_fetch_xor_explicit((_Atomic(unsigned long long)*)x, y, memory_order_seq_cst); +} + + +static inline void* atomic_load_ptr(void** x) { + return (void*)atomic_load_explicit((_Atomic(uintptr_t)*)x, memory_order_seq_cst); +} +static inline void atomic_store_ptr(void** x, void* y) { + atomic_store_explicit((_Atomic(uintptr_t)*)x, (uintptr_t)y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak_ptr(void** x, void** expected, void* y) { + return (int)atomic_compare_exchange_weak_explicit((_Atomic(uintptr_t)*)x, (unsigned long *)expected, (uintptr_t)y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong_ptr(void** x, void** expected, void* y) { + return (int)atomic_compare_exchange_strong_explicit((_Atomic(uintptr_t)*)x, (unsigned long *)expected, (uintptr_t)y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline void* atomic_exchange_ptr(void** x, void* y) { + return (void*)atomic_exchange_explicit((_Atomic(uintptr_t)*)x, (uintptr_t)y, memory_order_seq_cst); +} +static inline void* atomic_fetch_add_ptr(void** x, void* y) { + return (void*)atomic_fetch_add_explicit((_Atomic(uintptr_t)*)x, (uintptr_t)y, memory_order_seq_cst); +} +static inline void* atomic_fetch_sub_ptr(void** x, void* y) { + return (void*)atomic_fetch_sub_explicit((_Atomic(uintptr_t)*)x, (uintptr_t)y, memory_order_seq_cst); +} +static inline void* atomic_fetch_and_ptr(void** x, void* y) { + return (void*)atomic_fetch_and_explicit((_Atomic(uintptr_t)*)x, (uintptr_t)y, memory_order_seq_cst); +} +static inline void* atomic_fetch_or_ptr(void** x, void* y) { + return (void*)atomic_fetch_or_explicit((_Atomic(uintptr_t)*)x, (uintptr_t)y, memory_order_seq_cst); +} +static inline void* atomic_fetch_xor_ptr(void** x, void* y) { + return (void*)atomic_fetch_xor_explicit((_Atomic(uintptr_t)*)x, (uintptr_t)y, memory_order_seq_cst); +} + + +static inline unsigned atomic_load_u32(unsigned* x) { + return atomic_load_explicit((_Atomic(unsigned)*)x, memory_order_seq_cst); +} +static inline void atomic_store_u32(unsigned* x, unsigned y) { + atomic_store_explicit((_Atomic(unsigned)*)x, y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak_u32(unsigned* x, unsigned* expected, unsigned y) { + return (int)atomic_compare_exchange_weak_explicit((_Atomic(unsigned)*)x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong_u32(unsigned* x, unsigned* expected, unsigned y) { + return (int)atomic_compare_exchange_strong_explicit((_Atomic(unsigned)*)x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline unsigned atomic_exchange_u32(unsigned* x, unsigned y) { + return atomic_exchange_explicit((_Atomic(unsigned)*)x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_add_u32(unsigned* x, unsigned y) { + return atomic_fetch_add_explicit((_Atomic(unsigned)*)x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_sub_u32(unsigned* x, unsigned y) { + return atomic_fetch_sub_explicit((_Atomic(unsigned)*)x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_and_u32(unsigned* x, unsigned y) { + return atomic_fetch_and_explicit((_Atomic(unsigned)*)x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_or_u32(unsigned* x, unsigned y) { + return atomic_fetch_or_explicit((_Atomic(unsigned)*)x, y, memory_order_seq_cst); +} +static inline unsigned atomic_fetch_xor_u32(unsigned* x, unsigned y) { + return atomic_fetch_xor_explicit((_Atomic(unsigned)*)x, y, memory_order_seq_cst); +} + +static inline unsigned short atomic_load_u16(unsigned short* x) { + return atomic_load_explicit((_Atomic(unsigned short)*)x, memory_order_seq_cst); +} +static inline void atomic_store_u16(void* x, unsigned short y) { + atomic_store_explicit((_Atomic(unsigned short)*)x, y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak_u16(void* x, unsigned short* expected, unsigned short y) { + return (int)atomic_compare_exchange_weak_explicit((_Atomic(unsigned short)*)x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong_u16(unsigned short* x, unsigned short* expected, unsigned short y) { + return (int)atomic_compare_exchange_strong_explicit((_Atomic(unsigned short)*)x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline unsigned short atomic_exchange_u16(unsigned short* x, unsigned short y) { + return atomic_exchange_explicit((_Atomic(unsigned short)*)x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_add_u16(unsigned short* x, unsigned short y) { + return atomic_fetch_add_explicit((_Atomic(unsigned short)*)x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_sub_u16(unsigned short* x, unsigned short y) { + return atomic_fetch_sub_explicit((_Atomic(unsigned short)*)x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_and_u16(unsigned short* x, unsigned short y) { + return atomic_fetch_and_explicit((_Atomic(unsigned short)*)x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_or_u16(unsigned short* x, unsigned short y) { + return atomic_fetch_or_explicit((_Atomic(unsigned short)*)x, y, memory_order_seq_cst); +} +static inline unsigned short atomic_fetch_xor_u16(unsigned short* x, unsigned short y) { + return atomic_fetch_xor_explicit((_Atomic(unsigned short)*)x, y, memory_order_seq_cst); +} + +static inline unsigned char atomic_load_byte(unsigned char* x) { + return atomic_load_explicit((_Atomic(unsigned char)*)x, memory_order_seq_cst); +} +static inline void atomic_store_byte(unsigned char* x, unsigned char y) { + atomic_store_explicit((_Atomic(unsigned char)*)x, y, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_weak_byte(unsigned char* x, unsigned char* expected, unsigned char y) { + return (int)atomic_compare_exchange_weak_explicit((_Atomic(unsigned char)*)x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline int atomic_compare_exchange_strong_byte(unsigned char* x, unsigned char* expected, unsigned char y) { + return (int)atomic_compare_exchange_strong_explicit((_Atomic(unsigned char)*)x, expected, y, memory_order_seq_cst, memory_order_seq_cst); +} +static inline unsigned char atomic_exchange_byte(unsigned char* x, unsigned char y) { + return atomic_exchange_explicit((_Atomic(unsigned char)*)x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_add_byte(unsigned char* x, unsigned char y) { + return atomic_fetch_add_explicit((_Atomic(unsigned char)*)x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_sub_byte(unsigned char* x, unsigned char y) { + return atomic_fetch_sub_explicit((_Atomic(unsigned char)*)x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_and_byte(unsigned char* x, unsigned char y) { + return atomic_fetch_and_explicit((_Atomic(unsigned char)*)x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_or_byte(unsigned char* x, unsigned char y) { + return atomic_fetch_or_explicit((_Atomic(unsigned char)*)x, y, memory_order_seq_cst); +} +static inline unsigned char atomic_fetch_xor_byte(unsigned char* x, unsigned char y) { + return atomic_fetch_xor_explicit((_Atomic(unsigned char)*)x, y, memory_order_seq_cst); +} + +#endif +#endif + +#endif // $if 1 + + +// added by module `term`, file: term_nix.c.v:5: #if defined(__has_include) @@ -1259,7 +2050,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `term` +// added by module `term`, file: term_nix.c.v:6: #if defined(__has_include) @@ -1277,7 +2068,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `sync` +// added by module `sync`, file: sync_default.c.v:14: #if defined(__has_include) @@ -6854,7 +7645,7 @@ string string_clone(string a); string string_replace_once(string s, string rep, string with); string string_replace(string s, string rep, string with); string string_replace_each(string s, Array_string vals); -VV_LOCAL_SYMBOL int compare_11653268393309465375_RepIndex_by_idx(RepIndex* a, RepIndex* b) { +VV_LOCAL_SYMBOL int compare_2018276881664952276_RepIndex_by_idx(RepIndex* a, RepIndex* b) { if (a->idx < b->idx) return -1; else return 1; } @@ -7094,7 +7885,7 @@ Option_void os__execve(string cmdpath, Array_string cmdargs, Array_string envs); int os__is_atty(int fd); Option_void os__write_file_array(string path, array buffer); Option_Array_string os__glob(Array_string patterns); -VV_LOCAL_SYMBOL int compare_3075544183021293552_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_10044130939551424885_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -7275,7 +8066,7 @@ Array_string os__cmdline__only_non_options(Array_string args); Array_string os__cmdline__only_options(Array_string args); #define _const_v__token__max_keyword_len 20 v__token__KeywordsMatcher v__token__new_keywords_matcher_T_v__token__Kind(Map_string_v__token__Kind kw_map); -VV_LOCAL_SYMBOL int compare_186646746980636166_v__token__WIndex_by_word(v__token__WIndex* a, v__token__WIndex* b) { +VV_LOCAL_SYMBOL int compare_7621314236064146737_v__token__WIndex_by_word(v__token__WIndex* a, v__token__WIndex* b) { if (string__lt(a->word, b->word)) return -1; else return 1; } @@ -7424,7 +8215,7 @@ time__Time time__unix2(i64 abs, int microsecond); VV_LOCAL_SYMBOL multi_return_int_int_int time__calculate_date_from_offset(i64 day_offset_); VV_LOCAL_SYMBOL multi_return_int_int_int time__calculate_time_from_offset(i64 second_offset_); void v__dotgraph__start_digraph(void); -VV_LOCAL_SYMBOL void anon_fn_eb34f0b759dade77__82(void); +VV_LOCAL_SYMBOL void anon_fn_40181cb3d9c4559e__82(void); v__dotgraph__DotGraph* v__dotgraph__new(string name, string label, string color); void v__dotgraph__DotGraph_writeln(v__dotgraph__DotGraph* d, string line); void v__dotgraph__DotGraph_finish(v__dotgraph__DotGraph* d); @@ -7724,7 +8515,7 @@ Array_string Array_v__cflag__CFlag_c_options_only_object_files(Array_v__cflag__C multi_return_Array_string_Array_string_Array_string Array_v__cflag__CFlag_defines_others_libs(Array_v__cflag__CFlag cflags); VV_LOCAL_SYMBOL Option_string v__pkgconfig__desc(string mod); Option_v__pkgconfig__Main_ptr v__pkgconfig__main(Array_string args); -VV_LOCAL_SYMBOL int compare_16330786295575367509_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_6984583855671780374_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -7874,7 +8665,7 @@ v__pref__CompilerType v__pref__cc_from_string(string cc_str); v__pref__Arch v__pref__get_host_arch(void); VV_LOCAL_SYMBOL void v__pref__Preferences_parse_define(v__pref__Preferences* prefs, string define); Array_string v__pref__Preferences_should_compile_filtered_files(v__pref__Preferences* prefs, string dir, Array_string files_); -VV_LOCAL_SYMBOL int compare_13661271458656804876_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_16890712418519328305_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -7935,7 +8726,7 @@ u64 sync__thread_id(void); string _const_help__unknown_topic; // a string literal, inited later void help__print_and_exit(string topic); VV_LOCAL_SYMBOL string help__known_topics(string topicdir); -VV_LOCAL_SYMBOL int compare_10452767129756656329_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_1650400601261717902_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -7978,13 +8769,13 @@ v__util__Suggestion v__util__new_suggestion(string wanted, Array_string possibil void v__util__Suggestion_add(v__util__Suggestion* s, string val); void v__util__Suggestion_add_many(v__util__Suggestion* s, Array_string many); void v__util__Suggestion_sort(v__util__Suggestion* s); -VV_LOCAL_SYMBOL int compare_6907021362050549619_v__util__Possibility_by_similarity(v__util__Possibility* a, v__util__Possibility* b) { +VV_LOCAL_SYMBOL int compare_6081961377856465380_v__util__Possibility_by_similarity(v__util__Possibility* a, v__util__Possibility* b) { if (a->similarity < b->similarity) return -1; else return 1; } string v__util__Suggestion_say(v__util__Suggestion s, string msg); -VV_LOCAL_SYMBOL int compare_6907021362050549619_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_6081961377856465380_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -9073,7 +9864,7 @@ v__ast__Type v__parser__Parser_parse_fn_type(v__parser__Parser* p, string name); v__ast__Type v__parser__Parser_parse_type_with_mut(v__parser__Parser* p, bool is_mut); v__ast__Language v__parser__Parser_parse_language(v__parser__Parser* p); v__ast__Type v__parser__Parser_parse_inline_sum_type(v__parser__Parser* p); -VV_LOCAL_SYMBOL int compare_7932637671395545435_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_1376677008124459278_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -11918,7 +12709,7 @@ void v__ast__TypeSymbol_free(v__ast__TypeSymbol* it) { string_free(&(it->mod)); } -VV_LOCAL_SYMBOL void anon_fn_eb34f0b759dade77__82(void) { +VV_LOCAL_SYMBOL void anon_fn_40181cb3d9c4559e__82(void) { println(_SLIT("}")); } @@ -19704,7 +20495,7 @@ string string_replace_each(string s, Array_string vals) { if (idxs.len == 0) { return string_clone(s); } - qsort(idxs.data, idxs.len, idxs.element_size, (int (*)(const void *, const void *))&compare_11653268393309465375_RepIndex_by_idx); + qsort(idxs.data, idxs.len, idxs.element_size, (int (*)(const void *, const void *))&compare_2018276881664952276_RepIndex_by_idx); u8* b = malloc_noscan(new_len + 1); int idx_pos = 0; RepIndex cur_idx = ((RepIndex*)idxs.data)[idx_pos]; @@ -21048,7 +21839,7 @@ bool string_match_glob(string name, string pattern) { bool is_inverted = false; bool inner_match = false; int inner_idx = bstart + 1; - u8 inner_c = ((u8)(0)); + int inner_c = 0; if (inner_idx < plen) { inner_c = pattern.str[ inner_idx]; if (inner_c == '^') { @@ -24696,7 +25487,7 @@ Option_Array_string os__glob(Array_string patterns) { ; } - qsort(matches.data, matches.len, matches.element_size, (int (*)(const void *, const void *))&compare_3075544183021293552_string); + qsort(matches.data, matches.len, matches.element_size, (int (*)(const void *, const void *))&compare_10044130939551424885_string); Option_Array_string _t4; opt_ok(&(Array_string[]) { matches }, (Option*)(&_t4), sizeof(Array_string)); return _t4; @@ -27047,7 +27838,7 @@ v__token__KeywordsMatcher v__token__new_keywords_matcher_T_v__token__Kind(Map_st } for (int i = 0; i < _const_v__token__max_keyword_len; ++i) { if (km.words[v_fixed_index(i, 20)].len > 0) { - qsort(km.words[v_fixed_index(i, 20)].data, km.words[v_fixed_index(i, 20)].len, km.words[v_fixed_index(i, 20)].element_size, (int (*)(const void *, const void *))&compare_186646746980636166_v__token__WIndex_by_word); + qsort(km.words[v_fixed_index(i, 20)].data, km.words[v_fixed_index(i, 20)].len, km.words[v_fixed_index(i, 20)].element_size, (int (*)(const void *, const void *))&compare_7621314236064146737_v__token__WIndex_by_word); #if defined(CUSTOM_DEFINE_trace_keyword_matcher_initialisation) { print( str_intp(2, _MOV((StrIntpData[]){{_SLIT("word len: "), 0x6fe27, {.d_i32 = i}}, {_SLIT(" | words: "), 0, { .d_c = 0 }}}))); @@ -27085,7 +27876,7 @@ v__token__KeywordsMatcher v__token__new_keywords_matcher_T_int(Map_string_int kw } for (int i = 0; i < _const_v__token__max_keyword_len; ++i) { if (km.words[v_fixed_index(i, 20)].len > 0) { - qsort(km.words[v_fixed_index(i, 20)].data, km.words[v_fixed_index(i, 20)].len, km.words[v_fixed_index(i, 20)].element_size, (int (*)(const void *, const void *))&compare_186646746980636166_v__token__WIndex_by_word); + qsort(km.words[v_fixed_index(i, 20)].data, km.words[v_fixed_index(i, 20)].len, km.words[v_fixed_index(i, 20)].element_size, (int (*)(const void *, const void *))&compare_7621314236064146737_v__token__WIndex_by_word); #if defined(CUSTOM_DEFINE_trace_keyword_matcher_initialisation) { print( str_intp(2, _MOV((StrIntpData[]){{_SLIT("word len: "), 0x6fe27, {.d_i32 = i}}, {_SLIT(" | words: "), 0, { .d_c = 0 }}}))); @@ -29723,7 +30514,7 @@ VV_LOCAL_SYMBOL multi_return_int_int_int time__calculate_time_from_offset(i64 se void v__dotgraph__start_digraph(void) { println(_SLIT("digraph G {")); - atexit((voidptr) anon_fn_eb34f0b759dade77__82); + atexit((voidptr) anon_fn_40181cb3d9c4559e__82); } v__dotgraph__DotGraph* v__dotgraph__new(string name, string label, string color) { @@ -33052,7 +33843,7 @@ Option_v__pkgconfig__Main_ptr v__pkgconfig__main(Array_string args) { m->res = _const_v__pkgconfig__version; } else if (opt->listall) { Array_string modules = v__pkgconfig__list(); - qsort(modules.data, modules.len, modules.element_size, (int (*)(const void *, const void *))&compare_16330786295575367509_string); + qsort(modules.data, modules.len, modules.element_size, (int (*)(const void *, const void *))&compare_6984583855671780374_string); if (opt->description) { for (int _t1 = 0; _t1 < modules.len; ++_t1) { string mod = ((string*)modules.data)[_t1]; @@ -34487,7 +35278,7 @@ void v__pref__Preferences_fill_with_defaults(v__pref__Preferences* p) { } #endif } - string vhash = _SLIT("07cab64d1"); + string vhash = _SLIT("2a0b372"); p->cache_manager = v__vcache__new_cache_manager(new_array_from_c_array(7, 7, sizeof(string), _MOV((string[7]){string_clone(vhash), str_intp(6, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = v__pref__Backend_str(p->backend)}}, {_SLIT(" | "), 0xfe10, {.d_s = v__pref__OS_str(p->os)}}, {_SLIT(" | "), 0xfe10, {.d_s = p->ccompiler}}, {_SLIT(" | "), 0xfe10, {.d_s = p->is_prod ? _SLIT("true") : _SLIT("false")}}, {_SLIT(" | "), 0xfe10, {.d_s = p->sanitize ? _SLIT("true") : _SLIT("false")}}, {_SLIT0, 0, { .d_c = 0 }}})), string_clone(string_trim_space(p->cflags)), string_clone(string_trim_space(p->third_party_option)), string_clone(Array_string_str(p->compile_defines_all)), string_clone(Array_string_str(p->compile_defines)), string_clone(Array_string_str(p->lookup_path))}))); if (string__eq(os__user_os(), _SLIT("windows"))) { p->use_cache = false; @@ -35836,7 +36627,7 @@ VV_LOCAL_SYMBOL void v__pref__Preferences_parse_define(v__pref__Preferences* pre Array_string v__pref__Preferences_should_compile_filtered_files(v__pref__Preferences* prefs, string dir, Array_string files_) { Array_string res = __new_array_with_default(0, 0, sizeof(string), 0); Array_string files = array_clone_to_depth(&files_, 0); - qsort(files.data, files.len, files.element_size, (int (*)(const void *, const void *))&compare_13661271458656804876_string); + qsort(files.data, files.len, files.element_size, (int (*)(const void *, const void *))&compare_16890712418519328305_string); Array_string all_v_files = __new_array_with_default(0, 0, sizeof(string), 0); for (int _t1 = 0; _t1 < files.len; ++_t1) { string file = ((string*)files.data)[_t1]; @@ -36593,7 +37384,7 @@ int sync__channel_select(Array_sync__Channel_ptr* channels, Array_sync__Directio // assert if (!(channels->len == dir.len)) { VAssertMetaInfo v_assert_meta_info__t1 = {0}; - v_assert_meta_info__t1.fpath = _SLIT("/woodpecker/src/git.rustybever.be/Chewing_Bever/v/vlib/sync/channels.c.v"); + v_assert_meta_info__t1.fpath = _SLIT("/home/runner/work/v/v/vlib/sync/channels.c.v"); v_assert_meta_info__t1.line_nr = 550; v_assert_meta_info__t1.fn_name = _SLIT("sync.channel_select"); v_assert_meta_info__t1.src = _SLIT("channels.len == dir.len"); @@ -36608,7 +37399,7 @@ int sync__channel_select(Array_sync__Channel_ptr* channels, Array_sync__Directio // assert if (!(dir.len == objrefs->len)) { VAssertMetaInfo v_assert_meta_info__t2 = {0}; - v_assert_meta_info__t2.fpath = _SLIT("/woodpecker/src/git.rustybever.be/Chewing_Bever/v/vlib/sync/channels.c.v"); + v_assert_meta_info__t2.fpath = _SLIT("/home/runner/work/v/v/vlib/sync/channels.c.v"); v_assert_meta_info__t2.line_nr = 551; v_assert_meta_info__t2.fn_name = _SLIT("sync.channel_select"); v_assert_meta_info__t2.src = _SLIT("dir.len == objrefs.len"); @@ -37082,7 +37873,7 @@ VV_LOCAL_SYMBOL string help__known_topics(string topicdir) { array_push((array*)&_t3, &ti); } Array_string topics =_t3; - qsort(topics.data, topics.len, topics.element_size, (int (*)(const void *, const void *))&compare_10452767129756656329_string); + qsort(topics.data, topics.len, topics.element_size, (int (*)(const void *, const void *))&compare_1650400601261717902_string); array_push((array*)&res, _MOV((string[]){ string_clone(Array_string_join(topics, _SLIT(", "))) })); array_push((array*)&res, _MOV((string[]){ string_clone(_SLIT(".")) })); string _t7 = Array_string_join(res, _SLIT("")); @@ -37579,7 +38370,7 @@ void v__util__Suggestion_add_many(v__util__Suggestion* s, Array_string many) { } void v__util__Suggestion_sort(v__util__Suggestion* s) { - qsort(s->known.data, s->known.len, s->known.element_size, (int (*)(const void *, const void *))&compare_6907021362050549619_v__util__Possibility_by_similarity); + qsort(s->known.data, s->known.len, s->known.element_size, (int (*)(const void *, const void *))&compare_6081961377856465380_v__util__Possibility_by_similarity); } string v__util__Suggestion_say(v__util__Suggestion s, string msg) { @@ -37608,7 +38399,7 @@ string v__util__Suggestion_say(v__util__Suggestion s, string msg) { array_push((array*)&_t1, &ti); } Array_string values =_t1; - qsort(values.data, values.len, values.element_size, (int (*)(const void *, const void *))&compare_6907021362050549619_string); + qsort(values.data, values.len, values.element_size, (int (*)(const void *, const void *))&compare_6081961377856465380_string); if (values.len == 1) { res = /*f*/string__plus(res, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".\n1 possibility: "), 0xfe10, {.d_s = (*(string*)/*ee elem_sym */array_get(values, 0))}}, {_SLIT("."), 0, { .d_c = 0 }}}))); } else if (values.len < 25) { @@ -38376,9 +39167,9 @@ void v__util__prepare_tool_when_needed(string source_name) { string vexe = os__getenv(_SLIT("VEXE")); string vroot = os__dir(vexe); string stool = os__join_path(vroot, new_array_from_c_array(3, 3, sizeof(string), _MOV((string[3]){_SLIT("cmd"), _SLIT("tools"), source_name}))); - multi_return_string_string mr_14621 = v__util__tool_source2name_and_exe(stool); - string tool_name = mr_14621.arg0; - string tool_exe = mr_14621.arg1; + multi_return_string_string mr_14629 = v__util__tool_source2name_and_exe(stool); + string tool_name = mr_14629.arg0; + string tool_exe = mr_14629.arg1; if (v__util__should_recompile_tool(vexe, stool, tool_name, tool_exe)) { time__sleep(1001 * _const_time__millisecond); v__util__recompile_file(vexe, stool); @@ -44508,8 +45299,7 @@ string v__ast__Type_str(v__ast__Type t) { } string v__ast__Table_type_str(v__ast__Table* t, v__ast__Type typ) { - v__ast__TypeSymbol* sym = v__ast__Table_sym(t, typ); - string _t1 = sym->name; + string _t1 = v__ast__Table_sym(t, typ)->name; return _t1; } @@ -44634,8 +45424,7 @@ inline bool v__ast__Type_is_unsigned(v__ast__Type typ) { } v__ast__Type v__ast__Type_flip_signedness(v__ast__Type typ) { - v__ast__Type r = ((typ == (_const_v__ast__i8_type)) ? (_const_v__ast__byte_type) : (typ == (_const_v__ast__i16_type)) ? (_const_v__ast__u16_type) : (typ == (_const_v__ast__int_type)) ? (_const_v__ast__u32_type) : (typ == (_const_v__ast__isize_type)) ? (_const_v__ast__usize_type) : (typ == (_const_v__ast__i64_type)) ? (_const_v__ast__u64_type) : (typ == (_const_v__ast__byte_type)) ? (_const_v__ast__i8_type) : (typ == (_const_v__ast__u16_type)) ? (_const_v__ast__i16_type) : (typ == (_const_v__ast__u32_type)) ? (_const_v__ast__int_type) : (typ == (_const_v__ast__usize_type)) ? (_const_v__ast__isize_type) : (typ == (_const_v__ast__u64_type)) ? (_const_v__ast__i64_type) : (typ)); - v__ast__Type _t1 = r; + v__ast__Type _t1 = ((typ == (_const_v__ast__i8_type)) ? (_const_v__ast__byte_type) : (typ == (_const_v__ast__i16_type)) ? (_const_v__ast__u16_type) : (typ == (_const_v__ast__int_type)) ? (_const_v__ast__u32_type) : (typ == (_const_v__ast__isize_type)) ? (_const_v__ast__usize_type) : (typ == (_const_v__ast__i64_type)) ? (_const_v__ast__u64_type) : (typ == (_const_v__ast__byte_type)) ? (_const_v__ast__i8_type) : (typ == (_const_v__ast__u16_type)) ? (_const_v__ast__i16_type) : (typ == (_const_v__ast__u32_type)) ? (_const_v__ast__int_type) : (typ == (_const_v__ast__usize_type)) ? (_const_v__ast__isize_type) : (typ == (_const_v__ast__u64_type)) ? (_const_v__ast__i64_type) : (typ)); return _t1; } @@ -44664,7 +45453,7 @@ inline bool v__ast__Type_is_bool(v__ast__Type typ) { } Array_v__ast__Type v__ast__merge_types(Array_Array_v__ast__Type params) { - Array_v__ast__Type res = __new_array_with_default(0, 0, sizeof(v__ast__Type), 0); + Array_v__ast__Type res = __new_array_with_default(0, params.len, sizeof(v__ast__Type), 0); for (int _t1 = 0; _t1 < params.len; ++_t1) { Array_v__ast__Type types = ((Array_v__ast__Type*)params.data)[_t1]; _PUSH_MANY(&res, (types), _t2, Array_v__ast__Type); @@ -44674,20 +45463,8 @@ Array_v__ast__Type v__ast__merge_types(Array_Array_v__ast__Type params) { } v__ast__Type v__ast__mktyp(v__ast__Type typ) { - - if (typ == (_const_v__ast__float_literal_type)) { - v__ast__Type _t1 = _const_v__ast__f64_type; - return _t1; - } - else if (typ == (_const_v__ast__int_literal_type)) { - v__ast__Type _t2 = _const_v__ast__int_type; - return _t2; - } - else { - v__ast__Type _t3 = typ; - return _t3; - }; - return 0; + v__ast__Type _t1 = ((typ == (_const_v__ast__float_literal_type)) ? (_const_v__ast__f64_type) : (typ == (_const_v__ast__int_literal_type)) ? (_const_v__ast__int_type) : (typ)); + return _t1; } v__ast__Kind v__ast__Table_type_kind(v__ast__Table* t, v__ast__Type typ) { @@ -44967,207 +45744,206 @@ inline bool v__ast__TypeSymbol_is_builtin(v__ast__TypeSymbol* t) { } string v__ast__Kind_str(v__ast__Kind k) { - string _t1 = (string){.str=(byteptr)"", .is_lit=1}; + string _t2 = (string){.str=(byteptr)"", .is_lit=1}; switch (k) { case v__ast__Kind__placeholder: { - _t1 = _SLIT("placeholder"); + _t2 = _SLIT("placeholder"); break; } case v__ast__Kind__void: { - _t1 = _SLIT("void"); + _t2 = _SLIT("void"); break; } case v__ast__Kind__voidptr: { - _t1 = _SLIT("voidptr"); + _t2 = _SLIT("voidptr"); break; } case v__ast__Kind__charptr: { - _t1 = _SLIT("charptr"); + _t2 = _SLIT("charptr"); break; } case v__ast__Kind__byteptr: { - _t1 = _SLIT("byteptr"); + _t2 = _SLIT("byteptr"); break; } case v__ast__Kind__struct_: { - _t1 = _SLIT("struct"); + _t2 = _SLIT("struct"); break; } case v__ast__Kind__int: { - _t1 = _SLIT("int"); + _t2 = _SLIT("int"); break; } case v__ast__Kind__i8: { - _t1 = _SLIT("i8"); + _t2 = _SLIT("i8"); break; } case v__ast__Kind__i16: { - _t1 = _SLIT("i16"); + _t2 = _SLIT("i16"); break; } case v__ast__Kind__i64: { - _t1 = _SLIT("i64"); + _t2 = _SLIT("i64"); break; } case v__ast__Kind__isize: { - _t1 = _SLIT("isize"); + _t2 = _SLIT("isize"); break; } case v__ast__Kind__u8: { - _t1 = _SLIT("u8"); + _t2 = _SLIT("u8"); break; } case v__ast__Kind__u16: { - _t1 = _SLIT("u16"); + _t2 = _SLIT("u16"); break; } case v__ast__Kind__u32: { - _t1 = _SLIT("u32"); + _t2 = _SLIT("u32"); break; } case v__ast__Kind__u64: { - _t1 = _SLIT("u64"); + _t2 = _SLIT("u64"); break; } case v__ast__Kind__usize: { - _t1 = _SLIT("usize"); + _t2 = _SLIT("usize"); break; } case v__ast__Kind__int_literal: { - _t1 = _SLIT("int_literal"); + _t2 = _SLIT("int_literal"); break; } case v__ast__Kind__f32: { - _t1 = _SLIT("f32"); + _t2 = _SLIT("f32"); break; } case v__ast__Kind__f64: { - _t1 = _SLIT("f64"); + _t2 = _SLIT("f64"); break; } case v__ast__Kind__float_literal: { - _t1 = _SLIT("float_literal"); + _t2 = _SLIT("float_literal"); break; } case v__ast__Kind__string: { - _t1 = _SLIT("string"); + _t2 = _SLIT("string"); break; } case v__ast__Kind__char: { - _t1 = _SLIT("char"); + _t2 = _SLIT("char"); break; } case v__ast__Kind__bool: { - _t1 = _SLIT("bool"); + _t2 = _SLIT("bool"); break; } case v__ast__Kind__none_: { - _t1 = _SLIT("none"); + _t2 = _SLIT("none"); break; } case v__ast__Kind__array: { - _t1 = _SLIT("array"); + _t2 = _SLIT("array"); break; } case v__ast__Kind__array_fixed: { - _t1 = _SLIT("array_fixed"); + _t2 = _SLIT("array_fixed"); break; } case v__ast__Kind__map: { - _t1 = _SLIT("map"); + _t2 = _SLIT("map"); break; } case v__ast__Kind__chan: { - _t1 = _SLIT("chan"); + _t2 = _SLIT("chan"); break; } case v__ast__Kind__multi_return: { - _t1 = _SLIT("multi_return"); + _t2 = _SLIT("multi_return"); break; } case v__ast__Kind__sum_type: { - _t1 = _SLIT("sum_type"); + _t2 = _SLIT("sum_type"); break; } case v__ast__Kind__alias: { - _t1 = _SLIT("alias"); + _t2 = _SLIT("alias"); break; } case v__ast__Kind__enum_: { - _t1 = _SLIT("enum"); + _t2 = _SLIT("enum"); break; } case v__ast__Kind__any: { - _t1 = _SLIT("any"); + _t2 = _SLIT("any"); break; } case v__ast__Kind__function: { - _t1 = _SLIT("function"); + _t2 = _SLIT("function"); break; } case v__ast__Kind__interface_: { - _t1 = _SLIT("interface"); + _t2 = _SLIT("interface"); break; } case v__ast__Kind__generic_inst: { - _t1 = _SLIT("generic_inst"); + _t2 = _SLIT("generic_inst"); break; } case v__ast__Kind__rune: { - _t1 = _SLIT("rune"); + _t2 = _SLIT("rune"); break; } case v__ast__Kind__aggregate: { - _t1 = _SLIT("aggregate"); + _t2 = _SLIT("aggregate"); break; } case v__ast__Kind__thread: { - _t1 = _SLIT("thread"); + _t2 = _SLIT("thread"); break; } } - string k_str = _t1; - string _t2 = k_str; - return _t2; + string _t1 = _t2; + return _t1; } string Array_v__ast__Kind_str(Array_v__ast__Kind kinds) { @@ -46424,20 +47200,10 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; if ((*left->_v__ast__PrefixExpr).op == v__token__Kind__mul) { if (!c->inside_unsafe && !c->pref->translated && !c->file->is_translated) { v__checker__Checker_error(c, _SLIT("modifying variables via dereferencing can only be done in `unsafe` blocks"), node->pos); - } else { - if ((*left->_v__ast__PrefixExpr).right._typ == 266 /* v.ast.Ident */) { - if ((*(*left->_v__ast__PrefixExpr).right._v__ast__Ident).obj._typ == 324 /* v.ast.Var */) { - (*(*(*left->_v__ast__PrefixExpr).right._v__ast__Ident).obj._v__ast__Var).is_used = true; - } - - else { - } - ; + } else if (((*left->_v__ast__PrefixExpr).right)._typ == 266 /* v.ast.Ident */) { + if (((*(*left->_v__ast__PrefixExpr).right._v__ast__Ident).obj)._typ == 324 /* v.ast.Var */) { + (*(*(*left->_v__ast__PrefixExpr).right._v__ast__Ident).obj._v__ast__Var).is_used = true; } - - else { - } - ; } } if (is_decl) { @@ -46476,17 +47242,26 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; } v__ast__TypeSymbol* left_sym = v__ast__Table_sym(c->table, left_type_unwrapped); v__ast__TypeSymbol* right_sym = v__ast__Table_sym(c->table, right_type_unwrapped); - if (left_sym->kind == v__ast__Kind__array && !c->inside_unsafe && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__array && ((left)->_typ == 266 /* v.ast.Ident */ && !v__ast__Expr_is_blank_ident(/*rec*/*left)) && (right)._typ == 266 /* v.ast.Ident */) { + if (left_sym->kind == v__ast__Kind__array && !c->inside_unsafe && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__array && (left)->_typ == 266 /* v.ast.Ident */ && !v__ast__Expr_is_blank_ident(/*rec*/*left) && (right)._typ == 266 /* v.ast.Ident */) { v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("use `array2 "), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" array1.clone()` instead of `array2 "), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" array1` (or use `unsafe`)"), 0, { .d_c = 0 }}})), node->pos); } - if (left_sym->kind == v__ast__Kind__array_fixed && !c->inside_unsafe && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__array_fixed && ((left)->_typ == 266 /* v.ast.Ident */ && !v__ast__Expr_is_blank_ident(/*rec*/*left)) && (right)._typ == 266 /* v.ast.Ident */) { + if (left_sym->kind == v__ast__Kind__array && right_sym->kind == v__ast__Kind__array) { + v__ast__Array left_info = /* as */ *(v__ast__Array*)__as_cast((left_sym->info)._v__ast__Array,(left_sym->info)._typ, 411) /*expected idx: 411, name: v.ast.Array */ ; + v__ast__Type left_elem_type = v__ast__Table_unaliased_type(c->table, left_info.elem_type); + v__ast__Array right_info = /* as */ *(v__ast__Array*)__as_cast((right_sym->info)._v__ast__Array,(right_sym->info)._typ, 411) /*expected idx: 411, name: v.ast.Array */ ; + v__ast__Type right_elem_type = v__ast__Table_unaliased_type(c->table, right_info.elem_type); + if (left_info.nr_dims == right_info.nr_dims && v__ast__Type_alias_eq(left_elem_type, right_elem_type)) { + continue; + } + } + if (left_sym->kind == v__ast__Kind__array_fixed && !c->inside_unsafe && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__array_fixed && (left)->_typ == 266 /* v.ast.Ident */ && !v__ast__Expr_is_blank_ident(/*rec*/*left) && (right)._typ == 266 /* v.ast.Ident */) { if ((right_sym->info)._typ == 439 /* v.ast.ArrayFixed */) { if (v__ast__Type_is_ptr((*right_sym->info._v__ast__ArrayFixed).elem_type)) { v__checker__Checker_error(c, _SLIT("assignment from one fixed array to another with a pointer element type is prohibited outside of `unsafe`"), node->pos); } } } - if (left_sym->kind == v__ast__Kind__map && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__map && (((right)._typ == 266 /* v.ast.Ident */ && v__ast__Expr_is_auto_deref_var(right)) || !v__ast__Type_is_ptr(right_type)) && !v__ast__Expr_is_blank_ident(/*rec*/*left) && v__ast__Expr_is_lvalue(right)) { + if (left_sym->kind == v__ast__Kind__map && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__map && !v__ast__Expr_is_blank_ident(/*rec*/*left) && v__ast__Expr_is_lvalue(right) && (!v__ast__Type_is_ptr(right_type) || ((right)._typ == 266 /* v.ast.Ident */ && v__ast__Expr_is_auto_deref_var(right)))) { v__checker__Checker_error(c, _SLIT("cannot copy map: call `move` or `clone` method (or use a reference)"), v__ast__Expr_pos(right)); } bool left_is_ptr = v__ast__Type_is_ptr(left_type) || v__ast__TypeSymbol_is_pointer(left_sym); @@ -46498,7 +47273,7 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; if (!right_is_ptr && node->op == v__token__Kind__assign && v__ast__Type_is_number(right_type_unwrapped)) { v__checker__Checker_error(c, string__plus( str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot assign to `"), 0xfe10, {.d_s = v__ast__Expr_str(*left)}}, {_SLIT("`: "), 0, { .d_c = 0 }}})), v__checker__Checker_expected_msg(c, right_type_unwrapped, left_type_unwrapped)), v__ast__Expr_pos(right)); } - if (((right)._typ == 291 /* v.ast.StructInit */ || !right_is_ptr) && !(v__ast__TypeSymbol_is_number(right_sym) || v__ast__Type_has_flag(left_type, v__ast__TypeFlag__shared_f))) { + if (!v__ast__TypeSymbol_is_number(right_sym) && !v__ast__Type_has_flag(left_type, v__ast__TypeFlag__shared_f) && ((right)._typ == 291 /* v.ast.StructInit */ || !right_is_ptr)) { string left_name = v__ast__Table_type_to_str(c->table, left_type_unwrapped); v__ast__Type rtype = right_type_unwrapped; if (v__ast__Type_is_ptr(rtype)) { @@ -46586,7 +47361,7 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; } else { }; - if ((node->op == v__token__Kind__plus_assign || node->op == v__token__Kind__minus_assign || node->op == v__token__Kind__mod_assign || node->op == v__token__Kind__mult_assign || node->op == v__token__Kind__div_assign) && ((left_sym->kind == v__ast__Kind__struct_ && right_sym->kind == v__ast__Kind__struct_) || left_sym->kind == v__ast__Kind__alias)) { + if ((node->op == v__token__Kind__plus_assign || node->op == v__token__Kind__minus_assign || node->op == v__token__Kind__mod_assign || node->op == v__token__Kind__mult_assign || node->op == v__token__Kind__div_assign) && (left_sym->kind == v__ast__Kind__alias || (left_sym->kind == v__ast__Kind__struct_ && right_sym->kind == v__ast__Kind__struct_))) { string left_name = v__ast__Table_type_to_str(c->table, left_type_unwrapped); string right_name = v__ast__Table_type_to_str(c->table, right_type_unwrapped); v__ast__TypeSymbol* parent_sym = v__ast__Table_final_sym(c->table, left_type_unwrapped); @@ -46668,7 +47443,7 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; is_shared = (*(*left_first._v__ast__Ident).info._v__ast__IdentVar).share == v__ast__ShareType__shared_t; } bool old_inside_ref_lit = c->inside_ref_lit; - c->inside_ref_lit = (c->inside_ref_lit || right_node.op == v__token__Kind__amp || is_shared); + c->inside_ref_lit = c->inside_ref_lit || right_node.op == v__token__Kind__amp || is_shared; v__checker__Checker_expr(c, right_node.right); c->inside_ref_lit = old_inside_ref_lit; if (right_node.op == v__token__Kind__amp) { @@ -47096,7 +47871,7 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_check_shift(v__checker__Checker v__ast__Type v__checker__Checker_promote(v__checker__Checker* c, v__ast__Type left_type, v__ast__Type right_type) { if (v__ast__Type_is_any_kind_of_pointer(left_type)) { - if (v__ast__Type_is_int(right_type)) { + if (v__ast__Type_is_int(right_type) || c->pref->translated) { v__ast__Type _t1 = left_type; return _t1; } else { @@ -47104,7 +47879,7 @@ v__ast__Type v__checker__Checker_promote(v__checker__Checker* c, v__ast__Type le return _t2; } } else if (v__ast__Type_is_any_kind_of_pointer(right_type)) { - if (v__ast__Type_is_int(left_type)) { + if (v__ast__Type_is_int(left_type) || c->pref->translated) { v__ast__Type _t3 = right_type; return _t3; } else { @@ -47133,10 +47908,10 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_promote_num(v__checker__Checker v__ast__Type type_hi = left_type; v__ast__Type type_lo = right_type; if (v__ast__Type_idx(type_hi) < v__ast__Type_idx(type_lo)) { - v__ast__Type _var_16243 = type_hi; - v__ast__Type _var_16252 = type_lo; - type_hi = _var_16252; - type_lo = _var_16243; + v__ast__Type _var_16285 = type_hi; + v__ast__Type _var_16294 = type_lo; + type_hi = _var_16294; + type_lo = _var_16285; } int idx_hi = v__ast__Type_idx(type_hi); int idx_lo = v__ast__Type_idx(type_lo); @@ -47173,9 +47948,12 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_promote_num(v__checker__Checker } else if (idx_hi - idx_lo < (_const_v__ast__byte_type_idx - _const_v__ast__i8_type_idx)) { v__ast__Type _t9 = type_lo; return _t9; - } else { - v__ast__Type _t10 = _const_v__ast__void_type; + } else if (c->pref->translated) { + v__ast__Type _t10 = type_hi; return _t10; + } else { + v__ast__Type _t11 = _const_v__ast__void_type; + return _t11; } return 0; } @@ -48111,16 +48889,29 @@ v__ast__Type former_expected_type; ; node->left_type = map_info.key_type; } + else if (right_final->kind == (v__ast__Kind__array_fixed)) { + if (!(left_sym->kind == v__ast__Kind__sum_type || left_sym->kind == v__ast__Kind__interface_)) { + v__ast__Type elem_type = v__ast__TypeSymbol_array_fixed_info(right_final).elem_type; + Option_void _t3 = v__checker__Checker_check_expected(c, left_type, elem_type); + if (_t3.state != 0 && _t3.err._typ != _IError_None___index) { + IError err = _t3.err; + v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("left operand to `"), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT("` does not match the fixed array element type: "), 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT0, 0, { .d_c = 0 }}})), left_right_pos); + ; + } + + ; + } + } else { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT("` can only be used with arrays and maps"), 0, { .d_c = 0 }}})), node->pos); }; - v__ast__Type _t3 = _const_v__ast__bool_type; + v__ast__Type _t4 = _const_v__ast__bool_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t3; + return _t4; break; } case v__token__Kind__plus: @@ -48138,14 +48929,14 @@ v__ast__Type former_expected_type; if ((left_sym->info)._typ == 431 /* v.ast.Alias */ && (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 431) /*expected idx: 431, name: v.ast.Alias */ ).language != v__ast__Language__c && string__eq(c->mod, (*(string*)/*ee elem_sym */array_get(string_split(v__ast__Table_type_to_str(c->table, left_type), _SLIT(".")), 0))) && v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 431) /*expected idx: 431, name: v.ast.Alias */ ).parent_type))) { left_sym = v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 431) /*expected idx: 431, name: v.ast.Alias */ ).parent_type); } - if (left_sym->kind == v__ast__Kind__alias && (left_sym->info)._typ == 431 /* v.ast.Alias */ && !(v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 431) /*expected idx: 431, name: v.ast.Alias */ ).parent_type)))) { + if (!c->pref->translated && left_sym->kind == v__ast__Kind__alias && (left_sym->info)._typ == 431 /* v.ast.Alias */ && !(v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 431) /*expected idx: 431, name: v.ast.Alias */ ).parent_type)))) { if (v__ast__TypeSymbol_has_method(left_sym, v__token__Kind_str(node->op))) { - Option_v__ast__Fn _t4; - if (_t4 = v__ast__TypeSymbol_find_method(left_sym, v__token__Kind_str(node->op)), _t4.state == 0) { - v__ast__Fn method = *(v__ast__Fn*)_t4.data; + Option_v__ast__Fn _t5; + if (_t5 = v__ast__TypeSymbol_find_method(left_sym, v__token__Kind_str(node->op)), _t5.state == 0) { + v__ast__Fn method = *(v__ast__Fn*)_t5.data; return_type = method.return_type; } else { - IError err = _t4.err; + IError err = _t5.err; return_type = left_type; } } else { @@ -48157,14 +48948,14 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("mismatched types `"), 0xfe10, {.d_s = left_name}}, {_SLIT("` and `"), 0xfe10, {.d_s = right_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_right_pos); } } - } else if (right_sym->kind == v__ast__Kind__alias && (right_sym->info)._typ == 431 /* v.ast.Alias */ && !(v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((right_sym->info)._v__ast__Alias,(right_sym->info)._typ, 431) /*expected idx: 431, name: v.ast.Alias */ ).parent_type)))) { + } else if (!c->pref->translated && right_sym->kind == v__ast__Kind__alias && (right_sym->info)._typ == 431 /* v.ast.Alias */ && !(v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((right_sym->info)._v__ast__Alias,(right_sym->info)._typ, 431) /*expected idx: 431, name: v.ast.Alias */ ).parent_type)))) { if (v__ast__TypeSymbol_has_method(right_sym, v__token__Kind_str(node->op))) { - Option_v__ast__Fn _t5; - if (_t5 = v__ast__TypeSymbol_find_method(right_sym, v__token__Kind_str(node->op)), _t5.state == 0) { - v__ast__Fn method = *(v__ast__Fn*)_t5.data; + Option_v__ast__Fn _t6; + if (_t6 = v__ast__TypeSymbol_find_method(right_sym, v__token__Kind_str(node->op)), _t6.state == 0) { + v__ast__Fn method = *(v__ast__Fn*)_t6.data; return_type = method.return_type; } else { - IError err = _t5.err; + IError err = _t6.err; return_type = right_type; } } else { @@ -48179,12 +48970,12 @@ v__ast__Type former_expected_type; } if (left_sym->kind == v__ast__Kind__array || left_sym->kind == v__ast__Kind__array_fixed || left_sym->kind == v__ast__Kind__map || left_sym->kind == v__ast__Kind__struct_) { if (v__ast__TypeSymbol_has_method_with_generic_parent(left_sym, v__token__Kind_str(node->op))) { - Option_v__ast__Fn _t6; - if (_t6 = v__ast__TypeSymbol_find_method_with_generic_parent(left_sym, v__token__Kind_str(node->op)), _t6.state == 0) { - v__ast__Fn method = *(v__ast__Fn*)_t6.data; + Option_v__ast__Fn _t7; + if (_t7 = v__ast__TypeSymbol_find_method_with_generic_parent(left_sym, v__token__Kind_str(node->op)), _t7.state == 0) { + v__ast__Fn method = *(v__ast__Fn*)_t7.data; return_type = method.return_type; } else { - IError err = _t6.err; + IError err = _t7.err; return_type = left_type; } } else { @@ -48198,12 +48989,12 @@ v__ast__Type former_expected_type; } } else if (right_sym->kind == v__ast__Kind__array || right_sym->kind == v__ast__Kind__array_fixed || right_sym->kind == v__ast__Kind__map || right_sym->kind == v__ast__Kind__struct_) { if (v__ast__TypeSymbol_has_method_with_generic_parent(right_sym, v__token__Kind_str(node->op))) { - Option_v__ast__Fn _t7; - if (_t7 = v__ast__TypeSymbol_find_method_with_generic_parent(right_sym, v__token__Kind_str(node->op)), _t7.state == 0) { - v__ast__Fn method = *(v__ast__Fn*)_t7.data; + Option_v__ast__Fn _t8; + if (_t8 = v__ast__TypeSymbol_find_method_with_generic_parent(right_sym, v__token__Kind_str(node->op)), _t8.state == 0) { + v__ast__Fn method = *(v__ast__Fn*)_t8.data; return_type = method.return_type; } else { - IError err = _t7.err; + IError err = _t8.err; return_type = right_type; } } else { @@ -48265,13 +49056,13 @@ v__ast__Type former_expected_type; if ((left_sym->kind == v__ast__Kind__array || left_sym->kind == v__ast__Kind__array_fixed) && (right_sym->kind == v__ast__Kind__array || right_sym->kind == v__ast__Kind__array_fixed)) { v__checker__Checker_error(c, _SLIT("only `==` and `!=` are defined on arrays"), node->pos); } else if (left_sym->kind == v__ast__Kind__struct_ && (/* as */ *(v__ast__Struct*)__as_cast((left_sym->info)._v__ast__Struct,(left_sym->info)._typ, 416) /*expected idx: 416, name: v.ast.Struct */ ).generic_types.len > 0) { - v__ast__Type _t8 = _const_v__ast__bool_type; + v__ast__Type _t9 = _const_v__ast__bool_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t8; + return _t9; } else if (left_sym->kind == v__ast__Kind__struct_ && right_sym->kind == v__ast__Kind__struct_ && (node->op == v__token__Kind__eq || node->op == v__token__Kind__lt)) { if (!(v__ast__TypeSymbol_has_method(left_sym, v__token__Kind_str(node->op)) && v__ast__TypeSymbol_has_method(right_sym, v__token__Kind_str(node->op)))) { string left_name = v__ast__Table_type_to_str(c->table, left_type); @@ -48330,8 +49121,8 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, _SLIT("array append cannot be used in an expression"), node->pos); } v__checker__Checker_check_expr_opt_call(c, node->right, right_type); - multi_return_string_v__token__Pos mr_32778 = v__checker__Checker_fail_if_immutable(c, node->left); - node->auto_locked = mr_32778.arg0; + multi_return_string_v__token__Pos mr_33156 = v__checker__Checker_fail_if_immutable(c, node->left); + node->auto_locked = mr_33156.arg0; v__ast__Type left_value_type = v__ast__Table_value_type(c->table, v__checker__Checker_unwrap_generic(c, left_type)); v__ast__TypeSymbol* left_value_sym = v__ast__Table_sym(c->table, v__checker__Checker_unwrap_generic(c, left_value_type)); if (left_value_sym->kind == v__ast__Kind__interface_) { @@ -48344,13 +49135,13 @@ v__ast__Type former_expected_type; } else { v__checker__Checker_type_implements(c, v__ast__Table_value_type(c->table, right_type), left_value_type, right_pos); } - v__ast__Type _t9 = _const_v__ast__void_type; + v__ast__Type _t10 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t9; + return _t10; } else if (left_value_sym->kind == v__ast__Kind__sum_type) { if (right_final->kind != v__ast__Kind__array) { if (!v__ast__Table_is_sumtype_or_in_variant(c->table, left_value_type, right_type)) { @@ -48362,86 +49153,86 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot append `"), 0xfe10, {.d_s = right_sym->name}}, {_SLIT("` to `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), right_pos); } } - v__ast__Type _t10 = _const_v__ast__void_type; + v__ast__Type _t11 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t10; + return _t11; } v__ast__Type unwrapped_right_type = v__checker__Checker_unwrap_generic(c, right_type); if (v__checker__Checker_check_types(c, unwrapped_right_type, left_value_type)) { if (!(!v__ast__Type_is_ptr(unwrapped_right_type) && v__ast__Type_is_ptr(left_value_type) && v__ast__Type_share(left_value_type) == v__ast__ShareType__mut_t)) { - v__ast__Type _t11 = _const_v__ast__void_type; + v__ast__Type _t12 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t11; + return _t12; } } else if (v__checker__Checker_check_types(c, unwrapped_right_type, v__checker__Checker_unwrap_generic(c, left_type))) { - v__ast__Type _t12 = _const_v__ast__void_type; + v__ast__Type _t13 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t12; + return _t13; } v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot append `"), 0xfe10, {.d_s = right_sym->name}}, {_SLIT("` to `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), right_pos); - v__ast__Type _t13 = _const_v__ast__void_type; - // Defer begin - if (v__checker__Checker_infix_expr_defer_0) { - c->expected_type = former_expected_type; - } - // Defer end - return _t13; - } else { - v__ast__Type _t14 = v__checker__Checker_check_shift(c, node, left_type, right_type); + v__ast__Type _t14 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end return _t14; - } - break; - } - case v__token__Kind__right_shift: - { - v__ast__Type _t15 = v__checker__Checker_check_shift(c, node, left_type, right_type); - // Defer begin - if (v__checker__Checker_infix_expr_defer_0) { - c->expected_type = former_expected_type; - } - // Defer end - return _t15; - break; - } - case v__token__Kind__unsigned_right_shift: - { - int _t16; /* if prepend */ - if (!v__ast__Type_is_int(left_type)) { - v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid operation: shift on type `"), 0xfe10, {.d_s = v__ast__Table_sym(c->table, left_type)->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_pos); - _t16 = _const_v__ast__void_type_idx; - } else if (v__ast__Type_is_int_literal(left_type)) { - _t16 = _const_v__ast__u32_type_idx; - } else if (v__ast__Type_is_unsigned(left_type)) { - _t16 = left_type; } else { - _t16 = v__ast__Type_idx(left_type) + _const_v__ast__u32_type_idx - _const_v__ast__int_type_idx; - } - int modified_left_type = _t16; - if (modified_left_type == 0) { - v__ast__Type _t17 = _const_v__ast__void_type; + v__ast__Type _t15 = v__checker__Checker_check_shift(c, node, left_type, right_type); // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t17; + return _t15; + } + break; + } + case v__token__Kind__right_shift: + { + v__ast__Type _t16 = v__checker__Checker_check_shift(c, node, left_type, right_type); + // Defer begin + if (v__checker__Checker_infix_expr_defer_0) { + c->expected_type = former_expected_type; + } + // Defer end + return _t16; + break; + } + case v__token__Kind__unsigned_right_shift: + { + int _t17; /* if prepend */ + if (!v__ast__Type_is_int(left_type)) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid operation: shift on type `"), 0xfe10, {.d_s = v__ast__Table_sym(c->table, left_type)->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_pos); + _t17 = _const_v__ast__void_type_idx; + } else if (v__ast__Type_is_int_literal(left_type)) { + _t17 = _const_v__ast__u32_type_idx; + } else if (v__ast__Type_is_unsigned(left_type)) { + _t17 = left_type; + } else { + _t17 = v__ast__Type_idx(left_type) + _const_v__ast__u32_type_idx - _const_v__ast__int_type_idx; + } + int modified_left_type = _t17; + if (modified_left_type == 0) { + v__ast__Type _t18 = _const_v__ast__void_type; + // Defer begin + if (v__checker__Checker_infix_expr_defer_0) { + c->expected_type = former_expected_type; + } + // Defer end + return _t18; } *node = ((v__ast__InfixExpr){ .op = v__token__Kind__right_shift, @@ -48458,32 +49249,32 @@ v__ast__Type former_expected_type; .ct_right_value_evaled = 0, .ct_right_value = v__ast__empty_comptime_const_expr(), }); - v__ast__Type _t18 = v__checker__Checker_check_shift(c, node, left_type, right_type); + v__ast__Type _t19 = v__checker__Checker_check_shift(c, node, left_type, right_type); // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t18; + return _t19; break; } case v__token__Kind__key_is: case v__token__Kind__not_is: { v__ast__Expr right_expr = node->right; - v__ast__Type _t19 = 0; + v__ast__Type _t20 = 0; if (right_expr._typ == 292 /* v.ast.TypeNode */) { - _t19 = (*right_expr._v__ast__TypeNode).typ; + _t20 = (*right_expr._v__ast__TypeNode).typ; } else if (right_expr._typ == 278 /* v.ast.None */) { - _t19 = _const_v__ast__none_type_idx; + _t20 = _const_v__ast__none_type_idx; } else { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid type `"), 0xfe10, {.d_s = v__ast__Expr_str(right_expr)}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(right_expr)); - _t19 = ((v__ast__Type)(0)); + _t20 = ((v__ast__Type)(0)); } - v__ast__Type typ = _t19; + v__ast__Type typ = _t20; if (!v__ast__Type_alias_eq(typ, ((v__ast__Type)(0)))) { v__ast__TypeSymbol* typ_sym = v__ast__Table_sym(c->table, typ); string op = v__token__Kind_str(node->op); @@ -48502,13 +49293,13 @@ v__ast__Type former_expected_type; } } } - v__ast__Type _t20 = _const_v__ast__bool_type; + v__ast__Type _t21 = _const_v__ast__bool_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t20; + return _t21; break; } case v__token__Kind__arrow: @@ -48529,13 +49320,13 @@ v__ast__Type former_expected_type; } else { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot push on non-channel `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_pos); } - v__ast__Type _t21 = _const_v__ast__void_type; + v__ast__Type _t22 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t21; + return _t22; break; } case v__token__Kind__and: @@ -48680,16 +49471,7 @@ v__ast__Type former_expected_type; } if (!(v__checker__Checker_symmetric_check(c, left_type, right_type) && v__checker__Checker_symmetric_check(c, right_type, left_type)) && !c->pref->translated && !c->file->is_translated && !v__ast__Expr_is_auto_deref_var(node->left) && !v__ast__Expr_is_auto_deref_var(node->right)) { if (v__ast__Type_alias_eq(left_type, _const_v__ast__void_type) || v__ast__Type_alias_eq(right_type, _const_v__ast__void_type)) { - v__ast__Type _t22 = _const_v__ast__void_type; - // Defer begin - if (v__checker__Checker_infix_expr_defer_0) { - c->expected_type = former_expected_type; - } - // Defer end - return _t22; - } - if (v__ast__Type_nr_muls(left_type) > 0 && v__ast__Type_is_int(right_type)) { - v__ast__Type _t23 = return_type; + v__ast__Type _t23 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; @@ -48697,15 +49479,24 @@ v__ast__Type former_expected_type; // Defer end return _t23; } + if (v__ast__Type_nr_muls(left_type) > 0 && v__ast__Type_is_int(right_type)) { + v__ast__Type _t24 = return_type; + // Defer begin + if (v__checker__Checker_infix_expr_defer_0) { + c->expected_type = former_expected_type; + } + // Defer end + return _t24; + } v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("infix expr: cannot use `"), 0xfe10, {.d_s = right_sym->name}}, {_SLIT("` (right expression) as `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_right_pos); } - v__ast__Type _t24 = (v__token__Kind_is_relational(node->op) ? (_const_v__ast__bool_type) : (return_type)); + v__ast__Type _t25 = (v__token__Kind_is_relational(node->op) ? (_const_v__ast__bool_type) : (return_type)); // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t24; + return _t25; } VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_immutable(v__checker__Checker* c, v__ast__Expr expr_) { @@ -48767,19 +49558,19 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im if (v__ast__Type_has_flag(elem_type, v__ast__TypeFlag__shared_f)) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("you have to create a handle and `lock` it to modify `shared` "), 0xfe10, {.d_s = kind}}, {_SLIT(" element"), 0, { .d_c = 0 }}})), v__token__Pos_extend(v__ast__Expr_pos((*expr._v__ast__IndexExpr).left), (*expr._v__ast__IndexExpr).pos)); } - multi_return_string_v__token__Pos mr_43154 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); - to_lock = mr_43154.arg0; - pos = mr_43154.arg1; + multi_return_string_v__token__Pos mr_43532 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); + to_lock = mr_43532.arg0; + pos = mr_43532.arg1; } else if (expr._typ == 281 /* v.ast.ParExpr */) { - multi_return_string_v__token__Pos mr_43223 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); - to_lock = mr_43223.arg0; - pos = mr_43223.arg1; + multi_return_string_v__token__Pos mr_43601 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); + to_lock = mr_43601.arg0; + pos = mr_43601.arg1; } else if (expr._typ == 283 /* v.ast.PrefixExpr */) { - multi_return_string_v__token__Pos mr_43295 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); - to_lock = mr_43295.arg0; - pos = mr_43295.arg1; + multi_return_string_v__token__Pos mr_43673 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); + to_lock = mr_43673.arg0; + pos = mr_43673.arg1; } else if (expr._typ == 286 /* v.ast.SelectorExpr */) { if ((*expr._v__ast__SelectorExpr).expr_type == 0) { @@ -48829,9 +49620,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im string type_str = v__ast__Table_type_to_str(c->table, (*expr._v__ast__SelectorExpr).expr_type); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("field `"), 0xfe10, {.d_s = (*expr._v__ast__SelectorExpr).field_name}}, {_SLIT("` of struct `"), 0xfe10, {.d_s = type_str}}, {_SLIT("` is immutable"), 0, { .d_c = 0 }}})), (*expr._v__ast__SelectorExpr).pos); } - multi_return_string_v__token__Pos mr_44759 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); - to_lock = mr_44759.arg0; - pos = mr_44759.arg1; + multi_return_string_v__token__Pos mr_45137 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); + to_lock = mr_45137.arg0; + pos = mr_45137.arg1; } if ((to_lock).len != 0) { explicit_lock_needed = true; @@ -48937,9 +49728,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im } else if (expr._typ == 252 /* v.ast.CallExpr */) { if (string__eq((*expr._v__ast__CallExpr).name, _SLIT("slice"))) { - multi_return_string_v__token__Pos mr_46582 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); - to_lock = mr_46582.arg0; - pos = mr_46582.arg1; + multi_return_string_v__token__Pos mr_46960 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); + to_lock = mr_46960.arg0; + pos = mr_46960.arg1; if ((to_lock).len != 0) { explicit_lock_needed = true; } @@ -49344,9 +50135,9 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t13.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_59690 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); - field = mr_59690.arg0; - embed_types = mr_59690.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_60068 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); + field = mr_60068.arg0; + embed_types = mr_60068.arg1; node->from_embed_types = embed_types; if (sym->kind == v__ast__Kind__aggregate || sym->kind == v__ast__Kind__sum_type) { unknown_field_msg = IError_name_table[err._typ]._method_msg(err._object); @@ -49380,9 +50171,9 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t15.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_60521 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); - field = mr_60521.arg0; - embed_types = mr_60521.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_60899 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); + field = mr_60899.arg0; + embed_types = mr_60899.arg1; node->from_embed_types = embed_types; } } @@ -49908,7 +50699,8 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as return; } - if (string__eq(node->kind, _SLIT("include"))) { + if (string__eq(node->kind, _SLIT("include")) || string__eq(node->kind, _SLIT("insert"))) { + string original_flag = node->main; string flag = node->main; if (string_contains(flag, _SLIT("@VROOT"))) { Option_string _t1 = v__util__resolve_vmodroot(string_replace(flag, _SLIT("@VROOT"), _SLIT("@VMODROOT")), c->file->path); @@ -49919,13 +50711,13 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as } string vroot = (*(string*)_t1.data); - node->val = str_intp(2, _MOV((StrIntpData[]){{_SLIT("include "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); + node->val = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = node->kind}}, {_SLIT(" "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); node->main = vroot; flag = vroot; } if (string_contains(flag, _SLIT("@VEXEROOT"))) { string vroot = string_replace(flag, _SLIT("@VEXEROOT"), os__dir(v__pref__vexe_path())); - node->val = str_intp(2, _MOV((StrIntpData[]){{_SLIT("include "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); + node->val = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = node->kind}}, {_SLIT(" "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); node->main = vroot; flag = vroot; } @@ -49938,7 +50730,7 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as } string vroot = (*(string*)_t2.data); - node->val = str_intp(2, _MOV((StrIntpData[]){{_SLIT("include "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); + node->val = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = node->kind}}, {_SLIT(" "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); node->main = vroot; flag = vroot; } @@ -49954,54 +50746,66 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as node->main = env; } string flag_no_comment = string_trim_space(string_all_before(flag, _SLIT("//"))); - if (!((string_starts_with(flag_no_comment, _SLIT("\"")) && string_ends_with(flag_no_comment, _SLIT("\""))) || (string_starts_with(flag_no_comment, _SLIT("<")) && string_ends_with(flag_no_comment, _SLIT(">"))))) { - v__checker__Checker_error(c, _SLIT("including C files should use either `\"header_file.h\"` or `` quoting"), node->pos); + if (string__eq(node->kind, _SLIT("include"))) { + if (!((string_starts_with(flag_no_comment, _SLIT("\"")) && string_ends_with(flag_no_comment, _SLIT("\""))) || (string_starts_with(flag_no_comment, _SLIT("<")) && string_ends_with(flag_no_comment, _SLIT(">"))))) { + v__checker__Checker_error(c, _SLIT("including C files should use either `\"header_file.h\"` or `` quoting"), node->pos); + } + } + if (string__eq(node->kind, _SLIT("insert"))) { + if (!(string_starts_with(flag_no_comment, _SLIT("\"")) && string_ends_with(flag_no_comment, _SLIT("\"")))) { + v__checker__Checker_error(c, _SLIT("inserting .c or .h files, should use `\"header_file.h\"` quoting"), node->pos); + } + node->main = string_trim(node->main, _SLIT("\"")); + Option_string _t4; + if (_t4 = os__read_file(node->main), _t4.state == 0) { + string fcontent = *(string*)_t4.data; + node->val = fcontent; + } else { + IError err = _t4.err; + string missing_message = str_intp(3, _MOV((StrIntpData[]){{_SLIT("The file "), 0xfe10, {.d_s = original_flag}}, {_SLIT(", needed for insertion by module `"), 0xfe10, {.d_s = node->mod}}, {_SLIT("`,"), 0, { .d_c = 0 }}})); + if (os__is_file(node->main)) { + missing_message = /*f*/string__plus(missing_message, _SLIT(" is not readable.")); + } else { + missing_message = /*f*/string__plus(missing_message, _SLIT(" does not exist.")); + } + if ((node->msg).len != 0) { + missing_message = /*f*/string__plus(missing_message, str_intp(2, _MOV((StrIntpData[]){{_SLIT(" "), 0xfe10, {.d_s = node->msg}}, {_SLIT("."), 0, { .d_c = 0 }}}))); + } + v__checker__Checker_error(c, missing_message, node->pos); + } } } else if (string__eq(node->kind, _SLIT("pkgconfig"))) { Array_string args = (string_contains(node->main, _SLIT("--")) ? (string_split(node->main, _SLIT(" "))) : (string_split( str_intp(2, _MOV((StrIntpData[]){{_SLIT("--cflags --libs "), 0xfe10, {.d_s = node->main}}, {_SLIT0, 0, { .d_c = 0 }}})), _SLIT(" ")))); - Option_v__pkgconfig__Main_ptr _t4 = v__pkgconfig__main(args); - if (_t4.state != 0) { /*or block*/ - IError err = _t4.err; - v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); - return; - } - - v__pkgconfig__Main* m = (*(v__pkgconfig__Main**)_t4.data); - Option_string _t5 = v__pkgconfig__Main_run(m); + Option_v__pkgconfig__Main_ptr _t5 = v__pkgconfig__main(args); if (_t5.state != 0) { /*or block*/ IError err = _t5.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); return; } - string cflags = (*(string*)_t5.data); - Option_bool _t6 = v__ast__Table_parse_cflag(c->table, cflags, c->mod, c->pref->compile_defines_all); + v__pkgconfig__Main* m = (*(v__pkgconfig__Main**)_t5.data); + Option_string _t6 = v__pkgconfig__Main_run(m); if (_t6.state != 0) { /*or block*/ IError err = _t6.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); return; } - (*(bool*)_t6.data); + string cflags = (*(string*)_t6.data); + Option_bool _t7 = v__ast__Table_parse_cflag(c->table, cflags, c->mod, c->pref->compile_defines_all); + if (_t7.state != 0) { /*or block*/ + IError err = _t7.err; + v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); + return; + } + + (*(bool*)_t7.data); } else if (string__eq(node->kind, _SLIT("flag"))) { string flag = node->main; if (string_contains(flag, _SLIT("@VROOT"))) { - Option_string _t7 = v__util__resolve_vmodroot(string_replace(flag, _SLIT("@VROOT"), _SLIT("@VMODROOT")), c->file->path); - if (_t7.state != 0) { /*or block*/ - IError err = _t7.err; - v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); - return; - } - - flag = (*(string*)_t7.data); - } - if (string_contains(flag, _SLIT("@VEXEROOT"))) { - flag = string_replace(flag, _SLIT("@VEXEROOT"), os__dir(v__pref__vexe_path())); - } - if (string_contains(flag, _SLIT("@VMODROOT"))) { - Option_string _t8 = v__util__resolve_vmodroot(flag, c->file->path); + Option_string _t8 = v__util__resolve_vmodroot(string_replace(flag, _SLIT("@VROOT"), _SLIT("@VMODROOT")), c->file->path); if (_t8.state != 0) { /*or block*/ IError err = _t8.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); @@ -50010,8 +50814,11 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as flag = (*(string*)_t8.data); } - if (string_contains(flag, _SLIT("$env("))) { - Option_string _t9 = v__util__resolve_env_value(flag, true); + if (string_contains(flag, _SLIT("@VEXEROOT"))) { + flag = string_replace(flag, _SLIT("@VEXEROOT"), os__dir(v__pref__vexe_path())); + } + if (string_contains(flag, _SLIT("@VMODROOT"))) { + Option_string _t9 = v__util__resolve_vmodroot(flag, c->file->path); if (_t9.state != 0) { /*or block*/ IError err = _t9.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); @@ -50020,27 +50827,37 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as flag = (*(string*)_t9.data); } - Array_string _t10 = new_array_from_c_array(4, 4, sizeof(string), _MOV((string[4]){_SLIT("@VMOD"), _SLIT("@VMODULE"), _SLIT("@VPATH"), _SLIT("@VLIB_PATH")})); - for (int _t11 = 0; _t11 < _t10.len; ++_t11) { - string deprecated = ((string*)_t10.data)[_t11]; + if (string_contains(flag, _SLIT("$env("))) { + Option_string _t10 = v__util__resolve_env_value(flag, true); + if (_t10.state != 0) { /*or block*/ + IError err = _t10.err; + v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); + return; + } + + flag = (*(string*)_t10.data); + } + Array_string _t11 = new_array_from_c_array(4, 4, sizeof(string), _MOV((string[4]){_SLIT("@VMOD"), _SLIT("@VMODULE"), _SLIT("@VPATH"), _SLIT("@VLIB_PATH")})); + for (int _t12 = 0; _t12 < _t11.len; ++_t12) { + string deprecated = ((string*)_t11.data)[_t12]; if (string_contains(flag, deprecated)) { if (!string_contains(flag, _SLIT("@VMODROOT"))) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = deprecated}}, {_SLIT(" had been deprecated, use @VMODROOT instead."), 0, { .d_c = 0 }}})), node->pos); } } } - Option_bool _t12 = v__ast__Table_parse_cflag(c->table, flag, c->mod, c->pref->compile_defines_all); - if (_t12.state != 0) { /*or block*/ - IError err = _t12.err; + Option_bool _t13 = v__ast__Table_parse_cflag(c->table, flag, c->mod, c->pref->compile_defines_all); + if (_t13.state != 0) { /*or block*/ + IError err = _t13.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); ; } - (*(bool*)_t12.data); + (*(bool*)_t13.data); } else { if (!string__eq(node->kind, _SLIT("define"))) { - v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("expected `#define`, `#flag`, `#include` or `#pkgconfig` not "), 0xfe10, {.d_s = node->val}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("expected `#define`, `#flag`, `#include`, `#insert` or `#pkgconfig` not "), 0xfe10, {.d_s = node->val}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); } }; } @@ -51479,7 +52296,7 @@ v__ast__Type v__checker__Checker_lock_expr(v__checker__Checker* c, v__ast__LockE c->locked_names = __new_array_with_default(0, 0, sizeof(string), 0); v__ast__Type ret_type = _const_v__ast__void_type; if (node->stmts.len > 0) { - v__ast__Stmt last_stmt = (*(v__ast__Stmt*)/*ee elem_sym */array_get(node->stmts, node->stmts.len - 1)); + v__ast__Stmt last_stmt = (*(v__ast__Stmt*)array_last(node->stmts)); if ((last_stmt)._typ == 306 /* v.ast.ExprStmt */) { ret_type = (*last_stmt._v__ast__ExprStmt).typ; } @@ -51586,8 +52403,8 @@ v__ast__Type v__checker__Checker_postfix_expr(v__checker__Checker* c, v__ast__Po string typ_str = v__ast__Table_type_to_str(c->table, typ); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("invalid operation: "), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" (non-numeric type `"), 0xfe10, {.d_s = typ_str}}, {_SLIT("`)"), 0, { .d_c = 0 }}})), node->pos); } else { - multi_return_string_v__token__Pos mr_113972 = v__checker__Checker_fail_if_immutable(c, node->expr); - node->auto_locked = mr_113972.arg0; + multi_return_string_v__token__Pos mr_115132 = v__checker__Checker_fail_if_immutable(c, node->expr); + node->auto_locked = mr_115132.arg0; } v__ast__Type _t1 = typ; return _t1; @@ -54691,7 +55508,7 @@ v__ast__Scope* prev_fn_scope; } c->expected_type = _const_v__ast__void_type; c->table->cur_fn = node; - if (!v__ast__Type_alias_eq(node->return_type, _const_v__ast__void_type) && v__ast__Type_has_flag(node->return_type, v__ast__TypeFlag__optional) && (node->stmts.len == 0 || ((*(v__ast__Stmt*)/*ee elem_sym */array_get(node->stmts, node->stmts.len - 1)))._typ != 317 /* v.ast.Return */)) { + if (!v__ast__Type_alias_eq(node->return_type, _const_v__ast__void_type) && v__ast__Type_has_flag(node->return_type, v__ast__TypeFlag__optional) && (node->stmts.len == 0 || ((*(v__ast__Stmt*)array_last(node->stmts)))._typ != 317 /* v.ast.Return */)) { v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, node->return_type); if (sym->kind == v__ast__Kind__void) { array_push((array*)&node->stmts, _MOV((v__ast__Stmt[]){ v__ast__Return_to_sumtype_v__ast__Stmt(ADDR(v__ast__Return, (((v__ast__Return){.pos = node->pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.exprs = __new_array(0, 0, sizeof(v__ast__Expr)),.types = __new_array(0, 0, sizeof(v__ast__Type)),})))) })); @@ -55123,8 +55940,8 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__checker__Checker_error(c, _SLIT("cannot call a function that does not have a body"), node->pos); } if (node->concrete_types.len > 0 && func.generic_names.len > 0 && node->concrete_types.len != func.generic_names.len) { - string desc = (node->concrete_types.len > func.generic_names.len ? (_SLIT("many")) : (_SLIT("little"))); - v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("too "), 0xfe10, {.d_s = desc}}, {_SLIT(" generic parameters got "), 0xfe07, {.d_i32 = node->concrete_types.len}}, {_SLIT(", expected "), 0xfe07, {.d_i32 = func.generic_names.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->concrete_list_pos); + string plural = (func.generic_names.len == 1 ? (_SLIT("")) : (_SLIT("s"))); + v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("expected "), 0xfe07, {.d_i32 = func.generic_names.len}}, {_SLIT(" generic parameter"), 0xfe10, {.d_s = plural}}, {_SLIT(", got "), 0xfe07, {.d_i32 = node->concrete_types.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->concrete_list_pos); } for (int _t30 = 0; _t30 < node->concrete_types.len; ++_t30) { v__ast__Type concrete_type = ((v__ast__Type*)node->concrete_types.data)[_t30]; @@ -55225,9 +56042,9 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__checker__Checker_error(c, _SLIT("function with `shared` arguments cannot be called inside `lock`/`rlock` block"), call_arg->pos); } if (call_arg->is_mut) { - multi_return_string_v__token__Pos mr_28570 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); - string to_lock = mr_28570.arg0; - v__token__Pos pos = mr_28570.arg1; + multi_return_string_v__token__Pos mr_28526 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); + string to_lock = mr_28526.arg0; + v__token__Pos pos = mr_28526.arg1; if (!v__ast__Expr_is_lvalue(call_arg->expr)) { v__checker__Checker_error(c, _SLIT("cannot pass expression as `mut`"), v__ast__Expr_pos(call_arg->expr)); } @@ -55570,9 +56387,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal *(multi_return_v__ast__Fn_Array_v__ast__Type*) _t22.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.is_variadic = 0,.language = 0,.is_pub = 0,.is_ctor_new = 0,.is_deprecated = 0,.is_noreturn = 0,.is_unsafe = 0,.is_placeholder = 0,.is_main = 0,.is_test = 0,.is_keep_alive = 0,.is_method = 0,.no_body = 0,.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.file_mode = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type = 0,.receiver_type = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.params = __new_array(0, 0, sizeof(v__ast__Param)),.source_fn = 0,.usages = 0,.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_conditional = 0,.ctdefine_idx = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_41789 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t22.data); - method = mr_41789.arg0; - embed_types = mr_41789.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_41745 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t22.data); + method = mr_41745.arg0; + embed_types = mr_41745.arg1; if (embed_types.len != 0) { is_method_from_embed = true; node->from_embed_types = embed_types; @@ -55593,9 +56410,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("method with `shared` receiver cannot be called inside `lock`/`rlock` block"), node->pos); } if ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, 0)).is_mut) { - multi_return_string_v__token__Pos mr_42920 = v__checker__Checker_fail_if_immutable(c, node->left); - string to_lock = mr_42920.arg0; - v__token__Pos pos = mr_42920.arg1; + multi_return_string_v__token__Pos mr_42876 = v__checker__Checker_fail_if_immutable(c, node->left); + string to_lock = mr_42876.arg0; + v__token__Pos pos = mr_42876.arg1; if (!v__ast__Expr_is_lvalue(node->left)) { v__checker__Checker_error(c, _SLIT("cannot pass expression as `mut`"), v__ast__Expr_pos(node->left)); } @@ -55609,8 +56426,8 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("cannot call a method that does not have a body"), node->pos); } if (node->concrete_types.len > 0 && method.generic_names.len > 0 && node->concrete_types.len != method.generic_names.len) { - string desc = (node->concrete_types.len > method.generic_names.len ? (_SLIT("many")) : (_SLIT("little"))); - v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("too "), 0xfe10, {.d_s = desc}}, {_SLIT(" generic parameters got "), 0xfe07, {.d_i32 = node->concrete_types.len}}, {_SLIT(", expected "), 0xfe07, {.d_i32 = method.generic_names.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->concrete_list_pos); + string plural = (method.generic_names.len == 1 ? (_SLIT("")) : (_SLIT("s"))); + v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("expected "), 0xfe07, {.d_i32 = method.generic_names.len}}, {_SLIT(" generic parameter"), 0xfe10, {.d_s = plural}}, {_SLIT(", got "), 0xfe07, {.d_i32 = node->concrete_types.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->concrete_list_pos); } for (int _t23 = 0; _t23 < node->concrete_types.len; ++_t23) { v__ast__Type concrete_type = ((v__ast__Type*)node->concrete_types.data)[_t23]; @@ -55697,9 +56514,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("method with `shared` arguments cannot be called inside `lock`/`rlock` block"), arg->pos); } if (arg->is_mut) { - multi_return_string_v__token__Pos mr_46934 = v__checker__Checker_fail_if_immutable(c, arg->expr); - string to_lock = mr_46934.arg0; - v__token__Pos pos = mr_46934.arg1; + multi_return_string_v__token__Pos mr_46845 = v__checker__Checker_fail_if_immutable(c, arg->expr); + string to_lock = mr_46845.arg0; + v__token__Pos pos = mr_46845.arg1; if (!param_is_mut) { string tok = v__ast__ShareType_str(arg->share); v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = node->name}}, {_SLIT("` parameter `"), 0xfe10, {.d_s = param.name}}, {_SLIT("` is not `"), 0xfe10, {.d_s = tok}}, {_SLIT("`, `"), 0xfe10, {.d_s = tok}}, {_SLIT("` is not needed`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(arg->expr)); @@ -55881,8 +56698,8 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal return _t43; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_53834 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t42.data); - node->from_embed_types = mr_53834.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_53745 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t42.data); + node->from_embed_types = mr_53745.arg1; v__ast__Type _t44 = info.func.return_type; return _t44; } @@ -56260,6 +57077,16 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch } else if (string__eq(method_name, _SLIT("sort"))) { node->return_type = _const_v__ast__void_type; } else if (string__eq(method_name, _SLIT("contains"))) { + if (node->args.len != 1) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`.contains()` expected 1 argument, but got "), 0xfe07, {.d_i32 = node->args.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); + } else { + v__ast__Type arg_typ = v__ast__mktyp(v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr)); + string elem_typ_str = v__ast__Table_type_to_str(c->table, elem_typ); + string arg_typ_str = v__ast__Table_type_to_str(c->table, arg_typ); + if (!v__ast__TypeSymbol_has_method(&left_sym, _SLIT("contains")) && !string__eq(elem_typ_str, arg_typ_str)) { + v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("`.contains()` expected `"), 0xfe10, {.d_s = elem_typ_str}}, {_SLIT("` argument, but got `"), 0xfe10, {.d_s = arg_typ_str}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->pos); + } + } node->return_type = _const_v__ast__bool_type; } else if (string__eq(method_name, _SLIT("index"))) { node->return_type = _const_v__ast__int_type; @@ -56455,7 +57282,7 @@ bool v__checker__Checker_if_expr_defer_0 = false; bool node_is_expr = false; if (node->branches.len > 0 && node->has_else) { Array_v__ast__Stmt stmts = (*(v__ast__IfBranch*)/*ee elem_sym */array_get(node->branches, 0)).stmts; - if (stmts.len > 0 && ((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._typ == 306 /* v.ast.ExprStmt */ && !v__ast__Type_alias_eq((/* as */ *(v__ast__ExprStmt*)__as_cast(((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._v__ast__ExprStmt,((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._typ, 306) /*expected idx: 306, name: v.ast.ExprStmt */ ).typ, _const_v__ast__void_type)) { + if (stmts.len > 0 && ((*(v__ast__Stmt*)array_last(stmts)))._typ == 306 /* v.ast.ExprStmt */ && !v__ast__Type_alias_eq((/* as */ *(v__ast__ExprStmt*)__as_cast(((*(v__ast__Stmt*)array_last(stmts)))._v__ast__ExprStmt,((*(v__ast__Stmt*)array_last(stmts)))._typ, 306) /*expected idx: 306, name: v.ast.ExprStmt */ ).typ, _const_v__ast__void_type)) { node_is_expr = true; } } @@ -56608,6 +57435,12 @@ bool v__checker__Checker_if_expr_defer_0 = false; continue; } last_expr.typ = v__checker__Checker_expr(c, last_expr.expr); + if (v__ast__Table_type_kind(c->table, c->expected_type) == v__ast__Kind__multi_return && v__ast__Table_type_kind(c->table, last_expr.typ) == v__ast__Kind__multi_return) { + if (v__ast__Type_alias_eq(node->typ, _const_v__ast__void_type)) { + node->is_expr = true; + node->typ = c->expected_type; + } + } if (!v__checker__Checker_check_types(c, last_expr.typ, node->typ)) { if (v__ast__Type_alias_eq(node->typ, _const_v__ast__void_type)) { node->is_expr = true; @@ -56644,16 +57477,35 @@ bool v__checker__Checker_if_expr_defer_0 = false; if (v__checker__is_noreturn_callexpr(last_expr.expr)) { continue; } + v__ast__TypeSymbol* node_sym = v__ast__Table_sym(c->table, node->typ); + v__ast__TypeSymbol* last_sym = v__ast__Table_sym(c->table, last_expr.typ); + if (node_sym->kind == v__ast__Kind__multi_return && last_sym->kind == v__ast__Kind__multi_return) { + Array_v__ast__Type node_types = v__ast__TypeSymbol_mr_info(node_sym).types; + Array_v__ast__Type _t3 = {0}; + Array_v__ast__Type _t3_orig = v__ast__TypeSymbol_mr_info(last_sym).types; + int _t3_len = _t3_orig.len; + _t3 = __new_array(0, _t3_len, sizeof(v__ast__Type)); + + for (int _t4 = 0; _t4 < _t3_len; ++_t4) { + v__ast__Type it = ((v__ast__Type*) _t3_orig.data)[_t4]; + v__ast__Type ti = v__ast__mktyp(it); + array_push((array*)&_t3, &ti); + } + Array_v__ast__Type last_types =_t3; + if (Array_v__ast__Type_arr_eq(node_types, last_types)) { + continue; + } + } v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("mismatched types `"), 0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, node->typ)}}, {_SLIT("` and `"), 0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, last_expr.typ)}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->pos); } } else { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = if_kind}}, {_SLIT("` expression requires an expression as the last statement of every branch"), 0, { .d_c = 0 }}})), branch.pos); } - for (int _t3 = 0; _t3 < branch.stmts.len; ++_t3) { - v__ast__Stmt st = ((v__ast__Stmt*)branch.stmts.data)[_t3]; - Option_void _t4 = v__ast__Stmt_check_c_expr(st); - if (_t4.state != 0 && _t4.err._typ != _IError_None___index) { - IError err = _t4.err; + for (int _t5 = 0; _t5 < branch.stmts.len; ++_t5) { + v__ast__Stmt st = ((v__ast__Stmt*)branch.stmts.data)[_t5]; + Option_void _t6 = v__ast__Stmt_check_c_expr(st); + if (_t6.state != 0 && _t6.err._typ != _IError_None___index) { + IError err = _t6.err; v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`if` expression branch has "), 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT0, 0, { .d_c = 0 }}})), (*(st.pos))); ; } @@ -56675,9 +57527,9 @@ bool v__checker__Checker_if_expr_defer_0 = false; } } } - Option_bool _t5; - if (_t5 = v__checker__Checker_has_return(c, branch.stmts), _t5.state == 0) { - bool has_return = *(bool*)_t5.data; + Option_bool _t7; + if (_t7 = v__checker__Checker_has_return(c, branch.stmts), _t7.state == 0) { + bool has_return = *(bool*)_t7.data; if (has_return) { nbranches_with_return++; } else { @@ -56705,13 +57557,13 @@ bool v__checker__Checker_if_expr_defer_0 = false; string d = (node->is_comptime ? (_SLIT("$")) : (_SLIT(""))); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = if_kind}}, {_SLIT("` expression needs `"), 0xfe10, {.d_s = d}}, {_SLIT("else` clause"), 0, { .d_c = 0 }}})), node->pos); } - v__ast__Type _t6 = node->typ; + v__ast__Type _t8 = node->typ; // Defer begin if (v__checker__Checker_if_expr_defer_0) { c->expected_expr_type = _const_v__ast__void_type; } // Defer end - return _t6; + return _t8; } VV_LOCAL_SYMBOL void v__checker__Checker_smartcast_if_conds(v__checker__Checker* c, v__ast__Expr node, v__ast__Scope* scope) { @@ -57156,7 +58008,7 @@ bool v__checker__Checker_match_expr_defer_0 = false; } v__ast__Type expr_type = v__checker__Checker_expr(c, (*stmt._v__ast__ExprStmt).expr); if (first_iteration) { - if (node->is_expr && (v__ast__Type_has_flag(node->expected_type, v__ast__TypeFlag__optional) || v__ast__Table_type_kind(c->table, node->expected_type) == v__ast__Kind__sum_type)) { + if (node->is_expr && (v__ast__Type_has_flag(node->expected_type, v__ast__TypeFlag__optional) || (v__ast__Table_type_kind(c->table, node->expected_type) == v__ast__Kind__sum_type || v__ast__Table_type_kind(c->table, node->expected_type) == v__ast__Kind__multi_return))) { ret_type = node->expected_type; } else { ret_type = expr_type; @@ -57167,6 +58019,24 @@ bool v__checker__Checker_match_expr_defer_0 = false; v__ast__TypeSymbol* ret_sym = v__ast__Table_sym(c->table, ret_type); bool is_noreturn = v__checker__is_noreturn_callexpr((*stmt._v__ast__ExprStmt).expr); if (!(node->is_expr && ret_sym->kind == v__ast__Kind__sum_type && (v__ast__Type_has_flag(ret_type, v__ast__TypeFlag__generic) || v__ast__Table_is_sumtype_or_in_variant(c->table, ret_type, expr_type))) && !is_noreturn) { + v__ast__TypeSymbol* expr_sym = v__ast__Table_sym(c->table, expr_type); + if (expr_sym->kind == v__ast__Kind__multi_return && ret_sym->kind == v__ast__Kind__multi_return) { + Array_v__ast__Type ret_types = v__ast__TypeSymbol_mr_info(ret_sym).types; + Array_v__ast__Type _t7 = {0}; + Array_v__ast__Type _t7_orig = v__ast__TypeSymbol_mr_info(expr_sym).types; + int _t7_len = _t7_orig.len; + _t7 = __new_array(0, _t7_len, sizeof(v__ast__Type)); + + for (int _t8 = 0; _t8 < _t7_len; ++_t8) { + v__ast__Type it = ((v__ast__Type*) _t7_orig.data)[_t8]; + v__ast__Type ti = v__ast__mktyp(it); + array_push((array*)&_t7, &ti); + } + Array_v__ast__Type expr_types =_t7; + if (Array_v__ast__Type_arr_eq(expr_types, ret_types)) { + continue; + } + } v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("return type mismatch, it should be `"), 0xfe10, {.d_s = ret_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos((*stmt._v__ast__ExprStmt).expr)); } } @@ -57178,9 +58048,9 @@ bool v__checker__Checker_match_expr_defer_0 = false; } } first_iteration = false; - Option_bool _t7; - if (_t7 = v__checker__Checker_has_return(c, branch.stmts), _t7.state == 0) { - bool has_return = *(bool*)_t7.data; + Option_bool _t9; + if (_t9 = v__checker__Checker_has_return(c, branch.stmts), _t9.state == 0) { + bool has_return = *(bool*)_t9.data; if (has_return) { nbranches_with_return++; } else { @@ -57200,11 +58070,11 @@ bool v__checker__Checker_match_expr_defer_0 = false; string cond_var = v__checker__Checker_get_base_name(c, &node->cond); if ((cond_var).len != 0) { bool cond_is_auto_heap = false; - for (int _t8 = 0; _t8 < node->branches.len; ++_t8) { - v__ast__MatchBranch branch = ((v__ast__MatchBranch*)node->branches.data)[_t8]; - Option_v__ast__Var_ptr _t9; - if (_t9 = v__ast__Scope_find_var(branch.scope, cond_var), _t9.state == 0) { - v__ast__Var* v = *(v__ast__Var**)_t9.data; + for (int _t10 = 0; _t10 < node->branches.len; ++_t10) { + v__ast__MatchBranch branch = ((v__ast__MatchBranch*)node->branches.data)[_t10]; + Option_v__ast__Var_ptr _t11; + if (_t11 = v__ast__Scope_find_var(branch.scope, cond_var), _t11.state == 0) { + v__ast__Var* v = *(v__ast__Var**)_t11.data; if (v->is_auto_heap) { cond_is_auto_heap = true; break; @@ -57212,26 +58082,26 @@ bool v__checker__Checker_match_expr_defer_0 = false; } } if (cond_is_auto_heap) { - for (int _t10 = 0; _t10 < node->branches.len; ++_t10) { - v__ast__MatchBranch branch = ((v__ast__MatchBranch*)node->branches.data)[_t10]; - Option_v__ast__Var_ptr _t11 = v__ast__Scope_find_var(branch.scope, cond_var); - if (_t11.state != 0) { /*or block*/ - IError err = _t11.err; + for (int _t12 = 0; _t12 < node->branches.len; ++_t12) { + v__ast__MatchBranch branch = ((v__ast__MatchBranch*)node->branches.data)[_t12]; + Option_v__ast__Var_ptr _t13 = v__ast__Scope_find_var(branch.scope, cond_var); + if (_t13.state != 0) { /*or block*/ + IError err = _t13.err; continue; } - v__ast__Var* v = (*(v__ast__Var**)_t11.data); + v__ast__Var* v = (*(v__ast__Var**)_t13.data); v->is_auto_heap = true; } } } - v__ast__Type _t12 = ret_type; + v__ast__Type _t14 = ret_type; // Defer begin if (v__checker__Checker_match_expr_defer_0) { c->expected_expr_type = _const_v__ast__void_type; } // Defer end - return _t12; + return _t14; } VV_LOCAL_SYMBOL void v__checker__Checker_match_exprs(v__checker__Checker* c, v__ast__MatchExpr* node, v__ast__TypeSymbol cond_type_sym) { @@ -67119,6 +67989,7 @@ bool v__gen__c__Gen_stmt_defer_0 = false; v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("goto "), 0xfe10, {.d_s = v__gen__c__c_name((*node._v__ast__GotoStmt).name)}}, {_SLIT(";"), 0, { .d_c = 0 }}}))); } else if (node._typ == 313 /* v.ast.HashStmt */) { + int line_nr = (*node._v__ast__HashStmt).pos.line_nr + 1; string ct_condition = _SLIT(""); if ((*node._v__ast__HashStmt).ct_conds.len > 0) { int ct_condition_start = g->out.len; @@ -67147,7 +68018,7 @@ bool v__gen__c__Gen_stmt_defer_0 = false; if (ct_condition.len > 0) { strings__Builder_writeln(&g->definitions, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); } - strings__Builder_writeln(&g->definitions, str_intp(2, _MOV((StrIntpData[]){{_SLIT("// added by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`"), 0, { .d_c = 0 }}}))); + strings__Builder_writeln(&g->definitions, str_intp(4, _MOV((StrIntpData[]){{_SLIT("// added by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`, file: "), 0xfe10, {.d_s = os__file_name((*node._v__ast__HashStmt).source_file)}}, {_SLIT(":"), 0xfe07, {.d_i32 = line_nr}}, {_SLIT(":"), 0, { .d_c = 0 }}}))); strings__Builder_writeln(&g->definitions, guarded_include); if (ct_condition.len > 0) { strings__Builder_writeln(&g->definitions, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#endif // $if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); @@ -67158,13 +68029,22 @@ bool v__gen__c__Gen_stmt_defer_0 = false; if (ct_condition.len > 0) { strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); } - strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("// added by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`"), 0, { .d_c = 0 }}}))); + strings__Builder_writeln(&g->includes, str_intp(4, _MOV((StrIntpData[]){{_SLIT("// added by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`, file: "), 0xfe10, {.d_s = os__file_name((*node._v__ast__HashStmt).source_file)}}, {_SLIT(":"), 0xfe07, {.d_i32 = line_nr}}, {_SLIT(":"), 0, { .d_c = 0 }}}))); strings__Builder_writeln(&g->includes, guarded_include); if (ct_condition.len > 0) { strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#endif // $if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); } strings__Builder_writeln(&g->includes, _SLIT("\n")); } + } else if (string__eq((*node._v__ast__HashStmt).kind, _SLIT("insert"))) { + if (ct_condition.len > 0) { + strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); + } + strings__Builder_writeln(&g->includes, str_intp(4, _MOV((StrIntpData[]){{_SLIT("// inserted by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`, file: "), 0xfe10, {.d_s = os__file_name((*node._v__ast__HashStmt).source_file)}}, {_SLIT(":"), 0xfe07, {.d_i32 = line_nr}}, {_SLIT(":"), 0, { .d_c = 0 }}}))); + strings__Builder_writeln(&g->includes, (*node._v__ast__HashStmt).val); + if (ct_condition.len > 0) { + strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#endif // $if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); + } } else if (string__eq((*node._v__ast__HashStmt).kind, _SLIT("define"))) { if (ct_condition.len > 0) { strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); @@ -67313,8 +68193,8 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_write_sumtype_casting_fn(v__gen__c__Gen* g, *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t4.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_65344 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t4.data); - Array_v__ast__Type embed_types = mr_65344.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_65835 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t4.data); + Array_v__ast__Type embed_types = mr_65835.arg1; if (embed_types.len > 0) { v__ast__TypeSymbol* embed_sym = v__ast__Table_sym(g->table, (*(v__ast__Type*)array_last(embed_types))); ptr = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = v__ast__TypeSymbol_embed_name(embed_sym)}}, {_SLIT("_ptr"), 0, { .d_c = 0 }}})); @@ -68760,11 +69640,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_map_init(v__gen__c__Gen* g, v__ast__MapInit string value_typ_str = v__gen__c__Gen_typ(g, unwrap_val_typ); v__ast__TypeSymbol* value_sym = v__ast__Table_sym(g->table, unwrap_val_typ); v__ast__TypeSymbol* key_sym = v__ast__Table_final_sym(g->table, unwrap_key_typ); - multi_return_string_string_string_string mr_104581 = v__gen__c__Gen_map_fn_ptrs(g, *key_sym); - string hash_fn = mr_104581.arg0; - string key_eq_fn = mr_104581.arg1; - string clone_fn = mr_104581.arg2; - string free_fn = mr_104581.arg3; + multi_return_string_string_string_string mr_105072 = v__gen__c__Gen_map_fn_ptrs(g, *key_sym); + string hash_fn = mr_105072.arg0; + string key_eq_fn = mr_105072.arg1; + string clone_fn = mr_105072.arg2; + string free_fn = mr_105072.arg3; int size = node.vals.len; string shared_styp = _SLIT(""); string styp = _SLIT(""); @@ -69934,9 +70814,9 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_write_types(v__gen__c__Gen* g, Array_v__ast_ for (int _t3 = 0; _t3 < (*sym->info._v__ast__Struct).fields.len; ++_t3) { v__ast__StructField field = ((v__ast__StructField*)(*sym->info._v__ast__Struct).fields.data)[_t3]; if (v__ast__Type_has_flag(field.typ, v__ast__TypeFlag__optional)) { - multi_return_string_string mr_141649 = v__gen__c__Gen_optional_type_name(g, field.typ); - string styp = mr_141649.arg0; - string base = mr_141649.arg1; + multi_return_string_string mr_142140 = v__gen__c__Gen_optional_type_name(g, field.typ); + string styp = mr_142140.arg0; + string base = mr_142140.arg1; sync__RwMutex_lock(&g->done_optionals->mtx); /*lock*/ { if (!Array_string_contains(g->done_optionals->val, base)) { @@ -70176,7 +71056,7 @@ bool v__gen__c__Gen_or_block_defer_0 = false; g->inside_or_block = true; v__gen__c__Gen_or_block_defer_0 = true; Array_v__ast__Stmt stmts = or_block.stmts; - if (stmts.len > 0 && ((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, or_block.stmts.len - 1)))._typ == 306 /* v.ast.ExprStmt */ && !v__ast__Type_alias_eq((/* as */ *(v__ast__ExprStmt*)__as_cast(((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._v__ast__ExprStmt,((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._typ, 306) /*expected idx: 306, name: v.ast.ExprStmt */ ).typ, _const_v__ast__void_type)) { + if (stmts.len > 0 && ((*(v__ast__Stmt*)array_last(stmts)))._typ == 306 /* v.ast.ExprStmt */ && !v__ast__Type_alias_eq((/* as */ *(v__ast__ExprStmt*)__as_cast(((*(v__ast__Stmt*)array_last(stmts)))._v__ast__ExprStmt,((*(v__ast__Stmt*)array_last(stmts)))._typ, 306) /*expected idx: 306, name: v.ast.ExprStmt */ ).typ, _const_v__ast__void_type)) { g->indent++; for (int i = 0; i < stmts.len; ++i) { v__ast__Stmt stmt = ((v__ast__Stmt*)stmts.data)[i]; @@ -70199,7 +71079,7 @@ bool v__gen__c__Gen_or_block_defer_0 = false; g->indent--; } else { v__gen__c__Gen_stmts(g, stmts); - if (stmts.len > 0 && ((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, or_block.stmts.len - 1)))._typ == 306 /* v.ast.ExprStmt */) { + if (stmts.len > 0 && ((*(v__ast__Stmt*)array_last(stmts)))._typ == 306 /* v.ast.ExprStmt */) { v__gen__c__Gen_writeln(g, _SLIT(";")); } } @@ -70207,11 +71087,11 @@ bool v__gen__c__Gen_or_block_defer_0 = false; if (string__eq(g->file->mod.name, _SLIT("main")) && (isnil(g->fn_decl) || g->fn_decl->is_main)) { string err_msg = str_intp(3, _MOV((StrIntpData[]){{_SLIT("IError_name_table["), 0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._typ]._method_msg("), 0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._object)"), 0, { .d_c = 0 }}})); if (g->pref->is_debug) { - multi_return_int_string_string_string mr_150745 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); - int paline = mr_150745.arg0; - string pafile = mr_150745.arg1; - string pamod = mr_150745.arg2; - string pafn = mr_150745.arg3; + multi_return_int_string_string_string mr_151194 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); + int paline = mr_151194.arg0; + string pafile = mr_151194.arg1; + string pamod = mr_151194.arg2; + string pafn = mr_151194.arg3; v__gen__c__Gen_writeln(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("panic_debug("), 0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), 0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), 0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); } else { v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tpanic_optional_not_set( "), 0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); @@ -70321,11 +71201,11 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_type_default(v__gen__c__Gen* g, v__ast__Ty { v__ast__Map info = v__ast__TypeSymbol_map_info(sym); v__ast__TypeSymbol* key_typ = v__ast__Table_sym(g->table, info.key_type); - multi_return_string_string_string_string mr_153327 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); - string hash_fn = mr_153327.arg0; - string key_eq_fn = mr_153327.arg1; - string clone_fn = mr_153327.arg2; - string free_fn = mr_153327.arg3; + multi_return_string_string_string_string mr_153776 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); + string hash_fn = mr_153776.arg0; + string key_eq_fn = mr_153776.arg1; + string clone_fn = mr_153776.arg2; + string free_fn = mr_153776.arg3; string noscan_key = v__gen__c__Gen_check_noscan(g, info.key_type); string noscan_value = v__gen__c__Gen_check_noscan(g, info.value_type); string noscan = (noscan_key.len != 0 || noscan_value.len != 0 ? (_SLIT("_noscan")) : (_SLIT(""))); @@ -70853,8 +71733,8 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_interface_table(v__gen__c__Gen* g) { int params_start_pos = g->out.len; Array_v__ast__Param params = array_clone_to_depth(&method.params, 0); array_set(¶ms, 0, &(v__ast__Param[]) { ((v__ast__Param){(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).name,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_mut,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_auto_rec,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).type_pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_hidden,.typ = v__ast__Type_set_nr_muls(st, 1),}) }); - multi_return_Array_string_Array_string_Array_bool mr_167617 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); - Array_string fargs = mr_167617.arg0; + multi_return_Array_string_Array_string_Array_bool mr_168066 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); + Array_string fargs = mr_168066.arg0; string parameter_name = strings__Builder_cut_last(&g->out, g->out.len - params_start_pos); if (v__ast__Type_is_ptr(st)) { parameter_name = string_trim_string_left(parameter_name, _SLIT("__shared__")); @@ -70871,8 +71751,8 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_interface_table(v__gen__c__Gen* g) { *(multi_return_v__ast__Fn_Array_v__ast__Type*) _t26.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.is_variadic = 0,.language = 0,.is_pub = 0,.is_ctor_new = 0,.is_deprecated = 0,.is_noreturn = 0,.is_unsafe = 0,.is_placeholder = 0,.is_main = 0,.is_test = 0,.is_keep_alive = 0,.is_method = 0,.no_body = 0,.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.file_mode = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type = 0,.receiver_type = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.params = __new_array(0, 0, sizeof(v__ast__Param)),.source_fn = 0,.usages = 0,.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_conditional = 0,.ctdefine_idx = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_168081 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); - Array_v__ast__Type embed_types = mr_168081.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_168530 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); + Array_v__ast__Type embed_types = mr_168530.arg1; if (embed_types.len > 0 && !Array_string_contains(method_names, method.name)) { v__ast__TypeSymbol* embed_sym = v__ast__Table_sym(g->table, (*(v__ast__Type*)array_last(embed_types))); string method_name = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = embed_sym->cname}}, {_SLIT("_"), 0xfe10, {.d_s = method.name}}, {_SLIT0, 0, { .d_c = 0 }}})); @@ -76325,6 +77205,41 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_infix_expr_in_op(v__gen__c__Gen* g, v__ast__ v__gen__c__Gen_expr(g, node.right); } v__gen__c__Gen_write(g, _SLIT(")")); + } else if (right.unaliased_sym->kind == v__ast__Kind__array_fixed) { + if (left.sym->kind == v__ast__Kind__sum_type || left.sym->kind == v__ast__Kind__interface_) { + if ((node.right)._typ == 246 /* v.ast.ArrayInit */) { + if ((*node.right._v__ast__ArrayInit).exprs.len > 0) { + Array_v__ast__InfixExpr infix_exprs = __new_array_with_default(0, 0, sizeof(v__ast__InfixExpr), 0); + for (int i = 0; i < (*node.right._v__ast__ArrayInit).exprs.len; ++i) { + array_push((array*)&infix_exprs, _MOV((v__ast__InfixExpr[]){ ((v__ast__InfixExpr){.op = v__token__Kind__key_is,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_stmt = 0,.left = node.left,.right = (*(v__ast__Expr*)/*ee elem_sym */array_get((*node.right._v__ast__ArrayInit).exprs, i)),.left_type = node.left_type,.right_type = (*(v__ast__Type*)/*ee elem_sym */array_get((*node.right._v__ast__ArrayInit).expr_types, i)),.auto_locked = (string){.str=(byteptr)"", .is_lit=1},.or_block = (v__ast__OrExpr){.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},},.ct_left_value_evaled = 0,.ct_left_value = v__ast__empty_comptime_const_expr(),.ct_right_value_evaled = 0,.ct_right_value = v__ast__empty_comptime_const_expr(),}) })); + } + v__gen__c__Gen_write(g, _SLIT("(")); + v__gen__c__Gen_infix_expr_in_sumtype_interface_array(g, infix_exprs); + v__gen__c__Gen_write(g, _SLIT(")")); + return; + } + } + } + if ((node.right)._typ == 246 /* v.ast.ArrayInit */) { + if ((*node.right._v__ast__ArrayInit).exprs.len > 0) { + v__gen__c__Gen_write(g, _SLIT("(")); + v__gen__c__Gen_infix_expr_in_optimization(g, node.left, (*node.right._v__ast__ArrayInit)); + v__gen__c__Gen_write(g, _SLIT(")")); + return; + } + } + if ((right.sym->info)._typ == 411 /* v.ast.Array */) { + v__ast__Type elem_type = (*right.sym->info._v__ast__Array).elem_type; + v__gen__c__Type elem_type_ = v__gen__c__Gen_unwrap(g, elem_type); + if (elem_type_.sym->kind == v__ast__Kind__sum_type) { + if (Array_v__ast__Type_contains(v__ast__TypeSymbol_sumtype_info(elem_type_.sym).variants, node.left_type)) { + v__ast__CastExpr new_node_left = ((v__ast__CastExpr){.arg = v__ast__EmptyExpr_to_sumtype_v__ast__Expr(ADDR(v__ast__EmptyExpr, (((v__ast__EmptyExpr){.x = 0,})))),.typ = elem_type,.expr = node.left,.typname = (string){.str=(byteptr)"", .is_lit=1},.expr_type = node.left_type,.has_arg = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},}); + v__gen__c__Gen_gen_array_contains(g, node.right_type, node.right, v__ast__CastExpr_to_sumtype_v__ast__Expr(&new_node_left)); + return; + } + } + } + v__gen__c__Gen_gen_array_contains(g, node.right_type, node.right, node.left); } else if (right.unaliased_sym->kind == v__ast__Kind__string) { v__gen__c__Gen_write(g, _SLIT("string_contains(")); v__gen__c__Gen_expr(g, node.right); @@ -82079,7 +82994,7 @@ VV_LOCAL_SYMBOL v__ast__ArrayInit v__parser__Parser_array_init(v__parser__Parser if (exprs.len == 1 && (p->tok.kind == v__token__Kind__name || p->tok.kind == v__token__Kind__amp || p->tok.kind == v__token__Kind__lsbr) && p->tok.line_nr == line_nr) { elem_type = v__parser__Parser_parse_type(p); if (string__eq(v__ast__Table_sym(p->table, elem_type)->name, _SLIT("byte"))) { - v__parser__Parser_error(p, _SLIT("`byte` has been deprecated in favor of `u8`: use `[10]u8` instead of `[10]byte`")); + v__parser__Parser_error(p, _SLIT("`byte` has been deprecated in favor of `u8`: use `[10]u8{}` instead of `[10]byte{}`")); } last_pos = v__token__Token_pos(&p->tok); is_fixed = true; @@ -85206,7 +86121,7 @@ v__ast__Type v__parser__Parser_parse_inline_sum_type(v__parser__Parser* p) { array_push((array*)&_t1, &ti); } Array_string variant_names =_t1; - qsort(variant_names.data, variant_names.len, variant_names.element_size, (int (*)(const void *, const void *))&compare_7932637671395545435_string); + qsort(variant_names.data, variant_names.len, variant_names.element_size, (int (*)(const void *, const void *))&compare_1376677008124459278_string); string name = str_intp(2, _MOV((StrIntpData[]){{_SLIT("_v_anon_sum_type_"), 0xfe10, {.d_s = Array_string_join(variant_names, _SLIT("_"))}}, {_SLIT0, 0, { .d_c = 0 }}})); Array_v__ast__Type _t3 = {0}; Array_v__ast__TypeNode _t3_orig = variants; @@ -91984,7 +92899,7 @@ void v__builder__Builder_cc(v__builder__Builder* v) { v__builder__Builder_build_thirdparty_obj_files(v); v__builder__Builder_setup_output_name(v); if (v->pref->os != v__pref__OS__windows && string_contains(ccompiler, _SLIT("++"))) { - string cpp_atomic_h_path = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = _SLIT("/woodpecker/src/git.rustybever.be/Chewing_Bever/v")}}, {_SLIT("/thirdparty/stdatomic/nix/cpp/atomic.h"), 0, { .d_c = 0 }}})); + string cpp_atomic_h_path = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = _SLIT("/home/runner/work/v/v")}}, {_SLIT("/thirdparty/stdatomic/nix/cpp/atomic.h"), 0, { .d_c = 0 }}})); if (!os__exists(cpp_atomic_h_path)) { for (int _t4 = 0; _t4 < v->parsed_files.len; ++_t4) { v__ast__File* file = ((v__ast__File**)v->parsed_files.data)[_t4]; @@ -92004,7 +92919,7 @@ void v__builder__Builder_cc(v__builder__Builder* v) { eprintln( str_intp(2, _MOV((StrIntpData[]){{_SLIT("> creating "), 0xfe10, {.d_s = cpp_atomic_h_path}}, {_SLIT(" ..."), 0, { .d_c = 0 }}}))); } #endif - string cppgenv = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = _SLIT("/woodpecker/src/git.rustybever.be/Chewing_Bever/v")}}, {_SLIT("/thirdparty/stdatomic/nix/cpp/gen.v"), 0, { .d_c = 0 }}})); + string cppgenv = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = _SLIT("/home/runner/work/v/v")}}, {_SLIT("/thirdparty/stdatomic/nix/cpp/gen.v"), 0, { .d_c = 0 }}})); os__execute( str_intp(4, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = os__quoted_path(vexe)}}, {_SLIT(" run "), 0xfe10, {.d_s = os__quoted_path(cppgenv)}}, {_SLIT(" "), 0xfe10, {.d_s = os__quoted_path(ccompiler)}}, {_SLIT0, 0, { .d_c = 0 }}}))); break; } @@ -94552,7 +95467,7 @@ void _vinit(int ___argc, voidptr ___argv) { _const_v__util__const_tabs = new_array_from_c_array(10, 10, sizeof(string), _MOV((string[10]){ _SLIT(""), _SLIT("\t"), _SLIT("\t\t"), _SLIT("\t\t\t"), _SLIT("\t\t\t\t"), _SLIT("\t\t\t\t\t"), _SLIT("\t\t\t\t\t\t"), _SLIT("\t\t\t\t\t\t\t"), _SLIT("\t\t\t\t\t\t\t\t"), _SLIT("\t\t\t\t\t\t\t\t\t")})); - _const_v__util__builtin_module_names = new_array_from_c_array(4, 4, sizeof(string), _MOV((string[4]){_SLIT("builtin"), _SLIT("strconv"), _SLIT("strings"), _SLIT("dlmalloc")})); + _const_v__util__builtin_module_names = new_array_from_c_array(5, 5, sizeof(string), _MOV((string[5]){_SLIT("builtin"), _SLIT("strconv"), _SLIT("strings"), _SLIT("dlmalloc"), _SLIT("math")})); lines_cache = ((v__util__LinesCache*)memdup(&(v__util__LinesCache){.lines = new_map(sizeof(string), sizeof(Array_string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),}, sizeof(v__util__LinesCache))); // 3global g_timers = v__util__new_timers(((v__util__TimerParams){.should_print = false,.label = _SLIT("g_timers"),})); // 3global } diff --git a/v_win.c b/v_win.c index a19891b..52b0392 100644 --- a/v_win.c +++ b/v_win.c @@ -1,11 +1,11 @@ -#define V_COMMIT_HASH "32d7ae783" +#define V_COMMIT_HASH "5e8c4a3" #ifndef V_COMMIT_HASH - #define V_COMMIT_HASH "07cab64d1" + #define V_COMMIT_HASH "2a0b372" #endif #ifndef V_CURRENT_COMMIT_HASH - #define V_CURRENT_COMMIT_HASH "32d7ae7" + #define V_CURRENT_COMMIT_HASH "5e8c4a3" #endif // V comptime_definitions: @@ -1009,7 +1009,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; #endif -// added by module `builtin` +// added by module `builtin`, file: float.c.v:9: #if defined(__has_include) @@ -1027,7 +1027,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `time` +// added by module `time`, file: time.c.v:6: #if defined(__has_include) @@ -1045,7 +1045,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `time` +// added by module `time`, file: time_windows.c.v:6: #if defined(__has_include) @@ -1061,27 +1061,377 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; +// inserted by module `sync.stdatomic`, file: 1.declarations.c.v:8: +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ +#ifndef COMPAT_ATOMICS_WIN32_STDATOMIC_H +#define COMPAT_ATOMICS_WIN32_STDATOMIC_H -// added by module `sync.stdatomic` +#define WIN32_LEAN_AND_MEAN +#include +#include +#include -#if defined(__has_include) - -#if __has_include() -#include -#else -#error VERROR_MESSAGE Header file , needed for module `sync.stdatomic` was not found. Please install the corresponding development headers. +#ifdef __TINYC__ #endif -#else -#include +#define ATOMIC_FLAG_INIT 0 + +#define ATOMIC_VAR_INIT(value) (value) + +#define atomic_init(obj, value) \ + do \ + { \ + *(obj) = (value); \ + } while (0) + +#define kill_dependency(y) ((void)0) + +#define atomic_thread_fence(order) \ + MemoryBarrier(); + +#define atomic_signal_fence(order) \ + ((void)0) + +#define atomic_is_lock_free(obj) 0 + +typedef intptr_t atomic_flag; +typedef intptr_t atomic_bool; +typedef intptr_t atomic_char; +typedef intptr_t atomic_schar; +typedef intptr_t atomic_uchar; +typedef intptr_t atomic_short; +typedef intptr_t atomic_ushort; +typedef intptr_t atomic_int; +typedef intptr_t atomic_uint; +typedef intptr_t atomic_long; +typedef intptr_t atomic_ulong; +typedef intptr_t atomic_llong; +typedef intptr_t atomic_ullong; +typedef intptr_t atomic_wchar_t; +typedef intptr_t atomic_int_least8_t; +typedef intptr_t atomic_uint_least8_t; +typedef intptr_t atomic_int_least16_t; +typedef intptr_t atomic_uint_least16_t; +typedef intptr_t atomic_int_least32_t; +typedef intptr_t atomic_uint_least32_t; +typedef intptr_t atomic_int_least64_t; +typedef intptr_t atomic_uint_least64_t; +typedef intptr_t atomic_int_fast8_t; +typedef intptr_t atomic_uint_fast8_t; +typedef intptr_t atomic_int_fast16_t; +typedef intptr_t atomic_uint_fast16_t; +typedef intptr_t atomic_int_fast32_t; +typedef intptr_t atomic_uint_fast32_t; +typedef intptr_t atomic_int_fast64_t; +typedef intptr_t atomic_uint_fast64_t; +typedef intptr_t atomic_intptr_t; +typedef intptr_t atomic_uintptr_t; +typedef intptr_t atomic_size_t; +typedef intptr_t atomic_ptrdiff_t; +typedef intptr_t atomic_intmax_t; +typedef intptr_t atomic_uintmax_t; + +#ifdef __TINYC__ +/* + For TCC it is missing the x64 version of _InterlockedExchangeAdd64 so we + fake it (works the same) with InterlockedCompareExchange64 until it + succeeds +*/ +__CRT_INLINE LONGLONG _InterlockedExchangeAdd64(LONGLONG volatile *Addend, LONGLONG Value) +{ + LONGLONG Old; + do + { + Old = *Addend; + } while (InterlockedCompareExchange64(Addend, Old + Value, Old) != Old); + return Old; +} + +__CRT_INLINE LONG _InterlockedExchangeAdd(LONG volatile *Addend, LONG Value) +{ + LONG Old; + do + { + Old = *Addend; + } while (InterlockedCompareExchange(Addend, Old + Value, Old) != Old); + return Old; +} + +__CRT_INLINE SHORT _InterlockedExchangeAdd16(SHORT volatile *Addend, SHORT Value) +{ + SHORT Old; + do + { + Old = *Addend; + } while (InterlockedCompareExchange16(Addend, Old + Value, Old) != Old); + return Old; +} + +#define InterlockedIncrement64 _InterlockedExchangeAdd64 + #endif +#define atomic_store(object, desired) \ + do \ + { \ + *(object) = (desired); \ + MemoryBarrier(); \ + } while (0) + +#define atomic_store_explicit(object, desired, order) \ + atomic_store(object, desired) + +#define atomic_load(object) \ + (MemoryBarrier(), *(object)) + +#define atomic_load_explicit(object, order) \ + atomic_load(object) + +#define atomic_exchange(object, desired) \ + InterlockedExchangePointer(object, desired) + +#define atomic_exchange_explicit(object, desired, order) \ + atomic_exchange(object, desired) + +static inline int atomic_compare_exchange_strong(intptr_t *object, intptr_t *expected, + intptr_t desired) +{ + intptr_t old = *expected; + *expected = (intptr_t)InterlockedCompareExchangePointer( + (PVOID *)object, (PVOID)desired, (PVOID)old); + return *expected == old; +} + +#define atomic_compare_exchange_strong_explicit(object, expected, desired, success, failure) \ + atomic_compare_exchange_strong(object, expected, desired) + +#define atomic_compare_exchange_weak(object, expected, desired) \ + atomic_compare_exchange_strong(object, expected, desired) + +#define atomic_compare_exchange_weak_explicit(object, expected, desired, success, failure) \ + atomic_compare_exchange_weak(object, expected, desired) + +#ifdef _WIN64 + +#define atomic_fetch_add(object, operand) \ + InterlockedExchangeAdd64(object, operand) + +#define atomic_fetch_sub(object, operand) \ + InterlockedExchangeAdd64(object, -(operand)) + +#define atomic_fetch_or(object, operand) \ + InterlockedOr64(object, operand) + +#define atomic_fetch_xor(object, operand) \ + InterlockedXor64(object, operand) + +#define atomic_fetch_and(object, operand) \ + InterlockedAnd64(object, operand) +#else +#define atomic_fetch_add(object, operand) \ + InterlockedExchangeAdd(object, operand) + +#define atomic_fetch_sub(object, operand) \ + InterlockedExchangeAdd(object, -(operand)) + +#define atomic_fetch_or(object, operand) \ + InterlockedOr(object, operand) + +#define atomic_fetch_xor(object, operand) \ + InterlockedXor(object, operand) + +#define atomic_fetch_and(object, operand) \ + InterlockedAnd(object, operand) +#endif /* _WIN64 */ + +/* specialized versions with explicit object size */ + +#define atomic_load_ptr atomic_load +#define atomic_store_ptr atomic_store +#define atomic_compare_exchange_weak_ptr atomic_compare_exchange_weak +#define atomic_compare_exchange_strong_ptr atomic_compare_exchange_strong +#define atomic_exchange_ptr atomic_exchange +#define atomic_fetch_add_ptr atomic_fetch_add +#define atomic_fetch_sub_ptr atomic_fetch_sub +#define atomic_fetch_and_ptr atomic_fetch_and +#define atomic_fetch_or_ptr atomic_fetch_or +#define atomic_fetch_xor_ptr atomic_fetch_xor + +static inline void atomic_store_u64(unsigned long long* object, unsigned long long desired) { + do { + *(object) = (desired); + MemoryBarrier(); + } while (0); +} + +static inline unsigned long long atomic_load_u64(unsigned long long* object) { + return (MemoryBarrier(), *(object)); +} + +#define atomic_exchange_u64(object, desired) \ + InterlockedExchange64(object, desired) + +static inline int atomic_compare_exchange_strong_u64(unsigned long long* object, unsigned long long* expected, + unsigned long long desired) +{ + unsigned long long old = *expected; + *expected = InterlockedCompareExchange64(object, desired, old); + return *expected == old; +} + +#define atomic_compare_exchange_weak_u64(object, expected, desired) \ + atomic_compare_exchange_strong_u64(object, expected, desired) + +#define atomic_fetch_add_u64(object, operand) \ + InterlockedExchangeAdd64(object, operand) + +#define atomic_fetch_sub_u64(object, operand) \ + InterlockedExchangeAdd64(object, -(operand)) + +#define atomic_fetch_or_u64(object, operand) \ + InterlockedOr64(object, operand) + +#define atomic_fetch_xor_u64(object, operand) \ + InterlockedXor64(object, operand) + +#define atomic_fetch_and_u64(object, operand) \ + InterlockedAnd64(object, operand) +static inline void atomic_store_u32(unsigned* object, unsigned desired) { + do { + *(object) = (desired); + MemoryBarrier(); + } while (0); +} -// added by module `os` +static inline unsigned atomic_load_u32(unsigned* object) { + return (MemoryBarrier(), *(object)); +} + +#define atomic_exchange_u32(object, desired) \ + InterlockedExchange(object, desired) + +static inline int atomic_compare_exchange_strong_u32(unsigned* object, unsigned* expected, + unsigned desired) +{ + unsigned old = *expected; + *expected = InterlockedCompareExchange(object, desired, old); + return *expected == old; +} + +#define atomic_compare_exchange_weak_u32(object, expected, desired) \ + atomic_compare_exchange_strong_u32(object, expected, desired) + +#define atomic_fetch_add_u32(object, operand) \ + InterlockedExchangeAdd(object, operand) + +#define atomic_fetch_sub_u32(object, operand) \ + InterlockedExchangeAdd(object, -(operand)) + +#define atomic_fetch_or_u32(object, operand) \ + InterlockedOr(object, operand) + +#define atomic_fetch_xor_u32(object, operand) \ + InterlockedXor(object, operand) + +#define atomic_fetch_and_u32(object, operand) \ + InterlockedAnd(object, operand) + + + +static inline void atomic_store_u16(unsigned short* object, unsigned short desired) { + do { + *(object) = (desired); + MemoryBarrier(); + } while (0); +} + +static inline unsigned short atomic_load_u16(unsigned short* object) { + return (MemoryBarrier(), *(object)); +} + +#define atomic_exchange_u16(object, desired) \ + InterlockedExchange16(object, desired) + +static inline int atomic_compare_exchange_strong_u16(unsigned short* object, unsigned short* expected, + unsigned short desired) +{ + unsigned short old = *expected; + *expected = InterlockedCompareExchange16(object, desired, old); + return *expected == old; +} + +#define atomic_compare_exchange_weak_u16(object, expected, desired) \ + atomic_compare_exchange_strong_u16(object, expected, desired) + +#define atomic_fetch_add_u16(object, operand) \ + InterlockedExchangeAdd16(object, operand) + +#define atomic_fetch_sub_u16(object, operand) \ + InterlockedExchangeAdd16(object, -(operand)) + +#define atomic_fetch_or_u16(object, operand) \ + InterlockedOr16(object, operand) + +#define atomic_fetch_xor_u16(object, operand) \ + InterlockedXor16(object, operand) + +#define atomic_fetch_and_u16(object, operand) \ + InterlockedAnd16(object, operand) + + + +#define atomic_fetch_add_explicit(object, operand, order) \ + atomic_fetch_add(object, operand) + +#define atomic_fetch_sub_explicit(object, operand, order) \ + atomic_fetch_sub(object, operand) + +#define atomic_fetch_or_explicit(object, operand, order) \ + atomic_fetch_or(object, operand) + +#define atomic_fetch_xor_explicit(object, operand, order) \ + atomic_fetch_xor(object, operand) + +#define atomic_fetch_and_explicit(object, operand, order) \ + atomic_fetch_and(object, operand) + +#define atomic_flag_test_and_set(object) \ + atomic_exchange(object, 1) + +#define atomic_flag_test_and_set_explicit(object, order) \ + atomic_flag_test_and_set(object) + +#define atomic_flag_clear(object) \ + atomic_store(object, 0) + +#define atomic_flag_clear_explicit(object, order) \ + atomic_flag_clear(object) + +#endif /* COMPAT_ATOMICS_WIN32_STDATOMIC_H */ + + + +// added by module `os`, file: os.c.v:3: #if defined(__has_include) @@ -1099,13 +1449,13 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: os.c.v:4: #include -// added by module `os` +// added by module `os`, file: os_windows.c.v:6: #if defined(__has_include) @@ -1123,7 +1473,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: os_windows.c.v:7: #if defined(__has_include) @@ -1141,7 +1491,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `os` +// added by module `os`, file: signal.c.v:3: #if defined(__has_include) @@ -1159,7 +1509,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `sync` +// added by module `sync`, file: sync_windows.c.v:8: #if defined(__has_include) @@ -1177,7 +1527,7 @@ static inline uint64_t wy2u0k(uint64_t r, uint64_t k){ _wymum(&r,&k); return k; -// added by module `sync` +// added by module `sync`, file: sync_windows.c.v:9: #if defined(__has_include) @@ -6947,7 +7297,7 @@ string string_clone(string a); string string_replace_once(string s, string rep, string with); string string_replace(string s, string rep, string with); string string_replace_each(string s, Array_string vals); -VV_LOCAL_SYMBOL int compare_11653268393309465375_RepIndex_by_idx(RepIndex* a, RepIndex* b) { +VV_LOCAL_SYMBOL int compare_2018276881664952276_RepIndex_by_idx(RepIndex* a, RepIndex* b) { if (a->idx < b->idx) return -1; else return 1; } @@ -7124,7 +7474,7 @@ Array_string os__cmdline__only_non_options(Array_string args); Array_string os__cmdline__only_options(Array_string args); #define _const_v__token__max_keyword_len 20 v__token__KeywordsMatcher v__token__new_keywords_matcher_T_v__token__Kind(Map_string_v__token__Kind kw_map); -VV_LOCAL_SYMBOL int compare_186646746980636166_v__token__WIndex_by_word(v__token__WIndex* a, v__token__WIndex* b) { +VV_LOCAL_SYMBOL int compare_7621314236064146737_v__token__WIndex_by_word(v__token__WIndex* a, v__token__WIndex* b) { if (string__lt(a->word, b->word)) return -1; else return 1; } @@ -7277,7 +7627,7 @@ time__Time time__unix2(i64 abs, int microsecond); VV_LOCAL_SYMBOL multi_return_int_int_int time__calculate_date_from_offset(i64 day_offset_); VV_LOCAL_SYMBOL multi_return_int_int_int time__calculate_time_from_offset(i64 second_offset_); void v__dotgraph__start_digraph(void); -VV_LOCAL_SYMBOL void anon_fn_eb34f0b759dade77__82(void); +VV_LOCAL_SYMBOL void anon_fn_40181cb3d9c4559e__82(void); v__dotgraph__DotGraph* v__dotgraph__new(string name, string label, string color); void v__dotgraph__DotGraph_writeln(v__dotgraph__DotGraph* d, string line); void v__dotgraph__DotGraph_finish(v__dotgraph__DotGraph* d); @@ -7616,7 +7966,7 @@ Option_void os__execve(string cmdpath, Array_string cmdargs, Array_string envs); int os__is_atty(int fd); Option_void os__write_file_array(string path, array buffer); Option_Array_string os__glob(Array_string patterns); -VV_LOCAL_SYMBOL int compare_3075544183021293552_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_10044130939551424885_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -7934,7 +8284,7 @@ int rand__wyrand__WyRandRNG_block_size(rand__wyrand__WyRandRNG* rng); void rand__wyrand__WyRandRNG_free(rand__wyrand__WyRandRNG* rng); VV_LOCAL_SYMBOL Option_string v__pkgconfig__desc(string mod); Option_v__pkgconfig__Main_ptr v__pkgconfig__main(Array_string args); -VV_LOCAL_SYMBOL int compare_16330786295575367509_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_6984583855671780374_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -8070,7 +8420,7 @@ v__pref__CompilerType v__pref__cc_from_string(string cc_str); v__pref__Arch v__pref__get_host_arch(void); VV_LOCAL_SYMBOL void v__pref__Preferences_parse_define(v__pref__Preferences* prefs, string define); Array_string v__pref__Preferences_should_compile_filtered_files(v__pref__Preferences* prefs, string dir, Array_string files_); -VV_LOCAL_SYMBOL int compare_13661271458656804876_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_16890712418519328305_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -8132,7 +8482,7 @@ void sync__WaitGroup_wait(sync__WaitGroup* wg); string _const_help__unknown_topic; // a string literal, inited later void help__print_and_exit(string topic); VV_LOCAL_SYMBOL string help__known_topics(string topicdir); -VV_LOCAL_SYMBOL int compare_10452767129756656329_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_1650400601261717902_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -8175,13 +8525,13 @@ v__util__Suggestion v__util__new_suggestion(string wanted, Array_string possibil void v__util__Suggestion_add(v__util__Suggestion* s, string val); void v__util__Suggestion_add_many(v__util__Suggestion* s, Array_string many); void v__util__Suggestion_sort(v__util__Suggestion* s); -VV_LOCAL_SYMBOL int compare_6907021362050549619_v__util__Possibility_by_similarity(v__util__Possibility* a, v__util__Possibility* b) { +VV_LOCAL_SYMBOL int compare_6081961377856465380_v__util__Possibility_by_similarity(v__util__Possibility* a, v__util__Possibility* b) { if (a->similarity < b->similarity) return -1; else return 1; } string v__util__Suggestion_say(v__util__Suggestion s, string msg); -VV_LOCAL_SYMBOL int compare_6907021362050549619_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_6081961377856465380_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -9270,7 +9620,7 @@ v__ast__Type v__parser__Parser_parse_fn_type(v__parser__Parser* p, string name); v__ast__Type v__parser__Parser_parse_type_with_mut(v__parser__Parser* p, bool is_mut); v__ast__Language v__parser__Parser_parse_language(v__parser__Parser* p); v__ast__Type v__parser__Parser_parse_inline_sum_type(v__parser__Parser* p); -VV_LOCAL_SYMBOL int compare_7932637671395545435_string(string* a, string* b) { +VV_LOCAL_SYMBOL int compare_1376677008124459278_string(string* a, string* b) { if (string__lt(*a, *b)) return -1; else return 1; } @@ -11921,7 +12271,7 @@ void v__ast__TypeSymbol_free(v__ast__TypeSymbol* it) { string_free(&(it->mod)); } -VV_LOCAL_SYMBOL void anon_fn_eb34f0b759dade77__82(void) { +VV_LOCAL_SYMBOL void anon_fn_40181cb3d9c4559e__82(void) { println(_SLIT("}")); } @@ -19525,7 +19875,7 @@ string string_replace_each(string s, Array_string vals) { if (idxs.len == 0) { return string_clone(s); } - qsort(idxs.data, idxs.len, idxs.element_size, (int (*)(const void *, const void *))&compare_11653268393309465375_RepIndex_by_idx); + qsort(idxs.data, idxs.len, idxs.element_size, (int (*)(const void *, const void *))&compare_2018276881664952276_RepIndex_by_idx); u8* b = malloc_noscan(new_len + 1); int idx_pos = 0; RepIndex cur_idx = ((RepIndex*)idxs.data)[idx_pos]; @@ -20864,7 +21214,7 @@ bool string_match_glob(string name, string pattern) { bool is_inverted = false; bool inner_match = false; int inner_idx = bstart + 1; - u8 inner_c = ((u8)(0)); + int inner_c = 0; if (inner_idx < plen) { inner_c = pattern.str[ inner_idx]; if (inner_c == '^') { @@ -22237,7 +22587,7 @@ v__token__KeywordsMatcher v__token__new_keywords_matcher_T_v__token__Kind(Map_st } for (int i = 0; i < _const_v__token__max_keyword_len; ++i) { if (km.words[v_fixed_index(i, 20)].len > 0) { - qsort(km.words[v_fixed_index(i, 20)].data, km.words[v_fixed_index(i, 20)].len, km.words[v_fixed_index(i, 20)].element_size, (int (*)(const void *, const void *))&compare_186646746980636166_v__token__WIndex_by_word); + qsort(km.words[v_fixed_index(i, 20)].data, km.words[v_fixed_index(i, 20)].len, km.words[v_fixed_index(i, 20)].element_size, (int (*)(const void *, const void *))&compare_7621314236064146737_v__token__WIndex_by_word); } } v__token__KeywordsMatcher _t4 = km; @@ -22264,7 +22614,7 @@ v__token__KeywordsMatcher v__token__new_keywords_matcher_T_int(Map_string_int kw } for (int i = 0; i < _const_v__token__max_keyword_len; ++i) { if (km.words[v_fixed_index(i, 20)].len > 0) { - qsort(km.words[v_fixed_index(i, 20)].data, km.words[v_fixed_index(i, 20)].len, km.words[v_fixed_index(i, 20)].element_size, (int (*)(const void *, const void *))&compare_186646746980636166_v__token__WIndex_by_word); + qsort(km.words[v_fixed_index(i, 20)].data, km.words[v_fixed_index(i, 20)].len, km.words[v_fixed_index(i, 20)].element_size, (int (*)(const void *, const void *))&compare_7621314236064146737_v__token__WIndex_by_word); } } v__token__KeywordsMatcher _t4 = km; @@ -24865,7 +25215,7 @@ VV_LOCAL_SYMBOL multi_return_int_int_int time__calculate_time_from_offset(i64 se void v__dotgraph__start_digraph(void) { println(_SLIT("digraph G {")); - atexit((voidptr) anon_fn_eb34f0b759dade77__82); + atexit((voidptr) anon_fn_40181cb3d9c4559e__82); } v__dotgraph__DotGraph* v__dotgraph__new(string name, string label, string color) { @@ -28177,7 +28527,7 @@ Option_Array_string os__glob(Array_string patterns) { ; } - qsort(matches.data, matches.len, matches.element_size, (int (*)(const void *, const void *))&compare_3075544183021293552_string); + qsort(matches.data, matches.len, matches.element_size, (int (*)(const void *, const void *))&compare_10044130939551424885_string); Option_Array_string _t4; opt_ok(&(Array_string[]) { matches }, (Option*)(&_t4), sizeof(Array_string)); return _t4; @@ -31969,7 +32319,7 @@ Option_v__pkgconfig__Main_ptr v__pkgconfig__main(Array_string args) { m->res = _const_v__pkgconfig__version; } else if (opt->listall) { Array_string modules = v__pkgconfig__list(); - qsort(modules.data, modules.len, modules.element_size, (int (*)(const void *, const void *))&compare_16330786295575367509_string); + qsort(modules.data, modules.len, modules.element_size, (int (*)(const void *, const void *))&compare_6984583855671780374_string); if (opt->description) { for (int _t1 = 0; _t1 < modules.len; ++_t1) { string mod = ((string*)modules.data)[_t1]; @@ -33281,7 +33631,7 @@ void v__pref__Preferences_fill_with_defaults(v__pref__Preferences* p) { if ((p->third_party_option).len == 0) { p->third_party_option = p->cflags; } - string vhash = _SLIT("07cab64d1"); + string vhash = _SLIT("2a0b372"); p->cache_manager = v__vcache__new_cache_manager(new_array_from_c_array(7, 7, sizeof(string), _MOV((string[7]){string_clone(vhash), str_intp(6, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = v__pref__Backend_str(p->backend)}}, {_SLIT(" | "), 0xfe10, {.d_s = v__pref__OS_str(p->os)}}, {_SLIT(" | "), 0xfe10, {.d_s = p->ccompiler}}, {_SLIT(" | "), 0xfe10, {.d_s = p->is_prod ? _SLIT("true") : _SLIT("false")}}, {_SLIT(" | "), 0xfe10, {.d_s = p->sanitize ? _SLIT("true") : _SLIT("false")}}, {_SLIT0, 0, { .d_c = 0 }}})), string_clone(string_trim_space(p->cflags)), string_clone(string_trim_space(p->third_party_option)), string_clone(Array_string_str(p->compile_defines_all)), string_clone(Array_string_str(p->compile_defines)), string_clone(Array_string_str(p->lookup_path))}))); if (string__eq(os__user_os(), _SLIT("windows"))) { p->use_cache = false; @@ -34522,7 +34872,7 @@ VV_LOCAL_SYMBOL void v__pref__Preferences_parse_define(v__pref__Preferences* pre Array_string v__pref__Preferences_should_compile_filtered_files(v__pref__Preferences* prefs, string dir, Array_string files_) { Array_string res = __new_array_with_default(0, 0, sizeof(string), 0); Array_string files = array_clone_to_depth(&files_, 0); - qsort(files.data, files.len, files.element_size, (int (*)(const void *, const void *))&compare_13661271458656804876_string); + qsort(files.data, files.len, files.element_size, (int (*)(const void *, const void *))&compare_16890712418519328305_string); Array_string all_v_files = __new_array_with_default(0, 0, sizeof(string), 0); for (int _t1 = 0; _t1 < files.len; ++_t1) { string file = ((string*)files.data)[_t1]; @@ -35720,7 +36070,7 @@ VV_LOCAL_SYMBOL string help__known_topics(string topicdir) { array_push((array*)&_t3, &ti); } Array_string topics =_t3; - qsort(topics.data, topics.len, topics.element_size, (int (*)(const void *, const void *))&compare_10452767129756656329_string); + qsort(topics.data, topics.len, topics.element_size, (int (*)(const void *, const void *))&compare_1650400601261717902_string); array_push((array*)&res, _MOV((string[]){ string_clone(Array_string_join(topics, _SLIT(", "))) })); array_push((array*)&res, _MOV((string[]){ string_clone(_SLIT(".")) })); string _t7 = Array_string_join(res, _SLIT("")); @@ -36217,7 +36567,7 @@ void v__util__Suggestion_add_many(v__util__Suggestion* s, Array_string many) { } void v__util__Suggestion_sort(v__util__Suggestion* s) { - qsort(s->known.data, s->known.len, s->known.element_size, (int (*)(const void *, const void *))&compare_6907021362050549619_v__util__Possibility_by_similarity); + qsort(s->known.data, s->known.len, s->known.element_size, (int (*)(const void *, const void *))&compare_6081961377856465380_v__util__Possibility_by_similarity); } string v__util__Suggestion_say(v__util__Suggestion s, string msg) { @@ -36246,7 +36596,7 @@ string v__util__Suggestion_say(v__util__Suggestion s, string msg) { array_push((array*)&_t1, &ti); } Array_string values =_t1; - qsort(values.data, values.len, values.element_size, (int (*)(const void *, const void *))&compare_6907021362050549619_string); + qsort(values.data, values.len, values.element_size, (int (*)(const void *, const void *))&compare_6081961377856465380_string); if (values.len == 1) { res = /*f*/string__plus(res, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".\n1 possibility: "), 0xfe10, {.d_s = (*(string*)/*ee elem_sym */array_get(values, 0))}}, {_SLIT("."), 0, { .d_c = 0 }}}))); } else if (values.len < 25) { @@ -36994,9 +37344,9 @@ void v__util__prepare_tool_when_needed(string source_name) { string vexe = os__getenv(_SLIT("VEXE")); string vroot = os__dir(vexe); string stool = os__join_path(vroot, new_array_from_c_array(3, 3, sizeof(string), _MOV((string[3]){_SLIT("cmd"), _SLIT("tools"), source_name}))); - multi_return_string_string mr_14621 = v__util__tool_source2name_and_exe(stool); - string tool_name = mr_14621.arg0; - string tool_exe = mr_14621.arg1; + multi_return_string_string mr_14629 = v__util__tool_source2name_and_exe(stool); + string tool_name = mr_14629.arg0; + string tool_exe = mr_14629.arg1; if (v__util__should_recompile_tool(vexe, stool, tool_name, tool_exe)) { time__sleep(1001 * _const_time__millisecond); v__util__recompile_file(vexe, stool); @@ -43079,8 +43429,7 @@ string v__ast__Type_str(v__ast__Type t) { } string v__ast__Table_type_str(v__ast__Table* t, v__ast__Type typ) { - v__ast__TypeSymbol* sym = v__ast__Table_sym(t, typ); - string _t1 = sym->name; + string _t1 = v__ast__Table_sym(t, typ)->name; return _t1; } @@ -43205,8 +43554,7 @@ inline bool v__ast__Type_is_unsigned(v__ast__Type typ) { } v__ast__Type v__ast__Type_flip_signedness(v__ast__Type typ) { - v__ast__Type r = ((typ == (_const_v__ast__i8_type)) ? (_const_v__ast__byte_type) : (typ == (_const_v__ast__i16_type)) ? (_const_v__ast__u16_type) : (typ == (_const_v__ast__int_type)) ? (_const_v__ast__u32_type) : (typ == (_const_v__ast__isize_type)) ? (_const_v__ast__usize_type) : (typ == (_const_v__ast__i64_type)) ? (_const_v__ast__u64_type) : (typ == (_const_v__ast__byte_type)) ? (_const_v__ast__i8_type) : (typ == (_const_v__ast__u16_type)) ? (_const_v__ast__i16_type) : (typ == (_const_v__ast__u32_type)) ? (_const_v__ast__int_type) : (typ == (_const_v__ast__usize_type)) ? (_const_v__ast__isize_type) : (typ == (_const_v__ast__u64_type)) ? (_const_v__ast__i64_type) : (typ)); - v__ast__Type _t1 = r; + v__ast__Type _t1 = ((typ == (_const_v__ast__i8_type)) ? (_const_v__ast__byte_type) : (typ == (_const_v__ast__i16_type)) ? (_const_v__ast__u16_type) : (typ == (_const_v__ast__int_type)) ? (_const_v__ast__u32_type) : (typ == (_const_v__ast__isize_type)) ? (_const_v__ast__usize_type) : (typ == (_const_v__ast__i64_type)) ? (_const_v__ast__u64_type) : (typ == (_const_v__ast__byte_type)) ? (_const_v__ast__i8_type) : (typ == (_const_v__ast__u16_type)) ? (_const_v__ast__i16_type) : (typ == (_const_v__ast__u32_type)) ? (_const_v__ast__int_type) : (typ == (_const_v__ast__usize_type)) ? (_const_v__ast__isize_type) : (typ == (_const_v__ast__u64_type)) ? (_const_v__ast__i64_type) : (typ)); return _t1; } @@ -43235,7 +43583,7 @@ inline bool v__ast__Type_is_bool(v__ast__Type typ) { } Array_v__ast__Type v__ast__merge_types(Array_Array_v__ast__Type params) { - Array_v__ast__Type res = __new_array_with_default(0, 0, sizeof(v__ast__Type), 0); + Array_v__ast__Type res = __new_array_with_default(0, params.len, sizeof(v__ast__Type), 0); for (int _t1 = 0; _t1 < params.len; ++_t1) { Array_v__ast__Type types = ((Array_v__ast__Type*)params.data)[_t1]; _PUSH_MANY(&res, (types), _t2, Array_v__ast__Type); @@ -43245,20 +43593,8 @@ Array_v__ast__Type v__ast__merge_types(Array_Array_v__ast__Type params) { } v__ast__Type v__ast__mktyp(v__ast__Type typ) { - - if (typ == (_const_v__ast__float_literal_type)) { - v__ast__Type _t1 = _const_v__ast__f64_type; - return _t1; - } - else if (typ == (_const_v__ast__int_literal_type)) { - v__ast__Type _t2 = _const_v__ast__int_type; - return _t2; - } - else { - v__ast__Type _t3 = typ; - return _t3; - }; - return 0; + v__ast__Type _t1 = ((typ == (_const_v__ast__float_literal_type)) ? (_const_v__ast__f64_type) : (typ == (_const_v__ast__int_literal_type)) ? (_const_v__ast__int_type) : (typ)); + return _t1; } v__ast__Kind v__ast__Table_type_kind(v__ast__Table* t, v__ast__Type typ) { @@ -43538,207 +43874,206 @@ inline bool v__ast__TypeSymbol_is_builtin(v__ast__TypeSymbol* t) { } string v__ast__Kind_str(v__ast__Kind k) { - string _t1 = (string){.str=(byteptr)"", .is_lit=1}; + string _t2 = (string){.str=(byteptr)"", .is_lit=1}; switch (k) { case v__ast__Kind__placeholder: { - _t1 = _SLIT("placeholder"); + _t2 = _SLIT("placeholder"); break; } case v__ast__Kind__void: { - _t1 = _SLIT("void"); + _t2 = _SLIT("void"); break; } case v__ast__Kind__voidptr: { - _t1 = _SLIT("voidptr"); + _t2 = _SLIT("voidptr"); break; } case v__ast__Kind__charptr: { - _t1 = _SLIT("charptr"); + _t2 = _SLIT("charptr"); break; } case v__ast__Kind__byteptr: { - _t1 = _SLIT("byteptr"); + _t2 = _SLIT("byteptr"); break; } case v__ast__Kind__struct_: { - _t1 = _SLIT("struct"); + _t2 = _SLIT("struct"); break; } case v__ast__Kind__int: { - _t1 = _SLIT("int"); + _t2 = _SLIT("int"); break; } case v__ast__Kind__i8: { - _t1 = _SLIT("i8"); + _t2 = _SLIT("i8"); break; } case v__ast__Kind__i16: { - _t1 = _SLIT("i16"); + _t2 = _SLIT("i16"); break; } case v__ast__Kind__i64: { - _t1 = _SLIT("i64"); + _t2 = _SLIT("i64"); break; } case v__ast__Kind__isize: { - _t1 = _SLIT("isize"); + _t2 = _SLIT("isize"); break; } case v__ast__Kind__u8: { - _t1 = _SLIT("u8"); + _t2 = _SLIT("u8"); break; } case v__ast__Kind__u16: { - _t1 = _SLIT("u16"); + _t2 = _SLIT("u16"); break; } case v__ast__Kind__u32: { - _t1 = _SLIT("u32"); + _t2 = _SLIT("u32"); break; } case v__ast__Kind__u64: { - _t1 = _SLIT("u64"); + _t2 = _SLIT("u64"); break; } case v__ast__Kind__usize: { - _t1 = _SLIT("usize"); + _t2 = _SLIT("usize"); break; } case v__ast__Kind__int_literal: { - _t1 = _SLIT("int_literal"); + _t2 = _SLIT("int_literal"); break; } case v__ast__Kind__f32: { - _t1 = _SLIT("f32"); + _t2 = _SLIT("f32"); break; } case v__ast__Kind__f64: { - _t1 = _SLIT("f64"); + _t2 = _SLIT("f64"); break; } case v__ast__Kind__float_literal: { - _t1 = _SLIT("float_literal"); + _t2 = _SLIT("float_literal"); break; } case v__ast__Kind__string: { - _t1 = _SLIT("string"); + _t2 = _SLIT("string"); break; } case v__ast__Kind__char: { - _t1 = _SLIT("char"); + _t2 = _SLIT("char"); break; } case v__ast__Kind__bool: { - _t1 = _SLIT("bool"); + _t2 = _SLIT("bool"); break; } case v__ast__Kind__none_: { - _t1 = _SLIT("none"); + _t2 = _SLIT("none"); break; } case v__ast__Kind__array: { - _t1 = _SLIT("array"); + _t2 = _SLIT("array"); break; } case v__ast__Kind__array_fixed: { - _t1 = _SLIT("array_fixed"); + _t2 = _SLIT("array_fixed"); break; } case v__ast__Kind__map: { - _t1 = _SLIT("map"); + _t2 = _SLIT("map"); break; } case v__ast__Kind__chan: { - _t1 = _SLIT("chan"); + _t2 = _SLIT("chan"); break; } case v__ast__Kind__multi_return: { - _t1 = _SLIT("multi_return"); + _t2 = _SLIT("multi_return"); break; } case v__ast__Kind__sum_type: { - _t1 = _SLIT("sum_type"); + _t2 = _SLIT("sum_type"); break; } case v__ast__Kind__alias: { - _t1 = _SLIT("alias"); + _t2 = _SLIT("alias"); break; } case v__ast__Kind__enum_: { - _t1 = _SLIT("enum"); + _t2 = _SLIT("enum"); break; } case v__ast__Kind__any: { - _t1 = _SLIT("any"); + _t2 = _SLIT("any"); break; } case v__ast__Kind__function: { - _t1 = _SLIT("function"); + _t2 = _SLIT("function"); break; } case v__ast__Kind__interface_: { - _t1 = _SLIT("interface"); + _t2 = _SLIT("interface"); break; } case v__ast__Kind__generic_inst: { - _t1 = _SLIT("generic_inst"); + _t2 = _SLIT("generic_inst"); break; } case v__ast__Kind__rune: { - _t1 = _SLIT("rune"); + _t2 = _SLIT("rune"); break; } case v__ast__Kind__aggregate: { - _t1 = _SLIT("aggregate"); + _t2 = _SLIT("aggregate"); break; } case v__ast__Kind__thread: { - _t1 = _SLIT("thread"); + _t2 = _SLIT("thread"); break; } } - string k_str = _t1; - string _t2 = k_str; - return _t2; + string _t1 = _t2; + return _t1; } string Array_v__ast__Kind_str(Array_v__ast__Kind kinds) { @@ -44995,20 +45330,10 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; if ((*left->_v__ast__PrefixExpr).op == v__token__Kind__mul) { if (!c->inside_unsafe && !c->pref->translated && !c->file->is_translated) { v__checker__Checker_error(c, _SLIT("modifying variables via dereferencing can only be done in `unsafe` blocks"), node->pos); - } else { - if ((*left->_v__ast__PrefixExpr).right._typ == 305 /* v.ast.Ident */) { - if ((*(*left->_v__ast__PrefixExpr).right._v__ast__Ident).obj._typ == 363 /* v.ast.Var */) { - (*(*(*left->_v__ast__PrefixExpr).right._v__ast__Ident).obj._v__ast__Var).is_used = true; - } - - else { - } - ; + } else if (((*left->_v__ast__PrefixExpr).right)._typ == 305 /* v.ast.Ident */) { + if (((*(*left->_v__ast__PrefixExpr).right._v__ast__Ident).obj)._typ == 363 /* v.ast.Var */) { + (*(*(*left->_v__ast__PrefixExpr).right._v__ast__Ident).obj._v__ast__Var).is_used = true; } - - else { - } - ; } } if (is_decl) { @@ -45047,17 +45372,26 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; } v__ast__TypeSymbol* left_sym = v__ast__Table_sym(c->table, left_type_unwrapped); v__ast__TypeSymbol* right_sym = v__ast__Table_sym(c->table, right_type_unwrapped); - if (left_sym->kind == v__ast__Kind__array && !c->inside_unsafe && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__array && ((left)->_typ == 305 /* v.ast.Ident */ && !v__ast__Expr_is_blank_ident(/*rec*/*left)) && (right)._typ == 305 /* v.ast.Ident */) { + if (left_sym->kind == v__ast__Kind__array && !c->inside_unsafe && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__array && (left)->_typ == 305 /* v.ast.Ident */ && !v__ast__Expr_is_blank_ident(/*rec*/*left) && (right)._typ == 305 /* v.ast.Ident */) { v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("use `array2 "), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" array1.clone()` instead of `array2 "), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" array1` (or use `unsafe`)"), 0, { .d_c = 0 }}})), node->pos); } - if (left_sym->kind == v__ast__Kind__array_fixed && !c->inside_unsafe && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__array_fixed && ((left)->_typ == 305 /* v.ast.Ident */ && !v__ast__Expr_is_blank_ident(/*rec*/*left)) && (right)._typ == 305 /* v.ast.Ident */) { + if (left_sym->kind == v__ast__Kind__array && right_sym->kind == v__ast__Kind__array) { + v__ast__Array left_info = /* as */ *(v__ast__Array*)__as_cast((left_sym->info)._v__ast__Array,(left_sym->info)._typ, 450) /*expected idx: 450, name: v.ast.Array */ ; + v__ast__Type left_elem_type = v__ast__Table_unaliased_type(c->table, left_info.elem_type); + v__ast__Array right_info = /* as */ *(v__ast__Array*)__as_cast((right_sym->info)._v__ast__Array,(right_sym->info)._typ, 450) /*expected idx: 450, name: v.ast.Array */ ; + v__ast__Type right_elem_type = v__ast__Table_unaliased_type(c->table, right_info.elem_type); + if (left_info.nr_dims == right_info.nr_dims && v__ast__Type_alias_eq(left_elem_type, right_elem_type)) { + continue; + } + } + if (left_sym->kind == v__ast__Kind__array_fixed && !c->inside_unsafe && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__array_fixed && (left)->_typ == 305 /* v.ast.Ident */ && !v__ast__Expr_is_blank_ident(/*rec*/*left) && (right)._typ == 305 /* v.ast.Ident */) { if ((right_sym->info)._typ == 478 /* v.ast.ArrayFixed */) { if (v__ast__Type_is_ptr((*right_sym->info._v__ast__ArrayFixed).elem_type)) { v__checker__Checker_error(c, _SLIT("assignment from one fixed array to another with a pointer element type is prohibited outside of `unsafe`"), node->pos); } } } - if (left_sym->kind == v__ast__Kind__map && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__map && (((right)._typ == 305 /* v.ast.Ident */ && v__ast__Expr_is_auto_deref_var(right)) || !v__ast__Type_is_ptr(right_type)) && !v__ast__Expr_is_blank_ident(/*rec*/*left) && v__ast__Expr_is_lvalue(right)) { + if (left_sym->kind == v__ast__Kind__map && (node->op == v__token__Kind__assign || node->op == v__token__Kind__decl_assign) && right_sym->kind == v__ast__Kind__map && !v__ast__Expr_is_blank_ident(/*rec*/*left) && v__ast__Expr_is_lvalue(right) && (!v__ast__Type_is_ptr(right_type) || ((right)._typ == 305 /* v.ast.Ident */ && v__ast__Expr_is_auto_deref_var(right)))) { v__checker__Checker_error(c, _SLIT("cannot copy map: call `move` or `clone` method (or use a reference)"), v__ast__Expr_pos(right)); } bool left_is_ptr = v__ast__Type_is_ptr(left_type) || v__ast__TypeSymbol_is_pointer(left_sym); @@ -45069,7 +45403,7 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; if (!right_is_ptr && node->op == v__token__Kind__assign && v__ast__Type_is_number(right_type_unwrapped)) { v__checker__Checker_error(c, string__plus( str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot assign to `"), 0xfe10, {.d_s = v__ast__Expr_str(*left)}}, {_SLIT("`: "), 0, { .d_c = 0 }}})), v__checker__Checker_expected_msg(c, right_type_unwrapped, left_type_unwrapped)), v__ast__Expr_pos(right)); } - if (((right)._typ == 330 /* v.ast.StructInit */ || !right_is_ptr) && !(v__ast__TypeSymbol_is_number(right_sym) || v__ast__Type_has_flag(left_type, v__ast__TypeFlag__shared_f))) { + if (!v__ast__TypeSymbol_is_number(right_sym) && !v__ast__Type_has_flag(left_type, v__ast__TypeFlag__shared_f) && ((right)._typ == 330 /* v.ast.StructInit */ || !right_is_ptr)) { string left_name = v__ast__Table_type_to_str(c->table, left_type_unwrapped); v__ast__Type rtype = right_type_unwrapped; if (v__ast__Type_is_ptr(rtype)) { @@ -45157,7 +45491,7 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; } else { }; - if ((node->op == v__token__Kind__plus_assign || node->op == v__token__Kind__minus_assign || node->op == v__token__Kind__mod_assign || node->op == v__token__Kind__mult_assign || node->op == v__token__Kind__div_assign) && ((left_sym->kind == v__ast__Kind__struct_ && right_sym->kind == v__ast__Kind__struct_) || left_sym->kind == v__ast__Kind__alias)) { + if ((node->op == v__token__Kind__plus_assign || node->op == v__token__Kind__minus_assign || node->op == v__token__Kind__mod_assign || node->op == v__token__Kind__mult_assign || node->op == v__token__Kind__div_assign) && (left_sym->kind == v__ast__Kind__alias || (left_sym->kind == v__ast__Kind__struct_ && right_sym->kind == v__ast__Kind__struct_))) { string left_name = v__ast__Table_type_to_str(c->table, left_type_unwrapped); string right_name = v__ast__Table_type_to_str(c->table, right_type_unwrapped); v__ast__TypeSymbol* parent_sym = v__ast__Table_final_sym(c->table, left_type_unwrapped); @@ -45239,7 +45573,7 @@ bool v__checker__Checker_assign_stmt_defer_0 = false; is_shared = (*(*left_first._v__ast__Ident).info._v__ast__IdentVar).share == v__ast__ShareType__shared_t; } bool old_inside_ref_lit = c->inside_ref_lit; - c->inside_ref_lit = (c->inside_ref_lit || right_node.op == v__token__Kind__amp || is_shared); + c->inside_ref_lit = c->inside_ref_lit || right_node.op == v__token__Kind__amp || is_shared; v__checker__Checker_expr(c, right_node.right); c->inside_ref_lit = old_inside_ref_lit; if (right_node.op == v__token__Kind__amp) { @@ -45667,7 +46001,7 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_check_shift(v__checker__Checker v__ast__Type v__checker__Checker_promote(v__checker__Checker* c, v__ast__Type left_type, v__ast__Type right_type) { if (v__ast__Type_is_any_kind_of_pointer(left_type)) { - if (v__ast__Type_is_int(right_type)) { + if (v__ast__Type_is_int(right_type) || c->pref->translated) { v__ast__Type _t1 = left_type; return _t1; } else { @@ -45675,7 +46009,7 @@ v__ast__Type v__checker__Checker_promote(v__checker__Checker* c, v__ast__Type le return _t2; } } else if (v__ast__Type_is_any_kind_of_pointer(right_type)) { - if (v__ast__Type_is_int(left_type)) { + if (v__ast__Type_is_int(left_type) || c->pref->translated) { v__ast__Type _t3 = right_type; return _t3; } else { @@ -45704,10 +46038,10 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_promote_num(v__checker__Checker v__ast__Type type_hi = left_type; v__ast__Type type_lo = right_type; if (v__ast__Type_idx(type_hi) < v__ast__Type_idx(type_lo)) { - v__ast__Type _var_16243 = type_hi; - v__ast__Type _var_16252 = type_lo; - type_hi = _var_16252; - type_lo = _var_16243; + v__ast__Type _var_16285 = type_hi; + v__ast__Type _var_16294 = type_lo; + type_hi = _var_16294; + type_lo = _var_16285; } int idx_hi = v__ast__Type_idx(type_hi); int idx_lo = v__ast__Type_idx(type_lo); @@ -45744,9 +46078,12 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_promote_num(v__checker__Checker } else if (idx_hi - idx_lo < (_const_v__ast__byte_type_idx - _const_v__ast__i8_type_idx)) { v__ast__Type _t9 = type_lo; return _t9; - } else { - v__ast__Type _t10 = _const_v__ast__void_type; + } else if (c->pref->translated) { + v__ast__Type _t10 = type_hi; return _t10; + } else { + v__ast__Type _t11 = _const_v__ast__void_type; + return _t11; } return 0; } @@ -46652,16 +46989,29 @@ v__ast__Type former_expected_type; ; node->left_type = map_info.key_type; } + else if (right_final->kind == (v__ast__Kind__array_fixed)) { + if (!(left_sym->kind == v__ast__Kind__sum_type || left_sym->kind == v__ast__Kind__interface_)) { + v__ast__Type elem_type = v__ast__TypeSymbol_array_fixed_info(right_final).elem_type; + Option_void _t3 = v__checker__Checker_check_expected(c, left_type, elem_type); + if (_t3.state != 0 && _t3.err._typ != _IError_None___index) { + IError err = _t3.err; + v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("left operand to `"), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT("` does not match the fixed array element type: "), 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT0, 0, { .d_c = 0 }}})), left_right_pos); + ; + } + + ; + } + } else { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT("` can only be used with arrays and maps"), 0, { .d_c = 0 }}})), node->pos); }; - v__ast__Type _t3 = _const_v__ast__bool_type; + v__ast__Type _t4 = _const_v__ast__bool_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t3; + return _t4; break; } case v__token__Kind__plus: @@ -46679,14 +47029,14 @@ v__ast__Type former_expected_type; if ((left_sym->info)._typ == 470 /* v.ast.Alias */ && (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 470) /*expected idx: 470, name: v.ast.Alias */ ).language != v__ast__Language__c && string__eq(c->mod, (*(string*)/*ee elem_sym */array_get(string_split(v__ast__Table_type_to_str(c->table, left_type), _SLIT(".")), 0))) && v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 470) /*expected idx: 470, name: v.ast.Alias */ ).parent_type))) { left_sym = v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 470) /*expected idx: 470, name: v.ast.Alias */ ).parent_type); } - if (left_sym->kind == v__ast__Kind__alias && (left_sym->info)._typ == 470 /* v.ast.Alias */ && !(v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 470) /*expected idx: 470, name: v.ast.Alias */ ).parent_type)))) { + if (!c->pref->translated && left_sym->kind == v__ast__Kind__alias && (left_sym->info)._typ == 470 /* v.ast.Alias */ && !(v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((left_sym->info)._v__ast__Alias,(left_sym->info)._typ, 470) /*expected idx: 470, name: v.ast.Alias */ ).parent_type)))) { if (v__ast__TypeSymbol_has_method(left_sym, v__token__Kind_str(node->op))) { - Option_v__ast__Fn _t4; - if (_t4 = v__ast__TypeSymbol_find_method(left_sym, v__token__Kind_str(node->op)), _t4.state == 0) { - v__ast__Fn method = *(v__ast__Fn*)_t4.data; + Option_v__ast__Fn _t5; + if (_t5 = v__ast__TypeSymbol_find_method(left_sym, v__token__Kind_str(node->op)), _t5.state == 0) { + v__ast__Fn method = *(v__ast__Fn*)_t5.data; return_type = method.return_type; } else { - IError err = _t4.err; + IError err = _t5.err; return_type = left_type; } } else { @@ -46698,14 +47048,14 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("mismatched types `"), 0xfe10, {.d_s = left_name}}, {_SLIT("` and `"), 0xfe10, {.d_s = right_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_right_pos); } } - } else if (right_sym->kind == v__ast__Kind__alias && (right_sym->info)._typ == 470 /* v.ast.Alias */ && !(v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((right_sym->info)._v__ast__Alias,(right_sym->info)._typ, 470) /*expected idx: 470, name: v.ast.Alias */ ).parent_type)))) { + } else if (!c->pref->translated && right_sym->kind == v__ast__Kind__alias && (right_sym->info)._typ == 470 /* v.ast.Alias */ && !(v__ast__TypeSymbol_is_primitive(v__ast__Table_sym(c->table, (/* as */ *(v__ast__Alias*)__as_cast((right_sym->info)._v__ast__Alias,(right_sym->info)._typ, 470) /*expected idx: 470, name: v.ast.Alias */ ).parent_type)))) { if (v__ast__TypeSymbol_has_method(right_sym, v__token__Kind_str(node->op))) { - Option_v__ast__Fn _t5; - if (_t5 = v__ast__TypeSymbol_find_method(right_sym, v__token__Kind_str(node->op)), _t5.state == 0) { - v__ast__Fn method = *(v__ast__Fn*)_t5.data; + Option_v__ast__Fn _t6; + if (_t6 = v__ast__TypeSymbol_find_method(right_sym, v__token__Kind_str(node->op)), _t6.state == 0) { + v__ast__Fn method = *(v__ast__Fn*)_t6.data; return_type = method.return_type; } else { - IError err = _t5.err; + IError err = _t6.err; return_type = right_type; } } else { @@ -46720,12 +47070,12 @@ v__ast__Type former_expected_type; } if (left_sym->kind == v__ast__Kind__array || left_sym->kind == v__ast__Kind__array_fixed || left_sym->kind == v__ast__Kind__map || left_sym->kind == v__ast__Kind__struct_) { if (v__ast__TypeSymbol_has_method_with_generic_parent(left_sym, v__token__Kind_str(node->op))) { - Option_v__ast__Fn _t6; - if (_t6 = v__ast__TypeSymbol_find_method_with_generic_parent(left_sym, v__token__Kind_str(node->op)), _t6.state == 0) { - v__ast__Fn method = *(v__ast__Fn*)_t6.data; + Option_v__ast__Fn _t7; + if (_t7 = v__ast__TypeSymbol_find_method_with_generic_parent(left_sym, v__token__Kind_str(node->op)), _t7.state == 0) { + v__ast__Fn method = *(v__ast__Fn*)_t7.data; return_type = method.return_type; } else { - IError err = _t6.err; + IError err = _t7.err; return_type = left_type; } } else { @@ -46739,12 +47089,12 @@ v__ast__Type former_expected_type; } } else if (right_sym->kind == v__ast__Kind__array || right_sym->kind == v__ast__Kind__array_fixed || right_sym->kind == v__ast__Kind__map || right_sym->kind == v__ast__Kind__struct_) { if (v__ast__TypeSymbol_has_method_with_generic_parent(right_sym, v__token__Kind_str(node->op))) { - Option_v__ast__Fn _t7; - if (_t7 = v__ast__TypeSymbol_find_method_with_generic_parent(right_sym, v__token__Kind_str(node->op)), _t7.state == 0) { - v__ast__Fn method = *(v__ast__Fn*)_t7.data; + Option_v__ast__Fn _t8; + if (_t8 = v__ast__TypeSymbol_find_method_with_generic_parent(right_sym, v__token__Kind_str(node->op)), _t8.state == 0) { + v__ast__Fn method = *(v__ast__Fn*)_t8.data; return_type = method.return_type; } else { - IError err = _t7.err; + IError err = _t8.err; return_type = right_type; } } else { @@ -46806,13 +47156,13 @@ v__ast__Type former_expected_type; if ((left_sym->kind == v__ast__Kind__array || left_sym->kind == v__ast__Kind__array_fixed) && (right_sym->kind == v__ast__Kind__array || right_sym->kind == v__ast__Kind__array_fixed)) { v__checker__Checker_error(c, _SLIT("only `==` and `!=` are defined on arrays"), node->pos); } else if (left_sym->kind == v__ast__Kind__struct_ && (/* as */ *(v__ast__Struct*)__as_cast((left_sym->info)._v__ast__Struct,(left_sym->info)._typ, 455) /*expected idx: 455, name: v.ast.Struct */ ).generic_types.len > 0) { - v__ast__Type _t8 = _const_v__ast__bool_type; + v__ast__Type _t9 = _const_v__ast__bool_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t8; + return _t9; } else if (left_sym->kind == v__ast__Kind__struct_ && right_sym->kind == v__ast__Kind__struct_ && (node->op == v__token__Kind__eq || node->op == v__token__Kind__lt)) { if (!(v__ast__TypeSymbol_has_method(left_sym, v__token__Kind_str(node->op)) && v__ast__TypeSymbol_has_method(right_sym, v__token__Kind_str(node->op)))) { string left_name = v__ast__Table_type_to_str(c->table, left_type); @@ -46871,8 +47221,8 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, _SLIT("array append cannot be used in an expression"), node->pos); } v__checker__Checker_check_expr_opt_call(c, node->right, right_type); - multi_return_string_v__token__Pos mr_32778 = v__checker__Checker_fail_if_immutable(c, node->left); - node->auto_locked = mr_32778.arg0; + multi_return_string_v__token__Pos mr_33156 = v__checker__Checker_fail_if_immutable(c, node->left); + node->auto_locked = mr_33156.arg0; v__ast__Type left_value_type = v__ast__Table_value_type(c->table, v__checker__Checker_unwrap_generic(c, left_type)); v__ast__TypeSymbol* left_value_sym = v__ast__Table_sym(c->table, v__checker__Checker_unwrap_generic(c, left_value_type)); if (left_value_sym->kind == v__ast__Kind__interface_) { @@ -46885,13 +47235,13 @@ v__ast__Type former_expected_type; } else { v__checker__Checker_type_implements(c, v__ast__Table_value_type(c->table, right_type), left_value_type, right_pos); } - v__ast__Type _t9 = _const_v__ast__void_type; + v__ast__Type _t10 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t9; + return _t10; } else if (left_value_sym->kind == v__ast__Kind__sum_type) { if (right_final->kind != v__ast__Kind__array) { if (!v__ast__Table_is_sumtype_or_in_variant(c->table, left_value_type, right_type)) { @@ -46903,86 +47253,86 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot append `"), 0xfe10, {.d_s = right_sym->name}}, {_SLIT("` to `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), right_pos); } } - v__ast__Type _t10 = _const_v__ast__void_type; + v__ast__Type _t11 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t10; + return _t11; } v__ast__Type unwrapped_right_type = v__checker__Checker_unwrap_generic(c, right_type); if (v__checker__Checker_check_types(c, unwrapped_right_type, left_value_type)) { if (!(!v__ast__Type_is_ptr(unwrapped_right_type) && v__ast__Type_is_ptr(left_value_type) && v__ast__Type_share(left_value_type) == v__ast__ShareType__mut_t)) { - v__ast__Type _t11 = _const_v__ast__void_type; + v__ast__Type _t12 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t11; + return _t12; } } else if (v__checker__Checker_check_types(c, unwrapped_right_type, v__checker__Checker_unwrap_generic(c, left_type))) { - v__ast__Type _t12 = _const_v__ast__void_type; + v__ast__Type _t13 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t12; + return _t13; } v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot append `"), 0xfe10, {.d_s = right_sym->name}}, {_SLIT("` to `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), right_pos); - v__ast__Type _t13 = _const_v__ast__void_type; - // Defer begin - if (v__checker__Checker_infix_expr_defer_0) { - c->expected_type = former_expected_type; - } - // Defer end - return _t13; - } else { - v__ast__Type _t14 = v__checker__Checker_check_shift(c, node, left_type, right_type); + v__ast__Type _t14 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end return _t14; - } - break; - } - case v__token__Kind__right_shift: - { - v__ast__Type _t15 = v__checker__Checker_check_shift(c, node, left_type, right_type); - // Defer begin - if (v__checker__Checker_infix_expr_defer_0) { - c->expected_type = former_expected_type; - } - // Defer end - return _t15; - break; - } - case v__token__Kind__unsigned_right_shift: - { - int _t16; /* if prepend */ - if (!v__ast__Type_is_int(left_type)) { - v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid operation: shift on type `"), 0xfe10, {.d_s = v__ast__Table_sym(c->table, left_type)->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_pos); - _t16 = _const_v__ast__void_type_idx; - } else if (v__ast__Type_is_int_literal(left_type)) { - _t16 = _const_v__ast__u32_type_idx; - } else if (v__ast__Type_is_unsigned(left_type)) { - _t16 = left_type; } else { - _t16 = v__ast__Type_idx(left_type) + _const_v__ast__u32_type_idx - _const_v__ast__int_type_idx; - } - int modified_left_type = _t16; - if (modified_left_type == 0) { - v__ast__Type _t17 = _const_v__ast__void_type; + v__ast__Type _t15 = v__checker__Checker_check_shift(c, node, left_type, right_type); // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t17; + return _t15; + } + break; + } + case v__token__Kind__right_shift: + { + v__ast__Type _t16 = v__checker__Checker_check_shift(c, node, left_type, right_type); + // Defer begin + if (v__checker__Checker_infix_expr_defer_0) { + c->expected_type = former_expected_type; + } + // Defer end + return _t16; + break; + } + case v__token__Kind__unsigned_right_shift: + { + int _t17; /* if prepend */ + if (!v__ast__Type_is_int(left_type)) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid operation: shift on type `"), 0xfe10, {.d_s = v__ast__Table_sym(c->table, left_type)->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_pos); + _t17 = _const_v__ast__void_type_idx; + } else if (v__ast__Type_is_int_literal(left_type)) { + _t17 = _const_v__ast__u32_type_idx; + } else if (v__ast__Type_is_unsigned(left_type)) { + _t17 = left_type; + } else { + _t17 = v__ast__Type_idx(left_type) + _const_v__ast__u32_type_idx - _const_v__ast__int_type_idx; + } + int modified_left_type = _t17; + if (modified_left_type == 0) { + v__ast__Type _t18 = _const_v__ast__void_type; + // Defer begin + if (v__checker__Checker_infix_expr_defer_0) { + c->expected_type = former_expected_type; + } + // Defer end + return _t18; } *node = ((v__ast__InfixExpr){ .op = v__token__Kind__right_shift, @@ -46999,32 +47349,32 @@ v__ast__Type former_expected_type; .ct_right_value_evaled = 0, .ct_right_value = v__ast__empty_comptime_const_expr(), }); - v__ast__Type _t18 = v__checker__Checker_check_shift(c, node, left_type, right_type); + v__ast__Type _t19 = v__checker__Checker_check_shift(c, node, left_type, right_type); // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t18; + return _t19; break; } case v__token__Kind__key_is: case v__token__Kind__not_is: { v__ast__Expr right_expr = node->right; - v__ast__Type _t19 = 0; + v__ast__Type _t20 = 0; if (right_expr._typ == 331 /* v.ast.TypeNode */) { - _t19 = (*right_expr._v__ast__TypeNode).typ; + _t20 = (*right_expr._v__ast__TypeNode).typ; } else if (right_expr._typ == 317 /* v.ast.None */) { - _t19 = _const_v__ast__none_type_idx; + _t20 = _const_v__ast__none_type_idx; } else { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid type `"), 0xfe10, {.d_s = v__ast__Expr_str(right_expr)}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(right_expr)); - _t19 = ((v__ast__Type)(0)); + _t20 = ((v__ast__Type)(0)); } - v__ast__Type typ = _t19; + v__ast__Type typ = _t20; if (!v__ast__Type_alias_eq(typ, ((v__ast__Type)(0)))) { v__ast__TypeSymbol* typ_sym = v__ast__Table_sym(c->table, typ); string op = v__token__Kind_str(node->op); @@ -47043,13 +47393,13 @@ v__ast__Type former_expected_type; } } } - v__ast__Type _t20 = _const_v__ast__bool_type; + v__ast__Type _t21 = _const_v__ast__bool_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t20; + return _t21; break; } case v__token__Kind__arrow: @@ -47070,13 +47420,13 @@ v__ast__Type former_expected_type; } else { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot push on non-channel `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_pos); } - v__ast__Type _t21 = _const_v__ast__void_type; + v__ast__Type _t22 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t21; + return _t22; break; } case v__token__Kind__and: @@ -47221,16 +47571,7 @@ v__ast__Type former_expected_type; } if (!(v__checker__Checker_symmetric_check(c, left_type, right_type) && v__checker__Checker_symmetric_check(c, right_type, left_type)) && !c->pref->translated && !c->file->is_translated && !v__ast__Expr_is_auto_deref_var(node->left) && !v__ast__Expr_is_auto_deref_var(node->right)) { if (v__ast__Type_alias_eq(left_type, _const_v__ast__void_type) || v__ast__Type_alias_eq(right_type, _const_v__ast__void_type)) { - v__ast__Type _t22 = _const_v__ast__void_type; - // Defer begin - if (v__checker__Checker_infix_expr_defer_0) { - c->expected_type = former_expected_type; - } - // Defer end - return _t22; - } - if (v__ast__Type_nr_muls(left_type) > 0 && v__ast__Type_is_int(right_type)) { - v__ast__Type _t23 = return_type; + v__ast__Type _t23 = _const_v__ast__void_type; // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; @@ -47238,15 +47579,24 @@ v__ast__Type former_expected_type; // Defer end return _t23; } + if (v__ast__Type_nr_muls(left_type) > 0 && v__ast__Type_is_int(right_type)) { + v__ast__Type _t24 = return_type; + // Defer begin + if (v__checker__Checker_infix_expr_defer_0) { + c->expected_type = former_expected_type; + } + // Defer end + return _t24; + } v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("infix expr: cannot use `"), 0xfe10, {.d_s = right_sym->name}}, {_SLIT("` (right expression) as `"), 0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), left_right_pos); } - v__ast__Type _t24 = (v__token__Kind_is_relational(node->op) ? (_const_v__ast__bool_type) : (return_type)); + v__ast__Type _t25 = (v__token__Kind_is_relational(node->op) ? (_const_v__ast__bool_type) : (return_type)); // Defer begin if (v__checker__Checker_infix_expr_defer_0) { c->expected_type = former_expected_type; } // Defer end - return _t24; + return _t25; } VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_immutable(v__checker__Checker* c, v__ast__Expr expr_) { @@ -47308,19 +47658,19 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im if (v__ast__Type_has_flag(elem_type, v__ast__TypeFlag__shared_f)) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("you have to create a handle and `lock` it to modify `shared` "), 0xfe10, {.d_s = kind}}, {_SLIT(" element"), 0, { .d_c = 0 }}})), v__token__Pos_extend(v__ast__Expr_pos((*expr._v__ast__IndexExpr).left), (*expr._v__ast__IndexExpr).pos)); } - multi_return_string_v__token__Pos mr_43154 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); - to_lock = mr_43154.arg0; - pos = mr_43154.arg1; + multi_return_string_v__token__Pos mr_43532 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); + to_lock = mr_43532.arg0; + pos = mr_43532.arg1; } else if (expr._typ == 320 /* v.ast.ParExpr */) { - multi_return_string_v__token__Pos mr_43223 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); - to_lock = mr_43223.arg0; - pos = mr_43223.arg1; + multi_return_string_v__token__Pos mr_43601 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); + to_lock = mr_43601.arg0; + pos = mr_43601.arg1; } else if (expr._typ == 322 /* v.ast.PrefixExpr */) { - multi_return_string_v__token__Pos mr_43295 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); - to_lock = mr_43295.arg0; - pos = mr_43295.arg1; + multi_return_string_v__token__Pos mr_43673 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); + to_lock = mr_43673.arg0; + pos = mr_43673.arg1; } else if (expr._typ == 325 /* v.ast.SelectorExpr */) { if ((*expr._v__ast__SelectorExpr).expr_type == 0) { @@ -47370,9 +47720,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im string type_str = v__ast__Table_type_to_str(c->table, (*expr._v__ast__SelectorExpr).expr_type); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("field `"), 0xfe10, {.d_s = (*expr._v__ast__SelectorExpr).field_name}}, {_SLIT("` of struct `"), 0xfe10, {.d_s = type_str}}, {_SLIT("` is immutable"), 0, { .d_c = 0 }}})), (*expr._v__ast__SelectorExpr).pos); } - multi_return_string_v__token__Pos mr_44759 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); - to_lock = mr_44759.arg0; - pos = mr_44759.arg1; + multi_return_string_v__token__Pos mr_45137 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); + to_lock = mr_45137.arg0; + pos = mr_45137.arg1; } if ((to_lock).len != 0) { explicit_lock_needed = true; @@ -47478,9 +47828,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im } else if (expr._typ == 291 /* v.ast.CallExpr */) { if (string__eq((*expr._v__ast__CallExpr).name, _SLIT("slice"))) { - multi_return_string_v__token__Pos mr_46582 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); - to_lock = mr_46582.arg0; - pos = mr_46582.arg1; + multi_return_string_v__token__Pos mr_46960 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); + to_lock = mr_46960.arg0; + pos = mr_46960.arg1; if ((to_lock).len != 0) { explicit_lock_needed = true; } @@ -47880,9 +48230,9 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t13.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_59690 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); - field = mr_59690.arg0; - embed_types = mr_59690.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_60068 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); + field = mr_60068.arg0; + embed_types = mr_60068.arg1; node->from_embed_types = embed_types; if (sym->kind == v__ast__Kind__aggregate || sym->kind == v__ast__Kind__sum_type) { unknown_field_msg = IError_name_table[err._typ]._method_msg(err._object); @@ -47916,9 +48266,9 @@ v__ast__Type v__checker__Checker_selector_expr(v__checker__Checker* c, v__ast__S *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t15.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_60521 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); - field = mr_60521.arg0; - embed_types = mr_60521.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_60899 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); + field = mr_60899.arg0; + embed_types = mr_60899.arg1; node->from_embed_types = embed_types; } } @@ -48438,7 +48788,8 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as return; } - if (string__eq(node->kind, _SLIT("include"))) { + if (string__eq(node->kind, _SLIT("include")) || string__eq(node->kind, _SLIT("insert"))) { + string original_flag = node->main; string flag = node->main; if (string_contains(flag, _SLIT("@VROOT"))) { Option_string _t1 = v__util__resolve_vmodroot(string_replace(flag, _SLIT("@VROOT"), _SLIT("@VMODROOT")), c->file->path); @@ -48449,13 +48800,13 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as } string vroot = (*(string*)_t1.data); - node->val = str_intp(2, _MOV((StrIntpData[]){{_SLIT("include "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); + node->val = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = node->kind}}, {_SLIT(" "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); node->main = vroot; flag = vroot; } if (string_contains(flag, _SLIT("@VEXEROOT"))) { string vroot = string_replace(flag, _SLIT("@VEXEROOT"), os__dir(v__pref__vexe_path())); - node->val = str_intp(2, _MOV((StrIntpData[]){{_SLIT("include "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); + node->val = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = node->kind}}, {_SLIT(" "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); node->main = vroot; flag = vroot; } @@ -48468,7 +48819,7 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as } string vroot = (*(string*)_t2.data); - node->val = str_intp(2, _MOV((StrIntpData[]){{_SLIT("include "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); + node->val = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = node->kind}}, {_SLIT(" "), 0xfe10, {.d_s = vroot}}, {_SLIT0, 0, { .d_c = 0 }}})); node->main = vroot; flag = vroot; } @@ -48484,54 +48835,66 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as node->main = env; } string flag_no_comment = string_trim_space(string_all_before(flag, _SLIT("//"))); - if (!((string_starts_with(flag_no_comment, _SLIT("\"")) && string_ends_with(flag_no_comment, _SLIT("\""))) || (string_starts_with(flag_no_comment, _SLIT("<")) && string_ends_with(flag_no_comment, _SLIT(">"))))) { - v__checker__Checker_error(c, _SLIT("including C files should use either `\"header_file.h\"` or `` quoting"), node->pos); + if (string__eq(node->kind, _SLIT("include"))) { + if (!((string_starts_with(flag_no_comment, _SLIT("\"")) && string_ends_with(flag_no_comment, _SLIT("\""))) || (string_starts_with(flag_no_comment, _SLIT("<")) && string_ends_with(flag_no_comment, _SLIT(">"))))) { + v__checker__Checker_error(c, _SLIT("including C files should use either `\"header_file.h\"` or `` quoting"), node->pos); + } + } + if (string__eq(node->kind, _SLIT("insert"))) { + if (!(string_starts_with(flag_no_comment, _SLIT("\"")) && string_ends_with(flag_no_comment, _SLIT("\"")))) { + v__checker__Checker_error(c, _SLIT("inserting .c or .h files, should use `\"header_file.h\"` quoting"), node->pos); + } + node->main = string_trim(node->main, _SLIT("\"")); + Option_string _t4; + if (_t4 = os__read_file(node->main), _t4.state == 0) { + string fcontent = *(string*)_t4.data; + node->val = fcontent; + } else { + IError err = _t4.err; + string missing_message = str_intp(3, _MOV((StrIntpData[]){{_SLIT("The file "), 0xfe10, {.d_s = original_flag}}, {_SLIT(", needed for insertion by module `"), 0xfe10, {.d_s = node->mod}}, {_SLIT("`,"), 0, { .d_c = 0 }}})); + if (os__is_file(node->main)) { + missing_message = /*f*/string__plus(missing_message, _SLIT(" is not readable.")); + } else { + missing_message = /*f*/string__plus(missing_message, _SLIT(" does not exist.")); + } + if ((node->msg).len != 0) { + missing_message = /*f*/string__plus(missing_message, str_intp(2, _MOV((StrIntpData[]){{_SLIT(" "), 0xfe10, {.d_s = node->msg}}, {_SLIT("."), 0, { .d_c = 0 }}}))); + } + v__checker__Checker_error(c, missing_message, node->pos); + } } } else if (string__eq(node->kind, _SLIT("pkgconfig"))) { Array_string args = (string_contains(node->main, _SLIT("--")) ? (string_split(node->main, _SLIT(" "))) : (string_split( str_intp(2, _MOV((StrIntpData[]){{_SLIT("--cflags --libs "), 0xfe10, {.d_s = node->main}}, {_SLIT0, 0, { .d_c = 0 }}})), _SLIT(" ")))); - Option_v__pkgconfig__Main_ptr _t4 = v__pkgconfig__main(args); - if (_t4.state != 0) { /*or block*/ - IError err = _t4.err; - v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); - return; - } - - v__pkgconfig__Main* m = (*(v__pkgconfig__Main**)_t4.data); - Option_string _t5 = v__pkgconfig__Main_run(m); + Option_v__pkgconfig__Main_ptr _t5 = v__pkgconfig__main(args); if (_t5.state != 0) { /*or block*/ IError err = _t5.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); return; } - string cflags = (*(string*)_t5.data); - Option_bool _t6 = v__ast__Table_parse_cflag(c->table, cflags, c->mod, c->pref->compile_defines_all); + v__pkgconfig__Main* m = (*(v__pkgconfig__Main**)_t5.data); + Option_string _t6 = v__pkgconfig__Main_run(m); if (_t6.state != 0) { /*or block*/ IError err = _t6.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); return; } - (*(bool*)_t6.data); + string cflags = (*(string*)_t6.data); + Option_bool _t7 = v__ast__Table_parse_cflag(c->table, cflags, c->mod, c->pref->compile_defines_all); + if (_t7.state != 0) { /*or block*/ + IError err = _t7.err; + v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); + return; + } + + (*(bool*)_t7.data); } else if (string__eq(node->kind, _SLIT("flag"))) { string flag = node->main; if (string_contains(flag, _SLIT("@VROOT"))) { - Option_string _t7 = v__util__resolve_vmodroot(string_replace(flag, _SLIT("@VROOT"), _SLIT("@VMODROOT")), c->file->path); - if (_t7.state != 0) { /*or block*/ - IError err = _t7.err; - v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); - return; - } - - flag = (*(string*)_t7.data); - } - if (string_contains(flag, _SLIT("@VEXEROOT"))) { - flag = string_replace(flag, _SLIT("@VEXEROOT"), os__dir(v__pref__vexe_path())); - } - if (string_contains(flag, _SLIT("@VMODROOT"))) { - Option_string _t8 = v__util__resolve_vmodroot(flag, c->file->path); + Option_string _t8 = v__util__resolve_vmodroot(string_replace(flag, _SLIT("@VROOT"), _SLIT("@VMODROOT")), c->file->path); if (_t8.state != 0) { /*or block*/ IError err = _t8.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); @@ -48540,8 +48903,11 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as flag = (*(string*)_t8.data); } - if (string_contains(flag, _SLIT("$env("))) { - Option_string _t9 = v__util__resolve_env_value(flag, true); + if (string_contains(flag, _SLIT("@VEXEROOT"))) { + flag = string_replace(flag, _SLIT("@VEXEROOT"), os__dir(v__pref__vexe_path())); + } + if (string_contains(flag, _SLIT("@VMODROOT"))) { + Option_string _t9 = v__util__resolve_vmodroot(flag, c->file->path); if (_t9.state != 0) { /*or block*/ IError err = _t9.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); @@ -48550,27 +48916,37 @@ VV_LOCAL_SYMBOL void v__checker__Checker_hash_stmt(v__checker__Checker* c, v__as flag = (*(string*)_t9.data); } - Array_string _t10 = new_array_from_c_array(4, 4, sizeof(string), _MOV((string[4]){_SLIT("@VMOD"), _SLIT("@VMODULE"), _SLIT("@VPATH"), _SLIT("@VLIB_PATH")})); - for (int _t11 = 0; _t11 < _t10.len; ++_t11) { - string deprecated = ((string*)_t10.data)[_t11]; + if (string_contains(flag, _SLIT("$env("))) { + Option_string _t10 = v__util__resolve_env_value(flag, true); + if (_t10.state != 0) { /*or block*/ + IError err = _t10.err; + v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); + return; + } + + flag = (*(string*)_t10.data); + } + Array_string _t11 = new_array_from_c_array(4, 4, sizeof(string), _MOV((string[4]){_SLIT("@VMOD"), _SLIT("@VMODULE"), _SLIT("@VPATH"), _SLIT("@VLIB_PATH")})); + for (int _t12 = 0; _t12 < _t11.len; ++_t12) { + string deprecated = ((string*)_t11.data)[_t12]; if (string_contains(flag, deprecated)) { if (!string_contains(flag, _SLIT("@VMODROOT"))) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = deprecated}}, {_SLIT(" had been deprecated, use @VMODROOT instead."), 0, { .d_c = 0 }}})), node->pos); } } } - Option_bool _t12 = v__ast__Table_parse_cflag(c->table, flag, c->mod, c->pref->compile_defines_all); - if (_t12.state != 0) { /*or block*/ - IError err = _t12.err; + Option_bool _t13 = v__ast__Table_parse_cflag(c->table, flag, c->mod, c->pref->compile_defines_all); + if (_t13.state != 0) { /*or block*/ + IError err = _t13.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->pos); ; } - (*(bool*)_t12.data); + (*(bool*)_t13.data); } else { if (!string__eq(node->kind, _SLIT("define"))) { - v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("expected `#define`, `#flag`, `#include` or `#pkgconfig` not "), 0xfe10, {.d_s = node->val}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("expected `#define`, `#flag`, `#include`, `#insert` or `#pkgconfig` not "), 0xfe10, {.d_s = node->val}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); } }; } @@ -50009,7 +50385,7 @@ v__ast__Type v__checker__Checker_lock_expr(v__checker__Checker* c, v__ast__LockE c->locked_names = __new_array_with_default(0, 0, sizeof(string), 0); v__ast__Type ret_type = _const_v__ast__void_type; if (node->stmts.len > 0) { - v__ast__Stmt last_stmt = (*(v__ast__Stmt*)/*ee elem_sym */array_get(node->stmts, node->stmts.len - 1)); + v__ast__Stmt last_stmt = (*(v__ast__Stmt*)array_last(node->stmts)); if ((last_stmt)._typ == 345 /* v.ast.ExprStmt */) { ret_type = (*last_stmt._v__ast__ExprStmt).typ; } @@ -50116,8 +50492,8 @@ v__ast__Type v__checker__Checker_postfix_expr(v__checker__Checker* c, v__ast__Po string typ_str = v__ast__Table_type_to_str(c->table, typ); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("invalid operation: "), 0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" (non-numeric type `"), 0xfe10, {.d_s = typ_str}}, {_SLIT("`)"), 0, { .d_c = 0 }}})), node->pos); } else { - multi_return_string_v__token__Pos mr_113972 = v__checker__Checker_fail_if_immutable(c, node->expr); - node->auto_locked = mr_113972.arg0; + multi_return_string_v__token__Pos mr_115132 = v__checker__Checker_fail_if_immutable(c, node->expr); + node->auto_locked = mr_115132.arg0; } v__ast__Type _t1 = typ; return _t1; @@ -53206,7 +53582,7 @@ v__ast__Scope* prev_fn_scope; } c->expected_type = _const_v__ast__void_type; c->table->cur_fn = node; - if (!v__ast__Type_alias_eq(node->return_type, _const_v__ast__void_type) && v__ast__Type_has_flag(node->return_type, v__ast__TypeFlag__optional) && (node->stmts.len == 0 || ((*(v__ast__Stmt*)/*ee elem_sym */array_get(node->stmts, node->stmts.len - 1)))._typ != 356 /* v.ast.Return */)) { + if (!v__ast__Type_alias_eq(node->return_type, _const_v__ast__void_type) && v__ast__Type_has_flag(node->return_type, v__ast__TypeFlag__optional) && (node->stmts.len == 0 || ((*(v__ast__Stmt*)array_last(node->stmts)))._typ != 356 /* v.ast.Return */)) { v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, node->return_type); if (sym->kind == v__ast__Kind__void) { array_push((array*)&node->stmts, _MOV((v__ast__Stmt[]){ v__ast__Return_to_sumtype_v__ast__Stmt(ADDR(v__ast__Return, (((v__ast__Return){.pos = node->pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.exprs = __new_array(0, 0, sizeof(v__ast__Expr)),.types = __new_array(0, 0, sizeof(v__ast__Type)),})))) })); @@ -53638,8 +54014,8 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__checker__Checker_error(c, _SLIT("cannot call a function that does not have a body"), node->pos); } if (node->concrete_types.len > 0 && func.generic_names.len > 0 && node->concrete_types.len != func.generic_names.len) { - string desc = (node->concrete_types.len > func.generic_names.len ? (_SLIT("many")) : (_SLIT("little"))); - v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("too "), 0xfe10, {.d_s = desc}}, {_SLIT(" generic parameters got "), 0xfe07, {.d_i32 = node->concrete_types.len}}, {_SLIT(", expected "), 0xfe07, {.d_i32 = func.generic_names.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->concrete_list_pos); + string plural = (func.generic_names.len == 1 ? (_SLIT("")) : (_SLIT("s"))); + v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("expected "), 0xfe07, {.d_i32 = func.generic_names.len}}, {_SLIT(" generic parameter"), 0xfe10, {.d_s = plural}}, {_SLIT(", got "), 0xfe07, {.d_i32 = node->concrete_types.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->concrete_list_pos); } for (int _t30 = 0; _t30 < node->concrete_types.len; ++_t30) { v__ast__Type concrete_type = ((v__ast__Type*)node->concrete_types.data)[_t30]; @@ -53740,9 +54116,9 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__checker__Checker_error(c, _SLIT("function with `shared` arguments cannot be called inside `lock`/`rlock` block"), call_arg->pos); } if (call_arg->is_mut) { - multi_return_string_v__token__Pos mr_28570 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); - string to_lock = mr_28570.arg0; - v__token__Pos pos = mr_28570.arg1; + multi_return_string_v__token__Pos mr_28526 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); + string to_lock = mr_28526.arg0; + v__token__Pos pos = mr_28526.arg1; if (!v__ast__Expr_is_lvalue(call_arg->expr)) { v__checker__Checker_error(c, _SLIT("cannot pass expression as `mut`"), v__ast__Expr_pos(call_arg->expr)); } @@ -54085,9 +54461,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal *(multi_return_v__ast__Fn_Array_v__ast__Type*) _t22.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.is_variadic = 0,.language = 0,.is_pub = 0,.is_ctor_new = 0,.is_deprecated = 0,.is_noreturn = 0,.is_unsafe = 0,.is_placeholder = 0,.is_main = 0,.is_test = 0,.is_keep_alive = 0,.is_method = 0,.no_body = 0,.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.file_mode = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type = 0,.receiver_type = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.params = __new_array(0, 0, sizeof(v__ast__Param)),.source_fn = 0,.usages = 0,.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_conditional = 0,.ctdefine_idx = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_41789 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t22.data); - method = mr_41789.arg0; - embed_types = mr_41789.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_41745 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t22.data); + method = mr_41745.arg0; + embed_types = mr_41745.arg1; if (embed_types.len != 0) { is_method_from_embed = true; node->from_embed_types = embed_types; @@ -54108,9 +54484,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("method with `shared` receiver cannot be called inside `lock`/`rlock` block"), node->pos); } if ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, 0)).is_mut) { - multi_return_string_v__token__Pos mr_42920 = v__checker__Checker_fail_if_immutable(c, node->left); - string to_lock = mr_42920.arg0; - v__token__Pos pos = mr_42920.arg1; + multi_return_string_v__token__Pos mr_42876 = v__checker__Checker_fail_if_immutable(c, node->left); + string to_lock = mr_42876.arg0; + v__token__Pos pos = mr_42876.arg1; if (!v__ast__Expr_is_lvalue(node->left)) { v__checker__Checker_error(c, _SLIT("cannot pass expression as `mut`"), v__ast__Expr_pos(node->left)); } @@ -54124,8 +54500,8 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("cannot call a method that does not have a body"), node->pos); } if (node->concrete_types.len > 0 && method.generic_names.len > 0 && node->concrete_types.len != method.generic_names.len) { - string desc = (node->concrete_types.len > method.generic_names.len ? (_SLIT("many")) : (_SLIT("little"))); - v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("too "), 0xfe10, {.d_s = desc}}, {_SLIT(" generic parameters got "), 0xfe07, {.d_i32 = node->concrete_types.len}}, {_SLIT(", expected "), 0xfe07, {.d_i32 = method.generic_names.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->concrete_list_pos); + string plural = (method.generic_names.len == 1 ? (_SLIT("")) : (_SLIT("s"))); + v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("expected "), 0xfe07, {.d_i32 = method.generic_names.len}}, {_SLIT(" generic parameter"), 0xfe10, {.d_s = plural}}, {_SLIT(", got "), 0xfe07, {.d_i32 = node->concrete_types.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->concrete_list_pos); } for (int _t23 = 0; _t23 < node->concrete_types.len; ++_t23) { v__ast__Type concrete_type = ((v__ast__Type*)node->concrete_types.data)[_t23]; @@ -54212,9 +54588,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT("method with `shared` arguments cannot be called inside `lock`/`rlock` block"), arg->pos); } if (arg->is_mut) { - multi_return_string_v__token__Pos mr_46934 = v__checker__Checker_fail_if_immutable(c, arg->expr); - string to_lock = mr_46934.arg0; - v__token__Pos pos = mr_46934.arg1; + multi_return_string_v__token__Pos mr_46845 = v__checker__Checker_fail_if_immutable(c, arg->expr); + string to_lock = mr_46845.arg0; + v__token__Pos pos = mr_46845.arg1; if (!param_is_mut) { string tok = v__ast__ShareType_str(arg->share); v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = node->name}}, {_SLIT("` parameter `"), 0xfe10, {.d_s = param.name}}, {_SLIT("` is not `"), 0xfe10, {.d_s = tok}}, {_SLIT("`, `"), 0xfe10, {.d_s = tok}}, {_SLIT("` is not needed`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(arg->expr)); @@ -54396,8 +54772,8 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal return _t43; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_53834 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t42.data); - node->from_embed_types = mr_53834.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_53745 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t42.data); + node->from_embed_types = mr_53745.arg1; v__ast__Type _t44 = info.func.return_type; return _t44; } @@ -54763,6 +55139,16 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch } else if (string__eq(method_name, _SLIT("sort"))) { node->return_type = _const_v__ast__void_type; } else if (string__eq(method_name, _SLIT("contains"))) { + if (node->args.len != 1) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`.contains()` expected 1 argument, but got "), 0xfe07, {.d_i32 = node->args.len}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); + } else { + v__ast__Type arg_typ = v__ast__mktyp(v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr)); + string elem_typ_str = v__ast__Table_type_to_str(c->table, elem_typ); + string arg_typ_str = v__ast__Table_type_to_str(c->table, arg_typ); + if (!v__ast__TypeSymbol_has_method(&left_sym, _SLIT("contains")) && !string__eq(elem_typ_str, arg_typ_str)) { + v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("`.contains()` expected `"), 0xfe10, {.d_s = elem_typ_str}}, {_SLIT("` argument, but got `"), 0xfe10, {.d_s = arg_typ_str}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->pos); + } + } node->return_type = _const_v__ast__bool_type; } else if (string__eq(method_name, _SLIT("index"))) { node->return_type = _const_v__ast__int_type; @@ -54958,7 +55344,7 @@ bool v__checker__Checker_if_expr_defer_0 = false; bool node_is_expr = false; if (node->branches.len > 0 && node->has_else) { Array_v__ast__Stmt stmts = (*(v__ast__IfBranch*)/*ee elem_sym */array_get(node->branches, 0)).stmts; - if (stmts.len > 0 && ((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._typ == 345 /* v.ast.ExprStmt */ && !v__ast__Type_alias_eq((/* as */ *(v__ast__ExprStmt*)__as_cast(((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._v__ast__ExprStmt,((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._typ, 345) /*expected idx: 345, name: v.ast.ExprStmt */ ).typ, _const_v__ast__void_type)) { + if (stmts.len > 0 && ((*(v__ast__Stmt*)array_last(stmts)))._typ == 345 /* v.ast.ExprStmt */ && !v__ast__Type_alias_eq((/* as */ *(v__ast__ExprStmt*)__as_cast(((*(v__ast__Stmt*)array_last(stmts)))._v__ast__ExprStmt,((*(v__ast__Stmt*)array_last(stmts)))._typ, 345) /*expected idx: 345, name: v.ast.ExprStmt */ ).typ, _const_v__ast__void_type)) { node_is_expr = true; } } @@ -55111,6 +55497,12 @@ bool v__checker__Checker_if_expr_defer_0 = false; continue; } last_expr.typ = v__checker__Checker_expr(c, last_expr.expr); + if (v__ast__Table_type_kind(c->table, c->expected_type) == v__ast__Kind__multi_return && v__ast__Table_type_kind(c->table, last_expr.typ) == v__ast__Kind__multi_return) { + if (v__ast__Type_alias_eq(node->typ, _const_v__ast__void_type)) { + node->is_expr = true; + node->typ = c->expected_type; + } + } if (!v__checker__Checker_check_types(c, last_expr.typ, node->typ)) { if (v__ast__Type_alias_eq(node->typ, _const_v__ast__void_type)) { node->is_expr = true; @@ -55147,16 +55539,35 @@ bool v__checker__Checker_if_expr_defer_0 = false; if (v__checker__is_noreturn_callexpr(last_expr.expr)) { continue; } + v__ast__TypeSymbol* node_sym = v__ast__Table_sym(c->table, node->typ); + v__ast__TypeSymbol* last_sym = v__ast__Table_sym(c->table, last_expr.typ); + if (node_sym->kind == v__ast__Kind__multi_return && last_sym->kind == v__ast__Kind__multi_return) { + Array_v__ast__Type node_types = v__ast__TypeSymbol_mr_info(node_sym).types; + Array_v__ast__Type _t3 = {0}; + Array_v__ast__Type _t3_orig = v__ast__TypeSymbol_mr_info(last_sym).types; + int _t3_len = _t3_orig.len; + _t3 = __new_array(0, _t3_len, sizeof(v__ast__Type)); + + for (int _t4 = 0; _t4 < _t3_len; ++_t4) { + v__ast__Type it = ((v__ast__Type*) _t3_orig.data)[_t4]; + v__ast__Type ti = v__ast__mktyp(it); + array_push((array*)&_t3, &ti); + } + Array_v__ast__Type last_types =_t3; + if (Array_v__ast__Type_arr_eq(node_types, last_types)) { + continue; + } + } v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("mismatched types `"), 0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, node->typ)}}, {_SLIT("` and `"), 0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, last_expr.typ)}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->pos); } } else { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = if_kind}}, {_SLIT("` expression requires an expression as the last statement of every branch"), 0, { .d_c = 0 }}})), branch.pos); } - for (int _t3 = 0; _t3 < branch.stmts.len; ++_t3) { - v__ast__Stmt st = ((v__ast__Stmt*)branch.stmts.data)[_t3]; - Option_void _t4 = v__ast__Stmt_check_c_expr(st); - if (_t4.state != 0 && _t4.err._typ != _IError_None___index) { - IError err = _t4.err; + for (int _t5 = 0; _t5 < branch.stmts.len; ++_t5) { + v__ast__Stmt st = ((v__ast__Stmt*)branch.stmts.data)[_t5]; + Option_void _t6 = v__ast__Stmt_check_c_expr(st); + if (_t6.state != 0 && _t6.err._typ != _IError_None___index) { + IError err = _t6.err; v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`if` expression branch has "), 0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT0, 0, { .d_c = 0 }}})), (*(st.pos))); ; } @@ -55178,9 +55589,9 @@ bool v__checker__Checker_if_expr_defer_0 = false; } } } - Option_bool _t5; - if (_t5 = v__checker__Checker_has_return(c, branch.stmts), _t5.state == 0) { - bool has_return = *(bool*)_t5.data; + Option_bool _t7; + if (_t7 = v__checker__Checker_has_return(c, branch.stmts), _t7.state == 0) { + bool has_return = *(bool*)_t7.data; if (has_return) { nbranches_with_return++; } else { @@ -55208,13 +55619,13 @@ bool v__checker__Checker_if_expr_defer_0 = false; string d = (node->is_comptime ? (_SLIT("$")) : (_SLIT(""))); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("`"), 0xfe10, {.d_s = if_kind}}, {_SLIT("` expression needs `"), 0xfe10, {.d_s = d}}, {_SLIT("else` clause"), 0, { .d_c = 0 }}})), node->pos); } - v__ast__Type _t6 = node->typ; + v__ast__Type _t8 = node->typ; // Defer begin if (v__checker__Checker_if_expr_defer_0) { c->expected_expr_type = _const_v__ast__void_type; } // Defer end - return _t6; + return _t8; } VV_LOCAL_SYMBOL void v__checker__Checker_smartcast_if_conds(v__checker__Checker* c, v__ast__Expr node, v__ast__Scope* scope) { @@ -55659,7 +56070,7 @@ bool v__checker__Checker_match_expr_defer_0 = false; } v__ast__Type expr_type = v__checker__Checker_expr(c, (*stmt._v__ast__ExprStmt).expr); if (first_iteration) { - if (node->is_expr && (v__ast__Type_has_flag(node->expected_type, v__ast__TypeFlag__optional) || v__ast__Table_type_kind(c->table, node->expected_type) == v__ast__Kind__sum_type)) { + if (node->is_expr && (v__ast__Type_has_flag(node->expected_type, v__ast__TypeFlag__optional) || (v__ast__Table_type_kind(c->table, node->expected_type) == v__ast__Kind__sum_type || v__ast__Table_type_kind(c->table, node->expected_type) == v__ast__Kind__multi_return))) { ret_type = node->expected_type; } else { ret_type = expr_type; @@ -55670,6 +56081,24 @@ bool v__checker__Checker_match_expr_defer_0 = false; v__ast__TypeSymbol* ret_sym = v__ast__Table_sym(c->table, ret_type); bool is_noreturn = v__checker__is_noreturn_callexpr((*stmt._v__ast__ExprStmt).expr); if (!(node->is_expr && ret_sym->kind == v__ast__Kind__sum_type && (v__ast__Type_has_flag(ret_type, v__ast__TypeFlag__generic) || v__ast__Table_is_sumtype_or_in_variant(c->table, ret_type, expr_type))) && !is_noreturn) { + v__ast__TypeSymbol* expr_sym = v__ast__Table_sym(c->table, expr_type); + if (expr_sym->kind == v__ast__Kind__multi_return && ret_sym->kind == v__ast__Kind__multi_return) { + Array_v__ast__Type ret_types = v__ast__TypeSymbol_mr_info(ret_sym).types; + Array_v__ast__Type _t7 = {0}; + Array_v__ast__Type _t7_orig = v__ast__TypeSymbol_mr_info(expr_sym).types; + int _t7_len = _t7_orig.len; + _t7 = __new_array(0, _t7_len, sizeof(v__ast__Type)); + + for (int _t8 = 0; _t8 < _t7_len; ++_t8) { + v__ast__Type it = ((v__ast__Type*) _t7_orig.data)[_t8]; + v__ast__Type ti = v__ast__mktyp(it); + array_push((array*)&_t7, &ti); + } + Array_v__ast__Type expr_types =_t7; + if (Array_v__ast__Type_arr_eq(expr_types, ret_types)) { + continue; + } + } v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("return type mismatch, it should be `"), 0xfe10, {.d_s = ret_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos((*stmt._v__ast__ExprStmt).expr)); } } @@ -55681,9 +56110,9 @@ bool v__checker__Checker_match_expr_defer_0 = false; } } first_iteration = false; - Option_bool _t7; - if (_t7 = v__checker__Checker_has_return(c, branch.stmts), _t7.state == 0) { - bool has_return = *(bool*)_t7.data; + Option_bool _t9; + if (_t9 = v__checker__Checker_has_return(c, branch.stmts), _t9.state == 0) { + bool has_return = *(bool*)_t9.data; if (has_return) { nbranches_with_return++; } else { @@ -55703,11 +56132,11 @@ bool v__checker__Checker_match_expr_defer_0 = false; string cond_var = v__checker__Checker_get_base_name(c, &node->cond); if ((cond_var).len != 0) { bool cond_is_auto_heap = false; - for (int _t8 = 0; _t8 < node->branches.len; ++_t8) { - v__ast__MatchBranch branch = ((v__ast__MatchBranch*)node->branches.data)[_t8]; - Option_v__ast__Var_ptr _t9; - if (_t9 = v__ast__Scope_find_var(branch.scope, cond_var), _t9.state == 0) { - v__ast__Var* v = *(v__ast__Var**)_t9.data; + for (int _t10 = 0; _t10 < node->branches.len; ++_t10) { + v__ast__MatchBranch branch = ((v__ast__MatchBranch*)node->branches.data)[_t10]; + Option_v__ast__Var_ptr _t11; + if (_t11 = v__ast__Scope_find_var(branch.scope, cond_var), _t11.state == 0) { + v__ast__Var* v = *(v__ast__Var**)_t11.data; if (v->is_auto_heap) { cond_is_auto_heap = true; break; @@ -55715,26 +56144,26 @@ bool v__checker__Checker_match_expr_defer_0 = false; } } if (cond_is_auto_heap) { - for (int _t10 = 0; _t10 < node->branches.len; ++_t10) { - v__ast__MatchBranch branch = ((v__ast__MatchBranch*)node->branches.data)[_t10]; - Option_v__ast__Var_ptr _t11 = v__ast__Scope_find_var(branch.scope, cond_var); - if (_t11.state != 0) { /*or block*/ - IError err = _t11.err; + for (int _t12 = 0; _t12 < node->branches.len; ++_t12) { + v__ast__MatchBranch branch = ((v__ast__MatchBranch*)node->branches.data)[_t12]; + Option_v__ast__Var_ptr _t13 = v__ast__Scope_find_var(branch.scope, cond_var); + if (_t13.state != 0) { /*or block*/ + IError err = _t13.err; continue; } - v__ast__Var* v = (*(v__ast__Var**)_t11.data); + v__ast__Var* v = (*(v__ast__Var**)_t13.data); v->is_auto_heap = true; } } } - v__ast__Type _t12 = ret_type; + v__ast__Type _t14 = ret_type; // Defer begin if (v__checker__Checker_match_expr_defer_0) { c->expected_expr_type = _const_v__ast__void_type; } // Defer end - return _t12; + return _t14; } VV_LOCAL_SYMBOL void v__checker__Checker_match_exprs(v__checker__Checker* c, v__ast__MatchExpr* node, v__ast__TypeSymbol cond_type_sym) { @@ -65400,6 +65829,7 @@ bool v__gen__c__Gen_stmt_defer_0 = false; v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("goto "), 0xfe10, {.d_s = v__gen__c__c_name((*node._v__ast__GotoStmt).name)}}, {_SLIT(";"), 0, { .d_c = 0 }}}))); } else if (node._typ == 352 /* v.ast.HashStmt */) { + int line_nr = (*node._v__ast__HashStmt).pos.line_nr + 1; string ct_condition = _SLIT(""); if ((*node._v__ast__HashStmt).ct_conds.len > 0) { int ct_condition_start = g->out.len; @@ -65428,7 +65858,7 @@ bool v__gen__c__Gen_stmt_defer_0 = false; if (ct_condition.len > 0) { strings__Builder_writeln(&g->definitions, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); } - strings__Builder_writeln(&g->definitions, str_intp(2, _MOV((StrIntpData[]){{_SLIT("// added by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`"), 0, { .d_c = 0 }}}))); + strings__Builder_writeln(&g->definitions, str_intp(4, _MOV((StrIntpData[]){{_SLIT("// added by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`, file: "), 0xfe10, {.d_s = os__file_name((*node._v__ast__HashStmt).source_file)}}, {_SLIT(":"), 0xfe07, {.d_i32 = line_nr}}, {_SLIT(":"), 0, { .d_c = 0 }}}))); strings__Builder_writeln(&g->definitions, guarded_include); if (ct_condition.len > 0) { strings__Builder_writeln(&g->definitions, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#endif // $if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); @@ -65439,13 +65869,22 @@ bool v__gen__c__Gen_stmt_defer_0 = false; if (ct_condition.len > 0) { strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); } - strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("// added by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`"), 0, { .d_c = 0 }}}))); + strings__Builder_writeln(&g->includes, str_intp(4, _MOV((StrIntpData[]){{_SLIT("// added by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`, file: "), 0xfe10, {.d_s = os__file_name((*node._v__ast__HashStmt).source_file)}}, {_SLIT(":"), 0xfe07, {.d_i32 = line_nr}}, {_SLIT(":"), 0, { .d_c = 0 }}}))); strings__Builder_writeln(&g->includes, guarded_include); if (ct_condition.len > 0) { strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#endif // $if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); } strings__Builder_writeln(&g->includes, _SLIT("\n")); } + } else if (string__eq((*node._v__ast__HashStmt).kind, _SLIT("insert"))) { + if (ct_condition.len > 0) { + strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); + } + strings__Builder_writeln(&g->includes, str_intp(4, _MOV((StrIntpData[]){{_SLIT("// inserted by module `"), 0xfe10, {.d_s = (*node._v__ast__HashStmt).mod}}, {_SLIT("`, file: "), 0xfe10, {.d_s = os__file_name((*node._v__ast__HashStmt).source_file)}}, {_SLIT(":"), 0xfe07, {.d_i32 = line_nr}}, {_SLIT(":"), 0, { .d_c = 0 }}}))); + strings__Builder_writeln(&g->includes, (*node._v__ast__HashStmt).val); + if (ct_condition.len > 0) { + strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#endif // $if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); + } } else if (string__eq((*node._v__ast__HashStmt).kind, _SLIT("define"))) { if (ct_condition.len > 0) { strings__Builder_writeln(&g->includes, str_intp(2, _MOV((StrIntpData[]){{_SLIT("#if "), 0xfe10, {.d_s = ct_condition}}, {_SLIT0, 0, { .d_c = 0 }}}))); @@ -65594,8 +66033,8 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_write_sumtype_casting_fn(v__gen__c__Gen* g, *(multi_return_v__ast__StructField_Array_v__ast__Type*) _t4.data = (multi_return_v__ast__StructField_Array_v__ast__Type){.arg0=((v__ast__StructField){.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.has_default_expr = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_pub = 0,.default_val = (string){.str=(byteptr)"", .is_lit=1},.is_mut = 0,.is_global = 0,.is_volatile = 0,.default_expr = {0},.default_expr_typ = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.typ = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_65344 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t4.data); - Array_v__ast__Type embed_types = mr_65344.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_65835 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t4.data); + Array_v__ast__Type embed_types = mr_65835.arg1; if (embed_types.len > 0) { v__ast__TypeSymbol* embed_sym = v__ast__Table_sym(g->table, (*(v__ast__Type*)array_last(embed_types))); ptr = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = v__ast__TypeSymbol_embed_name(embed_sym)}}, {_SLIT("_ptr"), 0, { .d_c = 0 }}})); @@ -67041,11 +67480,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_map_init(v__gen__c__Gen* g, v__ast__MapInit string value_typ_str = v__gen__c__Gen_typ(g, unwrap_val_typ); v__ast__TypeSymbol* value_sym = v__ast__Table_sym(g->table, unwrap_val_typ); v__ast__TypeSymbol* key_sym = v__ast__Table_final_sym(g->table, unwrap_key_typ); - multi_return_string_string_string_string mr_104581 = v__gen__c__Gen_map_fn_ptrs(g, *key_sym); - string hash_fn = mr_104581.arg0; - string key_eq_fn = mr_104581.arg1; - string clone_fn = mr_104581.arg2; - string free_fn = mr_104581.arg3; + multi_return_string_string_string_string mr_105072 = v__gen__c__Gen_map_fn_ptrs(g, *key_sym); + string hash_fn = mr_105072.arg0; + string key_eq_fn = mr_105072.arg1; + string clone_fn = mr_105072.arg2; + string free_fn = mr_105072.arg3; int size = node.vals.len; string shared_styp = _SLIT(""); string styp = _SLIT(""); @@ -68200,9 +68639,9 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_write_types(v__gen__c__Gen* g, Array_v__ast_ for (int _t3 = 0; _t3 < (*sym->info._v__ast__Struct).fields.len; ++_t3) { v__ast__StructField field = ((v__ast__StructField*)(*sym->info._v__ast__Struct).fields.data)[_t3]; if (v__ast__Type_has_flag(field.typ, v__ast__TypeFlag__optional)) { - multi_return_string_string mr_141649 = v__gen__c__Gen_optional_type_name(g, field.typ); - string styp = mr_141649.arg0; - string base = mr_141649.arg1; + multi_return_string_string mr_142140 = v__gen__c__Gen_optional_type_name(g, field.typ); + string styp = mr_142140.arg0; + string base = mr_142140.arg1; sync__RwMutex_lock(&g->done_optionals->mtx); /*lock*/ { if (!Array_string_contains(g->done_optionals->val, base)) { @@ -68442,7 +68881,7 @@ bool v__gen__c__Gen_or_block_defer_0 = false; g->inside_or_block = true; v__gen__c__Gen_or_block_defer_0 = true; Array_v__ast__Stmt stmts = or_block.stmts; - if (stmts.len > 0 && ((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, or_block.stmts.len - 1)))._typ == 345 /* v.ast.ExprStmt */ && !v__ast__Type_alias_eq((/* as */ *(v__ast__ExprStmt*)__as_cast(((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._v__ast__ExprStmt,((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, stmts.len - 1)))._typ, 345) /*expected idx: 345, name: v.ast.ExprStmt */ ).typ, _const_v__ast__void_type)) { + if (stmts.len > 0 && ((*(v__ast__Stmt*)array_last(stmts)))._typ == 345 /* v.ast.ExprStmt */ && !v__ast__Type_alias_eq((/* as */ *(v__ast__ExprStmt*)__as_cast(((*(v__ast__Stmt*)array_last(stmts)))._v__ast__ExprStmt,((*(v__ast__Stmt*)array_last(stmts)))._typ, 345) /*expected idx: 345, name: v.ast.ExprStmt */ ).typ, _const_v__ast__void_type)) { g->indent++; for (int i = 0; i < stmts.len; ++i) { v__ast__Stmt stmt = ((v__ast__Stmt*)stmts.data)[i]; @@ -68465,7 +68904,7 @@ bool v__gen__c__Gen_or_block_defer_0 = false; g->indent--; } else { v__gen__c__Gen_stmts(g, stmts); - if (stmts.len > 0 && ((*(v__ast__Stmt*)/*ee elem_sym */array_get(stmts, or_block.stmts.len - 1)))._typ == 345 /* v.ast.ExprStmt */) { + if (stmts.len > 0 && ((*(v__ast__Stmt*)array_last(stmts)))._typ == 345 /* v.ast.ExprStmt */) { v__gen__c__Gen_writeln(g, _SLIT(";")); } } @@ -68473,11 +68912,11 @@ bool v__gen__c__Gen_or_block_defer_0 = false; if (string__eq(g->file->mod.name, _SLIT("main")) && (isnil(g->fn_decl) || g->fn_decl->is_main)) { string err_msg = str_intp(3, _MOV((StrIntpData[]){{_SLIT("IError_name_table["), 0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._typ]._method_msg("), 0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._object)"), 0, { .d_c = 0 }}})); if (g->pref->is_debug) { - multi_return_int_string_string_string mr_150745 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); - int paline = mr_150745.arg0; - string pafile = mr_150745.arg1; - string pamod = mr_150745.arg2; - string pafn = mr_150745.arg3; + multi_return_int_string_string_string mr_151194 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); + int paline = mr_151194.arg0; + string pafile = mr_151194.arg1; + string pamod = mr_151194.arg2; + string pafn = mr_151194.arg3; v__gen__c__Gen_writeln(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("panic_debug("), 0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), 0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), 0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), 0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); } else { v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tpanic_optional_not_set( "), 0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); @@ -68587,11 +69026,11 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_type_default(v__gen__c__Gen* g, v__ast__Ty { v__ast__Map info = v__ast__TypeSymbol_map_info(sym); v__ast__TypeSymbol* key_typ = v__ast__Table_sym(g->table, info.key_type); - multi_return_string_string_string_string mr_153327 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); - string hash_fn = mr_153327.arg0; - string key_eq_fn = mr_153327.arg1; - string clone_fn = mr_153327.arg2; - string free_fn = mr_153327.arg3; + multi_return_string_string_string_string mr_153776 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); + string hash_fn = mr_153776.arg0; + string key_eq_fn = mr_153776.arg1; + string clone_fn = mr_153776.arg2; + string free_fn = mr_153776.arg3; string noscan_key = v__gen__c__Gen_check_noscan(g, info.key_type); string noscan_value = v__gen__c__Gen_check_noscan(g, info.value_type); string noscan = (noscan_key.len != 0 || noscan_value.len != 0 ? (_SLIT("_noscan")) : (_SLIT(""))); @@ -69114,8 +69553,8 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_interface_table(v__gen__c__Gen* g) { int params_start_pos = g->out.len; Array_v__ast__Param params = array_clone_to_depth(&method.params, 0); array_set(¶ms, 0, &(v__ast__Param[]) { ((v__ast__Param){(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).name,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_mut,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_auto_rec,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).type_pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).is_hidden,.typ = v__ast__Type_set_nr_muls(st, 1),}) }); - multi_return_Array_string_Array_string_Array_bool mr_167617 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); - Array_string fargs = mr_167617.arg0; + multi_return_Array_string_Array_string_Array_bool mr_168066 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); + Array_string fargs = mr_168066.arg0; string parameter_name = strings__Builder_cut_last(&g->out, g->out.len - params_start_pos); if (v__ast__Type_is_ptr(st)) { parameter_name = string_trim_string_left(parameter_name, _SLIT("__shared__")); @@ -69132,8 +69571,8 @@ VV_LOCAL_SYMBOL string v__gen__c__Gen_interface_table(v__gen__c__Gen* g) { *(multi_return_v__ast__Fn_Array_v__ast__Type*) _t26.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.is_variadic = 0,.language = 0,.is_pub = 0,.is_ctor_new = 0,.is_deprecated = 0,.is_noreturn = 0,.is_unsafe = 0,.is_placeholder = 0,.is_main = 0,.is_test = 0,.is_keep_alive = 0,.is_method = 0,.no_body = 0,.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.file_mode = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.return_type = 0,.receiver_type = 0,.name = (string){.str=(byteptr)"", .is_lit=1},.params = __new_array(0, 0, sizeof(v__ast__Param)),.source_fn = 0,.usages = 0,.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.is_conditional = 0,.ctdefine_idx = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_168081 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); - Array_v__ast__Type embed_types = mr_168081.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_168530 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); + Array_v__ast__Type embed_types = mr_168530.arg1; if (embed_types.len > 0 && !Array_string_contains(method_names, method.name)) { v__ast__TypeSymbol* embed_sym = v__ast__Table_sym(g->table, (*(v__ast__Type*)array_last(embed_types))); string method_name = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = embed_sym->cname}}, {_SLIT("_"), 0xfe10, {.d_s = method.name}}, {_SLIT0, 0, { .d_c = 0 }}})); @@ -74540,6 +74979,41 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_infix_expr_in_op(v__gen__c__Gen* g, v__ast__ v__gen__c__Gen_expr(g, node.right); } v__gen__c__Gen_write(g, _SLIT(")")); + } else if (right.unaliased_sym->kind == v__ast__Kind__array_fixed) { + if (left.sym->kind == v__ast__Kind__sum_type || left.sym->kind == v__ast__Kind__interface_) { + if ((node.right)._typ == 285 /* v.ast.ArrayInit */) { + if ((*node.right._v__ast__ArrayInit).exprs.len > 0) { + Array_v__ast__InfixExpr infix_exprs = __new_array_with_default(0, 0, sizeof(v__ast__InfixExpr), 0); + for (int i = 0; i < (*node.right._v__ast__ArrayInit).exprs.len; ++i) { + array_push((array*)&infix_exprs, _MOV((v__ast__InfixExpr[]){ ((v__ast__InfixExpr){.op = v__token__Kind__key_is,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_stmt = 0,.left = node.left,.right = (*(v__ast__Expr*)/*ee elem_sym */array_get((*node.right._v__ast__ArrayInit).exprs, i)),.left_type = node.left_type,.right_type = (*(v__ast__Type*)/*ee elem_sym */array_get((*node.right._v__ast__ArrayInit).expr_types, i)),.auto_locked = (string){.str=(byteptr)"", .is_lit=1},.or_block = (v__ast__OrExpr){.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},},.ct_left_value_evaled = 0,.ct_left_value = v__ast__empty_comptime_const_expr(),.ct_right_value_evaled = 0,.ct_right_value = v__ast__empty_comptime_const_expr(),}) })); + } + v__gen__c__Gen_write(g, _SLIT("(")); + v__gen__c__Gen_infix_expr_in_sumtype_interface_array(g, infix_exprs); + v__gen__c__Gen_write(g, _SLIT(")")); + return; + } + } + } + if ((node.right)._typ == 285 /* v.ast.ArrayInit */) { + if ((*node.right._v__ast__ArrayInit).exprs.len > 0) { + v__gen__c__Gen_write(g, _SLIT("(")); + v__gen__c__Gen_infix_expr_in_optimization(g, node.left, (*node.right._v__ast__ArrayInit)); + v__gen__c__Gen_write(g, _SLIT(")")); + return; + } + } + if ((right.sym->info)._typ == 450 /* v.ast.Array */) { + v__ast__Type elem_type = (*right.sym->info._v__ast__Array).elem_type; + v__gen__c__Type elem_type_ = v__gen__c__Gen_unwrap(g, elem_type); + if (elem_type_.sym->kind == v__ast__Kind__sum_type) { + if (Array_v__ast__Type_contains(v__ast__TypeSymbol_sumtype_info(elem_type_.sym).variants, node.left_type)) { + v__ast__CastExpr new_node_left = ((v__ast__CastExpr){.arg = v__ast__EmptyExpr_to_sumtype_v__ast__Expr(ADDR(v__ast__EmptyExpr, (((v__ast__EmptyExpr){.x = 0,})))),.typ = elem_type,.expr = node.left,.typname = (string){.str=(byteptr)"", .is_lit=1},.expr_type = node.left_type,.has_arg = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},}); + v__gen__c__Gen_gen_array_contains(g, node.right_type, node.right, v__ast__CastExpr_to_sumtype_v__ast__Expr(&new_node_left)); + return; + } + } + } + v__gen__c__Gen_gen_array_contains(g, node.right_type, node.right, node.left); } else if (right.unaliased_sym->kind == v__ast__Kind__string) { v__gen__c__Gen_write(g, _SLIT("string_contains(")); v__gen__c__Gen_expr(g, node.right); @@ -80224,7 +80698,7 @@ VV_LOCAL_SYMBOL v__ast__ArrayInit v__parser__Parser_array_init(v__parser__Parser if (exprs.len == 1 && (p->tok.kind == v__token__Kind__name || p->tok.kind == v__token__Kind__amp || p->tok.kind == v__token__Kind__lsbr) && p->tok.line_nr == line_nr) { elem_type = v__parser__Parser_parse_type(p); if (string__eq(v__ast__Table_sym(p->table, elem_type)->name, _SLIT("byte"))) { - v__parser__Parser_error(p, _SLIT("`byte` has been deprecated in favor of `u8`: use `[10]u8` instead of `[10]byte`")); + v__parser__Parser_error(p, _SLIT("`byte` has been deprecated in favor of `u8`: use `[10]u8{}` instead of `[10]byte{}`")); } last_pos = v__token__Token_pos(&p->tok); is_fixed = true; @@ -83351,7 +83825,7 @@ v__ast__Type v__parser__Parser_parse_inline_sum_type(v__parser__Parser* p) { array_push((array*)&_t1, &ti); } Array_string variant_names =_t1; - qsort(variant_names.data, variant_names.len, variant_names.element_size, (int (*)(const void *, const void *))&compare_7932637671395545435_string); + qsort(variant_names.data, variant_names.len, variant_names.element_size, (int (*)(const void *, const void *))&compare_1376677008124459278_string); string name = str_intp(2, _MOV((StrIntpData[]){{_SLIT("_v_anon_sum_type_"), 0xfe10, {.d_s = Array_string_join(variant_names, _SLIT("_"))}}, {_SLIT0, 0, { .d_c = 0 }}})); Array_v__ast__Type _t3 = {0}; Array_v__ast__TypeNode _t3_orig = variants; @@ -90033,7 +90507,7 @@ void v__builder__Builder_cc(v__builder__Builder* v) { v__builder__Builder_build_thirdparty_obj_files(v); v__builder__Builder_setup_output_name(v); if (v->pref->os != v__pref__OS__windows && string_contains(ccompiler, _SLIT("++"))) { - string cpp_atomic_h_path = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = _SLIT("/woodpecker/src/git.rustybever.be/Chewing_Bever/v")}}, {_SLIT("/thirdparty/stdatomic/nix/cpp/atomic.h"), 0, { .d_c = 0 }}})); + string cpp_atomic_h_path = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = _SLIT("/home/runner/work/v/v")}}, {_SLIT("/thirdparty/stdatomic/nix/cpp/atomic.h"), 0, { .d_c = 0 }}})); if (!os__exists(cpp_atomic_h_path)) { for (int _t4 = 0; _t4 < v->parsed_files.len; ++_t4) { v__ast__File* file = ((v__ast__File**)v->parsed_files.data)[_t4]; @@ -90048,7 +90522,7 @@ void v__builder__Builder_cc(v__builder__Builder* v) { } } if (_t5) { - string cppgenv = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = _SLIT("/woodpecker/src/git.rustybever.be/Chewing_Bever/v")}}, {_SLIT("/thirdparty/stdatomic/nix/cpp/gen.v"), 0, { .d_c = 0 }}})); + string cppgenv = str_intp(2, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = _SLIT("/home/runner/work/v/v")}}, {_SLIT("/thirdparty/stdatomic/nix/cpp/gen.v"), 0, { .d_c = 0 }}})); os__execute( str_intp(4, _MOV((StrIntpData[]){{_SLIT0, 0xfe10, {.d_s = os__quoted_path(vexe)}}, {_SLIT(" run "), 0xfe10, {.d_s = os__quoted_path(cppgenv)}}, {_SLIT(" "), 0xfe10, {.d_s = os__quoted_path(ccompiler)}}, {_SLIT0, 0, { .d_c = 0 }}}))); break; } @@ -92443,7 +92917,7 @@ void _vinit(int ___argc, voidptr ___argv) { _const_v__util__const_tabs = new_array_from_c_array(10, 10, sizeof(string), _MOV((string[10]){ _SLIT(""), _SLIT("\t"), _SLIT("\t\t"), _SLIT("\t\t\t"), _SLIT("\t\t\t\t"), _SLIT("\t\t\t\t\t"), _SLIT("\t\t\t\t\t\t"), _SLIT("\t\t\t\t\t\t\t"), _SLIT("\t\t\t\t\t\t\t\t"), _SLIT("\t\t\t\t\t\t\t\t\t")})); - _const_v__util__builtin_module_names = new_array_from_c_array(4, 4, sizeof(string), _MOV((string[4]){_SLIT("builtin"), _SLIT("strconv"), _SLIT("strings"), _SLIT("dlmalloc")})); + _const_v__util__builtin_module_names = new_array_from_c_array(5, 5, sizeof(string), _MOV((string[5]){_SLIT("builtin"), _SLIT("strconv"), _SLIT("strings"), _SLIT("dlmalloc"), _SLIT("math")})); lines_cache = ((v__util__LinesCache*)memdup(&(v__util__LinesCache){.lines = new_map(sizeof(string), sizeof(Array_string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),}, sizeof(v__util__LinesCache))); // 3global g_timers = v__util__new_timers(((v__util__TimerParams){.should_print = false,.label = _SLIT("g_timers"),})); // 3global }