From ec312430fc0ca0177931eff95a0ddf42aa7c54a4 Mon Sep 17 00:00:00 2001 From: vbot Date: Fri, 13 May 2022 08:12:48 +0000 Subject: [PATCH] [v:master] b10cf3e0f - checker: allow to pass alias to array as a pointer (c2v) (#14389) --- v.c | 1479 +++++++++++++++++++++++++++--------------------------- v_win.c | 1485 ++++++++++++++++++++++++++++--------------------------- 2 files changed, 1517 insertions(+), 1447 deletions(-) diff --git a/v.c b/v.c index 2f91659..2980f8c 100644 --- a/v.c +++ b/v.c @@ -1,11 +1,11 @@ -#define V_COMMIT_HASH "0bd8d872d" +#define V_COMMIT_HASH "b10cf3e0f" #ifndef V_COMMIT_HASH - #define V_COMMIT_HASH "3afb88c4e" + #define V_COMMIT_HASH "0bd8d872d" #endif #ifndef V_CURRENT_COMMIT_HASH - #define V_CURRENT_COMMIT_HASH "0bd8d87" + #define V_CURRENT_COMMIT_HASH "b10cf3e" #endif // V comptime_definitions: @@ -4875,6 +4875,7 @@ struct v__ast__SumTypeDecl { string name; bool is_pub; v__token__Pos pos; + v__token__Pos name_pos; Array_v__ast__Comment comments; v__ast__Type typ; Array_v__ast__Type generic_types; @@ -5895,6 +5896,7 @@ struct v__parser__Parser { v__token__Token tok; v__token__Token prev_tok; v__token__Token peek_tok; + v__token__Token script_mode_start_token; Array_v__ast__Attr attrs; Array_v__ast__Import ast_imports; Array_string used_imports; @@ -5965,6 +5967,7 @@ struct v__parser__Parser { bool name_error : 1; bool comptime_if_cond : 1; bool should_abort : 1; + bool script_mode : 1; }; @@ -7649,6 +7652,7 @@ VV_LOCAL_SYMBOL void map_free_nop(voidptr _d1); VV_LOCAL_SYMBOL map new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr ), bool (*key_eq_fn)(voidptr , voidptr ), void (*clone_fn)(voidptr , voidptr ), void (*free_fn)(voidptr )); VV_LOCAL_SYMBOL map new_map_init(u64 (*hash_fn)(voidptr ), bool (*key_eq_fn)(voidptr , voidptr ), void (*clone_fn)(voidptr , voidptr ), void (*free_fn)(voidptr ), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values); map map_move(map* m); +void map_clear(map* m); VV_LOCAL_SYMBOL multi_return_u32_u32 map_key_to_index(map* m, voidptr pkey); VV_LOCAL_SYMBOL multi_return_u32_u32 map_meta_less(map* m, u32 _index, u32 _metas); VV_LOCAL_SYMBOL void map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi); @@ -8081,6 +8085,7 @@ VV_LOCAL_SYMBOL Array_string os__init_os_args(int argc, u8** argv); _option_Array_string os__ls(string path); _option_bool os__mkdir(string path); os__Result os__execute(string cmd); +os__Result os__raw_execute(string cmd); _option_void os__Command_start(os__Command* c); string os__Command_read_line(os__Command* c); _option_void os__Command_close(os__Command* c); @@ -10080,7 +10085,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_fn_decl(v__gen__c__Gen* g, v__ast__FnDecl no VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_fn_decl(v__gen__c__Gen* g, v__ast__FnDecl* node, bool skip); VV_LOCAL_SYMBOL _option_string v__gen__c__Gen_c_fn_name(v__gen__c__Gen* g, v__ast__FnDecl* node); string _const_v__gen__c__closure_ctx; // a string literal, inited later -VV_LOCAL_SYMBOL multi_return_string_string v__gen__c__closure_ctx(v__ast__FnDecl node); +VV_LOCAL_SYMBOL string v__gen__c__closure_ctx(v__ast__FnDecl node); VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn(v__gen__c__Gen* g, v__ast__AnonFn* node); VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn_decl(v__gen__c__Gen* g, v__ast__AnonFn* node); VV_LOCAL_SYMBOL string v__gen__c__Gen_defer_flag_var(v__gen__c__Gen* g, v__ast__DeferStmt* stmt); @@ -10390,6 +10395,7 @@ VV_LOCAL_SYMBOL void v__parser__Parser_top_level_statement_end(v__parser__Parser VV_LOCAL_SYMBOL void v__parser__Parser_rewind_scanner_to_current_token_in_new_mode(v__parser__Parser* p); bool v__parser__Parser_mark_var_as_used(v__parser__Parser* p, string varname); VV_LOCAL_SYMBOL v__ast__Stmt v__parser__Parser_unsafe_stmt(v__parser__Parser* p); +VV_LOCAL_SYMBOL bool v__parser__Parser_disallow_declarations_in_script_mode(v__parser__Parser* p); VV_LOCAL_SYMBOL void v__parser__Parser_trace(v__parser__Parser* p, string fbase, string message); VV_LOCAL_SYMBOL v__ast__Expr v__parser__Parser_sql_expr(v__parser__Parser* p); VV_LOCAL_SYMBOL v__ast__SqlStmt v__parser__Parser_sql_stmt(v__parser__Parser* p); @@ -11534,7 +11540,7 @@ static string indent_v__ast__CallExpr_str(v__ast__CallExpr it, int indent_count) string _t6 = indent_Array_v__ast__Type_str(it.from_embed_types, indent_count + 1); string _t7 = indent_Array_v__ast__Comment_str(it.comments, indent_count + 1); string _t8 = v__ast__Expr_str(it.left); - string _t9 = isnil(it.scope) ? _SLIT("nil") : (indent_count > 25) ? _SLIT("") : v__ast__Scope_str(*it.scope); + string _t9 = isnil(it.scope) ? _SLIT("nil") : (indent_count > 25)? _SLIT("") : v__ast__Scope_str(*it.scope); string _t10 = indent_v__token__Pos_str(it.pos, indent_count + 1); string _t11 = indent_v__token__Pos_str(it.name_pos, indent_count + 1); string _t12 = indent_v__token__Pos_str(it.concrete_list_pos, indent_count + 1); @@ -12876,6 +12882,11 @@ static inline v__ast__TypeInfo v__ast__Enum_to_sumtype_v__ast__TypeInfo(v__ast__ return (v__ast__TypeInfo){ ._v__ast__Enum = ptr, ._typ = 447}; } +static inline v__ast__TypeDecl v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(v__ast__SumTypeDecl* x) { + v__ast__SumTypeDecl* ptr = memdup(x, sizeof(v__ast__SumTypeDecl)); + return (v__ast__TypeDecl){ ._v__ast__SumTypeDecl = ptr, ._typ = 244, .name = (string*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, name)), .is_pub = (bool*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, is_pub)), .pos = (v__token__Pos*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, pos)), .comments = (Array_v__ast__Comment*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, comments))}; +} + static inline v__ast__TypeDecl v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(v__ast__FnTypeDecl* x) { v__ast__FnTypeDecl* ptr = memdup(x, sizeof(v__ast__FnTypeDecl)); return (v__ast__TypeDecl){ ._v__ast__FnTypeDecl = ptr, ._typ = 243, .name = (string*)((char*)ptr + __offsetof_ptr(ptr, v__ast__FnTypeDecl, name)), .is_pub = (bool*)((char*)ptr + __offsetof_ptr(ptr, v__ast__FnTypeDecl, is_pub)), .pos = (v__token__Pos*)((char*)ptr + __offsetof_ptr(ptr, v__ast__FnTypeDecl, pos)), .comments = (Array_v__ast__Comment*)((char*)ptr + __offsetof_ptr(ptr, v__ast__FnTypeDecl, comments))}; @@ -12886,11 +12897,6 @@ static inline v__ast__TypeDecl v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl return (v__ast__TypeDecl){ ._v__ast__AliasTypeDecl = ptr, ._typ = 242, .name = (string*)((char*)ptr + __offsetof_ptr(ptr, v__ast__AliasTypeDecl, name)), .is_pub = (bool*)((char*)ptr + __offsetof_ptr(ptr, v__ast__AliasTypeDecl, is_pub)), .pos = (v__token__Pos*)((char*)ptr + __offsetof_ptr(ptr, v__ast__AliasTypeDecl, pos)), .comments = (Array_v__ast__Comment*)((char*)ptr + __offsetof_ptr(ptr, v__ast__AliasTypeDecl, comments))}; } -static inline v__ast__TypeDecl v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(v__ast__SumTypeDecl* x) { - v__ast__SumTypeDecl* ptr = memdup(x, sizeof(v__ast__SumTypeDecl)); - return (v__ast__TypeDecl){ ._v__ast__SumTypeDecl = ptr, ._typ = 244, .name = (string*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, name)), .is_pub = (bool*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, is_pub)), .pos = (v__token__Pos*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, pos)), .comments = (Array_v__ast__Comment*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, comments))}; -} - static inline v__ast__TypeInfo v__ast__Alias_to_sumtype_v__ast__TypeInfo(v__ast__Alias* x) { v__ast__Alias* ptr = memdup(x, sizeof(v__ast__Alias)); return (v__ast__TypeInfo){ ._v__ast__Alias = ptr, ._typ = 433}; @@ -13638,9 +13644,7 @@ static int v_typeof_interface_idx_v__ast__walker__Visitor(int sidx) { /* v.ast.w // TypeDecl strings__Builder strings__new_builder(int initial_size) { strings__Builder res = ((__new_array_with_default(0, initial_size, sizeof(u8), 0))); - { // Unsafe block - res.flags = ArrayFlags__noslices; - } + ArrayFlags_set(&res.flags, ArrayFlags__noslices); return res; } @@ -13715,7 +13719,7 @@ void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other // Attr: [inline] inline u8 strings__Builder_byte_at(strings__Builder* b, int n) { - return ((u8*)(b->data))[n]; + return (*(u8*)/*ee elem_sym */array_get(*(((Array_u8*)(b))), n)); } // Attr: [inline] @@ -13761,15 +13765,10 @@ void strings__Builder_go_back_to(strings__Builder* b, int pos) { // Attr: [inline] inline void strings__Builder_writeln(strings__Builder* b, string s) { - int new_len = b->len + s.len + 1; - strings__Builder_ensure_cap(b, new_len); - { // Unsafe block - ((u8*)(b->data))[new_len - 1] = ((u8)('\n')); - if (s.len > 0) { - vmemcpy(((u8*)(b->data)) + b->len, s.str, s.len); - } - b->len = new_len; + if (s.len > 0) { + array_push_many(b, s.str, s.len); } + array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); } string strings__Builder_last_n(strings__Builder* b, int n) { @@ -13798,10 +13797,12 @@ void strings__Builder_ensure_cap(strings__Builder* b, int n) { if (n <= b->cap) { return; } - u8* new_data = _v_malloc(((u64)(n)) * ((u64)(b->element_size))); - if (b->data != 0) { - vmemcpy(new_data, b->data, b->len); - _v_free(b->data); + u8* new_data = vcalloc(n * b->element_size); + if (b->data != ((voidptr)(0))) { + vmemcpy(new_data, b->data, b->len * b->element_size); + if (ArrayFlags_has(&b->flags, ArrayFlags__noslices)) { + _v_free(b->data); + } } { // Unsafe block b->data = new_data; @@ -19756,6 +19757,11 @@ map map_move(map* m) { return r; } +void map_clear(map* m) { + m->len = 0; + m->key_values.len = 0; +} + // Attr: [inline] inline VV_LOCAL_SYMBOL multi_return_u32_u32 map_key_to_index(map* m, voidptr pkey) { u64 hash = m->hash_fn(pkey); @@ -19828,12 +19834,12 @@ VV_LOCAL_SYMBOL void map_set(map* m, voidptr key, voidptr value) { if (load_factor > _const_max_load_factor) { map_expand(m); } - multi_return_u32_u32 mr_10845 = map_key_to_index(m, key); - u32 index = mr_10845.arg0; - u32 meta = mr_10845.arg1; - multi_return_u32_u32 mr_10881 = map_meta_less(m, index, meta); - index = mr_10881.arg0; - meta = mr_10881.arg1; + multi_return_u32_u32 mr_11087 = map_key_to_index(m, key); + u32 index = mr_11087.arg0; + u32 meta = mr_11087.arg1; + multi_return_u32_u32 mr_11123 = map_meta_less(m, index, meta); + index = mr_11123.arg0; + meta = mr_11123.arg1; for (;;) { if (!(meta == m->metas[index])) break; int kv_index = ((int)(m->metas[index + 1U])); @@ -19884,12 +19890,12 @@ VV_LOCAL_SYMBOL void map_rehash(map* m) { continue; } voidptr pkey = DenseArray_key(&m->key_values, i); - multi_return_u32_u32 mr_12544 = map_key_to_index(m, pkey); - u32 index = mr_12544.arg0; - u32 meta = mr_12544.arg1; - multi_return_u32_u32 mr_12582 = map_meta_less(m, index, meta); - index = mr_12582.arg0; - meta = mr_12582.arg1; + multi_return_u32_u32 mr_12786 = map_key_to_index(m, pkey); + u32 index = mr_12786.arg0; + u32 meta = mr_12786.arg1; + multi_return_u32_u32 mr_12824 = map_meta_less(m, index, meta); + index = mr_12824.arg0; + meta = mr_12824.arg1; map_meta_greater(m, index, meta, ((u32)(i))); } } @@ -19908,9 +19914,9 @@ VV_LOCAL_SYMBOL void map_cached_rehash(map* m, u32 old_cap) { u32 old_index = ((i - old_probe_count) & (m->even_index >> 1U)); u32 index = (((old_index | (old_meta << m->shift))) & m->even_index); u32 meta = (((old_meta & _const_hash_mask)) | _const_probe_inc); - multi_return_u32_u32 mr_13381 = map_meta_less(m, index, meta); - index = mr_13381.arg0; - meta = mr_13381.arg1; + multi_return_u32_u32 mr_13623 = map_meta_less(m, index, meta); + index = mr_13623.arg0; + meta = mr_13623.arg1; u32 kv_index = old_metas[i + 1U]; map_meta_greater(m, index, meta, kv_index); } @@ -19919,9 +19925,9 @@ VV_LOCAL_SYMBOL void map_cached_rehash(map* m, u32 old_cap) { VV_LOCAL_SYMBOL voidptr map_get_and_set(map* m, voidptr key, voidptr zero) { for (;;) { - multi_return_u32_u32 mr_13829 = map_key_to_index(m, key); - u32 index = mr_13829.arg0; - u32 meta = mr_13829.arg1; + multi_return_u32_u32 mr_14071 = map_key_to_index(m, key); + u32 index = mr_14071.arg0; + u32 meta = mr_14071.arg1; for (;;) { if (meta == m->metas[index]) { int kv_index = ((int)(m->metas[index + 1U])); @@ -19943,9 +19949,9 @@ VV_LOCAL_SYMBOL voidptr map_get_and_set(map* m, voidptr key, voidptr zero) { } VV_LOCAL_SYMBOL voidptr map_get(map* m, voidptr key, voidptr zero) { - multi_return_u32_u32 mr_14552 = map_key_to_index(m, key); - u32 index = mr_14552.arg0; - u32 meta = mr_14552.arg1; + multi_return_u32_u32 mr_14794 = map_key_to_index(m, key); + u32 index = mr_14794.arg0; + u32 meta = mr_14794.arg1; for (;;) { if (meta == m->metas[index]) { int kv_index = ((int)(m->metas[index + 1U])); @@ -19965,9 +19971,9 @@ VV_LOCAL_SYMBOL voidptr map_get(map* m, voidptr key, voidptr zero) { } VV_LOCAL_SYMBOL voidptr map_get_check(map* m, voidptr key) { - multi_return_u32_u32 mr_15217 = map_key_to_index(m, key); - u32 index = mr_15217.arg0; - u32 meta = mr_15217.arg1; + multi_return_u32_u32 mr_15459 = map_key_to_index(m, key); + u32 index = mr_15459.arg0; + u32 meta = mr_15459.arg1; for (;;) { if (meta == m->metas[index]) { int kv_index = ((int)(m->metas[index + 1U])); @@ -19987,9 +19993,9 @@ VV_LOCAL_SYMBOL voidptr map_get_check(map* m, voidptr key) { } VV_LOCAL_SYMBOL bool map_exists(map* m, voidptr key) { - multi_return_u32_u32 mr_15727 = map_key_to_index(m, key); - u32 index = mr_15727.arg0; - u32 meta = mr_15727.arg1; + multi_return_u32_u32 mr_15969 = map_key_to_index(m, key); + u32 index = mr_15969.arg0; + u32 meta = mr_15969.arg1; for (;;) { if (meta == m->metas[index]) { int kv_index = ((int)(m->metas[index + 1U])); @@ -20020,12 +20026,12 @@ inline VV_LOCAL_SYMBOL void DenseArray_delete(DenseArray* d, int i) { // Attr: [unsafe] void map_delete(map* m, voidptr key) { - multi_return_u32_u32 mr_16356 = map_key_to_index(m, key); - u32 index = mr_16356.arg0; - u32 meta = mr_16356.arg1; - multi_return_u32_u32 mr_16392 = map_meta_less(m, index, meta); - index = mr_16392.arg0; - meta = mr_16392.arg1; + multi_return_u32_u32 mr_16598 = map_key_to_index(m, key); + u32 index = mr_16598.arg0; + u32 meta = mr_16598.arg1; + multi_return_u32_u32 mr_16634 = map_meta_less(m, index, meta); + index = mr_16634.arg0; + meta = mr_16634.arg1; for (;;) { if (!(meta == m->metas[index])) break; int kv_index = ((int)(m->metas[index + 1U])); @@ -24823,8 +24829,8 @@ VV_LOCAL_SYMBOL int os__vpclose(voidptr f) { } #else { - multi_return_int_bool mr_8922 = os__posix_wait4_to_exit_status(pclose(f)); - int ret = mr_8922.arg0; + multi_return_int_bool mr_8920 = os__posix_wait4_to_exit_status(pclose(f)); + int ret = mr_8920.arg0; int _t2 = ret; return _t2; } @@ -24870,9 +24876,9 @@ int os__system(string cmd) { } #if !defined(_WIN32) { - multi_return_int_bool mr_9929 = os__posix_wait4_to_exit_status(ret); - int pret = mr_9929.arg0; - bool is_signaled = mr_9929.arg1; + multi_return_int_bool mr_9927 = os__posix_wait4_to_exit_status(ret); + int pret = mr_9927.arg0; + bool is_signaled = mr_9927.arg1; if (is_signaled) { println(string__plus(string__plus( str_intp(2, _MOV((StrIntpData[]){{_SLIT("Terminated by signal "), /*100 &int*/0x4fe27, {.d_i32 = ret}}, {_SLIT(" ("), 0, { .d_c = 0 }}})), os__sigint_to_signal_name(pret)), _SLIT(")"))); } @@ -26884,10 +26890,9 @@ void os__walk_with_context(string path, voidptr context, void (*fcb)(voidptr , s for (int _t2 = 0; _t2 < files.len; ++_t2) { string file = ((string*)files.data)[_t2]; string p = string__plus(string__plus(path, local_path_separator), file); + fcb(context, p); if (os__is_dir(p) && !os__is_link(p)) { os__walk_with_context(p, context, (voidptr)fcb); - } else { - fcb(context, p); } } return; @@ -27400,6 +27405,12 @@ strings__Builder res; return _t2; } +// Attr: [unsafe] +os__Result os__raw_execute(string cmd) { + os__Result _t1 = os__execute(cmd); + return _t1; +} + // Attr: [manualfree] _option_void os__Command_start(os__Command* c) { bool os__Command_start_defer_0 = false; @@ -32373,9 +32384,9 @@ VV_LOCAL_SYMBOL _option_v__vmod__Manifest v__vmod__Parser_parse(v__vmod__Parser* return _t8; } - multi_return_Array_string_int mr_4989 = (*(multi_return_Array_string_int*)_t7.data); - Array_string vals = mr_4989.arg0; - int idx = mr_4989.arg1; + multi_return_Array_string_int mr_4988 = (*(multi_return_Array_string_int*)_t7.data); + Array_string vals = mr_4988.arg0; + int idx = mr_4988.arg1; map_set(&mn.unknown, &(string[]){field_name}, &(Array_string[]) { vals }); i = idx; continue; @@ -36008,7 +36019,7 @@ string time__Time_get_fmt_date_str(time__Time t, time__FormatDelimiter fmt_dlmtr } } string res = _t2; - string del = ((fmt_dlmtr == (time__FormatDelimiter__dot)) ? (_SLIT(".")) : (fmt_dlmtr == (time__FormatDelimiter__hyphen)) ? (_SLIT("-")) : (fmt_dlmtr == (time__FormatDelimiter__slash)) ? (_SLIT("/")) : (fmt_dlmtr == (time__FormatDelimiter__space)) ? (_SLIT(" ")) : (_SLIT(""))); + string del = ((fmt_dlmtr == (time__FormatDelimiter__dot))? (_SLIT(".")) : (fmt_dlmtr == (time__FormatDelimiter__hyphen))? (_SLIT("-")) : (fmt_dlmtr == (time__FormatDelimiter__slash))? (_SLIT("/")) : (fmt_dlmtr == (time__FormatDelimiter__space))? (_SLIT(" ")) : (_SLIT(""))); res = string_replace(res, _SLIT("|"), del); string _t3 = res; return _t3; @@ -36121,13 +36132,13 @@ _option_time__Time time__parse_rfc3339(string s) { return _t9; } - multi_return_int_int_int_int_i64_bool mr_1384 = (*(multi_return_int_int_int_int_i64_bool*)_t8.data); - hour_ = mr_1384.arg0; - minute_ = mr_1384.arg1; - second_ = mr_1384.arg2; - microsecond_ = mr_1384.arg3; - unix_offset = mr_1384.arg4; - is_local_time = mr_1384.arg5; + multi_return_int_int_int_int_i64_bool mr_1383 = (*(multi_return_int_int_int_int_i64_bool*)_t8.data); + hour_ = mr_1383.arg0; + minute_ = mr_1383.arg1; + second_ = mr_1383.arg2; + microsecond_ = mr_1383.arg3; + unix_offset = mr_1383.arg4; + is_local_time = mr_1383.arg5; t = time__new_time(((time__Time){.year = 0,.month = 0,.day = 0,.hour = hour_,.minute = minute_,.second = second_,.microsecond = microsecond_,._v_unix = 0,.is_local = 0,})); if (is_local_time) { _option_time__Time _t10; @@ -36231,10 +36242,10 @@ _option_time__Time time__parse_iso8601(string s) { return _t5; } - multi_return_int_int_int mr_3646 = (*(multi_return_int_int_int*)_t4.data); - int year = mr_3646.arg0; - int month = mr_3646.arg1; - int day = mr_3646.arg2; + multi_return_int_int_int mr_3644 = (*(multi_return_int_int_int*)_t4.data); + int year = mr_3644.arg0; + int month = mr_3644.arg1; + int day = mr_3644.arg2; int hour_ = 0; int minute_ = 0; int second_ = 0; @@ -36249,13 +36260,13 @@ _option_time__Time time__parse_iso8601(string s) { return _t7; } - multi_return_int_int_int_int_i64_bool mr_3888 = (*(multi_return_int_int_int_int_i64_bool*)_t6.data); - hour_ = mr_3888.arg0; - minute_ = mr_3888.arg1; - second_ = mr_3888.arg2; - microsecond_ = mr_3888.arg3; - unix_offset = mr_3888.arg4; - is_local_time = mr_3888.arg5; + multi_return_int_int_int_int_i64_bool mr_3885 = (*(multi_return_int_int_int_int_i64_bool*)_t6.data); + hour_ = mr_3885.arg0; + minute_ = mr_3885.arg1; + second_ = mr_3885.arg2; + microsecond_ = mr_3885.arg3; + unix_offset = mr_3885.arg4; + is_local_time = mr_3885.arg5; } time__Time t = time__new_time(((time__Time){ .year = year, @@ -36802,33 +36813,33 @@ i64 time__Duration_nanoseconds(time__Duration d) { } i64 time__Duration_microseconds(time__Duration d) { - i64 _t1 = ((i64)(d)) / 1000; + i64 _t1 = ((i64)(d)) / _const_time__microsecond; return _t1; } i64 time__Duration_milliseconds(time__Duration d) { - i64 _t1 = ((i64)(d)) / 1000000; + i64 _t1 = ((i64)(d)) / _const_time__millisecond; return _t1; } f64 time__Duration_seconds(time__Duration d) { i64 sec = d / _const_time__second; i64 nsec = d % _const_time__second; - f64 _t1 = ((f64)(sec)) + ((f64)(nsec)) / 1e9; + f64 _t1 = ((f64)(sec)) + ((f64)(nsec)) / _const_time__second; return _t1; } f64 time__Duration_minutes(time__Duration d) { i64 min = d / _const_time__minute; i64 nsec = d % _const_time__minute; - f64 _t1 = ((f64)(min)) + ((f64)(nsec)) / (60 * 1e9); + f64 _t1 = ((f64)(min)) + ((f64)(nsec)) / _const_time__minute; return _t1; } f64 time__Duration_hours(time__Duration d) { i64 hr = d / _const_time__hour; i64 nsec = d % _const_time__hour; - f64 _t1 = ((f64)(hr)) + ((f64)(nsec)) / (3600 * 1e9); + f64 _t1 = ((f64)(hr)) + ((f64)(nsec)) / _const_time__hour; return _t1; } @@ -38102,7 +38113,7 @@ void v__pref__Preferences_fill_with_defaults(v__pref__Preferences* p) { } #endif } - string vhash = _SLIT("3afb88c4e"); + string vhash = _SLIT("0bd8d872d"); 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, /*115 &v.pref.Backend*/0xfe10, {.d_s = v__pref__Backend_str(p->backend)}}, {_SLIT(" | "), /*115 &v.pref.OS*/0xfe10, {.d_s = v__pref__OS_str(p->os)}}, {_SLIT(" | "), /*115 &string*/0xfe10, {.d_s = p->ccompiler}}, {_SLIT(" | "), /*115 &bool*/0xfe10, {.d_s = p->is_prod ? _SLIT("true") : _SLIT("false")}}, {_SLIT(" | "), /*115 &bool*/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; @@ -41898,7 +41909,7 @@ _option_string v__util__cached_read_source_file(string path) { } string v__util__replace_op(string s) { - string _t1 = ((string__eq(s, _SLIT("+"))) ? (_SLIT("_plus")) : (string__eq(s, _SLIT("-"))) ? (_SLIT("_minus")) : (string__eq(s, _SLIT("*"))) ? (_SLIT("_mult")) : (string__eq(s, _SLIT("/"))) ? (_SLIT("_div")) : (string__eq(s, _SLIT("%"))) ? (_SLIT("_mod")) : (string__eq(s, _SLIT("<"))) ? (_SLIT("_lt")) : (string__eq(s, _SLIT(">"))) ? (_SLIT("_gt")) : (string__eq(s, _SLIT("=="))) ? (_SLIT("_eq")) : (_SLIT(""))); + string _t1 = ((string__eq(s, _SLIT("+")))? (_SLIT("_plus")) : (string__eq(s, _SLIT("-")))? (_SLIT("_minus")) : (string__eq(s, _SLIT("*")))? (_SLIT("_mult")) : (string__eq(s, _SLIT("/")))? (_SLIT("_div")) : (string__eq(s, _SLIT("%")))? (_SLIT("_mod")) : (string__eq(s, _SLIT("<")))? (_SLIT("_lt")) : (string__eq(s, _SLIT(">")))? (_SLIT("_gt")) : (string__eq(s, _SLIT("==")))? (_SLIT("_eq")) : (_SLIT(""))); return _t1; } @@ -42687,7 +42698,7 @@ bool v__ast__Expr_is_expr(v__ast__Expr expr) { } bool v__ast__Expr_is_lit(v__ast__Expr expr) { - bool _t1 = ((expr._typ == 252 /* v.ast.BoolLiteral */) ? (true) : (expr._typ == 257 /* v.ast.CharLiteral */) ? (true) : (expr._typ == 292 /* v.ast.StringLiteral */) ? (true) : (expr._typ == 273 /* v.ast.IntegerLiteral */) ? (true) : (false)); + bool _t1 = ((expr._typ == 252 /* v.ast.BoolLiteral */)? (true) : (expr._typ == 257 /* v.ast.CharLiteral */)? (true) : (expr._typ == 292 /* v.ast.StringLiteral */)? (true) : (expr._typ == 273 /* v.ast.IntegerLiteral */)? (true) : (false)); return _t1; } @@ -43785,7 +43796,7 @@ string v__ast__Attr_str(v__ast__Attr* a) { _t1 = a->name; } string arg = _t1; - s = /*f*/string__plus(s, ((a->kind == (v__ast__AttrKind__plain) || a->kind == (v__ast__AttrKind__number) || a->kind == (v__ast__AttrKind__bool)) ? (arg) : (a->kind == (v__ast__AttrKind__string)) ? ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("'"), /*115 &string*/0xfe10, {.d_s = arg}}, {_SLIT("'"), 0, { .d_c = 0 }}}))) : ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("if "), /*115 &string*/0xfe10, {.d_s = arg}}, {_SLIT0, 0, { .d_c = 0 }}}))))); + s = /*f*/string__plus(s, ((a->kind == (v__ast__AttrKind__plain) || a->kind == (v__ast__AttrKind__number) || a->kind == (v__ast__AttrKind__bool))? (arg) : (a->kind == (v__ast__AttrKind__string))? ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("'"), /*115 &string*/0xfe10, {.d_s = arg}}, {_SLIT("'"), 0, { .d_c = 0 }}}))) : ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("if "), /*115 &string*/0xfe10, {.d_s = arg}}, {_SLIT0, 0, { .d_c = 0 }}}))))); string _t2 = s; return _t2; } @@ -44325,7 +44336,7 @@ _option_v__ast__ComptTimeConstValue v__ast__ConstField_comptime_expr_value(v__as } bool v__ast__ConstField_is_simple_define_const(v__ast__ConstField* obj) { - bool _t1 = ((obj->expr._typ == 257 /* v.ast.CharLiteral */) ? (true) : (obj->expr._typ == 266 /* v.ast.FloatLiteral */) ? (true) : (obj->expr._typ == 273 /* v.ast.IntegerLiteral */) ? (true) : (false)); + bool _t1 = ((obj->expr._typ == 257 /* v.ast.CharLiteral */)? (true) : (obj->expr._typ == 266 /* v.ast.FloatLiteral */)? (true) : (obj->expr._typ == 273 /* v.ast.IntegerLiteral */)? (true) : (false)); return _t1; } @@ -44471,10 +44482,10 @@ _option_v__ast__ScopeStructField v__ast__Scope_find_struct_field(v__ast__Scope* _option_v__ast__Var_ptr v__ast__Scope_find_var(v__ast__Scope* s, string name) { _option_v__ast__ScopeObject _t1; if (_t1 = v__ast__Scope_find(s, name), _t1.state == 0) { - v__ast__ScopeObject* obj = HEAP(v__ast__ScopeObject, *(v__ast__ScopeObject*)_t1.data); - if ((*(obj))._typ == 326 /* v.ast.Var */) { + v__ast__ScopeObject obj = *(v__ast__ScopeObject*)_t1.data; + if (obj._typ == 326 /* v.ast.Var */) { _option_v__ast__Var_ptr _t2; - opt_ok2(&(v__ast__Var*[]) { &(*((obj->_v__ast__Var))) }, (_option*)(&_t2), sizeof(v__ast__Var*)); + opt_ok2(&(v__ast__Var*[]) { &(*obj._v__ast__Var) }, (_option*)(&_t2), sizeof(v__ast__Var*)); return _t2; } @@ -44488,10 +44499,10 @@ _option_v__ast__Var_ptr v__ast__Scope_find_var(v__ast__Scope* s, string name) { _option_v__ast__GlobalField_ptr v__ast__Scope_find_global(v__ast__Scope* s, string name) { _option_v__ast__ScopeObject _t1; if (_t1 = v__ast__Scope_find(s, name), _t1.state == 0) { - v__ast__ScopeObject* obj = HEAP(v__ast__ScopeObject, *(v__ast__ScopeObject*)_t1.data); - if ((*(obj))._typ == 325 /* v.ast.GlobalField */) { + v__ast__ScopeObject obj = *(v__ast__ScopeObject*)_t1.data; + if (obj._typ == 325 /* v.ast.GlobalField */) { _option_v__ast__GlobalField_ptr _t2; - opt_ok2(&(v__ast__GlobalField*[]) { &(*((obj->_v__ast__GlobalField))) }, (_option*)(&_t2), sizeof(v__ast__GlobalField*)); + opt_ok2(&(v__ast__GlobalField*[]) { &(*obj._v__ast__GlobalField) }, (_option*)(&_t2), sizeof(v__ast__GlobalField*)); return _t2; } @@ -44505,10 +44516,10 @@ _option_v__ast__GlobalField_ptr v__ast__Scope_find_global(v__ast__Scope* s, stri _option_v__ast__ConstField_ptr v__ast__Scope_find_const(v__ast__Scope* s, string name) { _option_v__ast__ScopeObject _t1; if (_t1 = v__ast__Scope_find(s, name), _t1.state == 0) { - v__ast__ScopeObject* obj = HEAP(v__ast__ScopeObject, *(v__ast__ScopeObject*)_t1.data); - if ((*(obj))._typ == 324 /* v.ast.ConstField */) { + v__ast__ScopeObject obj = *(v__ast__ScopeObject*)_t1.data; + if (obj._typ == 324 /* v.ast.ConstField */) { _option_v__ast__ConstField_ptr _t2; - opt_ok2(&(v__ast__ConstField*[]) { &(*((obj->_v__ast__ConstField))) }, (_option*)(&_t2), sizeof(v__ast__ConstField*)); + opt_ok2(&(v__ast__ConstField*[]) { &(*obj._v__ast__ConstField) }, (_option*)(&_t2), sizeof(v__ast__ConstField*)); return _t2; } @@ -48348,7 +48359,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 _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)); + 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; } @@ -48387,7 +48398,7 @@ Array_v__ast__Type v__ast__merge_types(Array_Array_v__ast__Type params) { } v__ast__Type v__ast__mktyp(v__ast__Type typ) { - 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)); + 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; } @@ -48740,9 +48751,9 @@ multi_return_int_int v__ast__Table_type_size(v__ast__Table* t, v__ast__Type typ) } case v__ast__Kind__alias: { - multi_return_int_int mr_21155 = v__ast__Table_type_size(t, (/* as */ *(v__ast__Alias*)__as_cast((sym->info)._v__ast__Alias,(sym->info)._typ, 433) /*expected idx: 433, name: v.ast.Alias */ ).parent_type); - size = mr_21155.arg0; - align = mr_21155.arg1; + multi_return_int_int mr_21154 = v__ast__Table_type_size(t, (/* as */ *(v__ast__Alias*)__as_cast((sym->info)._v__ast__Alias,(sym->info)._typ, 433) /*expected idx: 433, name: v.ast.Alias */ ).parent_type); + size = mr_21154.arg0; + align = mr_21154.arg1; break; } case v__ast__Kind__struct_: @@ -48770,9 +48781,9 @@ multi_return_int_int v__ast__Table_type_size(v__ast__Table* t, v__ast__Type typ) Array_v__ast__Type types = _t4; for (int _t7 = 0; _t7 < types.len; ++_t7) { v__ast__Type ftyp = ((v__ast__Type*)types.data)[_t7]; - multi_return_int_int mr_21466 = v__ast__Table_type_size(t, ftyp); - int field_size = mr_21466.arg0; - int alignment = mr_21466.arg1; + multi_return_int_int mr_21465 = v__ast__Table_type_size(t, ftyp); + int field_size = mr_21465.arg0; + int alignment = mr_21465.arg1; if (alignment > max_alignment) { max_alignment = alignment; } @@ -48799,8 +48810,8 @@ multi_return_int_int v__ast__Table_type_size(v__ast__Table* t, v__ast__Type typ) align = t->pointer_size; for (int _t8 = 0; _t8 < (*sym->info._v__ast__Interface).embeds.len; ++_t8) { v__ast__Type etyp = ((v__ast__Type*)(*sym->info._v__ast__Interface).embeds.data)[_t8]; - multi_return_int_int mr_22027 = v__ast__Table_type_size(t, etyp); - int esize = mr_22027.arg0; + multi_return_int_int mr_22026 = v__ast__Table_type_size(t, etyp); + int esize = mr_22026.arg0; size += esize - 2 * t->pointer_size; } } @@ -48813,9 +48824,9 @@ multi_return_int_int v__ast__Table_type_size(v__ast__Table* t, v__ast__Type typ) case v__ast__Kind__array_fixed: { v__ast__ArrayFixed info = /* as */ *(v__ast__ArrayFixed*)__as_cast((sym->info)._v__ast__ArrayFixed,(sym->info)._typ, 441) /*expected idx: 441, name: v.ast.ArrayFixed */ ; - multi_return_int_int mr_22224 = v__ast__Table_type_size(t, info.elem_type); - int elem_size = mr_22224.arg0; - int elem_align = mr_22224.arg1; + multi_return_int_int mr_22223 = v__ast__Table_type_size(t, info.elem_type); + int elem_size = mr_22223.arg0; + int elem_align = mr_22223.arg1; size = info.size * elem_size; align = elem_align; break; @@ -51018,7 +51029,7 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_check_shift(v__checker__Checker v__ast__Type _t8 = left_type; return _t8; } - int moffset = ((left_type_final == (_const_v__ast__char_type)) ? (7) : (left_type_final == (_const_v__ast__i8_type)) ? (7) : (left_type_final == (_const_v__ast__i16_type)) ? (15) : (left_type_final == (_const_v__ast__int_type)) ? (31) : (left_type_final == (_const_v__ast__i64_type)) ? (63) : (left_type_final == (_const_v__ast__byte_type)) ? (7) : (left_type_final == (_const_v__ast__u16_type)) ? (15) : (left_type_final == (_const_v__ast__u32_type)) ? (31) : (left_type_final == (_const_v__ast__u64_type)) ? (63) : (64)); + int moffset = ((left_type_final == (_const_v__ast__char_type))? (7) : (left_type_final == (_const_v__ast__i8_type))? (7) : (left_type_final == (_const_v__ast__i16_type))? (15) : (left_type_final == (_const_v__ast__int_type))? (31) : (left_type_final == (_const_v__ast__i64_type))? (63) : (left_type_final == (_const_v__ast__byte_type))? (7) : (left_type_final == (_const_v__ast__u16_type))? (15) : (left_type_final == (_const_v__ast__u32_type))? (31) : (left_type_final == (_const_v__ast__u64_type))? (63) : (64)); if (ival > moffset && !c->pref->translated && !c->file->is_translated) { v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("shift count for type `"), /*115 &string*/0xfe10, {.d_s = left_sym_final->name}}, {_SLIT("` too large (maximum: "), /*100 &int*/0xfe07, {.d_i32 = moffset}}, {_SLIT(" bits)"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(node->right)); v__ast__Type _t9 = left_type; @@ -51089,10 +51100,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_18084 = type_hi; - v__ast__Type _var_18093 = type_lo; - type_hi = _var_18093; - type_lo = _var_18084; + v__ast__Type _var_18083 = type_hi; + v__ast__Type _var_18092 = type_lo; + type_hi = _var_18092; + type_lo = _var_18083; } int idx_hi = v__ast__Type_idx(type_hi); int idx_lo = v__ast__Type_idx(type_lo); @@ -51883,7 +51894,47 @@ void v__checker__Checker_sum_type_decl(v__checker__Checker* c, v__ast__SumTypeDe } else if (sym->kind == v__ast__Kind__interface_ && sym->language != v__ast__Language__js) { v__checker__Checker_error(c, _SLIT("sum type cannot hold an interface"), variant.pos); } else if (sym->kind == v__ast__Kind__struct_ && sym->language == v__ast__Language__js) { - v__checker__Checker_error(c, _SLIT("sum type cannot hold an JS struct"), variant.pos); + v__checker__Checker_error(c, _SLIT("sum type cannot hold a JS struct"), variant.pos); + } else if ((sym->info)._typ == 418 /* v.ast.Struct */) { + if ((*sym->info._v__ast__Struct).is_generic) { + if (!v__ast__Type_has_flag(variant.typ, v__ast__TypeFlag__generic)) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("generic struct `"), /*115 &string*/0xfe10, {.d_s = sym->name}}, {_SLIT("` must specify generic type names, e.g. Foo"), 0, { .d_c = 0 }}})), variant.pos); + } + if (node.generic_types.len == 0) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("generic sumtype `"), /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("` must specify generic type names, e.g. Foo"), 0, { .d_c = 0 }}})), node.name_pos); + } else { + for (int _t3 = 0; _t3 < (*sym->info._v__ast__Struct).generic_types.len; ++_t3) { + v__ast__Type typ = ((v__ast__Type*)(*sym->info._v__ast__Struct).generic_types.data)[_t3]; + if (!Array_v__ast__Type_contains(node.generic_types, typ)) { + Array_string _t4 = {0}; + Array_v__ast__Type _t4_orig = node.generic_types; + int _t4_len = _t4_orig.len; + _t4 = __new_array(0, _t4_len, sizeof(string)); + + for (int _t5 = 0; _t5 < _t4_len; ++_t5) { + v__ast__Type it = ((v__ast__Type*) _t4_orig.data)[_t5]; + string ti = v__ast__Table_type_to_str(c->table, it); + array_push((array*)&_t4, &ti); + } + string sumtype_type_names = Array_string_join(_t4, _SLIT(", ")); + string generic_sumtype_name = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("<"), /*115 &string*/0xfe10, {.d_s = sumtype_type_names}}, {_SLIT(">"), 0, { .d_c = 0 }}})); + Array_string _t6 = {0}; + Array_v__ast__Type _t6_orig = (*sym->info._v__ast__Struct).generic_types; + int _t6_len = _t6_orig.len; + _t6 = __new_array(0, _t6_len, sizeof(string)); + + for (int _t7 = 0; _t7 < _t6_len; ++_t7) { + v__ast__Type it = ((v__ast__Type*) _t6_orig.data)[_t7]; + string ti = v__ast__Table_type_to_str(c->table, it); + array_push((array*)&_t6, &ti); + } + string variant_type_names = Array_string_join(_t6, _SLIT(", ")); + string generic_variant_name = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = sym->name}}, {_SLIT("<"), /*115 &string*/0xfe10, {.d_s = variant_type_names}}, {_SLIT(">"), 0, { .d_c = 0 }}})); + v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("generic type name `"), /*115 &string*/0xfe10, {.d_s = v__ast__Table_sym(c->table, typ)->name}}, {_SLIT("` of generic struct `"), /*115 &string*/0xfe10, {.d_s = generic_variant_name}}, {_SLIT("` is not mentioned in sumtype `"), /*115 &string*/0xfe10, {.d_s = generic_sumtype_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), variant.pos); + } + } + } + } } if (string__eq(string_trim_string_left(sym->name, string__plus(sym->mod, _SLIT("."))), node.name)) { v__checker__Checker_error(c, _SLIT("sum type cannot hold itself"), variant.pos); @@ -52057,10 +52108,10 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("negative value cannot be compared with `"), /*115 &string*/0xfe10, {.d_s = rt}}, {_SLIT("`"), 0, { .d_c = 0 }}})), (*node->left._v__ast__IntegerLiteral).pos); } } else if (is_left_type_signed != is_right_type_signed && left_type != _const_v__ast__int_literal_type_idx && right_type != _const_v__ast__int_literal_type_idx) { - multi_return_int_int mr_23224 = v__ast__Table_type_size(c->table, left_type); - int ls = mr_23224.arg0; - multi_return_int_int mr_23267 = v__ast__Table_type_size(c->table, right_type); - int rs = mr_23267.arg0; + multi_return_int_int mr_24200 = v__ast__Table_type_size(c->table, left_type); + int ls = mr_24200.arg0; + multi_return_int_int mr_24243 = v__ast__Table_type_size(c->table, right_type); + int rs = mr_24243.arg0; if (!c->pref->translated && ((is_left_type_signed && ls < rs) || (is_right_type_signed && rs < ls))) { string lt = v__ast__Table_sym(c->table, left_type)->name; string rt = v__ast__Table_sym(c->table, right_type)->name; @@ -52333,8 +52384,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_33986 = v__checker__Checker_fail_if_immutable(c, node->left); - node->auto_locked = mr_33986.arg0; + multi_return_string_v__token__Pos mr_34962 = v__checker__Checker_fail_if_immutable(c, node->left); + node->auto_locked = mr_34962.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_) { @@ -52770,19 +52821,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` "), /*115 &string*/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_44503 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); - to_lock = mr_44503.arg0; - pos = mr_44503.arg1; + multi_return_string_v__token__Pos mr_45479 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); + to_lock = mr_45479.arg0; + pos = mr_45479.arg1; } else if (expr._typ == 283 /* v.ast.ParExpr */) { - multi_return_string_v__token__Pos mr_44572 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); - to_lock = mr_44572.arg0; - pos = mr_44572.arg1; + multi_return_string_v__token__Pos mr_45548 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); + to_lock = mr_45548.arg0; + pos = mr_45548.arg1; } else if (expr._typ == 285 /* v.ast.PrefixExpr */) { - multi_return_string_v__token__Pos mr_44644 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); - to_lock = mr_44644.arg0; - pos = mr_44644.arg1; + multi_return_string_v__token__Pos mr_45620 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); + to_lock = mr_45620.arg0; + pos = mr_45620.arg1; } else if (expr._typ == 288 /* v.ast.SelectorExpr */) { if ((*expr._v__ast__SelectorExpr).expr_type == 0) { @@ -52832,9 +52883,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 `"), /*115 &string*/0xfe10, {.d_s = (*expr._v__ast__SelectorExpr).field_name}}, {_SLIT("` of struct `"), /*115 &string*/0xfe10, {.d_s = type_str}}, {_SLIT("` is immutable"), 0, { .d_c = 0 }}})), (*expr._v__ast__SelectorExpr).pos); } - multi_return_string_v__token__Pos mr_46108 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); - to_lock = mr_46108.arg0; - pos = mr_46108.arg1; + multi_return_string_v__token__Pos mr_47084 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); + to_lock = mr_47084.arg0; + pos = mr_47084.arg1; } if ((to_lock).len != 0) { explicit_lock_needed = true; @@ -52940,9 +52991,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im } else if (expr._typ == 254 /* v.ast.CallExpr */) { if (string__eq((*expr._v__ast__CallExpr).name, _SLIT("slice"))) { - multi_return_string_v__token__Pos mr_47931 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); - to_lock = mr_47931.arg0; - pos = mr_47931.arg1; + multi_return_string_v__token__Pos mr_48907 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); + to_lock = mr_48907.arg0; + pos = mr_48907.arg1; if ((to_lock).len != 0) { explicit_lock_needed = true; } @@ -53360,9 +53411,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){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.default_expr = {0},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_62025 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); - field = mr_62025.arg0; - embed_types = mr_62025.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_63001 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); + field = mr_63001.arg0; + embed_types = mr_63001.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); @@ -53396,9 +53447,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){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.default_expr = {0},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_62856 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); - field = mr_62856.arg0; - embed_types = mr_62856.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_63832 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); + field = mr_63832.arg0; + embed_types = mr_63832.arg1; node->from_embed_types = embed_types; } } @@ -54952,6 +55003,9 @@ v__ast__Type v__checker__Checker_cast_expr(v__checker__Checker* c, v__ast__CastE string snexpr = v__ast__Expr_str(node->expr); string ft = v__ast__Table_type_to_str(c->table, from_type); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot cast sumtype `"), /*115 &string*/0xfe10, {.d_s = ft}}, {_SLIT("` to string, use `"), /*115 &string*/0xfe10, {.d_s = snexpr}}, {_SLIT(".str()` instead."), 0, { .d_c = 0 }}})), node->pos); + } else if (final_from_sym->kind == v__ast__Kind__function) { + string fnexpr = v__ast__Expr_str(node->expr); + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot cast function `"), /*115 &string*/0xfe10, {.d_s = fnexpr}}, {_SLIT("` to string"), 0, { .d_c = 0 }}})), node->pos); } else if (!v__ast__Type_alias_eq(to_type, _const_v__ast__string_type) && v__ast__Type_alias_eq(from_type, _const_v__ast__string_type) && (!(to_sym->kind == v__ast__Kind__alias && string__eq(final_to_sym->name, _SLIT("string"))))) { string error_msg = str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot cast a string to a type `"), /*115 &string*/0xfe10, {.d_s = final_to_sym->name}}, {_SLIT("`, that is not an alias of string"), 0, { .d_c = 0 }}})); if ((node->expr)._typ == 292 /* v.ast.StringLiteral */) { @@ -55609,8 +55663,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: "), /*115 &string*/0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" (non-numeric type `"), /*115 &string*/0xfe10, {.d_s = typ_str}}, {_SLIT("`)"), 0, { .d_c = 0 }}})), node->pos); } else { - multi_return_string_v__token__Pos mr_116473 = v__checker__Checker_fail_if_immutable(c, node->expr); - node->auto_locked = mr_116473.arg0; + multi_return_string_v__token__Pos mr_117590 = v__checker__Checker_fail_if_immutable(c, node->expr); + node->auto_locked = mr_117590.arg0; } v__ast__Type _t1 = typ; return _t1; @@ -55647,6 +55701,8 @@ void v__checker__Checker_mark_as_referenced(v__checker__Checker* c, v__ast__Expr (*(*node->_v__ast__Ident).obj._v__ast__Var).is_auto_heap = true; } } + else if (type_sym->kind == (v__ast__Kind__sum_type) || type_sym->kind == (v__ast__Kind__interface_)) { + } else { (*(*node->_v__ast__Ident).obj._v__ast__Var).is_auto_heap = true; }; @@ -55814,38 +55870,25 @@ v__ast__Type v__checker__Checker_index_expr(v__checker__Checker* c, v__ast__Inde v__ast__Type typ = v__checker__Checker_expr(c, node->left); v__ast__TypeSymbol* typ_sym = v__ast__Table_final_sym(c->table, typ); node->left_type = typ; - for (;;) { - if (typ_sym->kind == (v__ast__Kind__map)) { - node->is_map = true; - break; - } - else if (typ_sym->kind == (v__ast__Kind__array)) { - node->is_array = true; - if (node->or_expr.kind != v__ast__OrKind__absent && (node->index)._typ == 286 /* v.ast.RangeExpr */) { - v__checker__Checker_error(c, _SLIT("custom error handling on range expressions for arrays is not supported yet."), node->or_expr.pos); - } - break; - } - else if (typ_sym->kind == (v__ast__Kind__array_fixed)) { - node->is_farray = true; - break; - } - else if (typ_sym->kind == (v__ast__Kind__any)) { - string gname = typ_sym->name; - typ = v__checker__Checker_unwrap_generic(c, typ); - node->left_type = typ; - typ_sym = v__ast__Table_final_sym(c->table, typ); - if (v__ast__Type_is_ptr(typ)) { - continue; - } else { - v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("generic type "), /*115 &string*/0xfe10, {.d_s = gname}}, {_SLIT(" does not support indexing, pass an array, or a reference instead, e.g. []"), /*115 &string*/0xfe10, {.d_s = gname}}, {_SLIT(" or &"), /*115 &string*/0xfe10, {.d_s = gname}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); - } - } - else { - break; - }; + if (typ_sym->kind == (v__ast__Kind__map)) { + node->is_map = true; } + else if (typ_sym->kind == (v__ast__Kind__array)) { + node->is_array = true; + if (node->or_expr.kind != v__ast__OrKind__absent && (node->index)._typ == 286 /* v.ast.RangeExpr */) { + v__checker__Checker_error(c, _SLIT("custom error handling on range expressions for arrays is not supported yet."), node->or_expr.pos); + } + } + else if (typ_sym->kind == (v__ast__Kind__array_fixed)) { + node->is_farray = true; + } + else if (typ_sym->kind == (v__ast__Kind__any)) { + typ = v__checker__Checker_unwrap_generic(c, typ); + typ_sym = v__ast__Table_final_sym(c->table, typ); + } + else { + }; if (!(typ_sym->kind == v__ast__Kind__array || typ_sym->kind == v__ast__Kind__array_fixed || typ_sym->kind == v__ast__Kind__string || typ_sym->kind == v__ast__Kind__map) && !v__ast__Type_is_ptr(typ) && !(v__ast__Type_alias_eq(typ, _const_v__ast__byteptr_type) || v__ast__Type_alias_eq(typ, _const_v__ast__charptr_type)) && !v__ast__Type_has_flag(typ, v__ast__TypeFlag__variadic)) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("type `"), /*115 &string*/0xfe10, {.d_s = typ_sym->name}}, {_SLIT("` does not support indexing"), 0, { .d_c = 0 }}})), node->pos); } @@ -56362,37 +56405,46 @@ void v__checker__Checker_fail_if_unreadable(v__checker__Checker* c, v__ast__Expr VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_call(v__checker__Checker* c, v__ast__ComptimeCall* node) { node->left_type = v__checker__Checker_expr(c, node->left); + if (string__eq(node->method_name, _SLIT("compile_error"))) { + v__checker__Checker_error(c, node->args_var, node->pos); + v__ast__Type _t1 = _const_v__ast__void_type; + return _t1; + } else if (string__eq(node->method_name, _SLIT("compile_warn"))) { + v__checker__Checker_warn(c, node->args_var, node->pos); + v__ast__Type _t2 = _const_v__ast__void_type; + return _t2; + } if (node->is_env) { - _option_string _t1 = v__util__resolve_env_value( str_intp(2, _MOV((StrIntpData[]){{_SLIT("$env('"), /*115 &string*/0xfe10, {.d_s = node->args_var}}, {_SLIT("')"), 0, { .d_c = 0 }}})), false); - if (_t1.state != 0) { /*or block*/ - IError err = _t1.err; + _option_string _t3 = v__util__resolve_env_value( str_intp(2, _MOV((StrIntpData[]){{_SLIT("$env('"), /*115 &string*/0xfe10, {.d_s = node->args_var}}, {_SLIT("')"), 0, { .d_c = 0 }}})), false); + if (_t3.state != 0) { /*or block*/ + IError err = _t3.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->env_pos); - v__ast__Type _t2 = _const_v__ast__string_type; - return _t2; + v__ast__Type _t4 = _const_v__ast__string_type; + return _t4; } - string env_value = (*(string*)_t1.data); + string env_value = (*(string*)_t3.data); node->env_value = env_value; - v__ast__Type _t3 = _const_v__ast__string_type; - return _t3; + v__ast__Type _t5 = _const_v__ast__string_type; + return _t5; } if (node->is_embed) { if (!Array_string_contains(_const_v__checker__valid_comptime_compression_types, node->embed_file.compression_type)) { - Array_string _t4 = {0}; - Array_string _t4_orig = _const_v__checker__valid_comptime_compression_types; - int _t4_len = _t4_orig.len; - _t4 = __new_array(0, _t4_len, sizeof(string)); + Array_string _t6 = {0}; + Array_string _t6_orig = _const_v__checker__valid_comptime_compression_types; + int _t6_len = _t6_orig.len; + _t6 = __new_array(0, _t6_len, sizeof(string)); - for (int _t5 = 0; _t5 < _t4_len; ++_t5) { - string it = ((string*) _t4_orig.data)[_t5]; + for (int _t7 = 0; _t7 < _t6_len; ++_t7) { + string it = ((string*) _t6_orig.data)[_t7]; string ti = str_intp(2, _MOV((StrIntpData[]){{_SLIT("."), /*115 &string*/0xfe10, {.d_s = it}}, {_SLIT0, 0, { .d_c = 0 }}})); - array_push((array*)&_t4, &ti); + array_push((array*)&_t6, &ti); } - string supported = Array_string_join(_t4, _SLIT(", ")); + string supported = Array_string_join(_t6, _SLIT(", ")); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("not supported compression type: ."), /*115 &string*/0xfe10, {.d_s = node->embed_file.compression_type}}, {_SLIT(". supported: "), /*115 &string*/0xfe10, {.d_s = supported}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); } - v__ast__Type _t6 = v__ast__Table_find_type_idx(c->table, _SLIT("v.embed_file.EmbedFileData")); - return _t6; + v__ast__Type _t8 = v__ast__Table_find_type_idx(c->table, _SLIT("v.embed_file.EmbedFileData")); + return _t8; } if (node->is_vweb) { v__ast__FnDecl* save_cur_fn = c->table->cur_fn; @@ -56401,9 +56453,9 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_call(v__checker__Check v__checker__Checker* c2 = v__checker__new_checker(c->table, pref2); c2->comptime_call_pos = node->pos.pos; v__checker__Checker_check(c2, (voidptr)&/*qq*/node->vweb_tmpl); - _PUSH_MANY(&c->warnings, (c2->warnings), _t7, Array_v__errors__Warning); - _PUSH_MANY(&c->errors, (c2->errors), _t8, Array_v__errors__Error); - _PUSH_MANY(&c->notices, (c2->notices), _t9, Array_v__errors__Notice); + _PUSH_MANY(&c->warnings, (c2->warnings), _t9, Array_v__errors__Warning); + _PUSH_MANY(&c->errors, (c2->errors), _t10, Array_v__errors__Error); + _PUSH_MANY(&c->notices, (c2->notices), _t11, Array_v__errors__Notice); c->nr_warnings += c2->nr_warnings; c->nr_errors += c2->nr_errors; c->nr_notices += c2->nr_notices; @@ -56412,35 +56464,35 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_call(v__checker__Check if (string__eq(node->method_name, _SLIT("html"))) { int rtyp = v__ast__Table_find_type_idx(c->table, _SLIT("vweb.Result")); node->result_type = rtyp; - v__ast__Type _t10 = rtyp; - return _t10; + v__ast__Type _t12 = rtyp; + return _t12; } if (string__eq(node->method_name, _SLIT("method"))) { for (int i = 0; i < node->args.len; ++i) { v__ast__CallArg arg = ((v__ast__CallArg*)node->args.data)[i]; (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, i)).typ = v__checker__Checker_expr(c, arg.expr); } - v__ast__Type _t11 = _const_v__ast__string_type; - return _t11; + v__ast__Type _t13 = _const_v__ast__string_type; + return _t13; } if (node->is_vweb) { - v__ast__Type _t12 = _const_v__ast__string_type; - return _t12; - } - _option_v__ast__Var_ptr _t13 = v__ast__Scope_find_var(node->scope, node->method_name); - if (_t13.state != 0) { /*or block*/ - IError err = _t13.err; - v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unknown identifier `"), /*115 &string*/0xfe10, {.d_s = node->method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->method_pos); - v__ast__Type _t14 = _const_v__ast__void_type; + v__ast__Type _t14 = _const_v__ast__string_type; return _t14; } + _option_v__ast__Var_ptr _t15 = v__ast__Scope_find_var(node->scope, node->method_name); + if (_t15.state != 0) { /*or block*/ + IError err = _t15.err; + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unknown identifier `"), /*115 &string*/0xfe10, {.d_s = node->method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->method_pos); + v__ast__Type _t16 = _const_v__ast__void_type; + return _t16; + } - v__ast__Var* v = (*(v__ast__Var**)_t13.data); + v__ast__Var* v = (*(v__ast__Var**)_t15.data); if (!v__ast__Type_alias_eq(v->typ, _const_v__ast__string_type)) { string s = v__checker__Checker_expected_msg(c, v->typ, _const_v__ast__string_type); v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid string method call: "), /*115 &string*/0xfe10, {.d_s = s}}, {_SLIT0, 0, { .d_c = 0 }}})), node->method_pos); - v__ast__Type _t15 = _const_v__ast__void_type; - return _t15; + v__ast__Type _t17 = _const_v__ast__void_type; + return _t17; } string method_name = _SLIT(""); if ((v->expr)._typ == 292 /* v.ast.StringLiteral */) { @@ -56449,18 +56501,18 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_call(v__checker__Check v__checker__Checker_error(c, _SLIT("todo: not a string literal"), node->method_pos); } v__ast__TypeSymbol* left_sym = v__ast__Table_sym(c->table, v__checker__Checker_unwrap_generic(c, node->left_type)); - _option_v__ast__Fn _t16 = v__ast__TypeSymbol_find_method(left_sym, method_name); - if (_t16.state != 0) { /*or block*/ - IError err = _t16.err; + _option_v__ast__Fn _t18 = v__ast__TypeSymbol_find_method(left_sym, method_name); + if (_t18.state != 0) { /*or block*/ + IError err = _t18.err; v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("could not find method `"), /*115 &string*/0xfe10, {.d_s = method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->method_pos); - v__ast__Type _t17 = _const_v__ast__void_type; - return _t17; + v__ast__Type _t19 = _const_v__ast__void_type; + return _t19; } - v__ast__Fn f = (*(v__ast__Fn*)_t16.data); + v__ast__Fn f = (*(v__ast__Fn*)_t18.data); node->result_type = f.return_type; - v__ast__Type _t18 = f.return_type; - return _t18; + v__ast__Type _t20 = f.return_type; + return _t20; } VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_selector(v__checker__Checker* c, v__ast__ComptimeSelector* node) { @@ -56520,8 +56572,8 @@ VV_LOCAL_SYMBOL _option_v__ast__ComptTimeConstValue v__checker__Checker_eval_com return _t2; } else if (expr._typ == 289 /* v.ast.SizeOf */) { - multi_return_int_int mr_4612 = v__ast__Table_type_size(c->table, (*expr._v__ast__SizeOf).typ); - int s = mr_4612.arg0; + multi_return_int_int mr_4820 = v__ast__Table_type_size(c->table, (*expr._v__ast__SizeOf).typ); + int s = mr_4820.arg0; _option_v__ast__ComptTimeConstValue _t3; opt_ok2(&(v__ast__ComptTimeConstValue[]) { int_to_sumtype_v__ast__ComptTimeConstValue(&s) }, (_option*)(&_t3), sizeof(v__ast__ComptTimeConstValue)); return _t3; @@ -57708,10 +57760,10 @@ VV_LOCAL_SYMBOL void v__checker__Checker_verify_all_vweb_routes(v__checker__Chec for (int _t2 = 0; _t2 < sym_app->methods.len; ++_t2) { v__ast__Fn m = ((v__ast__Fn*)sym_app->methods.data)[_t2]; if (m.return_type == typ_vweb_result) { - multi_return_bool_int_int mr_10729 = v__checker__Checker_verify_vweb_params_for_method(c, m); - bool is_ok = mr_10729.arg0; - int nroute_attributes = mr_10729.arg1; - int nargs = mr_10729.arg2; + multi_return_bool_int_int mr_10935 = v__checker__Checker_verify_vweb_params_for_method(c, m); + bool is_ok = mr_10935.arg0; + int nroute_attributes = mr_10935.arg1; + int nargs = mr_10935.arg2; if (!is_ok) { v__ast__FnDecl* f = ((v__ast__FnDecl*)(m.source_fn)); if (isnil(f)) { @@ -58475,7 +58527,7 @@ v__ast__Scope* prev_fn_scope; } } } - v__ast__TypeSymbol* return_sym = v__ast__Table_sym(c->table, node->return_type); + v__ast__TypeSymbol* return_sym = v__ast__Table_final_sym(c->table, node->return_type); if ((return_sym->info)._typ == 444 /* v.ast.MultiReturn */) { for (int _t4 = 0; _t4 < (*return_sym->info._v__ast__MultiReturn).types.len; ++_t4) { v__ast__Type multi_type = ((v__ast__Type*)(*return_sym->info._v__ast__MultiReturn).types.data)[_t4]; @@ -58899,8 +58951,7 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp ; _v_panic(_SLIT("unreachable")); VUNREACHABLE(); - } else if (string__eq(fn_name, _SLIT("json.encode"))) { - } else if (string__eq(fn_name, _SLIT("json.decode")) && node->args.len > 0) { + } else if (node->args.len > 0 && string__eq(fn_name, _SLIT("json.decode"))) { if (node->args.len != 2) { v__checker__Checker_error(c, _SLIT("json.decode expects 2 arguments, a type and a string (e.g `json.decode(T, '')`)"), node->pos); v__ast__Type _t8 = _const_v__ast__void_type; @@ -58962,11 +59013,9 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp } if (!found && (node->left)._typ == 271 /* v.ast.IndexExpr */) { v__checker__Checker_expr(c, node->left); - v__ast__IndexExpr expr = /* as */ *(v__ast__IndexExpr*)__as_cast((node->left)._v__ast__IndexExpr,(node->left)._typ, 271) /*expected idx: 271, name: v.ast.IndexExpr */ ; - v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, expr.left_type); - if (sym->kind == v__ast__Kind__array) { - v__ast__Array info = /* as */ *(v__ast__Array*)__as_cast((sym->info)._v__ast__Array,(sym->info)._typ, 413) /*expected idx: 413, name: v.ast.Array */ ; - v__ast__TypeSymbol* elem_sym = v__ast__Table_sym(c->table, info.elem_type); + v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, (*node->left._v__ast__IndexExpr).left_type); + if ((sym->info)._typ == 413 /* v.ast.Array */) { + v__ast__TypeSymbol* elem_sym = v__ast__Table_sym(c->table, (*sym->info._v__ast__Array).elem_type); if ((elem_sym->info)._typ == 445 /* v.ast.FnType */) { node->return_type = (*elem_sym->info._v__ast__FnType).func.return_type; v__ast__Type _t12 = (*elem_sym->info._v__ast__FnType).func.return_type; @@ -58974,9 +59023,8 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp } else { v__checker__Checker_error(c, _SLIT("cannot call the element of the array, it is not a function"), node->pos); } - } else if (sym->kind == v__ast__Kind__map) { - v__ast__Map info = /* as */ *(v__ast__Map*)__as_cast((sym->info)._v__ast__Map,(sym->info)._typ, 414) /*expected idx: 414, name: v.ast.Map */ ; - v__ast__TypeSymbol* value_sym = v__ast__Table_sym(c->table, info.value_type); + } else if ((sym->info)._typ == 414 /* v.ast.Map */) { + v__ast__TypeSymbol* value_sym = v__ast__Table_sym(c->table, (*sym->info._v__ast__Map).value_type); if ((value_sym->info)._typ == 445 /* v.ast.FnType */) { node->return_type = (*value_sym->info._v__ast__FnType).func.return_type; v__ast__Type _t13 = (*value_sym->info._v__ast__FnType).func.return_type; @@ -58984,9 +59032,8 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp } else { v__checker__Checker_error(c, _SLIT("cannot call the value of the map, it is not a function"), node->pos); } - } else if (sym->kind == v__ast__Kind__array_fixed) { - v__ast__ArrayFixed info = /* as */ *(v__ast__ArrayFixed*)__as_cast((sym->info)._v__ast__ArrayFixed,(sym->info)._typ, 441) /*expected idx: 441, name: v.ast.ArrayFixed */ ; - v__ast__TypeSymbol* elem_sym = v__ast__Table_sym(c->table, info.elem_type); + } else if ((sym->info)._typ == 441 /* v.ast.ArrayFixed */) { + v__ast__TypeSymbol* elem_sym = v__ast__Table_sym(c->table, (*sym->info._v__ast__ArrayFixed).elem_type); if ((elem_sym->info)._typ == 445 /* v.ast.FnType */) { node->return_type = (*elem_sym->info._v__ast__FnType).func.return_type; v__ast__Type _t14 = (*elem_sym->info._v__ast__FnType).func.return_type; @@ -59001,13 +59048,11 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp } if (!found && (node->left)._typ == 254 /* v.ast.CallExpr */) { v__checker__Checker_expr(c, node->left); - v__ast__CallExpr expr = /* as */ *(v__ast__CallExpr*)__as_cast((node->left)._v__ast__CallExpr,(node->left)._typ, 254) /*expected idx: 254, name: v.ast.CallExpr */ ; - v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, expr.return_type); - if (sym->kind == v__ast__Kind__function) { - v__ast__FnType info = /* as */ *(v__ast__FnType*)__as_cast((sym->info)._v__ast__FnType,(sym->info)._typ, 445) /*expected idx: 445, name: v.ast.FnType */ ; - node->return_type = info.func.return_type; + v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, (*node->left._v__ast__CallExpr).return_type); + if ((sym->info)._typ == 445 /* v.ast.FnType */) { + node->return_type = (*sym->info._v__ast__FnType).func.return_type; found = true; - func = info.func; + func = (*sym->info._v__ast__FnType).func; } } if (!found) { @@ -59156,7 +59201,7 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__checker__Checker_warn(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("function `"), /*115 &string*/0xfe10, {.d_s = func.name}}, {_SLIT("` must be called from an `unsafe` block"), 0, { .d_c = 0 }}})), node->pos); } node->is_keep_alive = func.is_keep_alive; - if (!string__eq(func.mod, _SLIT("builtin")) && func.language == v__ast__Language__v && func.no_body && !c->pref->translated && !c->file->is_translated && !func.is_unsafe) { + if (func.language == v__ast__Language__v && func.no_body && !c->pref->translated && !c->file->is_translated && !func.is_unsafe && !string__eq(func.mod, _SLIT("builtin"))) { 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) { @@ -59190,7 +59235,7 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp ; } - if ((string__eq(fn_name, _SLIT("println")) || string__eq(fn_name, _SLIT("print")) || string__eq(fn_name, _SLIT("eprintln")) || string__eq(fn_name, _SLIT("eprint")) || string__eq(fn_name, _SLIT("panic"))) && node->args.len > 0) { + if (node->args.len > 0 && (string__eq(fn_name, _SLIT("println")) || string__eq(fn_name, _SLIT("print")) || string__eq(fn_name, _SLIT("eprintln")) || string__eq(fn_name, _SLIT("eprint")) || string__eq(fn_name, _SLIT("panic")))) { c->inside_println_arg = true; c->expected_type = _const_v__ast__string_type; (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).typ = v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr); @@ -59207,7 +59252,7 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__ast__Type _t35 = func.return_type; return _t35; } - if (string__eq(fn_name, _SLIT("error")) && node->args.len == 1) { + if (node->args.len == 1 && string__eq(fn_name, _SLIT("error"))) { v__ast__CallArg arg = (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)); (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).typ = v__checker__Checker_expr(c, arg.expr); if (v__ast__Type_alias_eq((*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).typ, _const_v__ast__error_type)) { @@ -59262,9 +59307,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_29424 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); - string to_lock = mr_29424.arg0; - v__token__Pos pos = mr_29424.arg1; + multi_return_string_v__token__Pos mr_29230 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); + string to_lock = mr_29230.arg0; + v__token__Pos pos = mr_29230.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)); } @@ -59332,11 +59377,11 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp if ((v__ast__Type_alias_eq(arg_typ, _const_v__ast__bool_type) && v__ast__Type_is_int(param.typ)) || (v__ast__Type_is_int(arg_typ) && v__ast__Type_alias_eq(param.typ, _const_v__ast__bool_type))) { continue; } - bool param_is_number = v__ast__Type_is_number(param.typ); + bool param_is_number = v__ast__Type_is_number(v__ast__Table_unaliased_type(c->table, param.typ)); if (v__ast__Type_is_ptr(param.typ)) { param_is_number = v__ast__Type_is_number(v__ast__Type_deref(param.typ)); } - bool typ_is_number = v__ast__Type_is_number(arg_typ); + bool typ_is_number = v__ast__Type_is_number(v__ast__Table_unaliased_type(c->table, arg_typ)); if (v__ast__Type_is_ptr(arg_typ)) { typ_is_number = v__ast__Type_is_number(v__ast__Type_deref(arg_typ)); } @@ -59346,7 +59391,9 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp if (param.typ == _const_v__ast__voidptr_type_idx || arg_typ == _const_v__ast__voidptr_type_idx) { continue; } - if (((arg_typ_sym->kind == v__ast__Kind__array_fixed || arg_typ_sym->kind == v__ast__Kind__array) && (param_is_number || v__ast__Type_is_any_kind_of_pointer(param.typ))) || ((param_typ_sym->kind == v__ast__Kind__array_fixed || param_typ_sym->kind == v__ast__Kind__array) && (typ_is_number || v__ast__Type_is_any_kind_of_pointer(arg_typ)))) { + v__ast__TypeSymbol* param_typ_sym_ = v__ast__Table_sym(c->table, v__ast__Table_unaliased_type(c->table, param.typ)); + v__ast__TypeSymbol* arg_typ_sym_ = v__ast__Table_sym(c->table, v__ast__Table_unaliased_type(c->table, arg_typ)); + if (((arg_typ_sym_->kind == v__ast__Kind__array_fixed || arg_typ_sym_->kind == v__ast__Kind__array) && (param_is_number || v__ast__Type_is_any_kind_of_pointer(v__ast__Table_unaliased_type(c->table, param.typ)))) || ((param_typ_sym_->kind == v__ast__Kind__array_fixed || param_typ_sym_->kind == v__ast__Kind__array) && (typ_is_number || v__ast__Type_is_any_kind_of_pointer(v__ast__Table_unaliased_type(c->table, arg_typ))))) { continue; } if (v__ast__Type_is_any_kind_of_pointer(param.typ) && typ_is_number) { @@ -59527,12 +59574,10 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal if (!v__checker__Checker_check_types(c, arg_type, info.elem_type) && !v__checker__Checker_check_types(c, left_type, arg_type)) { v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("cannot "), /*115 &string*/0xfe10, {.d_s = method_name}}, {_SLIT(" `"), /*115 &string*/0xfe10, {.d_s = arg_sym->name}}, {_SLIT("` to `"), /*115 &string*/0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(arg_expr)); } - } else if (final_left_sym->kind == v__ast__Kind__array && (string__eq(method_name, _SLIT("first")) || string__eq(method_name, _SLIT("last")) || string__eq(method_name, _SLIT("pop")))) { - if ((final_left_sym->info)._typ == 413 /* v.ast.Array */) { - node->return_type = (*final_left_sym->info._v__ast__Array).elem_type; - v__ast__Type _t13 = node->return_type; - return _t13; - } + } else if ((final_left_sym->info)._typ == 413 /* v.ast.Array */ && (string__eq(method_name, _SLIT("first")) || string__eq(method_name, _SLIT("last")) || string__eq(method_name, _SLIT("pop")))) { + node->return_type = (*final_left_sym->info._v__ast__Array).elem_type; + v__ast__Type _t13 = node->return_type; + return _t13; } else if (v__pref__Backend_is_js(c->pref->backend) && string_starts_with(left_sym->name, _SLIT("Promise<")) && string__eq(method_name, _SLIT("wait"))) { v__ast__Struct info = /* as */ *(v__ast__Struct*)__as_cast((left_sym->info)._v__ast__Struct,(left_sym->info)._typ, 418) /*expected idx: 418, name: v.ast.Struct */ ; if (node->args.len > 0) { @@ -59599,9 +59644,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*) _t19.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.params = __new_array(0, 0, sizeof(v__ast__Param)),.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,.usages = 0,.ctdefine_idx = 0,.source_fn = 0,.language = 0,.file_mode = 0,.is_variadic = 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,.is_conditional = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_42802 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t19.data); - method = mr_42802.arg0; - embed_types = mr_42802.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_42804 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t19.data); + method = mr_42804.arg0; + embed_types = mr_42804.arg1; if (embed_types.len != 0) { is_method_from_embed = true; node->from_embed_types = embed_types; @@ -59649,9 +59694,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_45112 = v__checker__Checker_fail_if_immutable(c, node->left); - string to_lock = mr_45112.arg0; - v__token__Pos pos = mr_45112.arg1; + multi_return_string_v__token__Pos mr_45114 = v__checker__Checker_fail_if_immutable(c, node->left); + string to_lock = mr_45114.arg0; + v__token__Pos pos = mr_45114.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)); } @@ -59691,12 +59736,11 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__ast__Type exp_arg_typ = ((v__ast__Type)(0)); bool param_is_mut = false; bool no_type_promotion = false; - if (left_sym->kind == v__ast__Kind__chan) { - v__ast__Type elem_typ = (/* as */ *(v__ast__Chan*)__as_cast((left_sym->info)._v__ast__Chan,(left_sym->info)._typ, 442) /*expected idx: 442, name: v.ast.Chan */ ).elem_type; + if ((left_sym->info)._typ == 442 /* v.ast.Chan */) { if (string__eq(method_name, _SLIT("try_push"))) { - exp_arg_typ = v__ast__Type_ref(elem_typ); + exp_arg_typ = v__ast__Type_ref((*left_sym->info._v__ast__Chan).elem_type); } else if (string__eq(method_name, _SLIT("try_pop"))) { - exp_arg_typ = elem_typ; + exp_arg_typ = (*left_sym->info._v__ast__Chan).elem_type; param_is_mut = true; no_type_promotion = true; } @@ -59704,7 +59748,7 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal for (int i = 0; i < node->args.len; ++i) { v__ast__CallArg* arg = ((v__ast__CallArg*)node->args.data) + i; if (i > 0 || v__ast__Type_alias_eq(exp_arg_typ, ((v__ast__Type)(0)))) { - exp_arg_typ = (method.is_variadic && i >= method.params.len - 1 ? ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, method.params.len - 1)).typ) : ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, i + 1)).typ)); + exp_arg_typ = (method.is_variadic && i >= method.params.len - 1 ? ((*(v__ast__Param*)array_last(method.params)).typ) : ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, i + 1)).typ)); param_is_mut = false; no_type_promotion = false; } @@ -59723,7 +59767,7 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__ast__TypeSymbol* final_arg_sym = exp_arg_sym; v__ast__Type final_arg_typ = exp_arg_typ; if (method.is_variadic && (exp_arg_sym->info)._typ == 413 /* v.ast.Array */) { - final_arg_typ = v__ast__TypeSymbol_array_info(exp_arg_sym).elem_type; + final_arg_typ = (*exp_arg_sym->info._v__ast__Array).elem_type; final_arg_sym = v__ast__Table_sym(c->table, final_arg_typ); } if (v__ast__Type_has_flag(exp_arg_typ, v__ast__TypeFlag__generic)) { @@ -59747,16 +59791,22 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal } } } - v__ast__Param param = (method.is_variadic && i >= method.params.len - 1 ? ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, method.params.len - 1))) : ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, i + 1)))); + v__ast__Param _t30; /* if prepend */ + if (method.is_variadic && i >= method.params.len - 1) { + _t30 = (*(v__ast__Param*)array_last(method.params)); + } else { + _t30 = (*(v__ast__Param*)/*ee elem_sym */array_get(method.params, i + 1)); + } + v__ast__Param param = _t30; param_is_mut = param_is_mut || param.is_mut; v__ast__ShareType param_share = v__ast__Type_share(param.typ); if (param_share == v__ast__ShareType__shared_t && (c->locked_names.len > 0 || c->rlocked_names.len > 0)) { 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_49074 = v__checker__Checker_fail_if_immutable(c, arg->expr); - string to_lock = mr_49074.arg0; - v__token__Pos pos = mr_49074.arg1; + multi_return_string_v__token__Pos mr_49016 = v__checker__Checker_fail_if_immutable(c, arg->expr); + string to_lock = mr_49016.arg0; + v__token__Pos pos = mr_49016.arg1; if (!param_is_mut) { string tok = v__ast__ShareType_str(arg->share); v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT("`"), /*115 &string*/0xfe10, {.d_s = node->name}}, {_SLIT("` parameter `"), /*115 &string*/0xfe10, {.d_s = param.name}}, {_SLIT("` is not `"), /*115 &string*/0xfe10, {.d_s = tok}}, {_SLIT("`, `"), /*115 &string*/0xfe10, {.d_s = tok}}, {_SLIT("` is not needed`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(arg->expr)); @@ -59776,9 +59826,8 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_fail_if_unreadable(c, arg->expr, got_arg_typ, _SLIT("argument")); } } - if (left_sym->kind == v__ast__Kind__array && string__eq(method_name, _SLIT("sort_with_compare"))) { - v__ast__Array array_info = /* as */ *(v__ast__Array*)__as_cast((left_sym->info)._v__ast__Array,(left_sym->info)._typ, 413) /*expected idx: 413, name: v.ast.Array */ ; - v__ast__Type elem_typ = array_info.elem_type; + if ((left_sym->info)._typ == 413 /* v.ast.Array */ && string__eq(method_name, _SLIT("sort_with_compare"))) { + v__ast__Type elem_typ = (*left_sym->info._v__ast__Array).elem_type; v__ast__TypeSymbol* arg_sym = v__ast__Table_sym(c->table, arg->typ); if (arg_sym->kind == v__ast__Kind__function) { v__ast__FnType func_info = /* as */ *(v__ast__FnType*)__as_cast((arg_sym->info)._v__ast__FnType,(arg_sym->info)._typ, 445) /*expected idx: 445, name: v.ast.FnType */ ; @@ -59807,17 +59856,15 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal } continue; } - _option_void _t30 = v__checker__Checker_check_expected_call_arg(c, got_arg_typ, exp_arg_typ, node->language, *arg); - if (_t30.state != 0 && _t30.err._typ != _IError_None___index) { - IError err = _t30.err; + _option_void _t31 = v__checker__Checker_check_expected_call_arg(c, got_arg_typ, exp_arg_typ, node->language, *arg); + if (_t31.state != 0 && _t31.err._typ != _IError_None___index) { + IError err = _t31.err; v__ast__TypeSymbol* param_typ_sym = v__ast__Table_sym(c->table, exp_arg_typ); v__ast__TypeSymbol* arg_typ_sym = v__ast__Table_sym(c->table, got_arg_typ); - if (param_typ_sym->kind == v__ast__Kind__array && arg_typ_sym->kind == v__ast__Kind__array) { - v__ast__Array param_info = /* as */ *(v__ast__Array*)__as_cast((param_typ_sym->info)._v__ast__Array,(param_typ_sym->info)._typ, 413) /*expected idx: 413, name: v.ast.Array */ ; - v__ast__Type param_elem_type = v__ast__Table_unaliased_type(c->table, param_info.elem_type); - v__ast__Array arg_info = /* as */ *(v__ast__Array*)__as_cast((arg_typ_sym->info)._v__ast__Array,(arg_typ_sym->info)._typ, 413) /*expected idx: 413, name: v.ast.Array */ ; - v__ast__Type arg_elem_type = v__ast__Table_unaliased_type(c->table, arg_info.elem_type); - if (v__ast__Type_nr_muls(exp_arg_typ) == v__ast__Type_nr_muls(got_arg_typ) && param_info.nr_dims == arg_info.nr_dims && v__ast__Type_alias_eq(param_elem_type, arg_elem_type)) { + if ((param_typ_sym->info)._typ == 413 /* v.ast.Array */ && (arg_typ_sym->info)._typ == 413 /* v.ast.Array */) { + v__ast__Type param_elem_type = v__ast__Table_unaliased_type(c->table, (*param_typ_sym->info._v__ast__Array).elem_type); + v__ast__Type arg_elem_type = v__ast__Table_unaliased_type(c->table, (*arg_typ_sym->info._v__ast__Array).elem_type); + if (v__ast__Type_nr_muls(exp_arg_typ) == v__ast__Type_nr_muls(got_arg_typ) && (*param_typ_sym->info._v__ast__Array).nr_dims == (*arg_typ_sym->info._v__ast__Array).nr_dims && v__ast__Type_alias_eq(param_elem_type, arg_elem_type)) { continue; } } @@ -59861,12 +59908,12 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal node->return_type = method.return_type; } if (node->concrete_types.len > 0 && method.return_type != 0 && c->table->cur_fn->generic_names.len == 0) { - _option_v__ast__Type _t32; - if (_t32 = v__ast__Table_resolve_generic_to_concrete(c->table, method.return_type, method.generic_names, concrete_types), _t32.state == 0) { - v__ast__Type typ = *(v__ast__Type*)_t32.data; + _option_v__ast__Type _t33; + if (_t33 = v__ast__Table_resolve_generic_to_concrete(c->table, method.return_type, method.generic_names, concrete_types), _t33.state == 0) { + v__ast__Type typ = *(v__ast__Type*)_t33.data; node->return_type = typ; - v__ast__Type _t33 = typ; - return _t33; + v__ast__Type _t34 = typ; + return _t34; } } if (node->concrete_types.len > 0 && method.generic_names.len == 0) { @@ -59880,11 +59927,11 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal } } } - v__ast__Type _t34 = node->return_type; - return _t34; + v__ast__Type _t35 = node->return_type; + return _t35; } - v__ast__Type _t35 = method.return_type; - return _t35; + v__ast__Type _t36 = method.return_type; + return _t36; } if (string__eq(method_name, _SLIT("str"))) { if (left_sym->kind == v__ast__Kind__interface_) { @@ -59897,25 +59944,25 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT(".str() method calls should have no arguments"), node->pos); } v__checker__Checker_fail_if_unreadable(c, node->left, left_type, _SLIT("receiver")); - v__ast__Type _t36 = _const_v__ast__string_type; - return _t36; - } else if (string__eq(method_name, _SLIT("free"))) { - v__ast__Type _t37 = _const_v__ast__void_type; + v__ast__Type _t37 = _const_v__ast__string_type; return _t37; + } else if (string__eq(method_name, _SLIT("free"))) { + v__ast__Type _t38 = _const_v__ast__void_type; + return _t38; } - _option_v__ast__StructField _t38; - if (_t38 = v__ast__Table_find_field_with_embeds(c->table, left_sym, method_name), _t38.state == 0) { - v__ast__StructField field = *(v__ast__StructField*)_t38.data; + _option_v__ast__StructField _t39; + if (_t39 = v__ast__Table_find_field_with_embeds(c->table, left_sym, method_name), _t39.state == 0) { + v__ast__StructField field = *(v__ast__StructField*)_t39.data; v__ast__TypeSymbol* field_sym = v__ast__Table_sym(c->table, v__checker__Checker_unwrap_generic(c, field.typ)); if (field_sym->kind == v__ast__Kind__function) { node->is_method = false; node->is_field = true; v__ast__FnType info = /* as */ *(v__ast__FnType*)__as_cast((field_sym->info)._v__ast__FnType,(field_sym->info)._typ, 445) /*expected idx: 445, name: v.ast.FnType */ ; - _option_void _t39 = v__checker__Checker_check_expected_arg_count(c, node, (voidptr)&/*qq*/info.func); - if (_t39.state != 0 && _t39.err._typ != _IError_None___index) { - IError err = _t39.err; - v__ast__Type _t40 = info.func.return_type; - return _t40; + _option_void _t40 = v__checker__Checker_check_expected_arg_count(c, node, (voidptr)&/*qq*/info.func); + if (_t40.state != 0 && _t40.err._typ != _IError_None___index) { + IError err = _t40.err; + v__ast__Type _t41 = info.func.return_type; + return _t41; } ; @@ -59928,9 +59975,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal array_push((array*)&earg_types, _MOV((v__ast__Type[]){ targ })); if (i < info.func.params.len) { v__ast__Type exp_arg_typ = (*(v__ast__Param*)/*ee elem_sym */array_get(info.func.params, i)).typ; - _option_void _t42 = v__checker__Checker_check_expected_call_arg(c, targ, v__checker__Checker_unwrap_generic(c, exp_arg_typ), node->language, *arg); - if (_t42.state != 0 && _t42.err._typ != _IError_None___index) { - IError err = _t42.err; + _option_void _t43 = v__checker__Checker_check_expected_call_arg(c, targ, v__checker__Checker_unwrap_generic(c, exp_arg_typ), node->language, *arg); + if (_t43.state != 0 && _t43.err._typ != _IError_None___index) { + IError err = _t43.err; if (!v__ast__Type_alias_eq(targ, _const_v__ast__void_type)) { v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT(" in argument "), /*100 &int*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(" to `"), /*115 &string*/0xfe10, {.d_s = left_sym->name}}, {_SLIT("."), /*115 &string*/0xfe10, {.d_s = method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), arg->pos); } @@ -59942,35 +59989,35 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal } node->expected_arg_types = earg_types; node->is_method = true; - _option_multi_return_v__ast__StructField_Array_v__ast__Type _t43 = v__ast__Table_find_field_from_embeds(c->table, left_sym, method_name); - if (_t43.state != 0) { /*or block*/ - IError err = _t43.err; - v__ast__Type _t44 = info.func.return_type; - return _t44; + _option_multi_return_v__ast__StructField_Array_v__ast__Type _t44 = v__ast__Table_find_field_from_embeds(c->table, left_sym, method_name); + if (_t44.state != 0) { /*or block*/ + IError err = _t44.err; + v__ast__Type _t45 = info.func.return_type; + return _t45; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_56539 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t43.data); - node->from_embed_types = mr_56539.arg1; - v__ast__Type _t45 = info.func.return_type; - return _t45; + multi_return_v__ast__StructField_Array_v__ast__Type mr_56382 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t44.data); + node->from_embed_types = mr_56382.arg1; + v__ast__Type _t46 = info.func.return_type; + return _t46; } } if (!v__ast__Type_alias_eq(left_type, _const_v__ast__void_type)) { - Array_string _t46 = {0}; - Array_v__ast__Fn _t46_orig = left_sym->methods; - int _t46_len = _t46_orig.len; - _t46 = __new_array(0, _t46_len, sizeof(string)); + Array_string _t47 = {0}; + Array_v__ast__Fn _t47_orig = left_sym->methods; + int _t47_len = _t47_orig.len; + _t47 = __new_array(0, _t47_len, sizeof(string)); - for (int _t47 = 0; _t47 < _t46_len; ++_t47) { - v__ast__Fn it = ((v__ast__Fn*) _t46_orig.data)[_t47]; + for (int _t48 = 0; _t48 < _t47_len; ++_t48) { + v__ast__Fn it = ((v__ast__Fn*) _t47_orig.data)[_t48]; string ti = it.name; - array_push((array*)&_t46, &ti); + array_push((array*)&_t47, &ti); } - v__util__Suggestion suggestion = v__util__new_suggestion(method_name,_t46); + v__util__Suggestion suggestion = v__util__new_suggestion(method_name,_t47); v__checker__Checker_error(c, v__util__Suggestion_say(suggestion, unknown_method_msg), node->pos); } - v__ast__Type _t48 = _const_v__ast__void_type; - return _t48; + v__ast__Type _t49 = _const_v__ast__void_type; + return _t49; } VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_go_expr(v__checker__Checker* c, v__ast__GoExpr* node) { @@ -60314,7 +60361,7 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch if (string__eq(method_name, _SLIT("map"))) { v__checker__Checker_check_map_and_filter(c, true, elem_typ, *node); v__ast__TypeSymbol* arg_sym = v__ast__Table_sym(c->table, arg_type); - v__ast__Type ret_type = ((arg_sym->info._typ == 445 /* v.ast.FnType */) ? ((*arg_sym->info._v__ast__FnType).func.return_type) : (arg_type)); + v__ast__Type ret_type = ((arg_sym->info._typ == 445 /* v.ast.FnType */)? ((*arg_sym->info._v__ast__FnType).func.return_type) : (arg_type)); node->return_type = v__ast__Table_find_or_register_array(c->table, v__checker__Checker_unwrap_generic(c, ret_type)); if (v__ast__Type_has_flag(node->return_type, v__ast__TypeFlag__shared_f)) { node->return_type = v__ast__Type_deref(v__ast__Type_clear_flag(node->return_type, v__ast__TypeFlag__shared_f)); @@ -60499,7 +60546,7 @@ VV_LOCAL_SYMBOL void v__checker__Checker_for_in_stmt(v__checker__Checker* c, v__ v__checker__Checker_error(c, _SLIT("declare a key and a value variable when ranging a map: `for key, val in map {`\nuse `_` if you do not need the variable"), node->pos); } if (node->key_var.len > 0) { - v__ast__Type key_type = ((sym->kind == (v__ast__Kind__map)) ? (v__ast__TypeSymbol_map_info(sym).key_type) : (_const_v__ast__int_type)); + v__ast__Type key_type = ((sym->kind == (v__ast__Kind__map))? (v__ast__TypeSymbol_map_info(sym).key_type) : (_const_v__ast__int_type)); node->key_type = key_type; v__ast__Scope_update_var_type(node->scope, node->key_var, key_type); } @@ -62017,7 +62064,7 @@ void v__checker__Checker_return_stmt(v__checker__Checker* c, v__ast__Return* nod v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("fn `"), /*115 &string*/0xfe10, {.d_s = c->table->cur_fn->name}}, {_SLIT("` expects you to return a reference type `"), /*115 &string*/0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, exp_type)}}, {_SLIT("`, but you are returning `"), /*115 &string*/0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, got_typ)}}, {_SLIT("` instead"), 0, { .d_c = 0 }}})), pos); } if (v__ast__Type_is_ptr(exp_type) && v__ast__Type_is_ptr(got_typ)) { - v__ast__Expr* r_expr = &(*(v__ast__Expr*)/*ee elem_sym */array_get(node->exprs, i)); + v__ast__Expr* r_expr = &(*(v__ast__Expr*)/*ee elem_sym */array_get(node->exprs, (*(int*)/*ee elem_sym */array_get(expr_idxs, i)))); if ((r_expr)->_typ == 268 /* v.ast.Ident */) { if (((*r_expr->_v__ast__Ident).obj)._typ == 326 /* v.ast.Var */) { v__ast__Var* obj = &(*(*r_expr->_v__ast__Ident).obj._v__ast__Var); @@ -66619,6 +66666,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_assert_single_expr(v__gen__c__Gen* g, v_ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_assign_stmt(v__gen__c__Gen* g, v__ast__AssignStmt node_) { bool v__gen__c__Gen_gen_assign_stmt_defer_0 = false; +bool v__gen__c__Gen_gen_assign_stmt_defer_1 = false; bool af; string type_to_free; string sref_name; @@ -66632,6 +66680,7 @@ string sref_name; v__ast__Type return_type = _const_v__ast__void_type; bool is_decl = node.op == v__token__Kind__decl_assign; g->assign_op = node.op; + v__gen__c__Gen_gen_assign_stmt_defer_0 = true; v__token__Kind op = (is_decl ? (v__token__Kind__assign) : (node.op)); v__ast__Expr right_expr = (*(v__ast__Expr*)/*ee elem_sym */array_get(node.right, 0)); if (right_expr._typ == 254 /* v.ast.CallExpr */) { @@ -66670,7 +66719,7 @@ string sref_name; v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT(" "), /*115 &string*/0xfe10, {.d_s = sref_name}}, {_SLIT(" = ("), 0, { .d_c = 0 }}}))); v__gen__c__Gen_expr(g, left0); v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("); // free "), /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT(" on re-assignment2"), 0, { .d_c = 0 }}}))); - v__gen__c__Gen_gen_assign_stmt_defer_0 = true; + v__gen__c__Gen_gen_assign_stmt_defer_1 = true; } else { af = false; } @@ -66684,12 +66733,17 @@ string sref_name; if (sym->kind == v__ast__Kind__multi_return) { v__gen__c__Gen_gen_multi_return_assign(g, (voidptr)&/*qq*/node, return_type); // Defer begin - if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + if (v__gen__c__Gen_gen_assign_stmt_defer_1) { if (af) { v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT("_free(&"), /*115 &string*/0xfe10, {.d_s = sref_name}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); } } // Defer end + // Defer begin + if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + g->assign_op = v__token__Kind__unknown; + } + // Defer end return; } } @@ -66935,12 +66989,17 @@ string sref_name; v__gen__c__Gen_expr(g, val); v__gen__c__Gen_writeln(g, _SLIT(");")); // Defer begin - if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + if (v__gen__c__Gen_gen_assign_stmt_defer_1) { if (af) { v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT("_free(&"), /*115 &string*/0xfe10, {.d_s = sref_name}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); } } // Defer end + // Defer begin + if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + g->assign_op = v__token__Kind__unknown; + } + // Defer end return; } else { v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT(" = "), /*115 &string*/0xfe10, {.d_s = styp}}, {_SLIT("_"), /*115 &string*/0xfe10, {.d_s = v__util__replace_op(extracted_op)}}, {_SLIT("("), 0, { .d_c = 0 }}}))); @@ -67115,12 +67174,17 @@ string sref_name; } } // Defer begin -if (v__gen__c__Gen_gen_assign_stmt_defer_0) { +if (v__gen__c__Gen_gen_assign_stmt_defer_1) { if (af) { v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT("_free(&"), /*115 &string*/0xfe10, {.d_s = sref_name}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); } } // Defer end +// Defer begin +if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + g->assign_op = v__token__Kind__unknown; +} +// Defer end } VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_multi_return_assign(v__gen__c__Gen* g, v__ast__AssignStmt* node, v__ast__Type return_type) { @@ -69216,7 +69280,7 @@ strings__Builder fn_body; strings__Builder_write_string(&fn_body, str_intp(2, _MOV((StrIntpData[]){{_SLIT("tos2((byteptr)"), /*115 &string*/0xfe10, {.d_s = func}}, {_SLIT(")"), 0, { .d_c = 0 }}}))); } else { if (v__ast__Type_is_ptr(field.typ) && sym->kind == v__ast__Kind__struct_) { - funcprefix = /*f*/string__plus(funcprefix, _SLIT("(indent_count > 25) ? _SLIT(\"\") : ")); + funcprefix = /*f*/string__plus(funcprefix, _SLIT("(indent_count > 25)? _SLIT(\"\") : ")); } if (caller_should_free) { string tmpvar = v__gen__c__Gen_new_tmp_var(g); @@ -69255,8 +69319,8 @@ VV_LOCAL_SYMBOL multi_return_string_bool v__gen__c__struct_auto_str_func(v__ast_ eprintln( str_intp(6, _MOV((StrIntpData[]){{_SLIT("> struct_auto_str_func: "), /*115 &string*/0xfe10, {.d_s = sym->name}}, {_SLIT(" | field_type.debug() | "), /*115 &string*/0xfe10, {.d_s = fn_name}}, {_SLIT(" | "), /*115 &string*/0xfe10, {.d_s = field_name}}, {_SLIT(" | "), /*115 &bool*/0xfe10, {.d_s = has_custom_str ? _SLIT("true") : _SLIT("false")}}, {_SLIT(" | "), /*115 &bool*/0xfe10, {.d_s = expects_ptr ? _SLIT("true") : _SLIT("false")}}, {_SLIT0, 0, { .d_c = 0 }}}))); } #endif - multi_return_string_string mr_39682 = v__gen__c__deref_kind(expects_ptr, v__ast__Type_is_ptr(field_type), field_type); - string deref = mr_39682.arg0; + multi_return_string_string mr_39681 = v__gen__c__deref_kind(expects_ptr, v__ast__Type_is_ptr(field_type), field_type); + string deref = mr_39681.arg0; if (sym->kind == v__ast__Kind__enum_) { return (multi_return_string_bool){.arg0= str_intp(4, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = fn_name}}, {_SLIT("("), /*115 &string*/0xfe10, {.d_s = deref}}, {_SLIT("it."), /*115 &string*/0xfe10, {.d_s = v__gen__c__c_name(field_name)}}, {_SLIT(")"), 0, { .d_c = 0 }}})), .arg1=true}; } else if (v__gen__c__should_use_indent_func(sym->kind)) { @@ -73544,6 +73608,9 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_cast_expr(v__gen__c__Gen* g, v__ast__CastExp v__gen__c__Gen_expr(g, node.expr); v__gen__c__Gen_write(g, _SLIT("))")); } else if (sym->kind == v__ast__Kind__alias && v__ast__Table_final_sym(g->table, node.typ)->kind == v__ast__Kind__array_fixed) { + if ((node.expr)._typ == 248 /* v.ast.ArrayInit */ && g->assign_op != v__token__Kind__decl_assign) { + v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("("), /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, (*node.expr._v__ast__ArrayInit).typ)}}, {_SLIT(")"), 0, { .d_c = 0 }}}))); + } v__gen__c__Gen_expr(g, node.expr); } else if (v__ast__Type_alias_eq(node.expr_type, _const_v__ast__bool_type) && v__ast__Type_is_int(node.typ)) { string styp = v__gen__c__Gen_typ(g, node.typ); @@ -74472,9 +74539,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_146797 = v__gen__c__Gen_optional_type_name(g, field.typ); - string styp = mr_146797.arg0; - string base = mr_146797.arg1; + multi_return_string_string mr_146906 = v__gen__c__Gen_optional_type_name(g, field.typ); + string styp = mr_146906.arg0; + string base = mr_146906.arg1; sync__RwMutex_lock(&g->done_optionals->mtx); /*lock*/ { if (!Array_string_contains(g->done_optionals->val, base)) { @@ -74769,11 +74836,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["), /*115 &string*/0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._typ]._method_msg("), /*115 &string*/0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._object)"), 0, { .d_c = 0 }}})); if (g->pref->is_debug) { - multi_return_int_string_string_string mr_156580 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); - int paline = mr_156580.arg0; - string pafile = mr_156580.arg1; - string pamod = mr_156580.arg2; - string pafn = mr_156580.arg3; + multi_return_int_string_string_string mr_156689 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); + int paline = mr_156689.arg0; + string pafile = mr_156689.arg1; + string pamod = mr_156689.arg2; + string pafn = mr_156689.arg3; v__gen__c__Gen_writeln(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("panic_debug("), /*100 &int*/0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), /*115 &string*/0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), /*115 &string*/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( "), /*115 &string*/0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); @@ -74796,11 +74863,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["), /*115 &string*/0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._typ]._method_msg("), /*115 &string*/0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._object)"), 0, { .d_c = 0 }}})); if (g->pref->is_debug) { - multi_return_int_string_string_string mr_157847 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); - int paline = mr_157847.arg0; - string pafile = mr_157847.arg1; - string pamod = mr_157847.arg2; - string pafn = mr_157847.arg3; + multi_return_int_string_string_string mr_157956 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); + int paline = mr_157956.arg0; + string pafile = mr_157956.arg1; + string pamod = mr_157956.arg2; + string pafn = mr_157956.arg3; v__gen__c__Gen_writeln(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("panic_debug("), /*100 &int*/0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), /*115 &string*/0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), /*115 &string*/0xfe10, {.d_s = err_msg}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); } else { v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tpanic_result_not_set("), /*115 &string*/0xfe10, {.d_s = err_msg}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); @@ -74910,11 +74977,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_160457 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); - string hash_fn = mr_160457.arg0; - string key_eq_fn = mr_160457.arg1; - string clone_fn = mr_160457.arg2; - string free_fn = mr_160457.arg3; + multi_return_string_string_string_string mr_160566 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); + string hash_fn = mr_160566.arg0; + string key_eq_fn = mr_160566.arg1; + string clone_fn = mr_160566.arg2; + string free_fn = mr_160566.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(""))); @@ -75445,8 +75512,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)).name,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).type_pos,.typ = v__ast__Type_set_nr_muls(st, 1),(*(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)).is_hidden,}) }); - multi_return_Array_string_Array_string_Array_bool mr_174939 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); - Array_string fargs = mr_174939.arg0; + multi_return_Array_string_Array_string_Array_bool mr_175048 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); + Array_string fargs = mr_175048.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__")); @@ -75463,8 +75530,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){.params = __new_array(0, 0, sizeof(v__ast__Param)),.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,.usages = 0,.ctdefine_idx = 0,.source_fn = 0,.language = 0,.file_mode = 0,.is_variadic = 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,.is_conditional = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_175403 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); - Array_v__ast__Type embed_types = mr_175403.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_175512 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); + Array_v__ast__Type embed_types = mr_175512.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, /*115 &string*/0xfe10, {.d_s = embed_sym->cname}}, {_SLIT("_"), /*115 &string*/0xfe10, {.d_s = method.name}}, {_SLIT0, 0, { .d_c = 0 }}})); @@ -75751,7 +75818,7 @@ VV_LOCAL_SYMBOL string v__gen__c__c_closure_helpers(v__pref__Preferences* pref) if (pref->os != v__pref__OS__windows) { strings__Builder_writeln(&builder, _SLIT("#include ")); } - strings__Builder_write_string(&builder, _SLIT("\n#ifdef _MSC_VER\n\011#define __RETURN_ADDRESS() _ReturnAddress()\n#elif defined(__TINYC__) && defined(_WIN32)\n\011#define __RETURN_ADDRESS() __builtin_return_address(0)\n#else\n\011#define __RETURN_ADDRESS() __builtin_extract_return_addr(__builtin_return_address(0))\n#endif\n\n#ifdef __V_amd64\n#ifdef _WIN32\nstatic const char __closure_thunk[] = {\n\0110x48, 0x89, 0x0d, 0xc1, 0xff, 0xff, 0xff, // mov qword ptr [rip - 63], rcx # <_orig_rcx>\n\0110x8f, 0x05, 0xc3, 0xff, 0xff, 0xff, // pop qword ptr [rip - 61] # <_orig_rbp>\n\0110xff, 0x15, 0xd5, 0xff, 0xff, 0xff, // call qword ptr [rip - 43] # \n\0110x48, 0x8b, 0x0d, 0xae, 0xff, 0xff, 0xff, // mov rcx, qword ptr [rip - 82] # <_orig_rcx>\n\0110xff, 0x15, 0xc0, 0xff, 0xff, 0xff, // call qword ptr [rip - 64] # \n\0110xff, 0x35, 0xaa, 0xff, 0xff, 0xff, // push qword ptr [rip - 86] # <_orig_rbp>\n\0110xc3 // ret\n};\n#else\nstatic const char __closure_thunk[] = {\n\0110x48, 0x89, 0x3d, 0xc1, 0xff, 0xff, 0xff, // mov qword ptr [rip - 63], rdi # <_orig_rdi>\n\0110x8f, 0x05, 0xc3, 0xff, 0xff, 0xff, // pop qword ptr [rip - 61] # <_orig_rbp>\n\0110xff, 0x15, 0xd5, 0xff, 0xff, 0xff, // call qword ptr [rip - 43] # \n\0110x48, 0x8b, 0x3d, 0xae, 0xff, 0xff, 0xff, // mov rdi, qword ptr [rip - 82] # <_orig_rdi>\n\0110xff, 0x15, 0xc0, 0xff, 0xff, 0xff, // call qword ptr [rip - 64] # \n\0110xff, 0x35, 0xaa, 0xff, 0xff, 0xff, // push qword ptr [rip - 86] # <_orig_rbp>\n\0110xc3 // ret\n};\n#endif\n#define __CLOSURE_WRAPPER_OFFSET 19\n#define __CLOSURE_UNWRAPPER_OFFSET 32\n#define __CLOSURE_WRAPPER_EXTRA_PARAM void* _t\n#define __CLOSURE_WRAPPER_EXTRA_PARAM_COMMA ,\n#elif defined(__V_x86)\nstatic char __closure_thunk[] = {\n 0xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n 0x58, // pop eax\n 0x8f, 0x40, 0xe3, // pop dword ptr [eax - 29] # <_orig_rbp>\n 0xff, 0x50, 0xef, // call dword ptr [eax - 17] # \n 0xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n 0x58, // pop eax\n 0xff, 0x50, 0xdf, // call dword ptr [eax - 33] # \n 0xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n 0x58, // pop eax\n 0xff, 0x70, 0xce, // push dword ptr [eax - 50] # <_orig_rbp>\n 0xc3 // ret\n};\n\n#define __CLOSURE_WRAPPER_OFFSET 12\n#define __CLOSURE_UNWRAPPER_OFFSET 21\n#define __CLOSURE_WRAPPER_EXTRA_PARAM void* _t\n#define __CLOSURE_WRAPPER_EXTRA_PARAM_COMMA ,\n\n#elif defined(__V_arm64)\nstatic char __closure_thunk[] = {\n\0110x10, 0x00, 0x00, 0x10, // adr x16, start\n\0110x08, 0x82, 0x1c, 0xf8, // str x8, _orig_x8\n\0110x1e, 0x02, 0x1d, 0xf8, // str x30, _orig_x30\n\0110xf0, 0xfe, 0xff, 0x58, // ldr x16, wrapper\n\0110x00, 0x02, 0x3f, 0xd6, // blr x16\n\0110x70, 0xff, 0xff, 0x10, // adr x16, start\n\0110x08, 0x82, 0x5c, 0xf8, // ldr x8, _orig_x8\n\0110x30, 0xfe, 0xff, 0x58, // ldr x16, unwrapper\n\0110x00, 0x02, 0x3f, 0xd6, // blr x16\n\0110xf0, 0xfe, 0xff, 0x10, // adr x16, start\n\0110x1e, 0x02, 0x5d, 0xf8, // ldr x30, _orig_x30\n\0110xc0, 0x03, 0x5f, 0xd6 // ret\n};\n#define __CLOSURE_WRAPPER_OFFSET 20\n#define __CLOSURE_UNWRAPPER_OFFSET 36\n#define __CLOSURE_WRAPPER_EXTRA_PARAM\n#define __CLOSURE_WRAPPER_EXTRA_PARAM_COMMA\n#elif defined(__V_arm32)\nstatic char __closure_thunk[] = {\n 0x24, 0x00, 0x0f, 0xe5, // str r0, orig_r0\n 0x24, 0xe0, 0x0f, 0xe5, // str lr, orig_lr\n 0x1c, 0xc0, 0x1f, 0xe5, // ldr ip, wrapper\n 0x3c, 0xff, 0x2f, 0xe1, // blx ip\n 0x34, 0x00, 0x1f, 0xe5, // ldr r0, orig_r0\n 0x2c, 0xc0, 0x1f, 0xe5, // ldr ip, unwrapper\n 0x3c, 0xff, 0x2f, 0xe1, // blx ip\n 0x3c, 0xe0, 0x1f, 0xe5, // ldr lr, orig_lr\n 0x1e, 0xff, 0x2f, 0xe1 // bx lr\n};\n#define __CLOSURE_WRAPPER_OFFSET 16\n#define __CLOSURE_UNWRAPPER_OFFSET 28\n#define __CLOSURE_WRAPPER_EXTRA_PARAM void* _t\n#define __CLOSURE_WRAPPER_EXTRA_PARAM_COMMA ,\n#endif\n\nstatic int _V_PAGE_SIZE = 4096; // pre-initialized to the most common value, in case _vinit is not called (in a DLL, for example)\n\nstatic inline void __closure_set_data(void* closure, void* data) {\n void** p = closure;\n p[-1] = data;\n}\n\nstatic inline void __closure_set_function(void* closure, void* f) {\n void** p = closure;\n p[-2] = f;\n}\n\nstatic inline void __closure_set_wrapper(void* closure, void* f) {\n void** p = closure;\n p[-3] = f;\n}\n\nstatic inline void __closure_set_unwrapper(void* closure, void* f) {\n void** p = closure;\n p[-4] = f;\n}\n\nstatic inline void __closure_set_base_ptr(void* closure, void* bp) {\n void** p = closure;\n p[-5] = bp;\n}\n\nstatic void* __closure_create(void* fn, void* wrapper, void* unwrapper, void* data) {\n#ifdef _WIN32\n\011SYSTEM_INFO si;\n\011GetNativeSystemInfo(&si);\n\011uint32_t page_size = si.dwPageSize;\n\011char* p = VirtualAlloc(NULL, page_size * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);\n\011if (p == NULL) return 0;\n#else\n\011uint32_t page_size = sysconf(_SC_PAGESIZE);\n\011int prot = PROT_READ | PROT_WRITE;\n\011int flags = MAP_ANONYMOUS | MAP_PRIVATE;\n\011char* p = mmap(0, page_size * 2, prot, flags, -1, 0);\n\011if (p == MAP_FAILED) return 0;\n#endif\n\n\011void* closure = p + page_size;\n\011memcpy(closure, __closure_thunk, sizeof(__closure_thunk));\n\n#ifdef _WIN32\n\011DWORD _tmp;\n\011VirtualProtect(closure, page_size, PAGE_EXECUTE_READ, &_tmp);\n#else\n\011mprotect(closure, page_size, PROT_READ | PROT_EXEC);\n#endif\n\n\011__closure_set_data(closure, data);\n\011__closure_set_function(closure, fn);\n\011__closure_set_wrapper(closure, wrapper);\n\011__closure_set_unwrapper(closure, unwrapper);\n\011__closure_set_base_ptr(closure, p);\n\011return closure;\n}\n")); + strings__Builder_write_string(&builder, _SLIT("\n#ifdef _MSC_VER\n\011#define __RETURN_ADDRESS() ((char*)_ReturnAddress())\n#elif defined(__TINYC__) && defined(_WIN32)\n\011#define __RETURN_ADDRESS() ((char*)__builtin_return_address(0))\n#else\n\011#define __RETURN_ADDRESS() ((char*)__builtin_extract_return_addr(__builtin_return_address(0)))\n#endif\n\n#ifdef __V_amd64\nstatic const char __closure_thunk[] = {\n\0110x8f, 0x05, 0xda, 0xff, 0xff, 0xff, // pop QWORD PTR [rip - 0x26] # <_orig_rbp>\n\0110xff, 0x15, 0xe4, 0xff, 0xff, 0xff, // call QWORD PTR [rip - 0x1C] # \n\0110xff, 0x25, 0xce, 0xff, 0xff, 0xff, // jmp QWORD PTR [rip - 0x32] # \n};\n#define __CLOSURE_DATA_OFFSET 20\n#elif defined(__V_x86)\nstatic char __closure_thunk[] = {\n\0110xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n\0110x59, // pop ecx\n\0110x8f, 0x41, 0xeb, // pop DWORD PTR [ecx - 21] # <_orig_rbp>\n\0110xff, 0x51, 0xf3, // call DWORD PTR [ecx - 13] # \n\0110xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n\0110x59, // pop ecx\n\0110xff, 0x61, 0xdf, // jmp DWORD PTR [ecx - 33] # <_orig_rbp>\n};\n\n#define __CLOSURE_DATA_OFFSET 16\n#elif defined(__V_arm64)\nstatic char __closure_thunk[] = {\n\0110x10, 0x00, 0x00, 0x10, // adr x16, start\n\0110x1e, 0x02, 0x1e, 0xf8, // str x30, _orig_x30\n\0110x50, 0xff, 0xff, 0x58, // ldr x16, fn\n\0110x00, 0x02, 0x3f, 0xd6, // blr x16\n\0110x9e, 0xfe, 0xff, 0x58, // ldr x30, _orig_x30\n\0110xc0, 0x03, 0x5f, 0xd6 // ret\n};\n#define __CLOSURE_DATA_OFFSET 24\n#elif defined(__V_arm32)\nstatic char __closure_thunk[] = {\n\0110x18, 0xe0, 0x0f, 0xe5, // str lr, orig_lr\n\0110x14, 0xc0, 0x1f, 0xe5, // ldr ip, fn\n\0110x3c, 0xff, 0x2f, 0xe1, // blx ip\n\0110x24, 0xe0, 0x1f, 0xe5, // ldr lr, orig_lr\n\0110x1e, 0xff, 0x2f, 0xe1 // bx lr\n};\n#define __CLOSURE_DATA_OFFSET 16\n#endif\n\nstatic int _V_PAGE_SIZE = 4096; // pre-initialized to the most common value, in case _vinit is not called (in a DLL, for example)\n\nstatic inline void __closure_set_data(void* closure, void* data) {\n void** p = closure;\n p[-1] = data;\n}\n\nstatic inline void __closure_set_function(void* closure, void* f) {\n void** p = closure;\n p[-2] = f;\n}\n\nstatic void* __closure_create(void* fn, void* data) {\n#ifdef _WIN32\n\011SYSTEM_INFO si;\n\011GetNativeSystemInfo(&si);\n\011uint32_t page_size = si.dwPageSize;\n\011char* p = VirtualAlloc(NULL, page_size * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);\n\011if (p == NULL) return 0;\n#else\n\011uint32_t page_size = sysconf(_SC_PAGESIZE);\n\011int prot = PROT_READ | PROT_WRITE;\n\011int flags = MAP_ANONYMOUS | MAP_PRIVATE;\n\011char* p = mmap(0, page_size * 2, prot, flags, -1, 0);\n\011if (p == MAP_FAILED) return 0;\n#endif\n\n\011void* closure = p + page_size;\n\011memcpy(closure, __closure_thunk, sizeof(__closure_thunk));\n\n#ifdef _WIN32\n\011DWORD _tmp;\n\011VirtualProtect(closure, page_size, PAGE_EXECUTE_READ, &_tmp);\n#else\n\011mprotect(closure, page_size, PROT_READ | PROT_EXEC);\n#endif\n\n\011__closure_set_data(closure, data);\n\011__closure_set_function(closure, fn);\n\011return closure;\n}\n")); string _t1 = strings__Builder_str(&builder); return _t1; } @@ -77311,8 +77378,7 @@ int ctmp; bool is_closure = v__ast__Scope_has_inherited_vars(node->scope); string cur_closure_ctx = _SLIT(""); if (is_closure) { - multi_return_string_string mr_5443 = v__gen__c__closure_ctx(*node); - cur_closure_ctx = mr_5443.arg0; + cur_closure_ctx = v__gen__c__closure_ctx(*node); strings__Builder_write_string(&g->definitions, cur_closure_ctx); strings__Builder_writeln(&g->definitions, _SLIT(";")); } @@ -77410,19 +77476,11 @@ int ctmp; v__gen__c__Gen_write(g, fn_header); } int arg_start_pos = g->out.len; - multi_return_Array_string_Array_string_Array_bool mr_8607 = v__gen__c__Gen_fn_decl_params(g, node->params, node->scope, node->is_variadic); - Array_string fargs = mr_8607.arg0; - Array_string fargtypes = mr_8607.arg1; - Array_bool heap_promoted = mr_8607.arg2; + multi_return_Array_string_Array_string_Array_bool mr_8604 = v__gen__c__Gen_fn_decl_params(g, node->params, node->scope, node->is_variadic); + Array_string fargs = mr_8604.arg0; + Array_string fargtypes = mr_8604.arg1; + Array_bool heap_promoted = mr_8604.arg2; if (is_closure) { - string s = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = cur_closure_ctx}}, {_SLIT(" *"), /*115 &string*/0xfe10, {.d_s = _const_v__gen__c__closure_ctx}}, {_SLIT0, 0, { .d_c = 0 }}})); - if (node->params.len > 0) { - s = string__plus(_SLIT(", "), s); - } else { - strings__Builder_cut_to(&g->out, arg_start_pos); - } - strings__Builder_write_string(&g->definitions, s); - v__gen__c__Gen_write(g, s); g->nr_closures++; } string arg_str = strings__Builder_after(&g->out, arg_start_pos); @@ -77461,6 +77519,9 @@ int ctmp; } strings__Builder_writeln(&g->definitions, _SLIT(");")); v__gen__c__Gen_writeln(g, _SLIT(") {")); + if (is_closure) { + v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = cur_closure_ctx}}, {_SLIT("* "), /*115 &string*/0xfe10, {.d_s = _const_v__gen__c__closure_ctx}}, {_SLIT(" = *(void**)(__RETURN_ADDRESS() - __CLOSURE_DATA_OFFSET);"), 0, { .d_c = 0 }}}))); + } for (int i = 0; i < heap_promoted.len; ++i) { bool is_promoted = ((bool*)heap_promoted.data)[i]; if (is_promoted) { @@ -77633,8 +77694,9 @@ VV_LOCAL_SYMBOL _option_string v__gen__c__Gen_c_fn_name(v__gen__c__Gen* g, v__as return _t2; } -VV_LOCAL_SYMBOL multi_return_string_string v__gen__c__closure_ctx(v__ast__FnDecl node) { - return (multi_return_string_string){.arg0= str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct _V_"), /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("_Ctx"), 0, { .d_c = 0 }}})), .arg1= str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct _V_"), /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("_Args"), 0, { .d_c = 0 }}}))}; +VV_LOCAL_SYMBOL string v__gen__c__closure_ctx(v__ast__FnDecl node) { + string _t1 = str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct _V_"), /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("_Ctx"), 0, { .d_c = 0 }}})); + return _t1; } VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn(v__gen__c__Gen* g, v__ast__AnonFn* node) { @@ -77643,66 +77705,15 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn(v__gen__c__Gen* g, v__ast__AnonF v__gen__c__Gen_write(g, node->decl.name); return; } - multi_return_string_string mr_14693 = v__gen__c__closure_ctx(node->decl); - string ctx_struct = mr_14693.arg0; - string arg_struct = mr_14693.arg1; - v__gen__c__Gen_write(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("__closure_create("), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT(", "), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT("_wrapper, "), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT("_unwrapper, ("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT("*) memdup(&("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT("){"), 0, { .d_c = 0 }}}))); + string ctx_struct = v__gen__c__closure_ctx(node->decl); + v__gen__c__Gen_write(g, str_intp(4, _MOV((StrIntpData[]){{_SLIT("__closure_create("), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT(", ("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT("*) memdup(&("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT("){"), 0, { .d_c = 0 }}}))); g->indent++; for (int _t1 = 0; _t1 < node->inherited_vars.len; ++_t1) { v__ast__Param var = ((v__ast__Param*)node->inherited_vars.data)[_t1]; v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT("."), /*115 &string*/0xfe10, {.d_s = var.name}}, {_SLIT(" = "), /*115 &string*/0xfe10, {.d_s = var.name}}, {_SLIT(","), 0, { .d_c = 0 }}}))); } g->indent--; - int ps = g->table->pointer_size; - int is_big_cutoff = (g->pref->os == v__pref__OS__windows || g->pref->arch == v__pref__Arch__arm32 ? (ps) : (ps * 2)); - multi_return_int_int mr_15314 = v__ast__Table_type_size(g->table, node->decl.return_type); - int rt_size = mr_15314.arg0; - bool is_big = rt_size > is_big_cutoff; v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("}, sizeof("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT(")))"), 0, { .d_c = 0 }}}))); - strings__Builder sb = strings__new_builder(512); - string ret_styp = v__gen__c__Gen_typ(g, node->decl.return_type); - strings__Builder_write_string(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT(" VV_LOCAL_SYMBOL void "), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT("_wrapper("), 0, { .d_c = 0 }}}))); - if (is_big) { - strings__Builder_write_string(&sb, _SLIT("__CLOSURE_WRAPPER_EXTRA_PARAM ")); - if (node->decl.params.len > 0) { - strings__Builder_write_string(&sb, _SLIT("__CLOSURE_WRAPPER_EXTRA_PARAM_COMMA ")); - } - } - for (int i = 0; i < node->decl.params.len; ++i) { - v__ast__Param param = ((v__ast__Param*)node->decl.params.data)[i]; - if (i > 0) { - strings__Builder_write_string(&sb, _SLIT(", ")); - } - strings__Builder_write_string(&sb, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, param.typ)}}, {_SLIT(" a"), /*100 &int*/0xfe07, {.d_i32 = i + 1}}, {_SLIT0, 0, { .d_c = 0 }}}))); - } - strings__Builder_writeln(&sb, _SLIT(") {")); - if (node->decl.params.len > 0) { - strings__Builder_writeln(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT("void** closure_start = (void**)((char*)__RETURN_ADDRESS() - __CLOSURE_WRAPPER_OFFSET);\n "), /*115 &string*/0xfe10, {.d_s = arg_struct}}, {_SLIT("* args = closure_start[-5];"), 0, { .d_c = 0 }}}))); - for (int i = 0; i < node->decl.params.len; ++i) { - strings__Builder_writeln(&sb, str_intp(3, _MOV((StrIntpData[]){{_SLIT("\targs->a"), /*100 &int literal*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(" = a"), /*100 &int literal*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(";"), 0, { .d_c = 0 }}}))); - } - } - strings__Builder_writeln(&sb, _SLIT("}\n")); - strings__Builder_writeln(&sb, str_intp(3, _MOV((StrIntpData[]){{_SLIT(" VV_LOCAL_SYMBOL "), /*115 &string*/0xfe10, {.d_s = ret_styp}}, {_SLIT(" "), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT("_unwrapper(void) {\n void** closure_start = (void**)((char*)__RETURN_ADDRESS() - __CLOSURE_UNWRAPPER_OFFSET);\n void* userdata = closure_start[-1];"), 0, { .d_c = 0 }}}))); - strings__Builder_write_string(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\t"), /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, node->decl.return_type)}}, {_SLIT(" (*fn)("), 0, { .d_c = 0 }}}))); - for (int i = 0; i < node->decl.params.len; ++i) { - v__ast__Param param = ((v__ast__Param*)node->decl.params.data)[i]; - strings__Builder_write_string(&sb, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, param.typ)}}, {_SLIT(" a"), /*100 &int*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(", "), 0, { .d_c = 0 }}}))); - } - strings__Builder_writeln(&sb, _SLIT("void* userdata) = closure_start[-2];")); - if (node->decl.params.len > 0) { - strings__Builder_writeln(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\t"), /*115 &string*/0xfe10, {.d_s = arg_struct}}, {_SLIT("* args = closure_start[-5];"), 0, { .d_c = 0 }}}))); - } - if (node->decl.return_type == _const_v__ast__void_type_idx) { - strings__Builder_write_string(&sb, _SLIT("\tfn(")); - } else { - strings__Builder_write_string(&sb, _SLIT("\treturn fn(")); - } - for (int i = 0; i < node->decl.params.len; ++i) { - strings__Builder_write_string(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT("args->a"), /*100 &int literal*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(", "), 0, { .d_c = 0 }}}))); - } - strings__Builder_writeln(&sb, _SLIT("userdata);\n}")); - array_push((array*)&g->anon_fn_definitions, _MOV((string[]){ string_clone(strings__Builder_str(&sb)) })); g->empty_line = false; } @@ -77713,9 +77724,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn_decl(v__gen__c__Gen* g, v__ast__ node->has_gen = true; strings__Builder builder = strings__new_builder(256); if (node->inherited_vars.len > 0) { - multi_return_string_string mr_17185 = v__gen__c__closure_ctx(node->decl); - string ctx_struct = mr_17185.arg0; - string arg_struct = mr_17185.arg1; + string ctx_struct = v__gen__c__closure_ctx(node->decl); strings__Builder_writeln(&builder, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT(" {"), 0, { .d_c = 0 }}}))); for (int _t1 = 0; _t1 < node->inherited_vars.len; ++_t1) { v__ast__Param var = ((v__ast__Param*)node->inherited_vars.data)[_t1]; @@ -77723,14 +77732,6 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn_decl(v__gen__c__Gen* g, v__ast__ strings__Builder_writeln(&builder, str_intp(3, _MOV((StrIntpData[]){{_SLIT("\t"), /*115 &string*/0xfe10, {.d_s = styp}}, {_SLIT(" "), /*115 &string*/0xfe10, {.d_s = var.name}}, {_SLIT(";"), 0, { .d_c = 0 }}}))); } strings__Builder_writeln(&builder, _SLIT("};\n")); - if (node->decl.params.len > 0) { - strings__Builder_writeln(&builder, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = arg_struct}}, {_SLIT(" {"), 0, { .d_c = 0 }}}))); - for (int i = 0; i < node->decl.params.len; ++i) { - v__ast__Param param = ((v__ast__Param*)node->decl.params.data)[i]; - strings__Builder_writeln(&builder, str_intp(3, _MOV((StrIntpData[]){{_SLIT("\t"), /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, param.typ)}}, {_SLIT(" a"), /*100 &int*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(";"), 0, { .d_c = 0 }}}))); - } - strings__Builder_writeln(&builder, _SLIT("};\n")); - } } int pos = g->out.len; bool was_anon_fn = g->anon_fn; @@ -78577,11 +78578,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_fn_call(v__gen__c__Gen* g, v__ast__CallExpr } if (!print_auto_str) { if (g->pref->is_debug && string__eq(node.name, _SLIT("panic"))) { - multi_return_int_string_string_string mr_41840 = v__gen__c__Gen_panic_debug_info(g, node.pos); - int paline = mr_41840.arg0; - string pafile = mr_41840.arg1; - string pamod = mr_41840.arg2; - string pafn = mr_41840.arg3; + multi_return_int_string_string_string mr_39701 = v__gen__c__Gen_panic_debug_info(g, node.pos); + int paline = mr_39701.arg0; + string pafile = mr_39701.arg1; + string pamod = mr_39701.arg2; + string pafn = mr_39701.arg3; v__gen__c__Gen_write(g, str_intp(5, _MOV((StrIntpData[]){{_SLIT("panic_debug("), /*100 &int*/0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), /*115 &string*/0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), 0, { .d_c = 0 }}}))); v__gen__c__Gen_call_args(g, node); v__gen__c__Gen_write(g, _SLIT(")")); @@ -79938,7 +79939,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_index_expr(v__gen__c__Gen* g, v__ast__IndexE if ((node.index)._typ == 286 /* v.ast.RangeExpr */) { v__gen__c__Gen_range_expr(g, node, (*node.index._v__ast__RangeExpr)); } else { - v__ast__TypeSymbol* sym = v__ast__Table_final_sym(g->table, node.left_type); + v__ast__TypeSymbol* sym = v__ast__Table_final_sym(g->table, v__gen__c__Gen_unwrap_generic(g, node.left_type)); if (sym->kind == v__ast__Kind__array) { v__gen__c__Gen_index_of_array(g, node, *sym); } else if (sym->kind == v__ast__Kind__array_fixed) { @@ -82070,7 +82071,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_match_expr_sumtype(v__gen__c__Gen* g, v__ast } } if (is_expr && tmp_var.len == 0) { - v__gen__c__Gen_write(g, _SLIT(") ? ")); + v__gen__c__Gen_write(g, _SLIT(")? ")); } else { v__gen__c__Gen_writeln(g, _SLIT(") {")); } @@ -82325,7 +82326,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_match_expr_classic(v__gen__c__Gen* g, v__ast }; } if (is_expr && tmp_var.len == 0) { - v__gen__c__Gen_write(g, _SLIT(") ? ")); + v__gen__c__Gen_write(g, _SLIT(")? ")); } else { v__gen__c__Gen_writeln(g, _SLIT(") {")); } @@ -82767,7 +82768,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_sql_write_orm_primitive(v__gen__c__Gen* g, v if ((expr)._typ == 272 /* v.ast.InfixExpr */) { v__gen__c__Gen_write(g, _SLIT("(orm__InfixType){")); v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".name = _SLIT(\""), /*115 &v.ast.Expr*/0xfe10, {.d_s = v__ast__Expr_str((*expr._v__ast__InfixExpr).left)}}, {_SLIT("\"),"), 0, { .d_c = 0 }}}))); - string kind = (((*expr._v__ast__InfixExpr).op == (v__token__Kind__plus)) ? (_SLIT("orm__MathOperationKind__add")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__minus)) ? (_SLIT("orm__MathOperationKind__sub")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__div)) ? (_SLIT("orm__MathOperationKind__div")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__mul)) ? (_SLIT("orm__MathOperationKind__mul")) : (_SLIT(""))); + string kind = (((*expr._v__ast__InfixExpr).op == (v__token__Kind__plus))? (_SLIT("orm__MathOperationKind__add")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__minus))? (_SLIT("orm__MathOperationKind__sub")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__div))? (_SLIT("orm__MathOperationKind__div")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__mul))? (_SLIT("orm__MathOperationKind__mul")) : (_SLIT(""))); v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".operator = "), /*115 &string*/0xfe10, {.d_s = kind}}, {_SLIT(","), 0, { .d_c = 0 }}}))); v__gen__c__Gen_write(g, _SLIT(".right = ")); v__gen__c__Gen_sql_expr_to_orm_primitive(g, (*expr._v__ast__InfixExpr).right); @@ -86181,9 +86182,9 @@ VV_LOCAL_SYMBOL v__ast__Stmt v__parser__Parser_partial_assign_stmt(v__parser__Pa _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t2, Array_v__ast__Comment); Array_v__ast__Comment right_comments = __new_array_with_default(0, 0, sizeof(v__ast__Comment), 0); Array_v__ast__Expr right = __new_array_with_default(0, left.len, sizeof(v__ast__Expr), 0); - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_4062 = v__parser__Parser_expr_list(p); - right = mr_4062.arg0; - right_comments = mr_4062.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_4041 = v__parser__Parser_expr_list(p); + right = mr_4041.arg0; + right_comments = mr_4041.arg1; _PUSH_MANY(&comments, (right_comments), _t3, Array_v__ast__Comment); Array_v__ast__Comment end_comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,})); bool has_cross_var = false; @@ -86380,9 +86381,9 @@ VV_LOCAL_SYMBOL v__ast__HashStmt v__parser__Parser_hash(v__parser__Parser* p) { VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__Parser* p) { v__ast__ComptimeCall *err_node = HEAP(v__ast__ComptimeCall, (((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,},.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = (string){.str=(byteptr)"", .is_lit=1},.left = {0},.args_var = (string){.str=(byteptr)"", .is_lit=1},.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = 0,.is_embed = 0,.is_env = 0,.is_pkgconfig = 0,}))); + v__token__Pos start_pos = v__token__Token_pos(&p->tok); v__parser__Parser_check(p, v__token__Kind__dollar); - v__token__Pos start_pos = v__token__Token_pos(&p->prev_tok); - string error_msg = _SLIT("only `$tmpl()`, `$env()`, `$embed_file()`, `$pkgconfig()` and `$vweb.html()` comptime functions are supported right now"); + string error_msg = _SLIT("only `$tmpl()`, `$env()`, `$embed_file()`, `$pkgconfig()`, `$vweb.html()`, `$compile_error()` and `$compile_warn()` comptime functions are supported right now"); if (p->peek_tok.kind == v__token__Kind__dot) { string name = v__parser__Parser_check_name(p); if (!string__eq(name, _SLIT("vweb"))) { @@ -86401,8 +86402,7 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ bool is_embed_file = string__eq(method_name, _SLIT("embed_file")); bool is_html = string__eq(method_name, _SLIT("html")); v__parser__Parser_check(p, v__token__Kind__lpar); - v__token__Pos spos = v__token__Token_pos(&p->tok); - if (string__eq(method_name, _SLIT("env"))) { + if (string__eq(method_name, _SLIT("env")) || string__eq(method_name, _SLIT("pkgconfig")) || string__eq(method_name, _SLIT("compile_error")) || string__eq(method_name, _SLIT("compile_warn"))) { string s = p->tok.lit; v__parser__Parser_check(p, v__token__Kind__string); v__parser__Parser_check(p, v__token__Kind__rpar); @@ -86415,45 +86415,19 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ .args_var = s, .env_value = (string){.str=(byteptr)"", .is_lit=1}, .scope = 0, - .pos = v__token__Pos_extend(spos, v__token__Token_pos(&p->prev_tok)), + .pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)), .method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,}, - .env_pos = spos, + .env_pos = start_pos, .left_type = 0, .result_type = 0, .has_parens = 0, .is_vweb = 0, .is_embed = 0, - .is_env = true, - .is_pkgconfig = 0, + .is_env = string__eq(method_name, _SLIT("env")), + .is_pkgconfig = string__eq(method_name, _SLIT("pkgconfig")), }); return _t3; } - if (string__eq(method_name, _SLIT("pkgconfig"))) { - string s = p->tok.lit; - v__parser__Parser_check(p, v__token__Kind__string); - v__parser__Parser_check(p, v__token__Kind__rpar); - v__ast__ComptimeCall _t4 = ((v__ast__ComptimeCall){ - .vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),}, - .embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,}, - .args = __new_array(0, 0, sizeof(v__ast__CallArg)), - .method_name = method_name, - .left = {0}, - .args_var = s, - .env_value = (string){.str=(byteptr)"", .is_lit=1}, - .scope = 0, - .pos = v__token__Pos_extend(spos, v__token__Token_pos(&p->prev_tok)), - .method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,}, - .env_pos = spos, - .left_type = 0, - .result_type = 0, - .has_parens = 0, - .is_vweb = 0, - .is_embed = 0, - .is_env = 0, - .is_pkgconfig = true, - }); - return _t4; - } string literal_string_param = (is_html ? (_SLIT("")) : (p->tok.lit)); string path_of_literal_string_param = string_replace(literal_string_param, _SLIT("/"), _const_os__path_separator); if (!is_html) { @@ -86471,23 +86445,23 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ if (is_embed_file) { string epath = path_of_literal_string_param; if ((epath).len == 0) { - v__parser__Parser_error_with_pos(p, _SLIT("supply a valid relative or absolute file path to the file to embed"), spos); - v__ast__ComptimeCall _t5 = (*(err_node)); - return _t5; + v__parser__Parser_error_with_pos(p, _SLIT("supply a valid relative or absolute file path to the file to embed"), start_pos); + v__ast__ComptimeCall _t4 = (*(err_node)); + return _t4; } if (!p->pref->is_fmt) { string abs_path = os__real_path(epath); if (!os__exists(abs_path)) { epath = os__real_path(os__join_path_single(os__dir(p->file_name), epath)); if (!os__exists(epath)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\""), /*115 &string*/0xfe10, {.d_s = epath}}, {_SLIT("\" does not exist so it cannot be embedded"), 0, { .d_c = 0 }}})), spos); - v__ast__ComptimeCall _t6 = (*(err_node)); - return _t6; + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\""), /*115 &string*/0xfe10, {.d_s = epath}}, {_SLIT("\" does not exist so it cannot be embedded"), 0, { .d_c = 0 }}})), start_pos); + v__ast__ComptimeCall _t5 = (*(err_node)); + return _t5; } if (!os__is_file(epath)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\""), /*115 &string*/0xfe10, {.d_s = epath}}, {_SLIT("\" is not a file so it cannot be embedded"), 0, { .d_c = 0 }}})), spos); - v__ast__ComptimeCall _t7 = (*(err_node)); - return _t7; + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\""), /*115 &string*/0xfe10, {.d_s = epath}}, {_SLIT("\" is not a file so it cannot be embedded"), 0, { .d_c = 0 }}})), start_pos); + v__ast__ComptimeCall _t6 = (*(err_node)); + return _t6; } } else { epath = abs_path; @@ -86497,8 +86471,8 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ if (string__eq(embed_compression_type, _SLIT("zlib")) && (p->pref->is_prod || Array_string_contains(p->pref->compile_defines, _SLIT("debug_embed_file_in_prod")))) { v__parser__Parser_register_auto_import(p, _SLIT("v.preludes.embed_file.zlib")); } - v__ast__ComptimeCall _t8 = ((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = ((v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = literal_string_param,.apath = epath,.compression_type = embed_compression_type,.len = 0,.is_compressed = 0,}),.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = (string){.str=(byteptr)"", .is_lit=1},.left = {0},.args_var = (string){.str=(byteptr)"", .is_lit=1},.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)),.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = 0,.is_embed = true,.is_env = 0,.is_pkgconfig = 0,}); - return _t8; + v__ast__ComptimeCall _t7 = ((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = ((v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = literal_string_param,.apath = epath,.compression_type = embed_compression_type,.len = 0,.is_compressed = 0,}),.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = (string){.str=(byteptr)"", .is_lit=1},.left = {0},.args_var = (string){.str=(byteptr)"", .is_lit=1},.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)),.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = 0,.is_embed = true,.is_env = 0,.is_pkgconfig = 0,}); + return _t7; } Array_string fn_path = string_split(p->cur_fn_name, _SLIT("_")); string fn_path_joined = Array_string_join(fn_path, _const_os__path_separator); @@ -86522,16 +86496,16 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ } if (!os__exists(path)) { if (p->pref->is_fmt) { - v__ast__ComptimeCall _t9 = ((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,},.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = method_name,.left = {0},.args_var = literal_string_param,.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)),.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = true,.is_embed = 0,.is_env = 0,.is_pkgconfig = 0,}); - return _t9; + v__ast__ComptimeCall _t8 = ((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,},.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = method_name,.left = {0},.args_var = literal_string_param,.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)),.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = true,.is_embed = 0,.is_env = 0,.is_pkgconfig = 0,}); + return _t8; } if (is_html) { v__parser__Parser_error(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("vweb HTML template \""), /*115 &string*/0xfe10, {.d_s = path}}, {_SLIT("\" not found"), 0, { .d_c = 0 }}}))); } else { v__parser__Parser_error(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("template file \""), /*115 &string*/0xfe10, {.d_s = path}}, {_SLIT("\" not found"), 0, { .d_c = 0 }}}))); } - v__ast__ComptimeCall _t10 = (*(err_node)); - return _t10; + v__ast__ComptimeCall _t9 = (*(err_node)); + return _t9; } } string tmp_fn_name = string__plus(string_replace(p->cur_fn_name, _SLIT("."), _SLIT("__")), int_str(start_pos.pos)); @@ -86561,7 +86535,7 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ #endif v__ast__File* file = v__parser__parse_comptime(tmpl_path, v_code, p->table, p->pref, p->scope); file->path = tmpl_path; - v__ast__ComptimeCall _t11 = ((v__ast__ComptimeCall){ + v__ast__ComptimeCall _t10 = ((v__ast__ComptimeCall){ .vweb_tmpl = *file, .embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,}, .args = __new_array(0, 0, sizeof(v__ast__CallArg)), @@ -86581,7 +86555,7 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ .is_env = 0, .is_pkgconfig = 0, }); - return _t11; + return _t10; } VV_LOCAL_SYMBOL v__ast__ComptimeFor v__parser__Parser_comptime_for(v__parser__Parser* p) { @@ -86627,7 +86601,7 @@ VV_LOCAL_SYMBOL v__ast__ComptimeFor v__parser__Parser_comptime_for(v__parser__Pa VV_LOCAL_SYMBOL v__ast__AtExpr v__parser__Parser_at(v__parser__Parser* p) { string name = p->tok.lit; - v__token__AtKind kind = ((string__eq(name, _SLIT("@FN"))) ? (v__token__AtKind__fn_name) : (string__eq(name, _SLIT("@METHOD"))) ? (v__token__AtKind__method_name) : (string__eq(name, _SLIT("@MOD"))) ? (v__token__AtKind__mod_name) : (string__eq(name, _SLIT("@STRUCT"))) ? (v__token__AtKind__struct_name) : (string__eq(name, _SLIT("@FILE"))) ? (v__token__AtKind__file_path) : (string__eq(name, _SLIT("@LINE"))) ? (v__token__AtKind__line_nr) : (string__eq(name, _SLIT("@COLUMN"))) ? (v__token__AtKind__column_nr) : (string__eq(name, _SLIT("@VHASH"))) ? (v__token__AtKind__vhash) : (string__eq(name, _SLIT("@VMOD_FILE"))) ? (v__token__AtKind__vmod_file) : (string__eq(name, _SLIT("@VEXE"))) ? (v__token__AtKind__vexe_path) : (string__eq(name, _SLIT("@VEXEROOT"))) ? (v__token__AtKind__vexeroot_path) : (string__eq(name, _SLIT("@VMODROOT"))) ? (v__token__AtKind__vmodroot_path) : (string__eq(name, _SLIT("@VROOT"))) ? (v__token__AtKind__vroot_path) : (v__token__AtKind__unknown)); + v__token__AtKind kind = ((string__eq(name, _SLIT("@FN")))? (v__token__AtKind__fn_name) : (string__eq(name, _SLIT("@METHOD")))? (v__token__AtKind__method_name) : (string__eq(name, _SLIT("@MOD")))? (v__token__AtKind__mod_name) : (string__eq(name, _SLIT("@STRUCT")))? (v__token__AtKind__struct_name) : (string__eq(name, _SLIT("@FILE")))? (v__token__AtKind__file_path) : (string__eq(name, _SLIT("@LINE")))? (v__token__AtKind__line_nr) : (string__eq(name, _SLIT("@COLUMN")))? (v__token__AtKind__column_nr) : (string__eq(name, _SLIT("@VHASH")))? (v__token__AtKind__vhash) : (string__eq(name, _SLIT("@VMOD_FILE")))? (v__token__AtKind__vmod_file) : (string__eq(name, _SLIT("@VEXE")))? (v__token__AtKind__vexe_path) : (string__eq(name, _SLIT("@VEXEROOT")))? (v__token__AtKind__vexeroot_path) : (string__eq(name, _SLIT("@VMODROOT")))? (v__token__AtKind__vmodroot_path) : (string__eq(name, _SLIT("@VROOT")))? (v__token__AtKind__vroot_path) : (v__token__AtKind__unknown)); v__parser__Parser_next(p); v__ast__AtExpr _t1 = ((v__ast__AtExpr){.name = name,.pos = v__token__Token_pos(&p->tok),.kind = kind,.val = (string){.str=(byteptr)"", .is_lit=1},}); return _t1; @@ -86905,6 +86879,10 @@ v__ast__Expr v__parser__Parser_expr(v__parser__Parser* p, int precedence) { _option_v__ast__Expr _t2 = v__parser__Parser_check_expr(p, precedence); if (_t2.state != 0) { /*or block*/ IError err = _t2.err; + if (v__token__is_decl(p->tok.kind) && v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__Expr _t3 = v__ast__empty_expr(); + return _t3; + } *(v__ast__Expr*) _t2.data = v__ast__NodeError_to_sumtype_v__ast__Expr(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid expression: unexpected "), /*115 &v.token.Token*/0xfe10, {.d_s = v__token__Token_str(p->tok)}}, {_SLIT0, 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); } @@ -88299,10 +88277,11 @@ VV_LOCAL_SYMBOL v__ast__AnonFn v__parser__Parser_anon_fn(v__parser__Parser* p) { bool v__parser__Parser_anon_fn_defer_0 = false; v__token__Pos pos = v__token__Token_pos(&p->tok); v__parser__Parser_check(p, v__token__Kind__key_fn); - if (p->pref->is_script && p->tok.kind == v__token__Kind__name) { - v__parser__Parser_error_with_pos(p, _SLIT("function declarations in script mode should be before all script statements"), v__token__Token_pos(&p->tok)); - v__ast__AnonFn _t1 = ((v__ast__AnonFn){.decl = (v__ast__FnDecl){.receiver = (v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,},.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.params = __new_array(0, 0, sizeof(v__ast__Param)),.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.defer_stmts = __new_array(0, 0, sizeof(v__ast__DeferStmt)),.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.next_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.label_names = __new_array(0, 0, sizeof(string)),.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.source_file = 0,.scope = 0,.receiver_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.body_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,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_idx = 0,.ctdefine_idx = -1,.idx = 0,.return_type = 0,.ninstances = 0,.is_deprecated = 0,.is_pub = 0,.is_variadic = 0,.is_anon = 0,.is_noreturn = 0,.is_manualfree = 0,.is_main = 0,.is_test = 0,.is_conditional = 0,.is_exported = 0,.is_keep_alive = 0,.is_unsafe = 0,.is_markused = 0,.is_method = 0,.rec_mut = 0,.no_body = 0,.is_builtin = 0,.is_direct_arr = 0,.has_return = 0,.should_be_skipped = 0,.has_await = 0,},.inherited_vars = __new_array(0, 0, sizeof(v__ast__Param)),.typ = 0,.has_gen = 0,}); - return _t1; + if (p->tok.kind == v__token__Kind__name) { + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__AnonFn _t1 = ((v__ast__AnonFn){.decl = (v__ast__FnDecl){.receiver = (v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,},.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.params = __new_array(0, 0, sizeof(v__ast__Param)),.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.defer_stmts = __new_array(0, 0, sizeof(v__ast__DeferStmt)),.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.next_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.label_names = __new_array(0, 0, sizeof(string)),.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.source_file = 0,.scope = 0,.receiver_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.body_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,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_idx = 0,.ctdefine_idx = -1,.idx = 0,.return_type = 0,.ninstances = 0,.is_deprecated = 0,.is_pub = 0,.is_variadic = 0,.is_anon = 0,.is_noreturn = 0,.is_manualfree = 0,.is_main = 0,.is_test = 0,.is_conditional = 0,.is_exported = 0,.is_keep_alive = 0,.is_unsafe = 0,.is_markused = 0,.is_method = 0,.rec_mut = 0,.no_body = 0,.is_builtin = 0,.is_direct_arr = 0,.has_return = 0,.should_be_skipped = 0,.has_await = 0,},.inherited_vars = __new_array(0, 0, sizeof(v__ast__Param)),.typ = 0,.has_gen = 0,}); + return _t1; + } } bool old_inside_defer = p->inside_defer; p->inside_defer = false; @@ -88310,9 +88289,9 @@ bool v__parser__Parser_anon_fn_defer_0 = false; v__parser__Parser_anon_fn_defer_0 = true; p->scope->detached_from_parent = true; Array_v__ast__Param inherited_vars = (p->tok.kind == v__token__Kind__lsbr ? (v__parser__Parser_closure_vars(p)) : (__new_array_with_default(0, 0, sizeof(v__ast__Param), 0))); - multi_return_Array_v__ast__Param_bool_bool mr_18829 = v__parser__Parser_fn_args(p); - Array_v__ast__Param args = mr_18829.arg0; - bool is_variadic = mr_18829.arg2; + multi_return_Array_v__ast__Param_bool_bool mr_18748 = v__parser__Parser_fn_args(p); + Array_v__ast__Param args = mr_18748.arg0; + bool is_variadic = mr_18748.arg2; for (int _t2 = 0; _t2 < args.len; ++_t2) { v__ast__Param arg = ((v__ast__Param*)args.data)[_t2]; if (arg.name.len == 0 && v__ast__Table_sym(p->table, arg.typ)->kind != v__ast__Kind__placeholder) { @@ -90220,11 +90199,16 @@ v__ast__Type v__parser__Parser_parse_generic_inst_type(v__parser__Parser* p, str bool is_instance = false; for (;;) { if (!(p->tok.kind != v__token__Kind__eof)) break; + v__token__Pos type_pos = v__token__Token_pos(&p->tok); v__ast__Type gt = v__parser__Parser_parse_type(p); + type_pos = v__token__Pos_extend(type_pos, v__token__Token_pos(&p->prev_tok)); if (!v__ast__Type_has_flag(gt, v__ast__TypeFlag__generic)) { is_instance = true; } v__ast__TypeSymbol* gts = v__ast__Table_sym(p->table, gt); + if (!is_instance && gts->name.len > 1) { + v__parser__Parser_error_with_pos(p, _SLIT("generic struct parameter name needs to be exactly one char"), type_pos); + } bs_name = /*f*/string__plus(bs_name, gts->name); bs_cname = /*f*/string__plus(bs_cname, gts->cname); array_push((array*)&concrete_types, _MOV((v__ast__Type[]){ gt })); @@ -90294,7 +90278,7 @@ bool v__parser__parse_stmt_defer_0 = false; eprintln( str_intp(4, _MOV((StrIntpData[]){{_SLIT("> "), /*115 &string*/0xfe10, {.d_s = _SLIT("v.parser")}}, {_SLIT("."), /*115 &string*/0xfe10, {.d_s = _SLIT("parse_stmt")}}, {_SLIT(" text: "), /*115 &string*/0xfe10, {.d_s = text}}, {_SLIT0, 0, { .d_c = 0 }}}))); } #endif - v__parser__Parser p = ((v__parser__Parser){.imports = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.ast_imports = __new_array(0, 0, sizeof(v__ast__Import)),.used_imports = __new_array(0, 0, sizeof(string)),.auto_imports = __new_array(0, 0, sizeof(string)),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.vet_errors = __new_array(0, 0, sizeof(v__vet__Error)),.label_names = __new_array(0, 0, sizeof(string)),.global_labels = __new_array(0, 0, sizeof(string)),.defer_vars = __new_array(0, 0, sizeof(v__ast__Ident)),.struct_init_generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.if_cond_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.file_base = (string){.str=(byteptr)"", .is_lit=1},.file_name = (string){.str=(byteptr)"", .is_lit=1},.file_name_dir = (string){.str=(byteptr)"", .is_lit=1},.unique_prefix = (string){.str=(byteptr)"", .is_lit=1},.mod = (string){.str=(byteptr)"", .is_lit=1},.expr_mod = (string){.str=(byteptr)"", .is_lit=1},.cur_fn_name = (string){.str=(byteptr)"", .is_lit=1},.codegen_text = (string){.str=(byteptr)"", .is_lit=1},.pref = ((v__pref__Preferences*)memdup(&(v__pref__Preferences){.cache_manager = (v__vcache__CacheManager){.basepath = (string){.str=(byteptr)"", .is_lit=1},.original_vopts = (string){.str=(byteptr)"", .is_lit=1},.vopts = (string){.str=(byteptr)"", .is_lit=1},.k2cpath = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),},.profile_fns = __new_array(0, 0, sizeof(string)),.lookup_path = __new_array(0, 0, sizeof(string)),.run_only = __new_array(0, 0, sizeof(string)),.compile_defines = __new_array(0, 0, sizeof(string)),.compile_defines_all = __new_array(0, 0, sizeof(string)),.run_args = __new_array(0, 0, sizeof(string)),.printfn_list = __new_array(0, 0, sizeof(string)),.cleanup_files = __new_array(0, 0, sizeof(string)),.build_options = __new_array(0, 0, sizeof(string)),.test_runner = (string){.str=(byteptr)"", .is_lit=1},.profile_file = (string){.str=(byteptr)"", .is_lit=1},.dump_c_flags = (string){.str=(byteptr)"", .is_lit=1},.cflags = (string){.str=(byteptr)"", .is_lit=1},.ccompiler = (string){.str=(byteptr)"", .is_lit=1},.third_party_option = (string){.str=(byteptr)"", .is_lit=1},.bare_builtin_dir = (string){.str=(byteptr)"", .is_lit=1},.custom_prelude = (string){.str=(byteptr)"", .is_lit=1},.vroot = (string){.str=(byteptr)"", .is_lit=1},.out_name_c = (string){.str=(byteptr)"", .is_lit=1},.out_name = (string){.str=(byteptr)"", .is_lit=1},.path = (string){.str=(byteptr)"", .is_lit=1},.message_limit = 100,.checker_match_exhaustive_cutoff_limit = 12,.thread_stack_size = 8388608,.os = 0,.arch = 0,.backend = 0,.ccompiler_type = 0,.gc_mode = v__pref__GarbageCollectionMode__no_gc,.use_color = 0,.assert_failure_mode = 0,.build_mode = 0,.output_mode = v__pref__OutputMode__stdout,.is_verbose = 0,.is_glibc = 0,.is_musl = 0,.is_test = 0,.is_script = 0,.is_vsh = 0,.is_livemain = 0,.is_liveshared = 0,.is_shared = 0,.is_o = 0,.is_prof = 0,.is_prod = 0,.is_repl = 0,.is_run = 0,.is_debug = 0,.is_vlines = 0,.is_stats = 0,.is_fmt = 0,.is_vet = 0,.is_vweb = 0,.is_ios_simulator = 0,.is_apk = 0,.is_help = 0,.is_cstrict = 0,.profile_no_inline = 0,.translated = 0,.obfuscate = 0,.sanitize = 0,.sourcemap = 0,.sourcemap_inline = true,.sourcemap_src_included = 0,.show_cc = 0,.show_c_output = 0,.show_callgraph = 0,.show_depgraph = 0,.use_cache = 0,.retry_compilation = true,.m64 = 0,.building_v = 0,.autofree = 0,.compress = 0,.no_builtin = 0,.enable_globals = 0,.is_bare = 0,.no_preludes = 0,.output_cross_c = 0,.output_es5 = 0,.prealloc = 0,.print_v_files = 0,.skip_running = 0,.skip_warnings = 0,.warn_impure_v = 0,.warns_are_errors = 0,.fatal_errors = 0,.reuse_tmpc = 0,.no_rsp = 0,.no_std = 0,.no_parallel = 0,.only_check_syntax = 0,.check_only = 0,.experimental = 0,.skip_unused = 0,.show_timings = 0,.nofloat = 0,}, sizeof(v__pref__Preferences))),.scanner = v__scanner__new_scanner(text, v__scanner__CommentsMode__skip_comments, ((v__pref__Preferences*)memdup(&(v__pref__Preferences){.cache_manager = (v__vcache__CacheManager){.basepath = (string){.str=(byteptr)"", .is_lit=1},.original_vopts = (string){.str=(byteptr)"", .is_lit=1},.vopts = (string){.str=(byteptr)"", .is_lit=1},.k2cpath = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),},.profile_fns = __new_array(0, 0, sizeof(string)),.lookup_path = __new_array(0, 0, sizeof(string)),.run_only = __new_array(0, 0, sizeof(string)),.compile_defines = __new_array(0, 0, sizeof(string)),.compile_defines_all = __new_array(0, 0, sizeof(string)),.run_args = __new_array(0, 0, sizeof(string)),.printfn_list = __new_array(0, 0, sizeof(string)),.cleanup_files = __new_array(0, 0, sizeof(string)),.build_options = __new_array(0, 0, sizeof(string)),.test_runner = (string){.str=(byteptr)"", .is_lit=1},.profile_file = (string){.str=(byteptr)"", .is_lit=1},.dump_c_flags = (string){.str=(byteptr)"", .is_lit=1},.cflags = (string){.str=(byteptr)"", .is_lit=1},.ccompiler = (string){.str=(byteptr)"", .is_lit=1},.third_party_option = (string){.str=(byteptr)"", .is_lit=1},.bare_builtin_dir = (string){.str=(byteptr)"", .is_lit=1},.custom_prelude = (string){.str=(byteptr)"", .is_lit=1},.vroot = (string){.str=(byteptr)"", .is_lit=1},.out_name_c = (string){.str=(byteptr)"", .is_lit=1},.out_name = (string){.str=(byteptr)"", .is_lit=1},.path = (string){.str=(byteptr)"", .is_lit=1},.message_limit = 100,.checker_match_exhaustive_cutoff_limit = 12,.thread_stack_size = 8388608,.os = 0,.arch = 0,.backend = 0,.ccompiler_type = 0,.gc_mode = v__pref__GarbageCollectionMode__no_gc,.use_color = 0,.assert_failure_mode = 0,.build_mode = 0,.output_mode = v__pref__OutputMode__stdout,.is_verbose = 0,.is_glibc = 0,.is_musl = 0,.is_test = 0,.is_script = 0,.is_vsh = 0,.is_livemain = 0,.is_liveshared = 0,.is_shared = 0,.is_o = 0,.is_prof = 0,.is_prod = 0,.is_repl = 0,.is_run = 0,.is_debug = 0,.is_vlines = 0,.is_stats = 0,.is_fmt = 0,.is_vet = 0,.is_vweb = 0,.is_ios_simulator = 0,.is_apk = 0,.is_help = 0,.is_cstrict = 0,.profile_no_inline = 0,.translated = 0,.obfuscate = 0,.sanitize = 0,.sourcemap = 0,.sourcemap_inline = true,.sourcemap_src_included = 0,.show_cc = 0,.show_c_output = 0,.show_callgraph = 0,.show_depgraph = 0,.use_cache = 0,.retry_compilation = true,.m64 = 0,.building_v = 0,.autofree = 0,.compress = 0,.no_builtin = 0,.enable_globals = 0,.is_bare = 0,.no_preludes = 0,.output_cross_c = 0,.output_es5 = 0,.prealloc = 0,.print_v_files = 0,.skip_running = 0,.skip_warnings = 0,.warn_impure_v = 0,.warns_are_errors = 0,.fatal_errors = 0,.reuse_tmpc = 0,.no_rsp = 0,.no_std = 0,.no_parallel = 0,.only_check_syntax = 0,.check_only = 0,.experimental = 0,.skip_unused = 0,.show_timings = 0,.nofloat = 0,}, sizeof(v__pref__Preferences)))),.table = table,.scope = scope,.expr_level = 0,.n_asm = 0,.file_backend_mode = 0,.language = 0,.fn_language = 0,.comments_mode = v__scanner__CommentsMode__skip_comments,.inside_vlib_file = 0,.inside_test_file = true,.inside_if = 0,.inside_if_expr = 0,.inside_if_cond = 0,.inside_ct_if_expr = 0,.inside_or_expr = 0,.inside_for = 0,.inside_fn = 0,.inside_fn_return = 0,.inside_unsafe_fn = 0,.inside_str_interp = 0,.inside_array_lit = 0,.inside_in_array = 0,.inside_match = 0,.inside_select = 0,.inside_match_case = 0,.inside_match_body = 0,.inside_unsafe = 0,.inside_sum_type = 0,.inside_asm_template = 0,.inside_asm = 0,.inside_defer = 0,.inside_generic_params = 0,.inside_receiver_param = 0,.inside_struct_field_decl = 0,.or_is_handled = 0,.builtin_mod = 0,.is_manualfree = 0,.has_globals = 0,.is_generated = 0,.is_translated = 0,.is_amp = 0,.returns = 0,.is_stmt_ident = 0,.expecting_type = 0,.name_error = 0,.comptime_if_cond = 0,.should_abort = 0,}); + v__parser__Parser p = ((v__parser__Parser){.imports = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.ast_imports = __new_array(0, 0, sizeof(v__ast__Import)),.used_imports = __new_array(0, 0, sizeof(string)),.auto_imports = __new_array(0, 0, sizeof(string)),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.vet_errors = __new_array(0, 0, sizeof(v__vet__Error)),.label_names = __new_array(0, 0, sizeof(string)),.global_labels = __new_array(0, 0, sizeof(string)),.defer_vars = __new_array(0, 0, sizeof(v__ast__Ident)),.struct_init_generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.if_cond_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.file_base = (string){.str=(byteptr)"", .is_lit=1},.file_name = (string){.str=(byteptr)"", .is_lit=1},.file_name_dir = (string){.str=(byteptr)"", .is_lit=1},.unique_prefix = (string){.str=(byteptr)"", .is_lit=1},.mod = (string){.str=(byteptr)"", .is_lit=1},.expr_mod = (string){.str=(byteptr)"", .is_lit=1},.cur_fn_name = (string){.str=(byteptr)"", .is_lit=1},.codegen_text = (string){.str=(byteptr)"", .is_lit=1},.pref = ((v__pref__Preferences*)memdup(&(v__pref__Preferences){.cache_manager = (v__vcache__CacheManager){.basepath = (string){.str=(byteptr)"", .is_lit=1},.original_vopts = (string){.str=(byteptr)"", .is_lit=1},.vopts = (string){.str=(byteptr)"", .is_lit=1},.k2cpath = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),},.profile_fns = __new_array(0, 0, sizeof(string)),.lookup_path = __new_array(0, 0, sizeof(string)),.run_only = __new_array(0, 0, sizeof(string)),.compile_defines = __new_array(0, 0, sizeof(string)),.compile_defines_all = __new_array(0, 0, sizeof(string)),.run_args = __new_array(0, 0, sizeof(string)),.printfn_list = __new_array(0, 0, sizeof(string)),.cleanup_files = __new_array(0, 0, sizeof(string)),.build_options = __new_array(0, 0, sizeof(string)),.test_runner = (string){.str=(byteptr)"", .is_lit=1},.profile_file = (string){.str=(byteptr)"", .is_lit=1},.dump_c_flags = (string){.str=(byteptr)"", .is_lit=1},.cflags = (string){.str=(byteptr)"", .is_lit=1},.ccompiler = (string){.str=(byteptr)"", .is_lit=1},.third_party_option = (string){.str=(byteptr)"", .is_lit=1},.bare_builtin_dir = (string){.str=(byteptr)"", .is_lit=1},.custom_prelude = (string){.str=(byteptr)"", .is_lit=1},.vroot = (string){.str=(byteptr)"", .is_lit=1},.out_name_c = (string){.str=(byteptr)"", .is_lit=1},.out_name = (string){.str=(byteptr)"", .is_lit=1},.path = (string){.str=(byteptr)"", .is_lit=1},.message_limit = 100,.checker_match_exhaustive_cutoff_limit = 12,.thread_stack_size = 8388608,.os = 0,.arch = 0,.backend = 0,.ccompiler_type = 0,.gc_mode = v__pref__GarbageCollectionMode__no_gc,.use_color = 0,.assert_failure_mode = 0,.build_mode = 0,.output_mode = v__pref__OutputMode__stdout,.is_verbose = 0,.is_glibc = 0,.is_musl = 0,.is_test = 0,.is_script = 0,.is_vsh = 0,.is_livemain = 0,.is_liveshared = 0,.is_shared = 0,.is_o = 0,.is_prof = 0,.is_prod = 0,.is_repl = 0,.is_run = 0,.is_debug = 0,.is_vlines = 0,.is_stats = 0,.is_fmt = 0,.is_vet = 0,.is_vweb = 0,.is_ios_simulator = 0,.is_apk = 0,.is_help = 0,.is_cstrict = 0,.profile_no_inline = 0,.translated = 0,.obfuscate = 0,.sanitize = 0,.sourcemap = 0,.sourcemap_inline = true,.sourcemap_src_included = 0,.show_cc = 0,.show_c_output = 0,.show_callgraph = 0,.show_depgraph = 0,.use_cache = 0,.retry_compilation = true,.m64 = 0,.building_v = 0,.autofree = 0,.compress = 0,.no_builtin = 0,.enable_globals = 0,.is_bare = 0,.no_preludes = 0,.output_cross_c = 0,.output_es5 = 0,.prealloc = 0,.print_v_files = 0,.skip_running = 0,.skip_warnings = 0,.warn_impure_v = 0,.warns_are_errors = 0,.fatal_errors = 0,.reuse_tmpc = 0,.no_rsp = 0,.no_std = 0,.no_parallel = 0,.only_check_syntax = 0,.check_only = 0,.experimental = 0,.skip_unused = 0,.show_timings = 0,.nofloat = 0,}, sizeof(v__pref__Preferences))),.scanner = v__scanner__new_scanner(text, v__scanner__CommentsMode__skip_comments, ((v__pref__Preferences*)memdup(&(v__pref__Preferences){.cache_manager = (v__vcache__CacheManager){.basepath = (string){.str=(byteptr)"", .is_lit=1},.original_vopts = (string){.str=(byteptr)"", .is_lit=1},.vopts = (string){.str=(byteptr)"", .is_lit=1},.k2cpath = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),},.profile_fns = __new_array(0, 0, sizeof(string)),.lookup_path = __new_array(0, 0, sizeof(string)),.run_only = __new_array(0, 0, sizeof(string)),.compile_defines = __new_array(0, 0, sizeof(string)),.compile_defines_all = __new_array(0, 0, sizeof(string)),.run_args = __new_array(0, 0, sizeof(string)),.printfn_list = __new_array(0, 0, sizeof(string)),.cleanup_files = __new_array(0, 0, sizeof(string)),.build_options = __new_array(0, 0, sizeof(string)),.test_runner = (string){.str=(byteptr)"", .is_lit=1},.profile_file = (string){.str=(byteptr)"", .is_lit=1},.dump_c_flags = (string){.str=(byteptr)"", .is_lit=1},.cflags = (string){.str=(byteptr)"", .is_lit=1},.ccompiler = (string){.str=(byteptr)"", .is_lit=1},.third_party_option = (string){.str=(byteptr)"", .is_lit=1},.bare_builtin_dir = (string){.str=(byteptr)"", .is_lit=1},.custom_prelude = (string){.str=(byteptr)"", .is_lit=1},.vroot = (string){.str=(byteptr)"", .is_lit=1},.out_name_c = (string){.str=(byteptr)"", .is_lit=1},.out_name = (string){.str=(byteptr)"", .is_lit=1},.path = (string){.str=(byteptr)"", .is_lit=1},.message_limit = 100,.checker_match_exhaustive_cutoff_limit = 12,.thread_stack_size = 8388608,.os = 0,.arch = 0,.backend = 0,.ccompiler_type = 0,.gc_mode = v__pref__GarbageCollectionMode__no_gc,.use_color = 0,.assert_failure_mode = 0,.build_mode = 0,.output_mode = v__pref__OutputMode__stdout,.is_verbose = 0,.is_glibc = 0,.is_musl = 0,.is_test = 0,.is_script = 0,.is_vsh = 0,.is_livemain = 0,.is_liveshared = 0,.is_shared = 0,.is_o = 0,.is_prof = 0,.is_prod = 0,.is_repl = 0,.is_run = 0,.is_debug = 0,.is_vlines = 0,.is_stats = 0,.is_fmt = 0,.is_vet = 0,.is_vweb = 0,.is_ios_simulator = 0,.is_apk = 0,.is_help = 0,.is_cstrict = 0,.profile_no_inline = 0,.translated = 0,.obfuscate = 0,.sanitize = 0,.sourcemap = 0,.sourcemap_inline = true,.sourcemap_src_included = 0,.show_cc = 0,.show_c_output = 0,.show_callgraph = 0,.show_depgraph = 0,.use_cache = 0,.retry_compilation = true,.m64 = 0,.building_v = 0,.autofree = 0,.compress = 0,.no_builtin = 0,.enable_globals = 0,.is_bare = 0,.no_preludes = 0,.output_cross_c = 0,.output_es5 = 0,.prealloc = 0,.print_v_files = 0,.skip_running = 0,.skip_warnings = 0,.warn_impure_v = 0,.warns_are_errors = 0,.fatal_errors = 0,.reuse_tmpc = 0,.no_rsp = 0,.no_std = 0,.no_parallel = 0,.only_check_syntax = 0,.check_only = 0,.experimental = 0,.skip_unused = 0,.show_timings = 0,.nofloat = 0,}, sizeof(v__pref__Preferences)))),.table = table,.scope = scope,.expr_level = 0,.n_asm = 0,.file_backend_mode = 0,.language = 0,.fn_language = 0,.comments_mode = v__scanner__CommentsMode__skip_comments,.inside_vlib_file = 0,.inside_test_file = true,.inside_if = 0,.inside_if_expr = 0,.inside_if_cond = 0,.inside_ct_if_expr = 0,.inside_or_expr = 0,.inside_for = 0,.inside_fn = 0,.inside_fn_return = 0,.inside_unsafe_fn = 0,.inside_str_interp = 0,.inside_array_lit = 0,.inside_in_array = 0,.inside_match = 0,.inside_select = 0,.inside_match_case = 0,.inside_match_body = 0,.inside_unsafe = 0,.inside_sum_type = 0,.inside_asm_template = 0,.inside_asm = 0,.inside_defer = 0,.inside_generic_params = 0,.inside_receiver_param = 0,.inside_struct_field_decl = 0,.or_is_handled = 0,.builtin_mod = 0,.is_manualfree = 0,.has_globals = 0,.is_generated = 0,.is_translated = 0,.is_amp = 0,.returns = 0,.is_stmt_ident = 0,.expecting_type = 0,.name_error = 0,.comptime_if_cond = 0,.should_abort = 0,.script_mode = 0,}); v__parser__Parser_init_parse_fns(&p); v__util__timing_start(_SLIT("PARSE stmt")); v__parser__parse_stmt_defer_0 = true; @@ -90320,6 +90304,7 @@ v__ast__File* v__parser__parse_comptime(string tmpl_path, string text, v__ast__T .tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, + .script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), .ast_imports = __new_array(0, 0, sizeof(v__ast__Import)), .used_imports = __new_array(0, 0, sizeof(string)), @@ -90390,6 +90375,7 @@ v__ast__File* v__parser__parse_comptime(string tmpl_path, string text, v__ast__T .name_error = 0, .comptime_if_cond = 0, .should_abort = 0, + .script_mode = 0, }); v__ast__File* res = v__parser__Parser_parse(&p); v__parser__Parser_free_scanner(&p); @@ -90409,6 +90395,7 @@ v__ast__File* v__parser__parse_text(string text, string path, v__ast__Table* tab .tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, + .script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), .ast_imports = __new_array(0, 0, sizeof(v__ast__Import)), .used_imports = __new_array(0, 0, sizeof(string)), @@ -90479,6 +90466,7 @@ v__ast__File* v__parser__parse_text(string text, string path, v__ast__Table* tab .name_error = 0, .comptime_if_cond = 0, .should_abort = 0, + .script_mode = 0, }); v__parser__Parser_set_path(&p, path); v__ast__File* res = v__parser__Parser_parse(&p); @@ -90560,6 +90548,7 @@ v__ast__File* v__parser__parse_file(string path, v__ast__Table* table, v__scanne .tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, + .script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), .ast_imports = __new_array(0, 0, sizeof(v__ast__Import)), .used_imports = __new_array(0, 0, sizeof(string)), @@ -90630,6 +90619,7 @@ v__ast__File* v__parser__parse_file(string path, v__ast__Table* table, v__scanne .name_error = 0, .comptime_if_cond = 0, .should_abort = 0, + .script_mode = 0, }); v__parser__Parser_set_path(&p, path); v__ast__File* res = v__parser__Parser_parse(&p); @@ -90659,6 +90649,7 @@ multi_return_ref_v__ast__File_Array_v__vet__Error v__parser__parse_vet_file(stri .tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, + .script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), .ast_imports = __new_array(0, 0, sizeof(v__ast__Import)), .used_imports = __new_array(0, 0, sizeof(string)), @@ -90729,6 +90720,7 @@ multi_return_ref_v__ast__File_Array_v__vet__Error v__parser__parse_vet_file(stri .name_error = 0, .comptime_if_cond = 0, .should_abort = 0, + .script_mode = 0, }); v__parser__Parser_set_path(&p, path); if (string_contains_any_substr(p.scanner->text, new_array_from_c_array(2, 2, sizeof(string), _MOV((string[2]){_SLIT("\n "), _SLIT(" \n")})))) { @@ -91089,33 +91081,39 @@ v__ast__Stmt v__parser__Parser_top_stmt(v__parser__Parser* p) { return _t14; } else if (p->tok.kind == (v__token__Kind__dollar)) { + if (p->peek_tok.kind == v__token__Kind__eof) { + v__ast__Stmt _t15 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error(p, _SLIT("unexpected eof"))))); + return _t15; + } v__ast__IfExpr if_expr = v__parser__Parser_if_expr(p, true); - v__ast__Stmt _t15 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = if_expr.pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__IfExpr_to_sumtype_v__ast__Expr(&if_expr),.is_expr = 0,.typ = 0,})))); - return _t15; - } - else if (p->tok.kind == (v__token__Kind__hash)) { - v__ast__Stmt _t16 = v__ast__HashStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__HashStmt, (v__parser__Parser_hash(p)))); + v__ast__Stmt _t16 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = if_expr.pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__IfExpr_to_sumtype_v__ast__Expr(&if_expr),.is_expr = 0,.typ = 0,})))); return _t16; } - else if (p->tok.kind == (v__token__Kind__key_type)) { - v__ast__Stmt _t17 = v__ast__TypeDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__TypeDecl, (v__parser__Parser_type_decl(p)))); + else if (p->tok.kind == (v__token__Kind__hash)) { + v__ast__Stmt _t17 = v__ast__HashStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__HashStmt, (v__parser__Parser_hash(p)))); return _t17; } - else if (p->tok.kind == (v__token__Kind__key_enum)) { - v__ast__Stmt _t18 = v__ast__EnumDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__EnumDecl, (v__parser__Parser_enum_decl(p)))); + else if (p->tok.kind == (v__token__Kind__key_type)) { + v__ast__Stmt _t18 = v__ast__TypeDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__TypeDecl, (v__parser__Parser_type_decl(p)))); return _t18; } - else if (p->tok.kind == (v__token__Kind__key_union)) { - v__ast__Stmt _t19 = v__ast__StructDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__StructDecl, (v__parser__Parser_struct_decl(p)))); + else if (p->tok.kind == (v__token__Kind__key_enum)) { + v__ast__Stmt _t19 = v__ast__EnumDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__EnumDecl, (v__parser__Parser_enum_decl(p)))); return _t19; } - else if (p->tok.kind == (v__token__Kind__comment)) { - v__ast__Stmt _t20 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (v__parser__Parser_comment_stmt(p)))); + else if (p->tok.kind == (v__token__Kind__key_union)) { + v__ast__Stmt _t20 = v__ast__StructDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__StructDecl, (v__parser__Parser_struct_decl(p)))); return _t20; } + else if (p->tok.kind == (v__token__Kind__comment)) { + v__ast__Stmt _t21 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (v__parser__Parser_comment_stmt(p)))); + return _t21; + } else { p->inside_fn = true; if (p->pref->is_script && !p->pref->is_test) { + p->script_mode = true; + p->script_mode_start_token = p->tok; v__parser__Parser_open_scope(p); Array_v__ast__Stmt stmts = __new_array_with_default(0, 0, sizeof(v__ast__Stmt), 0); for (;;) { @@ -91123,7 +91121,8 @@ v__ast__Stmt v__parser__Parser_top_stmt(v__parser__Parser* p) { array_push((array*)&stmts, _MOV((v__ast__Stmt[]){ v__parser__Parser_stmt(p, false) })); } v__parser__Parser_close_scope(p); - v__ast__Stmt _t22 = v__ast__FnDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__FnDecl, (((v__ast__FnDecl){ + p->script_mode = false; + v__ast__Stmt _t23 = v__ast__FnDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__FnDecl, (((v__ast__FnDecl){ .receiver = (v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,}, .generic_names = __new_array(0, 0, sizeof(string)), .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), @@ -91175,21 +91174,21 @@ v__ast__Stmt v__parser__Parser_top_stmt(v__parser__Parser* p) { .should_be_skipped = 0, .has_await = 0, })))); - return _t22; - } else if (p->pref->is_fmt) { - v__ast__Stmt _t23 = v__parser__Parser_stmt(p, false); return _t23; - } else { - v__ast__Stmt _t24 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error(p, string__plus(_SLIT("bad top level statement "), v__token__Token_str(p->tok)))))); + } else if (p->pref->is_fmt) { + v__ast__Stmt _t24 = v__parser__Parser_stmt(p, false); return _t24; + } else { + v__ast__Stmt _t25 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error(p, string__plus(_SLIT("bad top level statement "), v__token__Token_str(p->tok)))))); + return _t25; } }; if (p->should_abort) { break; } } - v__ast__Stmt _t25 = v__ast__empty_stmt(); - return _t25; + v__ast__Stmt _t26 = v__ast__empty_stmt(); + return _t26; } v__ast__Comment v__parser__Parser_check_comment(v__parser__Parser* p) { @@ -91994,7 +91993,7 @@ VV_LOCAL_SYMBOL Array_v__ast__AsmIO v__parser__Parser_asm_ios(v__parser__Parser* if (p->tok.kind == v__token__Kind__lpar) { constraint = (output ? (_SLIT("+r")) : (_SLIT("r"))); } else { - constraint = /*f*/string__plus(constraint, ((p->tok.kind == (v__token__Kind__assign)) ? (_SLIT("=")) : (p->tok.kind == (v__token__Kind__plus)) ? (_SLIT("+")) : (p->tok.kind == (v__token__Kind__mod)) ? (_SLIT("%")) : (p->tok.kind == (v__token__Kind__amp)) ? (_SLIT("&")) : (_SLIT("")))); + constraint = /*f*/string__plus(constraint, ((p->tok.kind == (v__token__Kind__assign))? (_SLIT("=")) : (p->tok.kind == (v__token__Kind__plus))? (_SLIT("+")) : (p->tok.kind == (v__token__Kind__mod))? (_SLIT("%")) : (p->tok.kind == (v__token__Kind__amp))? (_SLIT("&")) : (_SLIT("")))); if ((constraint).len != 0) { v__parser__Parser_next(p); } @@ -92351,9 +92350,9 @@ VV_LOCAL_SYMBOL v__ast__Stmt v__parser__Parser_parse_multi_expr(v__parser__Parse v__token__Pos pos = v__token__Token_pos(&tok); Array_v__ast__Ident defer_vars = p->defer_vars; p->defer_vars = __new_array_with_default(0, 0, sizeof(v__ast__Ident), 0); - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_48067 = v__parser__Parser_expr_list(p); - Array_v__ast__Expr left = mr_48067.arg0; - Array_v__ast__Comment left_comments = mr_48067.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_48309 = v__parser__Parser_expr_list(p); + Array_v__ast__Expr left = mr_48309.arg0; + Array_v__ast__Comment left_comments = mr_48309.arg1; if (!(p->inside_defer && p->tok.kind == v__token__Kind__decl_assign)) { _PUSH_MANY(&defer_vars, (p->defer_vars), _t1, Array_v__ast__Ident); } @@ -92767,7 +92766,7 @@ v__ast__Expr v__parser__Parser_name_expr(v__parser__Parser* p) { string name = v__parser__Parser_check_name(p); v__parser__Parser_check(p, v__token__Kind__dot); string field = v__parser__Parser_check_name(p); - v__ast__GenericKindField fkind = ((string__eq(field, _SLIT("name"))) ? (v__ast__GenericKindField__name) : (string__eq(field, _SLIT("typ"))) ? (v__ast__GenericKindField__typ) : (v__ast__GenericKindField__unknown)); + v__ast__GenericKindField fkind = ((string__eq(field, _SLIT("name")))? (v__ast__GenericKindField__name) : (string__eq(field, _SLIT("typ")))? (v__ast__GenericKindField__typ) : (v__ast__GenericKindField__unknown)); v__token__Pos_extend(pos, v__token__Token_pos(&p->tok)); v__ast__Expr _t21 = v__ast__SelectorExpr_to_sumtype_v__ast__Expr(ADDR(v__ast__SelectorExpr, (((v__ast__SelectorExpr){.from_embed_types = __new_array(0, 0, sizeof(v__ast__Type)),.field_name = field,.expr = v__ast__Ident_to_sumtype_v__ast__Expr(ADDR(v__ast__Ident, (((v__ast__Ident){.obj = {0},.mod = (string){.str=(byteptr)"", .is_lit=1},.name = name,.info = {0},.scope = p->scope,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.tok_kind = 0,.language = 0,.kind = 0,.comptime = 0,.is_mut = 0,})))),.scope = p->scope,.pos = pos,.mut_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.expr_type = 0,.typ = 0,.name_type = 0,.next_token = 0,.gkind_field = fkind,.is_mut = 0,})))); return _t21; @@ -93549,6 +93548,10 @@ VV_LOCAL_SYMBOL v__ast__ConstDecl v__parser__Parser_const_decl(v__parser__Parser v__parser__Parser_next(p); } v__token__Pos const_pos = v__token__Token_pos(&p->tok); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__ConstDecl _t2 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); + return _t2; + } v__parser__Parser_check(p, v__token__Kind__key_const); bool is_block = p->tok.kind == v__token__Kind__lpar; if (is_block) { @@ -93561,30 +93564,30 @@ VV_LOCAL_SYMBOL v__ast__ConstDecl v__parser__Parser_const_decl(v__parser__Parser comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,})); if (is_block && p->tok.kind == v__token__Kind__eof) { v__parser__Parser_error(p, _SLIT("unexpected eof, expecting \302\264)\302\264")); - v__ast__ConstDecl _t2 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); - return _t2; + v__ast__ConstDecl _t3 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); + return _t3; } if (p->tok.kind == v__token__Kind__rpar) { break; } v__token__Pos pos = v__token__Token_pos(&p->tok); string name = v__parser__Parser_check_name(p); - _PUSH_MANY(&end_comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t3, Array_v__ast__Comment); + _PUSH_MANY(&end_comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t4, Array_v__ast__Comment); if (v__util__contains_capital(name)) { v__parser__Parser_warn_with_pos(p, _SLIT("const names cannot contain uppercase letters, use snake_case instead"), pos); } string full_name = v__parser__Parser_prepend_mod(p, name); v__parser__Parser_check(p, v__token__Kind__assign); - _PUSH_MANY(&end_comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t4, Array_v__ast__Comment); + _PUSH_MANY(&end_comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t5, Array_v__ast__Comment); if (p->tok.kind == v__token__Kind__key_fn) { v__parser__Parser_error(p, _SLIT("const initializer fn literal is not a constant")); - v__ast__ConstDecl _t5 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); - return _t5; + v__ast__ConstDecl _t6 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); + return _t6; } if (p->tok.kind == v__token__Kind__eof) { v__parser__Parser_error(p, _SLIT("unexpected eof, expecting an expression")); - v__ast__ConstDecl _t6 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); - return _t6; + v__ast__ConstDecl _t7 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); + return _t7; } v__ast__Expr expr = v__parser__Parser_expr(p, 0); v__ast__ConstField field = ((v__ast__ConstField){ @@ -93610,9 +93613,9 @@ VV_LOCAL_SYMBOL v__ast__ConstDecl v__parser__Parser_const_decl(v__parser__Parser if (is_block) { v__parser__Parser_check(p, v__token__Kind__rpar); } else { - _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,}))), _t8, Array_v__ast__Comment); + _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,}))), _t9, Array_v__ast__Comment); } - v__ast__ConstDecl _t9 = ((v__ast__ConstDecl){ + v__ast__ConstDecl _t10 = ((v__ast__ConstDecl){ .attrs = attrs, .fields = fields, .end_comments = comments, @@ -93620,7 +93623,7 @@ VV_LOCAL_SYMBOL v__ast__ConstDecl v__parser__Parser_const_decl(v__parser__Parser .is_pub = is_pub, .is_block = is_block, }); - return _t9; + return _t10; } VV_LOCAL_SYMBOL v__ast__Return v__parser__Parser_return_stmt(v__parser__Parser* p) { @@ -93631,9 +93634,9 @@ VV_LOCAL_SYMBOL v__ast__Return v__parser__Parser_return_stmt(v__parser__Parser* v__ast__Return _t1 = ((v__ast__Return){.pos = first_pos,.comments = comments,.exprs = __new_array(0, 0, sizeof(v__ast__Expr)),.types = __new_array(0, 0, sizeof(v__ast__Type)),}); return _t1; } - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_84732 = v__parser__Parser_expr_list(p); - Array_v__ast__Expr exprs = mr_84732.arg0; - Array_v__ast__Comment comments2 = mr_84732.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_85049 = v__parser__Parser_expr_list(p); + Array_v__ast__Expr exprs = mr_85049.arg0; + Array_v__ast__Comment comments2 = mr_85049.arg1; _PUSH_MANY(&comments, (comments2), _t2, Array_v__ast__Comment); v__token__Pos end_pos = v__ast__Expr_pos((*(v__ast__Expr*)array_last(exprs))); v__ast__Return _t3 = ((v__ast__Return){.pos = v__token__Pos_extend(first_pos, end_pos),.comments = comments,.exprs = exprs,.types = __new_array(0, 0, sizeof(v__ast__Type)),}); @@ -93663,6 +93666,10 @@ VV_LOCAL_SYMBOL v__ast__GlobalDecl v__parser__Parser_global_decl(v__parser__Pars } v__token__Pos start_pos = v__token__Token_pos(&p->tok); v__parser__Parser_check(p, v__token__Kind__key_global); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__GlobalDecl _t3 = ((v__ast__GlobalDecl){.mod = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_block = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__GlobalField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),}); + return _t3; + } bool is_block = p->tok.kind == v__token__Kind__lpar; if (is_block) { v__parser__Parser_next(p); @@ -93677,8 +93684,8 @@ VV_LOCAL_SYMBOL v__ast__GlobalDecl v__parser__Parser_global_decl(v__parser__Pars } if (is_block && p->tok.kind == v__token__Kind__eof) { v__parser__Parser_error(p, _SLIT("unexpected eof, expecting `)`")); - v__ast__GlobalDecl _t3 = ((v__ast__GlobalDecl){.mod = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_block = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__GlobalField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),}); - return _t3; + v__ast__GlobalDecl _t4 = ((v__ast__GlobalDecl){.mod = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_block = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__GlobalField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),}); + return _t4; } if (p->tok.kind == v__token__Kind__rpar) { break; @@ -93757,7 +93764,7 @@ VV_LOCAL_SYMBOL v__ast__GlobalDecl v__parser__Parser_global_decl(v__parser__Pars if (is_block) { v__parser__Parser_check(p, v__token__Kind__rpar); } - v__ast__GlobalDecl _t5 = ((v__ast__GlobalDecl){ + v__ast__GlobalDecl _t6 = ((v__ast__GlobalDecl){ .mod = p->mod, .pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)), .is_block = is_block, @@ -93765,7 +93772,7 @@ VV_LOCAL_SYMBOL v__ast__GlobalDecl v__parser__Parser_global_decl(v__parser__Pars .fields = fields, .end_comments = comments, }); - return _t5; + return _t6; } VV_LOCAL_SYMBOL v__ast__EnumDecl v__parser__Parser_enum_decl(v__parser__Parser* p) { @@ -93777,17 +93784,21 @@ VV_LOCAL_SYMBOL v__ast__EnumDecl v__parser__Parser_enum_decl(v__parser__Parser* } v__parser__Parser_check(p, v__token__Kind__key_enum); v__token__Pos end_pos = v__token__Token_pos(&p->tok); - string enum_name = v__parser__Parser_check_name(p); - if (enum_name.len == 1) { - v__parser__Parser_error_with_pos(p, _SLIT("single letter capital names are reserved for generic template types."), end_pos); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { v__ast__EnumDecl _t1 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); return _t1; } - if (_IN_MAP(ADDR(string, enum_name), ADDR(map, p->imported_symbols))) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register enum `"), /*115 &string*/0xfe10, {.d_s = enum_name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), end_pos); + string enum_name = v__parser__Parser_check_name(p); + if (enum_name.len == 1) { + v__parser__Parser_error_with_pos(p, _SLIT("single letter capital names are reserved for generic template types."), end_pos); v__ast__EnumDecl _t2 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); return _t2; } + if (_IN_MAP(ADDR(string, enum_name), ADDR(map, p->imported_symbols))) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register enum `"), /*115 &string*/0xfe10, {.d_s = enum_name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), end_pos); + v__ast__EnumDecl _t3 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); + return _t3; + } string name = v__parser__Parser_prepend_mod(p, enum_name); v__parser__Parser_check(p, v__token__Kind__lcbr); Array_v__ast__Comment enum_decl_comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,})); @@ -93823,15 +93834,15 @@ VV_LOCAL_SYMBOL v__ast__EnumDecl v__parser__Parser_enum_decl(v__parser__Parser* if (is_flag) { if (fields.len > 32) { v__parser__Parser_error(p, _SLIT("when an enum is used as bit field, it must have a max of 32 fields")); - v__ast__EnumDecl _t5 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); - return _t5; + v__ast__EnumDecl _t6 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); + return _t6; } - for (int _t6 = 0; _t6 < fields.len; ++_t6) { - v__ast__EnumField f = ((v__ast__EnumField*)fields.data)[_t6]; + for (int _t7 = 0; _t7 < fields.len; ++_t7) { + v__ast__EnumField f = ((v__ast__EnumField*)fields.data)[_t7]; if (f.has_expr) { v__parser__Parser_error_with_pos(p, _SLIT("when an enum is used as a bit field, you can not assign custom values"), f.pos); - v__ast__EnumDecl _t7 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); - return _t7; + v__ast__EnumDecl _t8 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); + return _t8; } } string pubfn = (string__eq(p->mod, _SLIT("main")) ? (_SLIT("fn")) : (_SLIT("pub fn"))); @@ -93865,8 +93876,8 @@ VV_LOCAL_SYMBOL v__ast__EnumDecl v__parser__Parser_enum_decl(v__parser__Parser* .is_multi_allowed = is_multi_allowed, }); v__ast__Table_register_enum_decl(p->table, enum_decl); - v__ast__EnumDecl _t8 = enum_decl; - return _t8; + v__ast__EnumDecl _t9 = enum_decl; + return _t9; } VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* p) { @@ -93879,20 +93890,24 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* v__token__Pos end_pos = v__token__Token_pos(&p->tok); v__token__Pos decl_pos = v__token__Pos_extend(start_pos, end_pos); v__token__Pos name_pos = v__token__Token_pos(&p->tok); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__TypeDecl _t1 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_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)),.typ = 0,.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.variants = __new_array(0, 0, sizeof(v__ast__TypeNode)),})))); + return _t1; + } string name = v__parser__Parser_check_name(p); if (name.len == 1 && u8_is_capital(string_at(name, 0))) { v__parser__Parser_error_with_pos(p, _SLIT("single letter capital names are reserved for generic template types."), decl_pos); - v__ast__TypeDecl _t1 = v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__FnTypeDecl, (((v__ast__FnTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.typ = 0,.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)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),})))); - return _t1; + v__ast__TypeDecl _t2 = v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__FnTypeDecl, (((v__ast__FnTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.typ = 0,.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)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),})))); + return _t2; } if (_IN_MAP(ADDR(string, name), ADDR(map, p->imported_symbols))) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register alias `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), end_pos); - v__ast__TypeDecl _t2 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t2; + v__ast__TypeDecl _t3 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t3; } Array_v__ast__TypeNode sum_variants = __new_array_with_default(0, 0, sizeof(v__ast__TypeNode), 0); - multi_return_Array_v__ast__Type_Array_string mr_91001 = v__parser__Parser_parse_generic_types(p); - Array_v__ast__Type generic_types = mr_91001.arg0; + multi_return_Array_v__ast__Type_Array_string mr_91545 = v__parser__Parser_parse_generic_types(p); + Array_v__ast__Type generic_types = mr_91545.arg0; v__token__Pos decl_pos_with_generics = v__token__Pos_extend(decl_pos, v__token__Token_pos(&p->prev_tok)); v__parser__Parser_check(p, v__token__Kind__assign); v__token__Pos type_pos = v__token__Token_pos(&p->tok); @@ -93905,7 +93920,7 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,})); Array_v__ast__Attr attrs = p->attrs; p->attrs = __new_array_with_default(0, 0, sizeof(v__ast__Attr), 0); - v__ast__TypeDecl _t3 = v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__FnTypeDecl, (((v__ast__FnTypeDecl){ + v__ast__TypeDecl _t4 = v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__FnTypeDecl, (((v__ast__FnTypeDecl){ .name = fn_name, .is_pub = is_pub, .typ = fn_type, @@ -93914,30 +93929,30 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* .comments = comments, .attrs = attrs, })))); - return _t3; + return _t4; } - _PUSH_MANY(&sum_variants, (v__parser__Parser_parse_sum_type_variants(p)), _t4, Array_v__ast__TypeNode); + _PUSH_MANY(&sum_variants, (v__parser__Parser_parse_sum_type_variants(p)), _t5, Array_v__ast__TypeNode); if (sum_variants.len > 1) { - for (int _t5 = 0; _t5 < sum_variants.len; ++_t5) { - v__ast__TypeNode variant = ((v__ast__TypeNode*)sum_variants.data)[_t5]; + for (int _t6 = 0; _t6 < sum_variants.len; ++_t6) { + v__ast__TypeNode variant = ((v__ast__TypeNode*)sum_variants.data)[_t6]; v__ast__TypeSymbol* variant_sym = v__ast__Table_sym(p->table, variant.typ); if (variant_sym->kind == v__ast__Kind__none_) { v__parser__Parser_error_with_pos(p, _SLIT("named sum type cannot have none as its variant"), variant.pos); - v__ast__TypeDecl _t6 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t6; + v__ast__TypeDecl _t7 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t7; } } - Array_v__ast__Type _t7 = {0}; - Array_v__ast__TypeNode _t7_orig = sum_variants; - int _t7_len = _t7_orig.len; - _t7 = __new_array(0, _t7_len, sizeof(v__ast__Type)); + Array_v__ast__Type _t8 = {0}; + Array_v__ast__TypeNode _t8_orig = sum_variants; + int _t8_len = _t8_orig.len; + _t8 = __new_array(0, _t8_len, sizeof(v__ast__Type)); - for (int _t8 = 0; _t8 < _t7_len; ++_t8) { - v__ast__TypeNode it = ((v__ast__TypeNode*) _t7_orig.data)[_t8]; + for (int _t9 = 0; _t9 < _t8_len; ++_t9) { + v__ast__TypeNode it = ((v__ast__TypeNode*) _t8_orig.data)[_t9]; v__ast__Type ti = it.typ; - array_push((array*)&_t7, &ti); + array_push((array*)&_t8, &ti); } - Array_v__ast__Type variant_types =_t7; + Array_v__ast__Type variant_types =_t8; string prepend_mod_name = v__parser__Parser_prepend_mod(p, name); int typ = v__ast__Table_register_sym(p->table, ((v__ast__TypeSymbol){ .methods = __new_array(0, 0, sizeof(v__ast__Fn)), @@ -93955,26 +93970,27 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* })); if (typ == _const_v__ast__invalid_type_idx) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register sum type `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); - v__ast__TypeDecl _t9 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.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)),.typ = 0,.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.variants = __new_array(0, 0, sizeof(v__ast__TypeNode)),})))); - return _t9; + v__ast__TypeDecl _t10 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_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)),.typ = 0,.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.variants = __new_array(0, 0, sizeof(v__ast__TypeNode)),})))); + return _t10; } comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,})); - v__ast__TypeDecl _t10 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){ + v__ast__TypeDecl _t11 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){ .name = name, .is_pub = is_pub, .pos = decl_pos, + .name_pos = name_pos, .comments = comments, .typ = typ, .generic_types = generic_types, .attrs = p->attrs, .variants = sum_variants, })))); - return _t10; + return _t11; } if (generic_types.len > 0) { v__parser__Parser_error_with_pos(p, _SLIT("generic type aliases are not yet implemented"), decl_pos_with_generics); - v__ast__TypeDecl _t11 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t11; + v__ast__TypeDecl _t12 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t12; } v__ast__Type parent_type = (*(v__ast__TypeNode*)/*ee elem_sym */array_get(sum_variants, 0)).typ; v__ast__TypeSymbol* parent_sym = v__ast__Table_sym(p->table, parent_type); @@ -93998,17 +94014,17 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* v__token__Pos type_end_pos = v__token__Token_pos(&p->prev_tok); if (idx == _const_v__ast__invalid_type_idx) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register alias `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); - v__ast__TypeDecl _t12 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t12; + v__ast__TypeDecl _t13 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t13; } if (idx == pidx) { v__token__Pos type_alias_pos = (*(v__ast__TypeNode*)/*ee elem_sym */array_get(sum_variants, 0)).pos; v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("a type alias can not refer to itself: "), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT0, 0, { .d_c = 0 }}})), v__token__Pos_extend(decl_pos, type_alias_pos)); - v__ast__TypeDecl _t13 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t13; + v__ast__TypeDecl _t14 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t14; } comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,})); - v__ast__TypeDecl _t14 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){ + v__ast__TypeDecl _t15 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){ .name = name, .is_pub = is_pub, .parent_type = parent_type, @@ -94016,7 +94032,7 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* .type_pos = v__token__Pos_extend(type_pos, type_end_pos), .comments = comments, })))); - return _t14; + return _t15; } VV_LOCAL_SYMBOL v__ast__Assoc v__parser__Parser_assoc(v__parser__Parser* p) { @@ -94184,6 +94200,17 @@ bool v__parser__Parser_unsafe_stmt_defer_0 = false; return _t6; } +VV_LOCAL_SYMBOL bool v__parser__Parser_disallow_declarations_in_script_mode(v__parser__Parser* p) { + if (p->script_mode) { + v__parser__Parser_note_with_pos(p, _SLIT("script mode started here"), v__token__Token_pos(&p->script_mode_start_token)); + v__parser__Parser_error_with_pos(p, _SLIT("all definitions must occur before code in script mode"), v__token__Token_pos(&p->tok)); + bool _t1 = true; + return _t1; + } + bool _t2 = false; + return _t2; +} + VV_LOCAL_SYMBOL void v__parser__Parser_trace(v__parser__Parser* p, string fbase, string message) { if (string__eq(p->file_base, fbase)) { println( str_intp(3, _MOV((StrIntpData[]){{_SLIT("> p.trace | "), /*115 &string*/0x14fe10, {.d_s = fbase}}, {_SLIT(" | "), /*115 &string*/0xfe10, {.d_s = message}}, {_SLIT0, 0, { .d_c = 0 }}}))); @@ -94484,32 +94511,26 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } v__token__Pos name_pos = v__token__Token_pos(&p->tok); v__parser__Parser_check_for_impure_v(p, language, name_pos); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__StructDecl _t1 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + return _t1; + } string name = v__parser__Parser_check_name(p); if (name.len == 1 && u8_is_capital(string_at(name, 0))) { v__parser__Parser_error_with_pos(p, _SLIT("single letter capital names are reserved for generic template types."), name_pos); - v__ast__StructDecl _t1 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - return _t1; + v__ast__StructDecl _t2 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + return _t2; } if (string__eq(name, _SLIT("IError")) && !string__eq(p->mod, _SLIT("builtin"))) { v__parser__Parser_error_with_pos(p, _SLIT("cannot register struct `IError`, it is builtin interface type"), name_pos); } v__ast__Table_start_parsing_type(p->table, v__parser__Parser_prepend_mod(p, name)); v__parser__Parser_struct_decl_defer_0 = true; - multi_return_Array_v__ast__Type_Array_string mr_1547 = v__parser__Parser_parse_generic_types(p); - Array_v__ast__Type generic_types = mr_1547.arg0; + multi_return_Array_v__ast__Type_Array_string mr_1623 = v__parser__Parser_parse_generic_types(p); + Array_v__ast__Type generic_types = mr_1623.arg0; bool no_body = p->tok.kind != v__token__Kind__lcbr; if (language == v__ast__Language__v && no_body) { v__parser__Parser_error(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), /*115 &string*/0xfe10, {.d_s = p->tok.lit}}, {_SLIT("` lacks body"), 0, { .d_c = 0 }}}))); - v__ast__StructDecl _t2 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - // Defer begin - if (v__parser__Parser_struct_decl_defer_0) { - v__ast__Table_reset_parsing_type(p->table); - } - // Defer end - return _t2; - } - if (language == v__ast__Language__v && !p->builtin_mod && !p->is_translated && name.len > 0 && !u8_is_capital(string_at(name, 0)) && !p->pref->translated && !p->is_translated) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct name `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("` must begin with capital letter"), 0, { .d_c = 0 }}})), name_pos); v__ast__StructDecl _t3 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -94518,8 +94539,8 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t3; } - if (name.len == 1) { - v__parser__Parser_error_with_pos(p, _SLIT("struct names must have more than one character"), name_pos); + if (language == v__ast__Language__v && !p->builtin_mod && !p->is_translated && name.len > 0 && !u8_is_capital(string_at(name, 0)) && !p->pref->translated && !p->is_translated) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct name `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("` must begin with capital letter"), 0, { .d_c = 0 }}})), name_pos); v__ast__StructDecl _t4 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -94528,8 +94549,8 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t4; } - if (_IN_MAP(ADDR(string, name), ADDR(map, p->imported_symbols))) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register struct `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), name_pos); + if (name.len == 1) { + v__parser__Parser_error_with_pos(p, _SLIT("struct names must have more than one character"), name_pos); v__ast__StructDecl _t5 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -94538,6 +94559,16 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t5; } + if (_IN_MAP(ADDR(string, name), ADDR(map, p->imported_symbols))) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register struct `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), name_pos); + v__ast__StructDecl _t6 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + // Defer begin + if (v__parser__Parser_struct_decl_defer_0) { + v__ast__Table_reset_parsing_type(p->table); + } + // Defer end + return _t6; + } string orig_name = name; if (language == v__ast__Language__c) { name = str_intp(2, _MOV((StrIntpData[]){{_SLIT("C."), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT0, 0, { .d_c = 0 }}})); @@ -94585,13 +94616,13 @@ bool v__parser__Parser_struct_decl_defer_0 = false; if (p->tok.kind == v__token__Kind__key_mut) { if (pub_mut_pos != -1) { v__parser__Parser_error(p, _SLIT("redefinition of `pub mut` section")); - v__ast__StructDecl _t7 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + v__ast__StructDecl _t8 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { v__ast__Table_reset_parsing_type(p->table); } // Defer end - return _t7; + return _t8; } v__parser__Parser_next(p); pub_mut_pos = ast_fields.len; @@ -94601,13 +94632,13 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } else { if (pub_pos != -1) { v__parser__Parser_error(p, _SLIT("redefinition of `pub` section")); - v__ast__StructDecl _t8 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + v__ast__StructDecl _t9 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { v__ast__Table_reset_parsing_type(p->table); } // Defer end - return _t8; + return _t9; } pub_pos = ast_fields.len; is_field_pub = true; @@ -94618,23 +94649,6 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } else if (p->tok.kind == v__token__Kind__key_mut) { if (mut_pos != -1) { v__parser__Parser_error(p, _SLIT("redefinition of `mut` section")); - v__ast__StructDecl _t9 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - // Defer begin - if (v__parser__Parser_struct_decl_defer_0) { - v__ast__Table_reset_parsing_type(p->table); - } - // Defer end - return _t9; - } - v__parser__Parser_next(p); - v__parser__Parser_check(p, v__token__Kind__colon); - mut_pos = ast_fields.len; - is_field_pub = false; - is_field_mut = true; - is_field_global = false; - } else if (p->tok.kind == v__token__Kind__key_global) { - if (global_pos != -1) { - v__parser__Parser_error(p, _SLIT("redefinition of `global` section")); v__ast__StructDecl _t10 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -94645,13 +94659,13 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } v__parser__Parser_next(p); v__parser__Parser_check(p, v__token__Kind__colon); - global_pos = ast_fields.len; - is_field_pub = true; + mut_pos = ast_fields.len; + is_field_pub = false; is_field_mut = true; - is_field_global = true; - } else if (p->tok.kind == v__token__Kind__key_module) { - if (module_pos != -1) { - v__parser__Parser_error(p, _SLIT("redefinition of `module` section")); + is_field_global = false; + } else if (p->tok.kind == v__token__Kind__key_global) { + if (global_pos != -1) { + v__parser__Parser_error(p, _SLIT("redefinition of `global` section")); v__ast__StructDecl _t11 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -94662,6 +94676,23 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } v__parser__Parser_next(p); v__parser__Parser_check(p, v__token__Kind__colon); + global_pos = ast_fields.len; + is_field_pub = true; + is_field_mut = true; + is_field_global = true; + } else if (p->tok.kind == v__token__Kind__key_module) { + if (module_pos != -1) { + v__parser__Parser_error(p, _SLIT("redefinition of `module` section")); + v__ast__StructDecl _t12 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + // Defer begin + if (v__parser__Parser_struct_decl_defer_0) { + v__ast__Table_reset_parsing_type(p->table); + } + // Defer end + return _t12; + } + v__parser__Parser_next(p); + v__parser__Parser_check(p, v__token__Kind__colon); module_pos = ast_fields.len; is_field_pub = false; is_field_mut = false; @@ -94689,21 +94720,10 @@ bool v__parser__Parser_struct_decl_defer_0 = false; if (is_embed) { type_pos = v__token__Token_pos(&p->tok); typ = v__parser__Parser_parse_type(p); - _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t13, Array_v__ast__Comment); + _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t14, Array_v__ast__Comment); type_pos = v__token__Pos_extend(type_pos, v__token__Token_pos(&p->prev_tok)); if (!is_on_top) { v__parser__Parser_error_with_pos(p, _SLIT("struct embedding must be declared at the beginning of the struct body"), type_pos); - v__ast__StructDecl _t14 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - // Defer begin - if (v__parser__Parser_struct_decl_defer_0) { - v__ast__Table_reset_parsing_type(p->table); - } - // Defer end - return _t14; - } - v__ast__TypeSymbol* sym = v__ast__Table_sym(p->table, typ); - if (Array_v__ast__Type_contains(embed_types, typ)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot embed `"), /*115 &string*/0xfe10, {.d_s = sym->name}}, {_SLIT("` more than once"), 0, { .d_c = 0 }}})), type_pos); v__ast__StructDecl _t15 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -94712,9 +94732,9 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t15; } - field_name = v__ast__TypeSymbol_embed_name(sym); - if (Array_string_contains(embed_field_names, field_name)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate field `"), /*115 &string*/0xfe10, {.d_s = field_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), type_pos); + v__ast__TypeSymbol* sym = v__ast__Table_sym(p->table, typ); + if (Array_v__ast__Type_contains(embed_types, typ)) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot embed `"), /*115 &string*/0xfe10, {.d_s = sym->name}}, {_SLIT("` more than once"), 0, { .d_c = 0 }}})), type_pos); v__ast__StructDecl _t16 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -94723,6 +94743,17 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t16; } + field_name = v__ast__TypeSymbol_embed_name(sym); + if (Array_string_contains(embed_field_names, field_name)) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate field `"), /*115 &string*/0xfe10, {.d_s = field_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), type_pos); + v__ast__StructDecl _t17 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + // Defer begin + if (v__parser__Parser_struct_decl_defer_0) { + v__ast__Table_reset_parsing_type(p->table); + } + // Defer end + return _t17; + } array_push((array*)&embed_field_names, _MOV((string[]){ string_clone(field_name) })); array_push((array*)&embed_types, _MOV((v__ast__Type[]){ typ })); array_push((array*)&embeds, _MOV((v__ast__Embed[]){ ((v__ast__Embed){.typ = typ,.pos = type_pos,.comments = comments,}) })); @@ -94739,18 +94770,18 @@ bool v__parser__Parser_struct_decl_defer_0 = false; typ = v__parser__Parser_parse_type(p); p->inside_struct_field_decl = false; if (v__ast__Type_idx(typ) == 0) { - v__ast__StructDecl _t21 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + v__ast__StructDecl _t22 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { v__ast__Table_reset_parsing_type(p->table); } // Defer end - return _t21; + return _t22; } type_pos = v__token__Token_pos(&p->prev_tok); field_pos = v__token__Pos_extend(field_start_pos, type_pos); } - _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t22, Array_v__ast__Comment); + _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t23, Array_v__ast__Comment); if (p->tok.kind == v__token__Kind__lsbr) { v__parser__Parser_attributes(p); } @@ -94768,7 +94799,7 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } ; has_default_expr = true; - _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t23, Array_v__ast__Comment); + _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t24, Array_v__ast__Comment); } array_push((array*)&ast_fields, _MOV((v__ast__StructField[]){ ((v__ast__StructField){ .comments = comments, @@ -94841,18 +94872,6 @@ bool v__parser__Parser_struct_decl_defer_0 = false; }); if (v__ast__Table_has_deep_child_no_ref(p->table, &t, name)) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid recursive struct `"), /*115 &string*/0xfe10, {.d_s = orig_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), name_pos); - v__ast__StructDecl _t26 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - // Defer begin - if (v__parser__Parser_struct_decl_defer_0) { - v__ast__Table_reset_parsing_type(p->table); - } - // Defer end - return _t26; - } - int ret = 0; - ret = v__ast__Table_register_sym(p->table, t); - if (ret == -1 && language != v__ast__Language__c) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register struct `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); v__ast__StructDecl _t27 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -94861,8 +94880,20 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t27; } + int ret = 0; + ret = v__ast__Table_register_sym(p->table, t); + if (ret == -1 && language != v__ast__Language__c) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register struct `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); + v__ast__StructDecl _t28 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + // Defer begin + if (v__parser__Parser_struct_decl_defer_0) { + v__ast__Table_reset_parsing_type(p->table); + } + // Defer end + return _t28; + } p->expr_mod = _SLIT(""); - v__ast__StructDecl _t28 = ((v__ast__StructDecl){ + v__ast__StructDecl _t29 = ((v__ast__StructDecl){ .generic_types = generic_types, .attrs = attrs, .end_comments = end_comments, @@ -94884,7 +94915,7 @@ bool v__parser__Parser_struct_decl_defer_0 = false; v__ast__Table_reset_parsing_type(p->table); } // Defer end - return _t28; + return _t29; } VV_LOCAL_SYMBOL v__ast__StructInit v__parser__Parser_struct_init(v__parser__Parser* p, string typ_str, bool short_syntax) { @@ -94994,6 +95025,10 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser } v__token__Pos name_pos = v__token__Token_pos(&p->tok); v__parser__Parser_check_for_impure_v(p, language, name_pos); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__InterfaceDecl _t1 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t1; + } string modless_name = v__parser__Parser_check_name(p); if (string__eq(modless_name, _SLIT("IError")) && !string__eq(p->mod, _SLIT("builtin"))) { v__parser__Parser_error_with_pos(p, _SLIT("cannot register interface `IError`, it is builtin interface type"), name_pos); @@ -95004,14 +95039,14 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser } else { interface_name = v__parser__Parser_prepend_mod(p, modless_name); } - multi_return_Array_v__ast__Type_Array_string mr_13116 = v__parser__Parser_parse_generic_types(p); - Array_v__ast__Type generic_types = mr_13116.arg0; + multi_return_Array_v__ast__Type_Array_string mr_13271 = v__parser__Parser_parse_generic_types(p); + Array_v__ast__Type generic_types = mr_13271.arg0; v__parser__Parser_check(p, v__token__Kind__lcbr); Array_v__ast__Comment pre_comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,})); if (_IN_MAP(ADDR(string, modless_name), ADDR(map, p->imported_symbols))) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register interface `"), /*115 &string*/0xfe10, {.d_s = interface_name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), name_pos); - v__ast__InterfaceDecl _t1 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); - return _t1; + v__ast__InterfaceDecl _t2 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t2; } int reg_idx = v__ast__Table_register_sym(p->table, ((v__ast__TypeSymbol){ .methods = __new_array(0, 0, sizeof(v__ast__Fn)), @@ -95029,8 +95064,8 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser })); if (reg_idx == -1) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register interface `"), /*115 &string*/0xfe10, {.d_s = interface_name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); - v__ast__InterfaceDecl _t2 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); - return _t2; + v__ast__InterfaceDecl _t3 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t3; } v__ast__Type typ = v__ast__new_type(reg_idx); v__ast__TypeSymbol* ts = v__ast__Table_sym(p->table, typ); @@ -95078,8 +95113,8 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser if (p->tok.kind == v__token__Kind__key_mut) { if (is_mut) { v__parser__Parser_error_with_pos(p, _SLIT("redefinition of `mut` section"), v__token__Token_pos(&p->tok)); - v__ast__InterfaceDecl _t5 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); - return _t5; + v__ast__InterfaceDecl _t6 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t6; } v__parser__Parser_next(p); v__parser__Parser_check(p, v__token__Kind__colon); @@ -95092,19 +95127,19 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser string name = v__parser__Parser_check_name(p); if (string__eq(name, _SLIT("type_name")) || string__eq(name, _SLIT("type_idx"))) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot override built-in method `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), method_start_pos); - v__ast__InterfaceDecl _t6 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); - return _t6; - } - if (v__ast__TypeSymbol_has_method(ts, name)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate method `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), method_start_pos); v__ast__InterfaceDecl _t7 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); return _t7; } - multi_return_Array_v__ast__Param_bool_bool mr_16252 = v__parser__Parser_fn_args(p); - Array_v__ast__Param args2 = mr_16252.arg0; - bool is_variadic = mr_16252.arg2; + if (v__ast__TypeSymbol_has_method(ts, name)) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate method `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), method_start_pos); + v__ast__InterfaceDecl _t8 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t8; + } + multi_return_Array_v__ast__Param_bool_bool mr_16407 = v__parser__Parser_fn_args(p); + Array_v__ast__Param args2 = mr_16407.arg0; + bool is_variadic = mr_16407.arg2; Array_v__ast__Param args = new_array_from_c_array(1, 1, sizeof(v__ast__Param), _MOV((v__ast__Param[1]){((v__ast__Param){.name = _SLIT("x"),.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,},.typ = typ,.is_mut = is_mut,.is_auto_rec = 0,.is_hidden = true,})})); - _PUSH_MANY(&args, (args2), _t8, Array_v__ast__Param); + _PUSH_MANY(&args, (args2), _t9, Array_v__ast__Param); v__ast__FnDecl method = ((v__ast__FnDecl){ .receiver = (v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,}, .generic_names = __new_array(0, 0, sizeof(string)), @@ -95234,17 +95269,17 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser array_push((array*)&info.fields, _MOV((v__ast__StructField[]){ ((v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.default_expr = {0},.name = field_name,.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,},.i = 0,.default_expr_typ = 0,.typ = field_typ,.has_default_expr = 0,.is_pub = true,.is_mut = is_mut,.is_global = 0,.is_volatile = 0,}) })); } } - Array_v__ast__Type _t14 = {0}; - Array_v__ast__InterfaceEmbedding _t14_orig = embeds; - int _t14_len = _t14_orig.len; - _t14 = __new_array(0, _t14_len, sizeof(v__ast__Type)); + Array_v__ast__Type _t15 = {0}; + Array_v__ast__InterfaceEmbedding _t15_orig = embeds; + int _t15_len = _t15_orig.len; + _t15 = __new_array(0, _t15_len, sizeof(v__ast__Type)); - for (int _t15 = 0; _t15 < _t14_len; ++_t15) { - v__ast__InterfaceEmbedding it = ((v__ast__InterfaceEmbedding*) _t14_orig.data)[_t15]; + for (int _t16 = 0; _t16 < _t15_len; ++_t16) { + v__ast__InterfaceEmbedding it = ((v__ast__InterfaceEmbedding*) _t15_orig.data)[_t16]; v__ast__Type ti = it.typ; - array_push((array*)&_t14, &ti); + array_push((array*)&_t15, &ti); } - info.embeds =_t14; + info.embeds =_t15; ts->info = v__ast__Interface_to_sumtype_v__ast__TypeInfo(&info); v__parser__Parser_top_level_statement_end(p); v__parser__Parser_check(p, v__token__Kind__rcbr); @@ -95267,8 +95302,8 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser .are_embeds_expanded = 0, }); v__ast__Table_register_interface(p->table, res); - v__ast__InterfaceDecl _t16 = res; - return _t16; + v__ast__InterfaceDecl _t17 = res; + return _t17; } VV_LOCAL_SYMBOL void v__parser__State_update(v__parser__State* state, string line) { @@ -99543,7 +99578,7 @@ void _vinit(int ___argc, voidptr ___argv) { { // Initializations for module v.ast.walker : } { // Initializations for module v.parser : - _const_v__parser__supported_comptime_calls = new_array_from_c_array(5, 5, sizeof(string), _MOV((string[5]){_SLIT("html"), _SLIT("tmpl"), _SLIT("env"), _SLIT("embed_file"), _SLIT("pkgconfig")})); + _const_v__parser__supported_comptime_calls = new_array_from_c_array(7, 7, sizeof(string), _MOV((string[7]){_SLIT("html"), _SLIT("tmpl"), _SLIT("env"), _SLIT("embed_file"), _SLIT("pkgconfig"), _SLIT("compile_error"), _SLIT("compile_warn")})); _const_v__parser__comptime_types = new_array_from_c_array(8, 8, sizeof(string), _MOV((string[8]){_SLIT("Map"), _SLIT("Array"), _SLIT("Int"), _SLIT("Float"), _SLIT("Struct"), _SLIT("Interface"), _SLIT("Enum"), _SLIT("Sumtype")})); _const_v__parser__valid_tokens_inside_types = new_array_from_c_array(7, 7, sizeof(v__token__Kind), _MOV((v__token__Kind[7]){v__token__Kind__lsbr, v__token__Kind__rsbr, v__token__Kind__name, v__token__Kind__dot, v__token__Kind__comma, v__token__Kind__key_fn, v__token__Kind__lt})); codegen_files = __new_array_with_default(0, 0, sizeof(v__ast__File*), 0); // 3global diff --git a/v_win.c b/v_win.c index f67a4ce..04690c5 100644 --- a/v_win.c +++ b/v_win.c @@ -1,11 +1,11 @@ -#define V_COMMIT_HASH "0bd8d872d" +#define V_COMMIT_HASH "b10cf3e0f" #ifndef V_COMMIT_HASH - #define V_COMMIT_HASH "3afb88c4e" + #define V_COMMIT_HASH "0bd8d872d" #endif #ifndef V_CURRENT_COMMIT_HASH - #define V_CURRENT_COMMIT_HASH "0bd8d87" + #define V_CURRENT_COMMIT_HASH "b10cf3e" #endif // V comptime_definitions: @@ -4500,6 +4500,7 @@ struct v__ast__SumTypeDecl { string name; bool is_pub; v__token__Pos pos; + v__token__Pos name_pos; Array_v__ast__Comment comments; v__ast__Type typ; Array_v__ast__Type generic_types; @@ -5520,6 +5521,7 @@ struct v__parser__Parser { v__token__Token tok; v__token__Token prev_tok; v__token__Token peek_tok; + v__token__Token script_mode_start_token; Array_v__ast__Attr attrs; Array_v__ast__Import ast_imports; Array_string used_imports; @@ -5590,6 +5592,7 @@ struct v__parser__Parser { bool name_error; bool comptime_if_cond; bool should_abort; + bool script_mode; }; @@ -7301,6 +7304,7 @@ VV_LOCAL_SYMBOL void map_free_nop(voidptr _d1); VV_LOCAL_SYMBOL map new_map(int key_bytes, int value_bytes, u64 (*hash_fn)(voidptr ), bool (*key_eq_fn)(voidptr , voidptr ), void (*clone_fn)(voidptr , voidptr ), void (*free_fn)(voidptr )); VV_LOCAL_SYMBOL map new_map_init(u64 (*hash_fn)(voidptr ), bool (*key_eq_fn)(voidptr , voidptr ), void (*clone_fn)(voidptr , voidptr ), void (*free_fn)(voidptr ), int n, int key_bytes, int value_bytes, voidptr keys, voidptr values); map map_move(map* m); +void map_clear(map* m); VV_LOCAL_SYMBOL multi_return_u32_u32 map_key_to_index(map* m, voidptr pkey); VV_LOCAL_SYMBOL multi_return_u32_u32 map_meta_less(map* m, u32 _index, u32 _metas); VV_LOCAL_SYMBOL void map_meta_greater(map* m, u32 _index, u32 _metas, u32 kvi); @@ -8086,6 +8090,7 @@ _option_string os__get_module_filename(os__HANDLE handle); VV_LOCAL_SYMBOL voidptr os__ptr_win_get_error_msg(u32 code); string os__get_error_msg(int code); os__Result os__execute(string cmd); +os__Result os__raw_execute(string cmd); _option_bool os__symlink(string origin, string target); _option_bool os__link(string origin, string target); void os__File_close(os__File* f); @@ -9835,7 +9840,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_fn_decl(v__gen__c__Gen* g, v__ast__FnDecl no VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_fn_decl(v__gen__c__Gen* g, v__ast__FnDecl* node, bool skip); VV_LOCAL_SYMBOL _option_string v__gen__c__Gen_c_fn_name(v__gen__c__Gen* g, v__ast__FnDecl* node); string _const_v__gen__c__closure_ctx; // a string literal, inited later -VV_LOCAL_SYMBOL multi_return_string_string v__gen__c__closure_ctx(v__ast__FnDecl node); +VV_LOCAL_SYMBOL string v__gen__c__closure_ctx(v__ast__FnDecl node); VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn(v__gen__c__Gen* g, v__ast__AnonFn* node); VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn_decl(v__gen__c__Gen* g, v__ast__AnonFn* node); VV_LOCAL_SYMBOL string v__gen__c__Gen_defer_flag_var(v__gen__c__Gen* g, v__ast__DeferStmt* stmt); @@ -10145,6 +10150,7 @@ VV_LOCAL_SYMBOL void v__parser__Parser_top_level_statement_end(v__parser__Parser VV_LOCAL_SYMBOL void v__parser__Parser_rewind_scanner_to_current_token_in_new_mode(v__parser__Parser* p); bool v__parser__Parser_mark_var_as_used(v__parser__Parser* p, string varname); VV_LOCAL_SYMBOL v__ast__Stmt v__parser__Parser_unsafe_stmt(v__parser__Parser* p); +VV_LOCAL_SYMBOL bool v__parser__Parser_disallow_declarations_in_script_mode(v__parser__Parser* p); VV_LOCAL_SYMBOL void v__parser__Parser_trace(v__parser__Parser* p, string fbase, string message); VV_LOCAL_SYMBOL v__ast__Expr v__parser__Parser_sql_expr(v__parser__Parser* p); VV_LOCAL_SYMBOL v__ast__SqlStmt v__parser__Parser_sql_stmt(v__parser__Parser* p); @@ -11218,7 +11224,7 @@ static string indent_v__ast__CallExpr_str(v__ast__CallExpr it, int indent_count) string _t6 = indent_Array_v__ast__Type_str(it.from_embed_types, indent_count + 1); string _t7 = indent_Array_v__ast__Comment_str(it.comments, indent_count + 1); string _t8 = v__ast__Expr_str(it.left); - string _t9 = isnil(it.scope) ? _SLIT("nil") : (indent_count > 25) ? _SLIT("") : v__ast__Scope_str(*it.scope); + string _t9 = isnil(it.scope) ? _SLIT("nil") : (indent_count > 25)? _SLIT("") : v__ast__Scope_str(*it.scope); string _t10 = indent_v__token__Pos_str(it.pos, indent_count + 1); string _t11 = indent_v__token__Pos_str(it.name_pos, indent_count + 1); string _t12 = indent_v__token__Pos_str(it.concrete_list_pos, indent_count + 1); @@ -12437,6 +12443,11 @@ static inline v__ast__TypeInfo v__ast__Enum_to_sumtype_v__ast__TypeInfo(v__ast__ return (v__ast__TypeInfo){ ._v__ast__Enum = ptr, ._typ = 486}; } +static inline v__ast__TypeDecl v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(v__ast__SumTypeDecl* x) { + v__ast__SumTypeDecl* ptr = memdup(x, sizeof(v__ast__SumTypeDecl)); + return (v__ast__TypeDecl){ ._v__ast__SumTypeDecl = ptr, ._typ = 283, .name = (string*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, name)), .is_pub = (bool*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, is_pub)), .pos = (v__token__Pos*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, pos)), .comments = (Array_v__ast__Comment*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, comments))}; +} + static inline v__ast__TypeDecl v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(v__ast__FnTypeDecl* x) { v__ast__FnTypeDecl* ptr = memdup(x, sizeof(v__ast__FnTypeDecl)); return (v__ast__TypeDecl){ ._v__ast__FnTypeDecl = ptr, ._typ = 282, .name = (string*)((char*)ptr + __offsetof_ptr(ptr, v__ast__FnTypeDecl, name)), .is_pub = (bool*)((char*)ptr + __offsetof_ptr(ptr, v__ast__FnTypeDecl, is_pub)), .pos = (v__token__Pos*)((char*)ptr + __offsetof_ptr(ptr, v__ast__FnTypeDecl, pos)), .comments = (Array_v__ast__Comment*)((char*)ptr + __offsetof_ptr(ptr, v__ast__FnTypeDecl, comments))}; @@ -12447,11 +12458,6 @@ static inline v__ast__TypeDecl v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl return (v__ast__TypeDecl){ ._v__ast__AliasTypeDecl = ptr, ._typ = 281, .name = (string*)((char*)ptr + __offsetof_ptr(ptr, v__ast__AliasTypeDecl, name)), .is_pub = (bool*)((char*)ptr + __offsetof_ptr(ptr, v__ast__AliasTypeDecl, is_pub)), .pos = (v__token__Pos*)((char*)ptr + __offsetof_ptr(ptr, v__ast__AliasTypeDecl, pos)), .comments = (Array_v__ast__Comment*)((char*)ptr + __offsetof_ptr(ptr, v__ast__AliasTypeDecl, comments))}; } -static inline v__ast__TypeDecl v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(v__ast__SumTypeDecl* x) { - v__ast__SumTypeDecl* ptr = memdup(x, sizeof(v__ast__SumTypeDecl)); - return (v__ast__TypeDecl){ ._v__ast__SumTypeDecl = ptr, ._typ = 283, .name = (string*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, name)), .is_pub = (bool*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, is_pub)), .pos = (v__token__Pos*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, pos)), .comments = (Array_v__ast__Comment*)((char*)ptr + __offsetof_ptr(ptr, v__ast__SumTypeDecl, comments))}; -} - static inline v__ast__TypeInfo v__ast__Alias_to_sumtype_v__ast__TypeInfo(v__ast__Alias* x) { v__ast__Alias* ptr = memdup(x, sizeof(v__ast__Alias)); return (v__ast__TypeInfo){ ._v__ast__Alias = ptr, ._typ = 472}; @@ -13199,9 +13205,7 @@ static int v_typeof_interface_idx_v__ast__walker__Visitor(int sidx) { /* v.ast.w // TypeDecl strings__Builder strings__new_builder(int initial_size) { strings__Builder res = ((__new_array_with_default(0, initial_size, sizeof(u8), 0))); - { // Unsafe block - res.flags = ArrayFlags__noslices; - } + ArrayFlags_set(&res.flags, ArrayFlags__noslices); return res; } @@ -13276,7 +13280,7 @@ void strings__Builder_drain_builder(strings__Builder* b, strings__Builder* other // Attr: [inline] inline u8 strings__Builder_byte_at(strings__Builder* b, int n) { - return ((u8*)(b->data))[n]; + return (*(u8*)/*ee elem_sym */array_get(*(((Array_u8*)(b))), n)); } // Attr: [inline] @@ -13322,15 +13326,10 @@ void strings__Builder_go_back_to(strings__Builder* b, int pos) { // Attr: [inline] inline void strings__Builder_writeln(strings__Builder* b, string s) { - int new_len = b->len + s.len + 1; - strings__Builder_ensure_cap(b, new_len); - { // Unsafe block - ((u8*)(b->data))[new_len - 1] = ((u8)('\n')); - if (s.len > 0) { - vmemcpy(((u8*)(b->data)) + b->len, s.str, s.len); - } - b->len = new_len; + if (s.len > 0) { + array_push_many(b, s.str, s.len); } + array_push((array*)b, _MOV((u8[]){ ((u8)('\n')) })); } string strings__Builder_last_n(strings__Builder* b, int n) { @@ -13359,10 +13358,12 @@ void strings__Builder_ensure_cap(strings__Builder* b, int n) { if (n <= b->cap) { return; } - u8* new_data = _v_malloc(((u64)(n)) * ((u64)(b->element_size))); - if (b->data != 0) { - vmemcpy(new_data, b->data, b->len); - _v_free(b->data); + u8* new_data = vcalloc(n * b->element_size); + if (b->data != ((voidptr)(0))) { + vmemcpy(new_data, b->data, b->len * b->element_size); + if (ArrayFlags_has(&b->flags, ArrayFlags__noslices)) { + _v_free(b->data); + } } { // Unsafe block b->data = new_data; @@ -19145,6 +19146,11 @@ map map_move(map* m) { return r; } +void map_clear(map* m) { + m->len = 0; + m->key_values.len = 0; +} + // Attr: [inline] inline VV_LOCAL_SYMBOL multi_return_u32_u32 map_key_to_index(map* m, voidptr pkey) { u64 hash = m->hash_fn(pkey); @@ -19217,12 +19223,12 @@ VV_LOCAL_SYMBOL void map_set(map* m, voidptr key, voidptr value) { if (load_factor > _const_max_load_factor) { map_expand(m); } - multi_return_u32_u32 mr_10845 = map_key_to_index(m, key); - u32 index = mr_10845.arg0; - u32 meta = mr_10845.arg1; - multi_return_u32_u32 mr_10881 = map_meta_less(m, index, meta); - index = mr_10881.arg0; - meta = mr_10881.arg1; + multi_return_u32_u32 mr_11087 = map_key_to_index(m, key); + u32 index = mr_11087.arg0; + u32 meta = mr_11087.arg1; + multi_return_u32_u32 mr_11123 = map_meta_less(m, index, meta); + index = mr_11123.arg0; + meta = mr_11123.arg1; for (;;) { if (!(meta == m->metas[index])) break; int kv_index = ((int)(m->metas[index + 1U])); @@ -19273,12 +19279,12 @@ VV_LOCAL_SYMBOL void map_rehash(map* m) { continue; } voidptr pkey = DenseArray_key(&m->key_values, i); - multi_return_u32_u32 mr_12544 = map_key_to_index(m, pkey); - u32 index = mr_12544.arg0; - u32 meta = mr_12544.arg1; - multi_return_u32_u32 mr_12582 = map_meta_less(m, index, meta); - index = mr_12582.arg0; - meta = mr_12582.arg1; + multi_return_u32_u32 mr_12786 = map_key_to_index(m, pkey); + u32 index = mr_12786.arg0; + u32 meta = mr_12786.arg1; + multi_return_u32_u32 mr_12824 = map_meta_less(m, index, meta); + index = mr_12824.arg0; + meta = mr_12824.arg1; map_meta_greater(m, index, meta, ((u32)(i))); } } @@ -19297,9 +19303,9 @@ VV_LOCAL_SYMBOL void map_cached_rehash(map* m, u32 old_cap) { u32 old_index = ((i - old_probe_count) & (m->even_index >> 1U)); u32 index = (((old_index | (old_meta << m->shift))) & m->even_index); u32 meta = (((old_meta & _const_hash_mask)) | _const_probe_inc); - multi_return_u32_u32 mr_13381 = map_meta_less(m, index, meta); - index = mr_13381.arg0; - meta = mr_13381.arg1; + multi_return_u32_u32 mr_13623 = map_meta_less(m, index, meta); + index = mr_13623.arg0; + meta = mr_13623.arg1; u32 kv_index = old_metas[i + 1U]; map_meta_greater(m, index, meta, kv_index); } @@ -19308,9 +19314,9 @@ VV_LOCAL_SYMBOL void map_cached_rehash(map* m, u32 old_cap) { VV_LOCAL_SYMBOL voidptr map_get_and_set(map* m, voidptr key, voidptr zero) { for (;;) { - multi_return_u32_u32 mr_13829 = map_key_to_index(m, key); - u32 index = mr_13829.arg0; - u32 meta = mr_13829.arg1; + multi_return_u32_u32 mr_14071 = map_key_to_index(m, key); + u32 index = mr_14071.arg0; + u32 meta = mr_14071.arg1; for (;;) { if (meta == m->metas[index]) { int kv_index = ((int)(m->metas[index + 1U])); @@ -19332,9 +19338,9 @@ VV_LOCAL_SYMBOL voidptr map_get_and_set(map* m, voidptr key, voidptr zero) { } VV_LOCAL_SYMBOL voidptr map_get(map* m, voidptr key, voidptr zero) { - multi_return_u32_u32 mr_14552 = map_key_to_index(m, key); - u32 index = mr_14552.arg0; - u32 meta = mr_14552.arg1; + multi_return_u32_u32 mr_14794 = map_key_to_index(m, key); + u32 index = mr_14794.arg0; + u32 meta = mr_14794.arg1; for (;;) { if (meta == m->metas[index]) { int kv_index = ((int)(m->metas[index + 1U])); @@ -19354,9 +19360,9 @@ VV_LOCAL_SYMBOL voidptr map_get(map* m, voidptr key, voidptr zero) { } VV_LOCAL_SYMBOL voidptr map_get_check(map* m, voidptr key) { - multi_return_u32_u32 mr_15217 = map_key_to_index(m, key); - u32 index = mr_15217.arg0; - u32 meta = mr_15217.arg1; + multi_return_u32_u32 mr_15459 = map_key_to_index(m, key); + u32 index = mr_15459.arg0; + u32 meta = mr_15459.arg1; for (;;) { if (meta == m->metas[index]) { int kv_index = ((int)(m->metas[index + 1U])); @@ -19376,9 +19382,9 @@ VV_LOCAL_SYMBOL voidptr map_get_check(map* m, voidptr key) { } VV_LOCAL_SYMBOL bool map_exists(map* m, voidptr key) { - multi_return_u32_u32 mr_15727 = map_key_to_index(m, key); - u32 index = mr_15727.arg0; - u32 meta = mr_15727.arg1; + multi_return_u32_u32 mr_15969 = map_key_to_index(m, key); + u32 index = mr_15969.arg0; + u32 meta = mr_15969.arg1; for (;;) { if (meta == m->metas[index]) { int kv_index = ((int)(m->metas[index + 1U])); @@ -19409,12 +19415,12 @@ inline VV_LOCAL_SYMBOL void DenseArray_delete(DenseArray* d, int i) { // Attr: [unsafe] void map_delete(map* m, voidptr key) { - multi_return_u32_u32 mr_16356 = map_key_to_index(m, key); - u32 index = mr_16356.arg0; - u32 meta = mr_16356.arg1; - multi_return_u32_u32 mr_16392 = map_meta_less(m, index, meta); - index = mr_16392.arg0; - meta = mr_16392.arg1; + multi_return_u32_u32 mr_16598 = map_key_to_index(m, key); + u32 index = mr_16598.arg0; + u32 meta = mr_16598.arg1; + multi_return_u32_u32 mr_16634 = map_meta_less(m, index, meta); + index = mr_16634.arg0; + meta = mr_16634.arg1; for (;;) { if (!(meta == m->metas[index])) break; int kv_index = ((int)(m->metas[index + 1U])); @@ -28498,10 +28504,9 @@ void os__walk_with_context(string path, voidptr context, void (*fcb)(voidptr , s for (int _t2 = 0; _t2 < files.len; ++_t2) { string file = ((string*)files.data)[_t2]; string p = string__plus(string__plus(path, local_path_separator), file); + fcb(context, p); if (os__is_dir(p) && !os__is_link(p)) { os__walk_with_context(p, context, (voidptr)fcb); - } else { - fcb(context, p); } } return; @@ -28869,6 +28874,12 @@ os__Result os__execute(string cmd) { os__Result _t1 = ((os__Result){.exit_code = -1,.output = _SLIT(";, &&, || and \\n are not allowed in shell commands"),}); return _t1; } + os__Result _t2 = os__raw_execute(cmd); + return _t2; +} + +// Attr: [unsafe] +os__Result os__raw_execute(string cmd) { u32* child_stdin = ((u32*)(0)); u32* child_stdout_read = ((u32*)(0)); u32* child_stdout_write = ((u32*)(0)); @@ -28879,15 +28890,15 @@ os__Result os__execute(string cmd) { if (!create_pipe_ok) { int error_num = ((int)(GetLastError())); string error_msg = os__get_error_msg(error_num); - os__Result _t2 = ((os__Result){.exit_code = error_num,.output = str_intp(2, _MOV((StrIntpData[]){{_SLIT("exec failed (CreatePipe): "), /*115 &string*/0xfe10, {.d_s = error_msg}}, {_SLIT0, 0, { .d_c = 0 }}})),}); - return _t2; + os__Result _t1 = ((os__Result){.exit_code = error_num,.output = str_intp(2, _MOV((StrIntpData[]){{_SLIT("exec failed (CreatePipe): "), /*115 &string*/0xfe10, {.d_s = error_msg}}, {_SLIT0, 0, { .d_c = 0 }}})),}); + return _t1; } bool set_handle_info_ok = SetHandleInformation(child_stdout_read, HANDLE_FLAG_INHERIT, 0U); if (!set_handle_info_ok) { int error_num = ((int)(GetLastError())); string error_msg = os__get_error_msg(error_num); - os__Result _t3 = ((os__Result){.exit_code = error_num,.output = str_intp(2, _MOV((StrIntpData[]){{_SLIT("exec failed (SetHandleInformation): "), /*115 &string*/0xfe10, {.d_s = error_msg}}, {_SLIT0, 0, { .d_c = 0 }}})),}); - return _t3; + os__Result _t2 = ((os__Result){.exit_code = error_num,.output = str_intp(2, _MOV((StrIntpData[]){{_SLIT("exec failed (SetHandleInformation): "), /*115 &string*/0xfe10, {.d_s = error_msg}}, {_SLIT0, 0, { .d_c = 0 }}})),}); + return _t2; } os__ProcessInformation proc_info = ((os__ProcessInformation){.h_process = 0,.h_thread = 0,.dw_process_id = 0,.dw_thread_id = 0,}); os__StartupInfo start_info = ((os__StartupInfo){ @@ -28916,8 +28927,8 @@ os__Result os__execute(string cmd) { if (!create_process_ok) { int error_num = ((int)(GetLastError())); string error_msg = os__get_error_msg(error_num); - os__Result _t4 = ((os__Result){.exit_code = error_num,.output = str_intp(4, _MOV((StrIntpData[]){{_SLIT("exec failed (CreateProcess) with code "), /*100 &int*/0xfe07, {.d_i32 = error_num}}, {_SLIT(": "), /*115 &string*/0xfe10, {.d_s = error_msg}}, {_SLIT(" cmd: "), /*115 &string*/0xfe10, {.d_s = cmd}}, {_SLIT0, 0, { .d_c = 0 }}})),}); - return _t4; + os__Result _t3 = ((os__Result){.exit_code = error_num,.output = str_intp(4, _MOV((StrIntpData[]){{_SLIT("exec failed (CreateProcess) with code "), /*100 &int*/0xfe07, {.d_i32 = error_num}}, {_SLIT(": "), /*115 &string*/0xfe10, {.d_s = error_msg}}, {_SLIT(" cmd: "), /*115 &string*/0xfe10, {.d_s = cmd}}, {_SLIT0, 0, { .d_c = 0 }}})),}); + return _t3; } CloseHandle(child_stdin); CloseHandle(child_stdout_write); @@ -28941,8 +28952,8 @@ os__Result os__execute(string cmd) { GetExitCodeProcess(proc_info.h_process, ((voidptr)(&exit_code))); CloseHandle(proc_info.h_process); CloseHandle(proc_info.h_thread); - os__Result _t5 = ((os__Result){.exit_code = ((int)(exit_code)),.output = soutput,}); - return _t5; + os__Result _t4 = ((os__Result){.exit_code = ((int)(exit_code)),.output = soutput,}); + return _t4; } _option_bool os__symlink(string origin, string target) { @@ -33218,7 +33229,7 @@ string time__Time_get_fmt_date_str(time__Time t, time__FormatDelimiter fmt_dlmtr } } string res = _t2; - string del = ((fmt_dlmtr == (time__FormatDelimiter__dot)) ? (_SLIT(".")) : (fmt_dlmtr == (time__FormatDelimiter__hyphen)) ? (_SLIT("-")) : (fmt_dlmtr == (time__FormatDelimiter__slash)) ? (_SLIT("/")) : (fmt_dlmtr == (time__FormatDelimiter__space)) ? (_SLIT(" ")) : (_SLIT(""))); + string del = ((fmt_dlmtr == (time__FormatDelimiter__dot))? (_SLIT(".")) : (fmt_dlmtr == (time__FormatDelimiter__hyphen))? (_SLIT("-")) : (fmt_dlmtr == (time__FormatDelimiter__slash))? (_SLIT("/")) : (fmt_dlmtr == (time__FormatDelimiter__space))? (_SLIT(" ")) : (_SLIT(""))); res = string_replace(res, _SLIT("|"), del); string _t3 = res; return _t3; @@ -33331,13 +33342,13 @@ _option_time__Time time__parse_rfc3339(string s) { return _t9; } - multi_return_int_int_int_int_i64_bool mr_1384 = (*(multi_return_int_int_int_int_i64_bool*)_t8.data); - hour_ = mr_1384.arg0; - minute_ = mr_1384.arg1; - second_ = mr_1384.arg2; - microsecond_ = mr_1384.arg3; - unix_offset = mr_1384.arg4; - is_local_time = mr_1384.arg5; + multi_return_int_int_int_int_i64_bool mr_1383 = (*(multi_return_int_int_int_int_i64_bool*)_t8.data); + hour_ = mr_1383.arg0; + minute_ = mr_1383.arg1; + second_ = mr_1383.arg2; + microsecond_ = mr_1383.arg3; + unix_offset = mr_1383.arg4; + is_local_time = mr_1383.arg5; t = time__new_time(((time__Time){.year = 0,.month = 0,.day = 0,.hour = hour_,.minute = minute_,.second = second_,.microsecond = microsecond_,._v_unix = 0,.is_local = 0,})); if (is_local_time) { _option_time__Time _t10; @@ -33441,10 +33452,10 @@ _option_time__Time time__parse_iso8601(string s) { return _t5; } - multi_return_int_int_int mr_3646 = (*(multi_return_int_int_int*)_t4.data); - int year = mr_3646.arg0; - int month = mr_3646.arg1; - int day = mr_3646.arg2; + multi_return_int_int_int mr_3644 = (*(multi_return_int_int_int*)_t4.data); + int year = mr_3644.arg0; + int month = mr_3644.arg1; + int day = mr_3644.arg2; int hour_ = 0; int minute_ = 0; int second_ = 0; @@ -33459,13 +33470,13 @@ _option_time__Time time__parse_iso8601(string s) { return _t7; } - multi_return_int_int_int_int_i64_bool mr_3888 = (*(multi_return_int_int_int_int_i64_bool*)_t6.data); - hour_ = mr_3888.arg0; - minute_ = mr_3888.arg1; - second_ = mr_3888.arg2; - microsecond_ = mr_3888.arg3; - unix_offset = mr_3888.arg4; - is_local_time = mr_3888.arg5; + multi_return_int_int_int_int_i64_bool mr_3885 = (*(multi_return_int_int_int_int_i64_bool*)_t6.data); + hour_ = mr_3885.arg0; + minute_ = mr_3885.arg1; + second_ = mr_3885.arg2; + microsecond_ = mr_3885.arg3; + unix_offset = mr_3885.arg4; + is_local_time = mr_3885.arg5; } time__Time t = time__new_time(((time__Time){ .year = year, @@ -33960,33 +33971,33 @@ i64 time__Duration_nanoseconds(time__Duration d) { } i64 time__Duration_microseconds(time__Duration d) { - i64 _t1 = ((i64)(d)) / 1000; + i64 _t1 = ((i64)(d)) / _const_time__microsecond; return _t1; } i64 time__Duration_milliseconds(time__Duration d) { - i64 _t1 = ((i64)(d)) / 1000000; + i64 _t1 = ((i64)(d)) / _const_time__millisecond; return _t1; } f64 time__Duration_seconds(time__Duration d) { i64 sec = d / _const_time__second; i64 nsec = d % _const_time__second; - f64 _t1 = ((f64)(sec)) + ((f64)(nsec)) / 1e9; + f64 _t1 = ((f64)(sec)) + ((f64)(nsec)) / _const_time__second; return _t1; } f64 time__Duration_minutes(time__Duration d) { i64 min = d / _const_time__minute; i64 nsec = d % _const_time__minute; - f64 _t1 = ((f64)(min)) + ((f64)(nsec)) / (60 * 1e9); + f64 _t1 = ((f64)(min)) + ((f64)(nsec)) / _const_time__minute; return _t1; } f64 time__Duration_hours(time__Duration d) { i64 hr = d / _const_time__hour; i64 nsec = d % _const_time__hour; - f64 _t1 = ((f64)(hr)) + ((f64)(nsec)) / (3600 * 1e9); + f64 _t1 = ((f64)(hr)) + ((f64)(nsec)) / _const_time__hour; return _t1; } @@ -34572,9 +34583,9 @@ VV_LOCAL_SYMBOL _option_v__vmod__Manifest v__vmod__Parser_parse(v__vmod__Parser* return _t8; } - multi_return_Array_string_int mr_4989 = (*(multi_return_Array_string_int*)_t7.data); - Array_string vals = mr_4989.arg0; - int idx = mr_4989.arg1; + multi_return_Array_string_int mr_4988 = (*(multi_return_Array_string_int*)_t7.data); + Array_string vals = mr_4988.arg0; + int idx = mr_4988.arg1; map_set(&mn.unknown, &(string[]){field_name}, &(Array_string[]) { vals }); i = idx; continue; @@ -36449,7 +36460,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("3afb88c4e"); + string vhash = _SLIT("0bd8d872d"); 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, /*115 &v.pref.Backend*/0xfe10, {.d_s = v__pref__Backend_str(p->backend)}}, {_SLIT(" | "), /*115 &v.pref.OS*/0xfe10, {.d_s = v__pref__OS_str(p->os)}}, {_SLIT(" | "), /*115 &string*/0xfe10, {.d_s = p->ccompiler}}, {_SLIT(" | "), /*115 &bool*/0xfe10, {.d_s = p->is_prod ? _SLIT("true") : _SLIT("false")}}, {_SLIT(" | "), /*115 &bool*/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; @@ -40018,7 +40029,7 @@ _option_string v__util__cached_read_source_file(string path) { } string v__util__replace_op(string s) { - string _t1 = ((string__eq(s, _SLIT("+"))) ? (_SLIT("_plus")) : (string__eq(s, _SLIT("-"))) ? (_SLIT("_minus")) : (string__eq(s, _SLIT("*"))) ? (_SLIT("_mult")) : (string__eq(s, _SLIT("/"))) ? (_SLIT("_div")) : (string__eq(s, _SLIT("%"))) ? (_SLIT("_mod")) : (string__eq(s, _SLIT("<"))) ? (_SLIT("_lt")) : (string__eq(s, _SLIT(">"))) ? (_SLIT("_gt")) : (string__eq(s, _SLIT("=="))) ? (_SLIT("_eq")) : (_SLIT(""))); + string _t1 = ((string__eq(s, _SLIT("+")))? (_SLIT("_plus")) : (string__eq(s, _SLIT("-")))? (_SLIT("_minus")) : (string__eq(s, _SLIT("*")))? (_SLIT("_mult")) : (string__eq(s, _SLIT("/")))? (_SLIT("_div")) : (string__eq(s, _SLIT("%")))? (_SLIT("_mod")) : (string__eq(s, _SLIT("<")))? (_SLIT("_lt")) : (string__eq(s, _SLIT(">")))? (_SLIT("_gt")) : (string__eq(s, _SLIT("==")))? (_SLIT("_eq")) : (_SLIT(""))); return _t1; } @@ -40798,7 +40809,7 @@ bool v__ast__Expr_is_expr(v__ast__Expr expr) { } bool v__ast__Expr_is_lit(v__ast__Expr expr) { - bool _t1 = ((expr._typ == 291 /* v.ast.BoolLiteral */) ? (true) : (expr._typ == 296 /* v.ast.CharLiteral */) ? (true) : (expr._typ == 331 /* v.ast.StringLiteral */) ? (true) : (expr._typ == 312 /* v.ast.IntegerLiteral */) ? (true) : (false)); + bool _t1 = ((expr._typ == 291 /* v.ast.BoolLiteral */)? (true) : (expr._typ == 296 /* v.ast.CharLiteral */)? (true) : (expr._typ == 331 /* v.ast.StringLiteral */)? (true) : (expr._typ == 312 /* v.ast.IntegerLiteral */)? (true) : (false)); return _t1; } @@ -41896,7 +41907,7 @@ string v__ast__Attr_str(v__ast__Attr* a) { _t1 = a->name; } string arg = _t1; - s = /*f*/string__plus(s, ((a->kind == (v__ast__AttrKind__plain) || a->kind == (v__ast__AttrKind__number) || a->kind == (v__ast__AttrKind__bool)) ? (arg) : (a->kind == (v__ast__AttrKind__string)) ? ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("'"), /*115 &string*/0xfe10, {.d_s = arg}}, {_SLIT("'"), 0, { .d_c = 0 }}}))) : ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("if "), /*115 &string*/0xfe10, {.d_s = arg}}, {_SLIT0, 0, { .d_c = 0 }}}))))); + s = /*f*/string__plus(s, ((a->kind == (v__ast__AttrKind__plain) || a->kind == (v__ast__AttrKind__number) || a->kind == (v__ast__AttrKind__bool))? (arg) : (a->kind == (v__ast__AttrKind__string))? ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("'"), /*115 &string*/0xfe10, {.d_s = arg}}, {_SLIT("'"), 0, { .d_c = 0 }}}))) : ( str_intp(2, _MOV((StrIntpData[]){{_SLIT("if "), /*115 &string*/0xfe10, {.d_s = arg}}, {_SLIT0, 0, { .d_c = 0 }}}))))); string _t2 = s; return _t2; } @@ -42436,7 +42447,7 @@ _option_v__ast__ComptTimeConstValue v__ast__ConstField_comptime_expr_value(v__as } bool v__ast__ConstField_is_simple_define_const(v__ast__ConstField* obj) { - bool _t1 = ((obj->expr._typ == 296 /* v.ast.CharLiteral */) ? (true) : (obj->expr._typ == 305 /* v.ast.FloatLiteral */) ? (true) : (obj->expr._typ == 312 /* v.ast.IntegerLiteral */) ? (true) : (false)); + bool _t1 = ((obj->expr._typ == 296 /* v.ast.CharLiteral */)? (true) : (obj->expr._typ == 305 /* v.ast.FloatLiteral */)? (true) : (obj->expr._typ == 312 /* v.ast.IntegerLiteral */)? (true) : (false)); return _t1; } @@ -42582,10 +42593,10 @@ _option_v__ast__ScopeStructField v__ast__Scope_find_struct_field(v__ast__Scope* _option_v__ast__Var_ptr v__ast__Scope_find_var(v__ast__Scope* s, string name) { _option_v__ast__ScopeObject _t1; if (_t1 = v__ast__Scope_find(s, name), _t1.state == 0) { - v__ast__ScopeObject* obj = HEAP(v__ast__ScopeObject, *(v__ast__ScopeObject*)_t1.data); - if ((*(obj))._typ == 365 /* v.ast.Var */) { + v__ast__ScopeObject obj = *(v__ast__ScopeObject*)_t1.data; + if (obj._typ == 365 /* v.ast.Var */) { _option_v__ast__Var_ptr _t2; - opt_ok2(&(v__ast__Var*[]) { &(*((obj->_v__ast__Var))) }, (_option*)(&_t2), sizeof(v__ast__Var*)); + opt_ok2(&(v__ast__Var*[]) { &(*obj._v__ast__Var) }, (_option*)(&_t2), sizeof(v__ast__Var*)); return _t2; } @@ -42599,10 +42610,10 @@ _option_v__ast__Var_ptr v__ast__Scope_find_var(v__ast__Scope* s, string name) { _option_v__ast__GlobalField_ptr v__ast__Scope_find_global(v__ast__Scope* s, string name) { _option_v__ast__ScopeObject _t1; if (_t1 = v__ast__Scope_find(s, name), _t1.state == 0) { - v__ast__ScopeObject* obj = HEAP(v__ast__ScopeObject, *(v__ast__ScopeObject*)_t1.data); - if ((*(obj))._typ == 364 /* v.ast.GlobalField */) { + v__ast__ScopeObject obj = *(v__ast__ScopeObject*)_t1.data; + if (obj._typ == 364 /* v.ast.GlobalField */) { _option_v__ast__GlobalField_ptr _t2; - opt_ok2(&(v__ast__GlobalField*[]) { &(*((obj->_v__ast__GlobalField))) }, (_option*)(&_t2), sizeof(v__ast__GlobalField*)); + opt_ok2(&(v__ast__GlobalField*[]) { &(*obj._v__ast__GlobalField) }, (_option*)(&_t2), sizeof(v__ast__GlobalField*)); return _t2; } @@ -42616,10 +42627,10 @@ _option_v__ast__GlobalField_ptr v__ast__Scope_find_global(v__ast__Scope* s, stri _option_v__ast__ConstField_ptr v__ast__Scope_find_const(v__ast__Scope* s, string name) { _option_v__ast__ScopeObject _t1; if (_t1 = v__ast__Scope_find(s, name), _t1.state == 0) { - v__ast__ScopeObject* obj = HEAP(v__ast__ScopeObject, *(v__ast__ScopeObject*)_t1.data); - if ((*(obj))._typ == 363 /* v.ast.ConstField */) { + v__ast__ScopeObject obj = *(v__ast__ScopeObject*)_t1.data; + if (obj._typ == 363 /* v.ast.ConstField */) { _option_v__ast__ConstField_ptr _t2; - opt_ok2(&(v__ast__ConstField*[]) { &(*((obj->_v__ast__ConstField))) }, (_option*)(&_t2), sizeof(v__ast__ConstField*)); + opt_ok2(&(v__ast__ConstField*[]) { &(*obj._v__ast__ConstField) }, (_option*)(&_t2), sizeof(v__ast__ConstField*)); return _t2; } @@ -46418,7 +46429,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 _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)); + 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; } @@ -46457,7 +46468,7 @@ Array_v__ast__Type v__ast__merge_types(Array_Array_v__ast__Type params) { } v__ast__Type v__ast__mktyp(v__ast__Type typ) { - 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)); + 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; } @@ -46810,9 +46821,9 @@ multi_return_int_int v__ast__Table_type_size(v__ast__Table* t, v__ast__Type typ) } case v__ast__Kind__alias: { - multi_return_int_int mr_21155 = v__ast__Table_type_size(t, (/* as */ *(v__ast__Alias*)__as_cast((sym->info)._v__ast__Alias,(sym->info)._typ, 472) /*expected idx: 472, name: v.ast.Alias */ ).parent_type); - size = mr_21155.arg0; - align = mr_21155.arg1; + multi_return_int_int mr_21154 = v__ast__Table_type_size(t, (/* as */ *(v__ast__Alias*)__as_cast((sym->info)._v__ast__Alias,(sym->info)._typ, 472) /*expected idx: 472, name: v.ast.Alias */ ).parent_type); + size = mr_21154.arg0; + align = mr_21154.arg1; break; } case v__ast__Kind__struct_: @@ -46840,9 +46851,9 @@ multi_return_int_int v__ast__Table_type_size(v__ast__Table* t, v__ast__Type typ) Array_v__ast__Type types = _t4; for (int _t7 = 0; _t7 < types.len; ++_t7) { v__ast__Type ftyp = ((v__ast__Type*)types.data)[_t7]; - multi_return_int_int mr_21466 = v__ast__Table_type_size(t, ftyp); - int field_size = mr_21466.arg0; - int alignment = mr_21466.arg1; + multi_return_int_int mr_21465 = v__ast__Table_type_size(t, ftyp); + int field_size = mr_21465.arg0; + int alignment = mr_21465.arg1; if (alignment > max_alignment) { max_alignment = alignment; } @@ -46869,8 +46880,8 @@ multi_return_int_int v__ast__Table_type_size(v__ast__Table* t, v__ast__Type typ) align = t->pointer_size; for (int _t8 = 0; _t8 < (*sym->info._v__ast__Interface).embeds.len; ++_t8) { v__ast__Type etyp = ((v__ast__Type*)(*sym->info._v__ast__Interface).embeds.data)[_t8]; - multi_return_int_int mr_22027 = v__ast__Table_type_size(t, etyp); - int esize = mr_22027.arg0; + multi_return_int_int mr_22026 = v__ast__Table_type_size(t, etyp); + int esize = mr_22026.arg0; size += esize - 2 * t->pointer_size; } } @@ -46883,9 +46894,9 @@ multi_return_int_int v__ast__Table_type_size(v__ast__Table* t, v__ast__Type typ) case v__ast__Kind__array_fixed: { v__ast__ArrayFixed info = /* as */ *(v__ast__ArrayFixed*)__as_cast((sym->info)._v__ast__ArrayFixed,(sym->info)._typ, 480) /*expected idx: 480, name: v.ast.ArrayFixed */ ; - multi_return_int_int mr_22224 = v__ast__Table_type_size(t, info.elem_type); - int elem_size = mr_22224.arg0; - int elem_align = mr_22224.arg1; + multi_return_int_int mr_22223 = v__ast__Table_type_size(t, info.elem_type); + int elem_size = mr_22223.arg0; + int elem_align = mr_22223.arg1; size = info.size * elem_size; align = elem_align; break; @@ -49088,7 +49099,7 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_check_shift(v__checker__Checker v__ast__Type _t8 = left_type; return _t8; } - int moffset = ((left_type_final == (_const_v__ast__char_type)) ? (7) : (left_type_final == (_const_v__ast__i8_type)) ? (7) : (left_type_final == (_const_v__ast__i16_type)) ? (15) : (left_type_final == (_const_v__ast__int_type)) ? (31) : (left_type_final == (_const_v__ast__i64_type)) ? (63) : (left_type_final == (_const_v__ast__byte_type)) ? (7) : (left_type_final == (_const_v__ast__u16_type)) ? (15) : (left_type_final == (_const_v__ast__u32_type)) ? (31) : (left_type_final == (_const_v__ast__u64_type)) ? (63) : (64)); + int moffset = ((left_type_final == (_const_v__ast__char_type))? (7) : (left_type_final == (_const_v__ast__i8_type))? (7) : (left_type_final == (_const_v__ast__i16_type))? (15) : (left_type_final == (_const_v__ast__int_type))? (31) : (left_type_final == (_const_v__ast__i64_type))? (63) : (left_type_final == (_const_v__ast__byte_type))? (7) : (left_type_final == (_const_v__ast__u16_type))? (15) : (left_type_final == (_const_v__ast__u32_type))? (31) : (left_type_final == (_const_v__ast__u64_type))? (63) : (64)); if (ival > moffset && !c->pref->translated && !c->file->is_translated) { v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("shift count for type `"), /*115 &string*/0xfe10, {.d_s = left_sym_final->name}}, {_SLIT("` too large (maximum: "), /*100 &int*/0xfe07, {.d_i32 = moffset}}, {_SLIT(" bits)"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(node->right)); v__ast__Type _t9 = left_type; @@ -49159,10 +49170,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_18084 = type_hi; - v__ast__Type _var_18093 = type_lo; - type_hi = _var_18093; - type_lo = _var_18084; + v__ast__Type _var_18083 = type_hi; + v__ast__Type _var_18092 = type_lo; + type_hi = _var_18092; + type_lo = _var_18083; } int idx_hi = v__ast__Type_idx(type_hi); int idx_lo = v__ast__Type_idx(type_lo); @@ -49923,7 +49934,47 @@ void v__checker__Checker_sum_type_decl(v__checker__Checker* c, v__ast__SumTypeDe } else if (sym->kind == v__ast__Kind__interface_ && sym->language != v__ast__Language__js) { v__checker__Checker_error(c, _SLIT("sum type cannot hold an interface"), variant.pos); } else if (sym->kind == v__ast__Kind__struct_ && sym->language == v__ast__Language__js) { - v__checker__Checker_error(c, _SLIT("sum type cannot hold an JS struct"), variant.pos); + v__checker__Checker_error(c, _SLIT("sum type cannot hold a JS struct"), variant.pos); + } else if ((sym->info)._typ == 457 /* v.ast.Struct */) { + if ((*sym->info._v__ast__Struct).is_generic) { + if (!v__ast__Type_has_flag(variant.typ, v__ast__TypeFlag__generic)) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("generic struct `"), /*115 &string*/0xfe10, {.d_s = sym->name}}, {_SLIT("` must specify generic type names, e.g. Foo"), 0, { .d_c = 0 }}})), variant.pos); + } + if (node.generic_types.len == 0) { + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("generic sumtype `"), /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("` must specify generic type names, e.g. Foo"), 0, { .d_c = 0 }}})), node.name_pos); + } else { + for (int _t3 = 0; _t3 < (*sym->info._v__ast__Struct).generic_types.len; ++_t3) { + v__ast__Type typ = ((v__ast__Type*)(*sym->info._v__ast__Struct).generic_types.data)[_t3]; + if (!Array_v__ast__Type_contains(node.generic_types, typ)) { + Array_string _t4 = {0}; + Array_v__ast__Type _t4_orig = node.generic_types; + int _t4_len = _t4_orig.len; + _t4 = __new_array(0, _t4_len, sizeof(string)); + + for (int _t5 = 0; _t5 < _t4_len; ++_t5) { + v__ast__Type it = ((v__ast__Type*) _t4_orig.data)[_t5]; + string ti = v__ast__Table_type_to_str(c->table, it); + array_push((array*)&_t4, &ti); + } + string sumtype_type_names = Array_string_join(_t4, _SLIT(", ")); + string generic_sumtype_name = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("<"), /*115 &string*/0xfe10, {.d_s = sumtype_type_names}}, {_SLIT(">"), 0, { .d_c = 0 }}})); + Array_string _t6 = {0}; + Array_v__ast__Type _t6_orig = (*sym->info._v__ast__Struct).generic_types; + int _t6_len = _t6_orig.len; + _t6 = __new_array(0, _t6_len, sizeof(string)); + + for (int _t7 = 0; _t7 < _t6_len; ++_t7) { + v__ast__Type it = ((v__ast__Type*) _t6_orig.data)[_t7]; + string ti = v__ast__Table_type_to_str(c->table, it); + array_push((array*)&_t6, &ti); + } + string variant_type_names = Array_string_join(_t6, _SLIT(", ")); + string generic_variant_name = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = sym->name}}, {_SLIT("<"), /*115 &string*/0xfe10, {.d_s = variant_type_names}}, {_SLIT(">"), 0, { .d_c = 0 }}})); + v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("generic type name `"), /*115 &string*/0xfe10, {.d_s = v__ast__Table_sym(c->table, typ)->name}}, {_SLIT("` of generic struct `"), /*115 &string*/0xfe10, {.d_s = generic_variant_name}}, {_SLIT("` is not mentioned in sumtype `"), /*115 &string*/0xfe10, {.d_s = generic_sumtype_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), variant.pos); + } + } + } + } } if (string__eq(string_trim_string_left(sym->name, string__plus(sym->mod, _SLIT("."))), node.name)) { v__checker__Checker_error(c, _SLIT("sum type cannot hold itself"), variant.pos); @@ -50097,10 +50148,10 @@ v__ast__Type former_expected_type; v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("negative value cannot be compared with `"), /*115 &string*/0xfe10, {.d_s = rt}}, {_SLIT("`"), 0, { .d_c = 0 }}})), (*node->left._v__ast__IntegerLiteral).pos); } } else if (is_left_type_signed != is_right_type_signed && left_type != _const_v__ast__int_literal_type_idx && right_type != _const_v__ast__int_literal_type_idx) { - multi_return_int_int mr_23224 = v__ast__Table_type_size(c->table, left_type); - int ls = mr_23224.arg0; - multi_return_int_int mr_23267 = v__ast__Table_type_size(c->table, right_type); - int rs = mr_23267.arg0; + multi_return_int_int mr_24200 = v__ast__Table_type_size(c->table, left_type); + int ls = mr_24200.arg0; + multi_return_int_int mr_24243 = v__ast__Table_type_size(c->table, right_type); + int rs = mr_24243.arg0; if (!c->pref->translated && ((is_left_type_signed && ls < rs) || (is_right_type_signed && rs < ls))) { string lt = v__ast__Table_sym(c->table, left_type)->name; string rt = v__ast__Table_sym(c->table, right_type)->name; @@ -50373,8 +50424,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_33986 = v__checker__Checker_fail_if_immutable(c, node->left); - node->auto_locked = mr_33986.arg0; + multi_return_string_v__token__Pos mr_34962 = v__checker__Checker_fail_if_immutable(c, node->left); + node->auto_locked = mr_34962.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_) { @@ -50810,19 +50861,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` "), /*115 &string*/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_44503 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); - to_lock = mr_44503.arg0; - pos = mr_44503.arg1; + multi_return_string_v__token__Pos mr_45479 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__IndexExpr).left); + to_lock = mr_45479.arg0; + pos = mr_45479.arg1; } else if (expr._typ == 322 /* v.ast.ParExpr */) { - multi_return_string_v__token__Pos mr_44572 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); - to_lock = mr_44572.arg0; - pos = mr_44572.arg1; + multi_return_string_v__token__Pos mr_45548 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__ParExpr).expr); + to_lock = mr_45548.arg0; + pos = mr_45548.arg1; } else if (expr._typ == 324 /* v.ast.PrefixExpr */) { - multi_return_string_v__token__Pos mr_44644 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); - to_lock = mr_44644.arg0; - pos = mr_44644.arg1; + multi_return_string_v__token__Pos mr_45620 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__PrefixExpr).right); + to_lock = mr_45620.arg0; + pos = mr_45620.arg1; } else if (expr._typ == 327 /* v.ast.SelectorExpr */) { if ((*expr._v__ast__SelectorExpr).expr_type == 0) { @@ -50872,9 +50923,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 `"), /*115 &string*/0xfe10, {.d_s = (*expr._v__ast__SelectorExpr).field_name}}, {_SLIT("` of struct `"), /*115 &string*/0xfe10, {.d_s = type_str}}, {_SLIT("` is immutable"), 0, { .d_c = 0 }}})), (*expr._v__ast__SelectorExpr).pos); } - multi_return_string_v__token__Pos mr_46108 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); - to_lock = mr_46108.arg0; - pos = mr_46108.arg1; + multi_return_string_v__token__Pos mr_47084 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__SelectorExpr).expr); + to_lock = mr_47084.arg0; + pos = mr_47084.arg1; } if ((to_lock).len != 0) { explicit_lock_needed = true; @@ -50980,9 +51031,9 @@ VV_LOCAL_SYMBOL multi_return_string_v__token__Pos v__checker__Checker_fail_if_im } else if (expr._typ == 293 /* v.ast.CallExpr */) { if (string__eq((*expr._v__ast__CallExpr).name, _SLIT("slice"))) { - multi_return_string_v__token__Pos mr_47931 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); - to_lock = mr_47931.arg0; - pos = mr_47931.arg1; + multi_return_string_v__token__Pos mr_48907 = v__checker__Checker_fail_if_immutable(c, (*expr._v__ast__CallExpr).left); + to_lock = mr_48907.arg0; + pos = mr_48907.arg1; if ((to_lock).len != 0) { explicit_lock_needed = true; } @@ -51395,9 +51446,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){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.default_expr = {0},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_62025 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); - field = mr_62025.arg0; - embed_types = mr_62025.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_63001 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t13.data); + field = mr_63001.arg0; + embed_types = mr_63001.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); @@ -51431,9 +51482,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){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.default_expr = {0},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_62856 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); - field = mr_62856.arg0; - embed_types = mr_62856.arg1; + multi_return_v__ast__StructField_Array_v__ast__Type mr_63832 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t15.data); + field = mr_63832.arg0; + embed_types = mr_63832.arg1; node->from_embed_types = embed_types; } } @@ -52981,6 +53032,9 @@ v__ast__Type v__checker__Checker_cast_expr(v__checker__Checker* c, v__ast__CastE string snexpr = v__ast__Expr_str(node->expr); string ft = v__ast__Table_type_to_str(c->table, from_type); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("cannot cast sumtype `"), /*115 &string*/0xfe10, {.d_s = ft}}, {_SLIT("` to string, use `"), /*115 &string*/0xfe10, {.d_s = snexpr}}, {_SLIT(".str()` instead."), 0, { .d_c = 0 }}})), node->pos); + } else if (final_from_sym->kind == v__ast__Kind__function) { + string fnexpr = v__ast__Expr_str(node->expr); + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot cast function `"), /*115 &string*/0xfe10, {.d_s = fnexpr}}, {_SLIT("` to string"), 0, { .d_c = 0 }}})), node->pos); } else if (!v__ast__Type_alias_eq(to_type, _const_v__ast__string_type) && v__ast__Type_alias_eq(from_type, _const_v__ast__string_type) && (!(to_sym->kind == v__ast__Kind__alias && string__eq(final_to_sym->name, _SLIT("string"))))) { string error_msg = str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot cast a string to a type `"), /*115 &string*/0xfe10, {.d_s = final_to_sym->name}}, {_SLIT("`, that is not an alias of string"), 0, { .d_c = 0 }}})); if ((node->expr)._typ == 331 /* v.ast.StringLiteral */) { @@ -53638,8 +53692,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: "), /*115 &string*/0xfe10, {.d_s = v__token__Kind_str(node->op)}}, {_SLIT(" (non-numeric type `"), /*115 &string*/0xfe10, {.d_s = typ_str}}, {_SLIT("`)"), 0, { .d_c = 0 }}})), node->pos); } else { - multi_return_string_v__token__Pos mr_116473 = v__checker__Checker_fail_if_immutable(c, node->expr); - node->auto_locked = mr_116473.arg0; + multi_return_string_v__token__Pos mr_117590 = v__checker__Checker_fail_if_immutable(c, node->expr); + node->auto_locked = mr_117590.arg0; } v__ast__Type _t1 = typ; return _t1; @@ -53676,6 +53730,8 @@ void v__checker__Checker_mark_as_referenced(v__checker__Checker* c, v__ast__Expr (*(*node->_v__ast__Ident).obj._v__ast__Var).is_auto_heap = true; } } + else if (type_sym->kind == (v__ast__Kind__sum_type) || type_sym->kind == (v__ast__Kind__interface_)) { + } else { (*(*node->_v__ast__Ident).obj._v__ast__Var).is_auto_heap = true; }; @@ -53843,38 +53899,25 @@ v__ast__Type v__checker__Checker_index_expr(v__checker__Checker* c, v__ast__Inde v__ast__Type typ = v__checker__Checker_expr(c, node->left); v__ast__TypeSymbol* typ_sym = v__ast__Table_final_sym(c->table, typ); node->left_type = typ; - for (;;) { - if (typ_sym->kind == (v__ast__Kind__map)) { - node->is_map = true; - break; - } - else if (typ_sym->kind == (v__ast__Kind__array)) { - node->is_array = true; - if (node->or_expr.kind != v__ast__OrKind__absent && (node->index)._typ == 325 /* v.ast.RangeExpr */) { - v__checker__Checker_error(c, _SLIT("custom error handling on range expressions for arrays is not supported yet."), node->or_expr.pos); - } - break; - } - else if (typ_sym->kind == (v__ast__Kind__array_fixed)) { - node->is_farray = true; - break; - } - else if (typ_sym->kind == (v__ast__Kind__any)) { - string gname = typ_sym->name; - typ = v__checker__Checker_unwrap_generic(c, typ); - node->left_type = typ; - typ_sym = v__ast__Table_final_sym(c->table, typ); - if (v__ast__Type_is_ptr(typ)) { - continue; - } else { - v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("generic type "), /*115 &string*/0xfe10, {.d_s = gname}}, {_SLIT(" does not support indexing, pass an array, or a reference instead, e.g. []"), /*115 &string*/0xfe10, {.d_s = gname}}, {_SLIT(" or &"), /*115 &string*/0xfe10, {.d_s = gname}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); - } - } - else { - break; - }; + if (typ_sym->kind == (v__ast__Kind__map)) { + node->is_map = true; } + else if (typ_sym->kind == (v__ast__Kind__array)) { + node->is_array = true; + if (node->or_expr.kind != v__ast__OrKind__absent && (node->index)._typ == 325 /* v.ast.RangeExpr */) { + v__checker__Checker_error(c, _SLIT("custom error handling on range expressions for arrays is not supported yet."), node->or_expr.pos); + } + } + else if (typ_sym->kind == (v__ast__Kind__array_fixed)) { + node->is_farray = true; + } + else if (typ_sym->kind == (v__ast__Kind__any)) { + typ = v__checker__Checker_unwrap_generic(c, typ); + typ_sym = v__ast__Table_final_sym(c->table, typ); + } + else { + }; if (!(typ_sym->kind == v__ast__Kind__array || typ_sym->kind == v__ast__Kind__array_fixed || typ_sym->kind == v__ast__Kind__string || typ_sym->kind == v__ast__Kind__map) && !v__ast__Type_is_ptr(typ) && !(v__ast__Type_alias_eq(typ, _const_v__ast__byteptr_type) || v__ast__Type_alias_eq(typ, _const_v__ast__charptr_type)) && !v__ast__Type_has_flag(typ, v__ast__TypeFlag__variadic)) { v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("type `"), /*115 &string*/0xfe10, {.d_s = typ_sym->name}}, {_SLIT("` does not support indexing"), 0, { .d_c = 0 }}})), node->pos); } @@ -54383,37 +54426,46 @@ void v__checker__Checker_fail_if_unreadable(v__checker__Checker* c, v__ast__Expr VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_call(v__checker__Checker* c, v__ast__ComptimeCall* node) { node->left_type = v__checker__Checker_expr(c, node->left); + if (string__eq(node->method_name, _SLIT("compile_error"))) { + v__checker__Checker_error(c, node->args_var, node->pos); + v__ast__Type _t1 = _const_v__ast__void_type; + return _t1; + } else if (string__eq(node->method_name, _SLIT("compile_warn"))) { + v__checker__Checker_warn(c, node->args_var, node->pos); + v__ast__Type _t2 = _const_v__ast__void_type; + return _t2; + } if (node->is_env) { - _option_string _t1 = v__util__resolve_env_value( str_intp(2, _MOV((StrIntpData[]){{_SLIT("$env('"), /*115 &string*/0xfe10, {.d_s = node->args_var}}, {_SLIT("')"), 0, { .d_c = 0 }}})), false); - if (_t1.state != 0) { /*or block*/ - IError err = _t1.err; + _option_string _t3 = v__util__resolve_env_value( str_intp(2, _MOV((StrIntpData[]){{_SLIT("$env('"), /*115 &string*/0xfe10, {.d_s = node->args_var}}, {_SLIT("')"), 0, { .d_c = 0 }}})), false); + if (_t3.state != 0) { /*or block*/ + IError err = _t3.err; v__checker__Checker_error(c, IError_name_table[err._typ]._method_msg(err._object), node->env_pos); - v__ast__Type _t2 = _const_v__ast__string_type; - return _t2; + v__ast__Type _t4 = _const_v__ast__string_type; + return _t4; } - string env_value = (*(string*)_t1.data); + string env_value = (*(string*)_t3.data); node->env_value = env_value; - v__ast__Type _t3 = _const_v__ast__string_type; - return _t3; + v__ast__Type _t5 = _const_v__ast__string_type; + return _t5; } if (node->is_embed) { if (!Array_string_contains(_const_v__checker__valid_comptime_compression_types, node->embed_file.compression_type)) { - Array_string _t4 = {0}; - Array_string _t4_orig = _const_v__checker__valid_comptime_compression_types; - int _t4_len = _t4_orig.len; - _t4 = __new_array(0, _t4_len, sizeof(string)); + Array_string _t6 = {0}; + Array_string _t6_orig = _const_v__checker__valid_comptime_compression_types; + int _t6_len = _t6_orig.len; + _t6 = __new_array(0, _t6_len, sizeof(string)); - for (int _t5 = 0; _t5 < _t4_len; ++_t5) { - string it = ((string*) _t4_orig.data)[_t5]; + for (int _t7 = 0; _t7 < _t6_len; ++_t7) { + string it = ((string*) _t6_orig.data)[_t7]; string ti = str_intp(2, _MOV((StrIntpData[]){{_SLIT("."), /*115 &string*/0xfe10, {.d_s = it}}, {_SLIT0, 0, { .d_c = 0 }}})); - array_push((array*)&_t4, &ti); + array_push((array*)&_t6, &ti); } - string supported = Array_string_join(_t4, _SLIT(", ")); + string supported = Array_string_join(_t6, _SLIT(", ")); v__checker__Checker_error(c, str_intp(3, _MOV((StrIntpData[]){{_SLIT("not supported compression type: ."), /*115 &string*/0xfe10, {.d_s = node->embed_file.compression_type}}, {_SLIT(". supported: "), /*115 &string*/0xfe10, {.d_s = supported}}, {_SLIT0, 0, { .d_c = 0 }}})), node->pos); } - v__ast__Type _t6 = v__ast__Table_find_type_idx(c->table, _SLIT("v.embed_file.EmbedFileData")); - return _t6; + v__ast__Type _t8 = v__ast__Table_find_type_idx(c->table, _SLIT("v.embed_file.EmbedFileData")); + return _t8; } if (node->is_vweb) { v__ast__FnDecl* save_cur_fn = c->table->cur_fn; @@ -54422,9 +54474,9 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_call(v__checker__Check v__checker__Checker* c2 = v__checker__new_checker(c->table, pref2); c2->comptime_call_pos = node->pos.pos; v__checker__Checker_check(c2, (voidptr)&/*qq*/node->vweb_tmpl); - _PUSH_MANY(&c->warnings, (c2->warnings), _t7, Array_v__errors__Warning); - _PUSH_MANY(&c->errors, (c2->errors), _t8, Array_v__errors__Error); - _PUSH_MANY(&c->notices, (c2->notices), _t9, Array_v__errors__Notice); + _PUSH_MANY(&c->warnings, (c2->warnings), _t9, Array_v__errors__Warning); + _PUSH_MANY(&c->errors, (c2->errors), _t10, Array_v__errors__Error); + _PUSH_MANY(&c->notices, (c2->notices), _t11, Array_v__errors__Notice); c->nr_warnings += c2->nr_warnings; c->nr_errors += c2->nr_errors; c->nr_notices += c2->nr_notices; @@ -54433,35 +54485,35 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_call(v__checker__Check if (string__eq(node->method_name, _SLIT("html"))) { int rtyp = v__ast__Table_find_type_idx(c->table, _SLIT("vweb.Result")); node->result_type = rtyp; - v__ast__Type _t10 = rtyp; - return _t10; + v__ast__Type _t12 = rtyp; + return _t12; } if (string__eq(node->method_name, _SLIT("method"))) { for (int i = 0; i < node->args.len; ++i) { v__ast__CallArg arg = ((v__ast__CallArg*)node->args.data)[i]; (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, i)).typ = v__checker__Checker_expr(c, arg.expr); } - v__ast__Type _t11 = _const_v__ast__string_type; - return _t11; + v__ast__Type _t13 = _const_v__ast__string_type; + return _t13; } if (node->is_vweb) { - v__ast__Type _t12 = _const_v__ast__string_type; - return _t12; - } - _option_v__ast__Var_ptr _t13 = v__ast__Scope_find_var(node->scope, node->method_name); - if (_t13.state != 0) { /*or block*/ - IError err = _t13.err; - v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unknown identifier `"), /*115 &string*/0xfe10, {.d_s = node->method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->method_pos); - v__ast__Type _t14 = _const_v__ast__void_type; + v__ast__Type _t14 = _const_v__ast__string_type; return _t14; } + _option_v__ast__Var_ptr _t15 = v__ast__Scope_find_var(node->scope, node->method_name); + if (_t15.state != 0) { /*or block*/ + IError err = _t15.err; + v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("unknown identifier `"), /*115 &string*/0xfe10, {.d_s = node->method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->method_pos); + v__ast__Type _t16 = _const_v__ast__void_type; + return _t16; + } - v__ast__Var* v = (*(v__ast__Var**)_t13.data); + v__ast__Var* v = (*(v__ast__Var**)_t15.data); if (!v__ast__Type_alias_eq(v->typ, _const_v__ast__string_type)) { string s = v__checker__Checker_expected_msg(c, v->typ, _const_v__ast__string_type); v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid string method call: "), /*115 &string*/0xfe10, {.d_s = s}}, {_SLIT0, 0, { .d_c = 0 }}})), node->method_pos); - v__ast__Type _t15 = _const_v__ast__void_type; - return _t15; + v__ast__Type _t17 = _const_v__ast__void_type; + return _t17; } string method_name = _SLIT(""); if ((v->expr)._typ == 331 /* v.ast.StringLiteral */) { @@ -54470,18 +54522,18 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_call(v__checker__Check v__checker__Checker_error(c, _SLIT("todo: not a string literal"), node->method_pos); } v__ast__TypeSymbol* left_sym = v__ast__Table_sym(c->table, v__checker__Checker_unwrap_generic(c, node->left_type)); - _option_v__ast__Fn _t16 = v__ast__TypeSymbol_find_method(left_sym, method_name); - if (_t16.state != 0) { /*or block*/ - IError err = _t16.err; + _option_v__ast__Fn _t18 = v__ast__TypeSymbol_find_method(left_sym, method_name); + if (_t18.state != 0) { /*or block*/ + IError err = _t18.err; v__checker__Checker_error(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("could not find method `"), /*115 &string*/0xfe10, {.d_s = method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), node->method_pos); - v__ast__Type _t17 = _const_v__ast__void_type; - return _t17; + v__ast__Type _t19 = _const_v__ast__void_type; + return _t19; } - v__ast__Fn f = (*(v__ast__Fn*)_t16.data); + v__ast__Fn f = (*(v__ast__Fn*)_t18.data); node->result_type = f.return_type; - v__ast__Type _t18 = f.return_type; - return _t18; + v__ast__Type _t20 = f.return_type; + return _t20; } VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_comptime_selector(v__checker__Checker* c, v__ast__ComptimeSelector* node) { @@ -54541,8 +54593,8 @@ VV_LOCAL_SYMBOL _option_v__ast__ComptTimeConstValue v__checker__Checker_eval_com return _t2; } else if (expr._typ == 328 /* v.ast.SizeOf */) { - multi_return_int_int mr_4612 = v__ast__Table_type_size(c->table, (*expr._v__ast__SizeOf).typ); - int s = mr_4612.arg0; + multi_return_int_int mr_4820 = v__ast__Table_type_size(c->table, (*expr._v__ast__SizeOf).typ); + int s = mr_4820.arg0; _option_v__ast__ComptTimeConstValue _t3; opt_ok2(&(v__ast__ComptTimeConstValue[]) { int_to_sumtype_v__ast__ComptTimeConstValue(&s) }, (_option*)(&_t3), sizeof(v__ast__ComptTimeConstValue)); return _t3; @@ -55729,10 +55781,10 @@ VV_LOCAL_SYMBOL void v__checker__Checker_verify_all_vweb_routes(v__checker__Chec for (int _t2 = 0; _t2 < sym_app->methods.len; ++_t2) { v__ast__Fn m = ((v__ast__Fn*)sym_app->methods.data)[_t2]; if (m.return_type == typ_vweb_result) { - multi_return_bool_int_int mr_10729 = v__checker__Checker_verify_vweb_params_for_method(c, m); - bool is_ok = mr_10729.arg0; - int nroute_attributes = mr_10729.arg1; - int nargs = mr_10729.arg2; + multi_return_bool_int_int mr_10935 = v__checker__Checker_verify_vweb_params_for_method(c, m); + bool is_ok = mr_10935.arg0; + int nroute_attributes = mr_10935.arg1; + int nargs = mr_10935.arg2; if (!is_ok) { v__ast__FnDecl* f = ((v__ast__FnDecl*)(m.source_fn)); if (isnil(f)) { @@ -56489,7 +56541,7 @@ v__ast__Scope* prev_fn_scope; } } } - v__ast__TypeSymbol* return_sym = v__ast__Table_sym(c->table, node->return_type); + v__ast__TypeSymbol* return_sym = v__ast__Table_final_sym(c->table, node->return_type); if ((return_sym->info)._typ == 483 /* v.ast.MultiReturn */) { for (int _t4 = 0; _t4 < (*return_sym->info._v__ast__MultiReturn).types.len; ++_t4) { v__ast__Type multi_type = ((v__ast__Type*)(*return_sym->info._v__ast__MultiReturn).types.data)[_t4]; @@ -56913,8 +56965,7 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp ; _v_panic(_SLIT("unreachable")); VUNREACHABLE(); - } else if (string__eq(fn_name, _SLIT("json.encode"))) { - } else if (string__eq(fn_name, _SLIT("json.decode")) && node->args.len > 0) { + } else if (node->args.len > 0 && string__eq(fn_name, _SLIT("json.decode"))) { if (node->args.len != 2) { v__checker__Checker_error(c, _SLIT("json.decode expects 2 arguments, a type and a string (e.g `json.decode(T, '')`)"), node->pos); v__ast__Type _t8 = _const_v__ast__void_type; @@ -56976,11 +57027,9 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp } if (!found && (node->left)._typ == 310 /* v.ast.IndexExpr */) { v__checker__Checker_expr(c, node->left); - v__ast__IndexExpr expr = /* as */ *(v__ast__IndexExpr*)__as_cast((node->left)._v__ast__IndexExpr,(node->left)._typ, 310) /*expected idx: 310, name: v.ast.IndexExpr */ ; - v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, expr.left_type); - if (sym->kind == v__ast__Kind__array) { - v__ast__Array info = /* as */ *(v__ast__Array*)__as_cast((sym->info)._v__ast__Array,(sym->info)._typ, 452) /*expected idx: 452, name: v.ast.Array */ ; - v__ast__TypeSymbol* elem_sym = v__ast__Table_sym(c->table, info.elem_type); + v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, (*node->left._v__ast__IndexExpr).left_type); + if ((sym->info)._typ == 452 /* v.ast.Array */) { + v__ast__TypeSymbol* elem_sym = v__ast__Table_sym(c->table, (*sym->info._v__ast__Array).elem_type); if ((elem_sym->info)._typ == 484 /* v.ast.FnType */) { node->return_type = (*elem_sym->info._v__ast__FnType).func.return_type; v__ast__Type _t12 = (*elem_sym->info._v__ast__FnType).func.return_type; @@ -56988,9 +57037,8 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp } else { v__checker__Checker_error(c, _SLIT("cannot call the element of the array, it is not a function"), node->pos); } - } else if (sym->kind == v__ast__Kind__map) { - v__ast__Map info = /* as */ *(v__ast__Map*)__as_cast((sym->info)._v__ast__Map,(sym->info)._typ, 453) /*expected idx: 453, name: v.ast.Map */ ; - v__ast__TypeSymbol* value_sym = v__ast__Table_sym(c->table, info.value_type); + } else if ((sym->info)._typ == 453 /* v.ast.Map */) { + v__ast__TypeSymbol* value_sym = v__ast__Table_sym(c->table, (*sym->info._v__ast__Map).value_type); if ((value_sym->info)._typ == 484 /* v.ast.FnType */) { node->return_type = (*value_sym->info._v__ast__FnType).func.return_type; v__ast__Type _t13 = (*value_sym->info._v__ast__FnType).func.return_type; @@ -56998,9 +57046,8 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp } else { v__checker__Checker_error(c, _SLIT("cannot call the value of the map, it is not a function"), node->pos); } - } else if (sym->kind == v__ast__Kind__array_fixed) { - v__ast__ArrayFixed info = /* as */ *(v__ast__ArrayFixed*)__as_cast((sym->info)._v__ast__ArrayFixed,(sym->info)._typ, 480) /*expected idx: 480, name: v.ast.ArrayFixed */ ; - v__ast__TypeSymbol* elem_sym = v__ast__Table_sym(c->table, info.elem_type); + } else if ((sym->info)._typ == 480 /* v.ast.ArrayFixed */) { + v__ast__TypeSymbol* elem_sym = v__ast__Table_sym(c->table, (*sym->info._v__ast__ArrayFixed).elem_type); if ((elem_sym->info)._typ == 484 /* v.ast.FnType */) { node->return_type = (*elem_sym->info._v__ast__FnType).func.return_type; v__ast__Type _t14 = (*elem_sym->info._v__ast__FnType).func.return_type; @@ -57015,13 +57062,11 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp } if (!found && (node->left)._typ == 293 /* v.ast.CallExpr */) { v__checker__Checker_expr(c, node->left); - v__ast__CallExpr expr = /* as */ *(v__ast__CallExpr*)__as_cast((node->left)._v__ast__CallExpr,(node->left)._typ, 293) /*expected idx: 293, name: v.ast.CallExpr */ ; - v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, expr.return_type); - if (sym->kind == v__ast__Kind__function) { - v__ast__FnType info = /* as */ *(v__ast__FnType*)__as_cast((sym->info)._v__ast__FnType,(sym->info)._typ, 484) /*expected idx: 484, name: v.ast.FnType */ ; - node->return_type = info.func.return_type; + v__ast__TypeSymbol* sym = v__ast__Table_sym(c->table, (*node->left._v__ast__CallExpr).return_type); + if ((sym->info)._typ == 484 /* v.ast.FnType */) { + node->return_type = (*sym->info._v__ast__FnType).func.return_type; found = true; - func = info.func; + func = (*sym->info._v__ast__FnType).func; } } if (!found) { @@ -57170,7 +57215,7 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__checker__Checker_warn(c, str_intp(2, _MOV((StrIntpData[]){{_SLIT("function `"), /*115 &string*/0xfe10, {.d_s = func.name}}, {_SLIT("` must be called from an `unsafe` block"), 0, { .d_c = 0 }}})), node->pos); } node->is_keep_alive = func.is_keep_alive; - if (!string__eq(func.mod, _SLIT("builtin")) && func.language == v__ast__Language__v && func.no_body && !c->pref->translated && !c->file->is_translated && !func.is_unsafe) { + if (func.language == v__ast__Language__v && func.no_body && !c->pref->translated && !c->file->is_translated && !func.is_unsafe && !string__eq(func.mod, _SLIT("builtin"))) { 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) { @@ -57204,7 +57249,7 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp ; } - if ((string__eq(fn_name, _SLIT("println")) || string__eq(fn_name, _SLIT("print")) || string__eq(fn_name, _SLIT("eprintln")) || string__eq(fn_name, _SLIT("eprint")) || string__eq(fn_name, _SLIT("panic"))) && node->args.len > 0) { + if (node->args.len > 0 && (string__eq(fn_name, _SLIT("println")) || string__eq(fn_name, _SLIT("print")) || string__eq(fn_name, _SLIT("eprintln")) || string__eq(fn_name, _SLIT("eprint")) || string__eq(fn_name, _SLIT("panic")))) { c->inside_println_arg = true; c->expected_type = _const_v__ast__string_type; (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).typ = v__checker__Checker_expr(c, (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).expr); @@ -57221,7 +57266,7 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp v__ast__Type _t35 = func.return_type; return _t35; } - if (string__eq(fn_name, _SLIT("error")) && node->args.len == 1) { + if (node->args.len == 1 && string__eq(fn_name, _SLIT("error"))) { v__ast__CallArg arg = (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)); (*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).typ = v__checker__Checker_expr(c, arg.expr); if (v__ast__Type_alias_eq((*(v__ast__CallArg*)/*ee elem_sym */array_get(node->args, 0)).typ, _const_v__ast__error_type)) { @@ -57276,9 +57321,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_29424 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); - string to_lock = mr_29424.arg0; - v__token__Pos pos = mr_29424.arg1; + multi_return_string_v__token__Pos mr_29230 = v__checker__Checker_fail_if_immutable(c, call_arg->expr); + string to_lock = mr_29230.arg0; + v__token__Pos pos = mr_29230.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)); } @@ -57346,11 +57391,11 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp if ((v__ast__Type_alias_eq(arg_typ, _const_v__ast__bool_type) && v__ast__Type_is_int(param.typ)) || (v__ast__Type_is_int(arg_typ) && v__ast__Type_alias_eq(param.typ, _const_v__ast__bool_type))) { continue; } - bool param_is_number = v__ast__Type_is_number(param.typ); + bool param_is_number = v__ast__Type_is_number(v__ast__Table_unaliased_type(c->table, param.typ)); if (v__ast__Type_is_ptr(param.typ)) { param_is_number = v__ast__Type_is_number(v__ast__Type_deref(param.typ)); } - bool typ_is_number = v__ast__Type_is_number(arg_typ); + bool typ_is_number = v__ast__Type_is_number(v__ast__Table_unaliased_type(c->table, arg_typ)); if (v__ast__Type_is_ptr(arg_typ)) { typ_is_number = v__ast__Type_is_number(v__ast__Type_deref(arg_typ)); } @@ -57360,7 +57405,9 @@ v__ast__Type v__checker__Checker_fn_call(v__checker__Checker* c, v__ast__CallExp if (param.typ == _const_v__ast__voidptr_type_idx || arg_typ == _const_v__ast__voidptr_type_idx) { continue; } - if (((arg_typ_sym->kind == v__ast__Kind__array_fixed || arg_typ_sym->kind == v__ast__Kind__array) && (param_is_number || v__ast__Type_is_any_kind_of_pointer(param.typ))) || ((param_typ_sym->kind == v__ast__Kind__array_fixed || param_typ_sym->kind == v__ast__Kind__array) && (typ_is_number || v__ast__Type_is_any_kind_of_pointer(arg_typ)))) { + v__ast__TypeSymbol* param_typ_sym_ = v__ast__Table_sym(c->table, v__ast__Table_unaliased_type(c->table, param.typ)); + v__ast__TypeSymbol* arg_typ_sym_ = v__ast__Table_sym(c->table, v__ast__Table_unaliased_type(c->table, arg_typ)); + if (((arg_typ_sym_->kind == v__ast__Kind__array_fixed || arg_typ_sym_->kind == v__ast__Kind__array) && (param_is_number || v__ast__Type_is_any_kind_of_pointer(v__ast__Table_unaliased_type(c->table, param.typ)))) || ((param_typ_sym_->kind == v__ast__Kind__array_fixed || param_typ_sym_->kind == v__ast__Kind__array) && (typ_is_number || v__ast__Type_is_any_kind_of_pointer(v__ast__Table_unaliased_type(c->table, arg_typ))))) { continue; } if (v__ast__Type_is_any_kind_of_pointer(param.typ) && typ_is_number) { @@ -57541,12 +57588,10 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal if (!v__checker__Checker_check_types(c, arg_type, info.elem_type) && !v__checker__Checker_check_types(c, left_type, arg_type)) { v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("cannot "), /*115 &string*/0xfe10, {.d_s = method_name}}, {_SLIT(" `"), /*115 &string*/0xfe10, {.d_s = arg_sym->name}}, {_SLIT("` to `"), /*115 &string*/0xfe10, {.d_s = left_sym->name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(arg_expr)); } - } else if (final_left_sym->kind == v__ast__Kind__array && (string__eq(method_name, _SLIT("first")) || string__eq(method_name, _SLIT("last")) || string__eq(method_name, _SLIT("pop")))) { - if ((final_left_sym->info)._typ == 452 /* v.ast.Array */) { - node->return_type = (*final_left_sym->info._v__ast__Array).elem_type; - v__ast__Type _t13 = node->return_type; - return _t13; - } + } else if ((final_left_sym->info)._typ == 452 /* v.ast.Array */ && (string__eq(method_name, _SLIT("first")) || string__eq(method_name, _SLIT("last")) || string__eq(method_name, _SLIT("pop")))) { + node->return_type = (*final_left_sym->info._v__ast__Array).elem_type; + v__ast__Type _t13 = node->return_type; + return _t13; } else if (v__pref__Backend_is_js(c->pref->backend) && string_starts_with(left_sym->name, _SLIT("Promise<")) && string__eq(method_name, _SLIT("wait"))) { v__ast__Struct info = /* as */ *(v__ast__Struct*)__as_cast((left_sym->info)._v__ast__Struct,(left_sym->info)._typ, 457) /*expected idx: 457, name: v.ast.Struct */ ; if (node->args.len > 0) { @@ -57613,9 +57658,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*) _t19.data = (multi_return_v__ast__Fn_Array_v__ast__Type){.arg0=((v__ast__Fn){.params = __new_array(0, 0, sizeof(v__ast__Param)),.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,.usages = 0,.ctdefine_idx = 0,.source_fn = 0,.language = 0,.file_mode = 0,.is_variadic = 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,.is_conditional = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_42802 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t19.data); - method = mr_42802.arg0; - embed_types = mr_42802.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_42804 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t19.data); + method = mr_42804.arg0; + embed_types = mr_42804.arg1; if (embed_types.len != 0) { is_method_from_embed = true; node->from_embed_types = embed_types; @@ -57663,9 +57708,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_45112 = v__checker__Checker_fail_if_immutable(c, node->left); - string to_lock = mr_45112.arg0; - v__token__Pos pos = mr_45112.arg1; + multi_return_string_v__token__Pos mr_45114 = v__checker__Checker_fail_if_immutable(c, node->left); + string to_lock = mr_45114.arg0; + v__token__Pos pos = mr_45114.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)); } @@ -57705,12 +57750,11 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__ast__Type exp_arg_typ = ((v__ast__Type)(0)); bool param_is_mut = false; bool no_type_promotion = false; - if (left_sym->kind == v__ast__Kind__chan) { - v__ast__Type elem_typ = (/* as */ *(v__ast__Chan*)__as_cast((left_sym->info)._v__ast__Chan,(left_sym->info)._typ, 481) /*expected idx: 481, name: v.ast.Chan */ ).elem_type; + if ((left_sym->info)._typ == 481 /* v.ast.Chan */) { if (string__eq(method_name, _SLIT("try_push"))) { - exp_arg_typ = v__ast__Type_ref(elem_typ); + exp_arg_typ = v__ast__Type_ref((*left_sym->info._v__ast__Chan).elem_type); } else if (string__eq(method_name, _SLIT("try_pop"))) { - exp_arg_typ = elem_typ; + exp_arg_typ = (*left_sym->info._v__ast__Chan).elem_type; param_is_mut = true; no_type_promotion = true; } @@ -57718,7 +57762,7 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal for (int i = 0; i < node->args.len; ++i) { v__ast__CallArg* arg = ((v__ast__CallArg*)node->args.data) + i; if (i > 0 || v__ast__Type_alias_eq(exp_arg_typ, ((v__ast__Type)(0)))) { - exp_arg_typ = (method.is_variadic && i >= method.params.len - 1 ? ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, method.params.len - 1)).typ) : ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, i + 1)).typ)); + exp_arg_typ = (method.is_variadic && i >= method.params.len - 1 ? ((*(v__ast__Param*)array_last(method.params)).typ) : ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, i + 1)).typ)); param_is_mut = false; no_type_promotion = false; } @@ -57737,7 +57781,7 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__ast__TypeSymbol* final_arg_sym = exp_arg_sym; v__ast__Type final_arg_typ = exp_arg_typ; if (method.is_variadic && (exp_arg_sym->info)._typ == 452 /* v.ast.Array */) { - final_arg_typ = v__ast__TypeSymbol_array_info(exp_arg_sym).elem_type; + final_arg_typ = (*exp_arg_sym->info._v__ast__Array).elem_type; final_arg_sym = v__ast__Table_sym(c->table, final_arg_typ); } if (v__ast__Type_has_flag(exp_arg_typ, v__ast__TypeFlag__generic)) { @@ -57761,16 +57805,22 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal } } } - v__ast__Param param = (method.is_variadic && i >= method.params.len - 1 ? ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, method.params.len - 1))) : ((*(v__ast__Param*)/*ee elem_sym */array_get(method.params, i + 1)))); + v__ast__Param _t30; /* if prepend */ + if (method.is_variadic && i >= method.params.len - 1) { + _t30 = (*(v__ast__Param*)array_last(method.params)); + } else { + _t30 = (*(v__ast__Param*)/*ee elem_sym */array_get(method.params, i + 1)); + } + v__ast__Param param = _t30; param_is_mut = param_is_mut || param.is_mut; v__ast__ShareType param_share = v__ast__Type_share(param.typ); if (param_share == v__ast__ShareType__shared_t && (c->locked_names.len > 0 || c->rlocked_names.len > 0)) { 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_49074 = v__checker__Checker_fail_if_immutable(c, arg->expr); - string to_lock = mr_49074.arg0; - v__token__Pos pos = mr_49074.arg1; + multi_return_string_v__token__Pos mr_49016 = v__checker__Checker_fail_if_immutable(c, arg->expr); + string to_lock = mr_49016.arg0; + v__token__Pos pos = mr_49016.arg1; if (!param_is_mut) { string tok = v__ast__ShareType_str(arg->share); v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT("`"), /*115 &string*/0xfe10, {.d_s = node->name}}, {_SLIT("` parameter `"), /*115 &string*/0xfe10, {.d_s = param.name}}, {_SLIT("` is not `"), /*115 &string*/0xfe10, {.d_s = tok}}, {_SLIT("`, `"), /*115 &string*/0xfe10, {.d_s = tok}}, {_SLIT("` is not needed`"), 0, { .d_c = 0 }}})), v__ast__Expr_pos(arg->expr)); @@ -57790,9 +57840,8 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_fail_if_unreadable(c, arg->expr, got_arg_typ, _SLIT("argument")); } } - if (left_sym->kind == v__ast__Kind__array && string__eq(method_name, _SLIT("sort_with_compare"))) { - v__ast__Array array_info = /* as */ *(v__ast__Array*)__as_cast((left_sym->info)._v__ast__Array,(left_sym->info)._typ, 452) /*expected idx: 452, name: v.ast.Array */ ; - v__ast__Type elem_typ = array_info.elem_type; + if ((left_sym->info)._typ == 452 /* v.ast.Array */ && string__eq(method_name, _SLIT("sort_with_compare"))) { + v__ast__Type elem_typ = (*left_sym->info._v__ast__Array).elem_type; v__ast__TypeSymbol* arg_sym = v__ast__Table_sym(c->table, arg->typ); if (arg_sym->kind == v__ast__Kind__function) { v__ast__FnType func_info = /* as */ *(v__ast__FnType*)__as_cast((arg_sym->info)._v__ast__FnType,(arg_sym->info)._typ, 484) /*expected idx: 484, name: v.ast.FnType */ ; @@ -57821,17 +57870,15 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal } continue; } - _option_void _t30 = v__checker__Checker_check_expected_call_arg(c, got_arg_typ, exp_arg_typ, node->language, *arg); - if (_t30.state != 0 && _t30.err._typ != _IError_None___index) { - IError err = _t30.err; + _option_void _t31 = v__checker__Checker_check_expected_call_arg(c, got_arg_typ, exp_arg_typ, node->language, *arg); + if (_t31.state != 0 && _t31.err._typ != _IError_None___index) { + IError err = _t31.err; v__ast__TypeSymbol* param_typ_sym = v__ast__Table_sym(c->table, exp_arg_typ); v__ast__TypeSymbol* arg_typ_sym = v__ast__Table_sym(c->table, got_arg_typ); - if (param_typ_sym->kind == v__ast__Kind__array && arg_typ_sym->kind == v__ast__Kind__array) { - v__ast__Array param_info = /* as */ *(v__ast__Array*)__as_cast((param_typ_sym->info)._v__ast__Array,(param_typ_sym->info)._typ, 452) /*expected idx: 452, name: v.ast.Array */ ; - v__ast__Type param_elem_type = v__ast__Table_unaliased_type(c->table, param_info.elem_type); - v__ast__Array arg_info = /* as */ *(v__ast__Array*)__as_cast((arg_typ_sym->info)._v__ast__Array,(arg_typ_sym->info)._typ, 452) /*expected idx: 452, name: v.ast.Array */ ; - v__ast__Type arg_elem_type = v__ast__Table_unaliased_type(c->table, arg_info.elem_type); - if (v__ast__Type_nr_muls(exp_arg_typ) == v__ast__Type_nr_muls(got_arg_typ) && param_info.nr_dims == arg_info.nr_dims && v__ast__Type_alias_eq(param_elem_type, arg_elem_type)) { + if ((param_typ_sym->info)._typ == 452 /* v.ast.Array */ && (arg_typ_sym->info)._typ == 452 /* v.ast.Array */) { + v__ast__Type param_elem_type = v__ast__Table_unaliased_type(c->table, (*param_typ_sym->info._v__ast__Array).elem_type); + v__ast__Type arg_elem_type = v__ast__Table_unaliased_type(c->table, (*arg_typ_sym->info._v__ast__Array).elem_type); + if (v__ast__Type_nr_muls(exp_arg_typ) == v__ast__Type_nr_muls(got_arg_typ) && (*param_typ_sym->info._v__ast__Array).nr_dims == (*arg_typ_sym->info._v__ast__Array).nr_dims && v__ast__Type_alias_eq(param_elem_type, arg_elem_type)) { continue; } } @@ -57875,12 +57922,12 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal node->return_type = method.return_type; } if (node->concrete_types.len > 0 && method.return_type != 0 && c->table->cur_fn->generic_names.len == 0) { - _option_v__ast__Type _t32; - if (_t32 = v__ast__Table_resolve_generic_to_concrete(c->table, method.return_type, method.generic_names, concrete_types), _t32.state == 0) { - v__ast__Type typ = *(v__ast__Type*)_t32.data; + _option_v__ast__Type _t33; + if (_t33 = v__ast__Table_resolve_generic_to_concrete(c->table, method.return_type, method.generic_names, concrete_types), _t33.state == 0) { + v__ast__Type typ = *(v__ast__Type*)_t33.data; node->return_type = typ; - v__ast__Type _t33 = typ; - return _t33; + v__ast__Type _t34 = typ; + return _t34; } } if (node->concrete_types.len > 0 && method.generic_names.len == 0) { @@ -57894,11 +57941,11 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal } } } - v__ast__Type _t34 = node->return_type; - return _t34; + v__ast__Type _t35 = node->return_type; + return _t35; } - v__ast__Type _t35 = method.return_type; - return _t35; + v__ast__Type _t36 = method.return_type; + return _t36; } if (string__eq(method_name, _SLIT("str"))) { if (left_sym->kind == v__ast__Kind__interface_) { @@ -57911,25 +57958,25 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal v__checker__Checker_error(c, _SLIT(".str() method calls should have no arguments"), node->pos); } v__checker__Checker_fail_if_unreadable(c, node->left, left_type, _SLIT("receiver")); - v__ast__Type _t36 = _const_v__ast__string_type; - return _t36; - } else if (string__eq(method_name, _SLIT("free"))) { - v__ast__Type _t37 = _const_v__ast__void_type; + v__ast__Type _t37 = _const_v__ast__string_type; return _t37; + } else if (string__eq(method_name, _SLIT("free"))) { + v__ast__Type _t38 = _const_v__ast__void_type; + return _t38; } - _option_v__ast__StructField _t38; - if (_t38 = v__ast__Table_find_field_with_embeds(c->table, left_sym, method_name), _t38.state == 0) { - v__ast__StructField field = *(v__ast__StructField*)_t38.data; + _option_v__ast__StructField _t39; + if (_t39 = v__ast__Table_find_field_with_embeds(c->table, left_sym, method_name), _t39.state == 0) { + v__ast__StructField field = *(v__ast__StructField*)_t39.data; v__ast__TypeSymbol* field_sym = v__ast__Table_sym(c->table, v__checker__Checker_unwrap_generic(c, field.typ)); if (field_sym->kind == v__ast__Kind__function) { node->is_method = false; node->is_field = true; v__ast__FnType info = /* as */ *(v__ast__FnType*)__as_cast((field_sym->info)._v__ast__FnType,(field_sym->info)._typ, 484) /*expected idx: 484, name: v.ast.FnType */ ; - _option_void _t39 = v__checker__Checker_check_expected_arg_count(c, node, (voidptr)&/*qq*/info.func); - if (_t39.state != 0 && _t39.err._typ != _IError_None___index) { - IError err = _t39.err; - v__ast__Type _t40 = info.func.return_type; - return _t40; + _option_void _t40 = v__checker__Checker_check_expected_arg_count(c, node, (voidptr)&/*qq*/info.func); + if (_t40.state != 0 && _t40.err._typ != _IError_None___index) { + IError err = _t40.err; + v__ast__Type _t41 = info.func.return_type; + return _t41; } ; @@ -57942,9 +57989,9 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal array_push((array*)&earg_types, _MOV((v__ast__Type[]){ targ })); if (i < info.func.params.len) { v__ast__Type exp_arg_typ = (*(v__ast__Param*)/*ee elem_sym */array_get(info.func.params, i)).typ; - _option_void _t42 = v__checker__Checker_check_expected_call_arg(c, targ, v__checker__Checker_unwrap_generic(c, exp_arg_typ), node->language, *arg); - if (_t42.state != 0 && _t42.err._typ != _IError_None___index) { - IError err = _t42.err; + _option_void _t43 = v__checker__Checker_check_expected_call_arg(c, targ, v__checker__Checker_unwrap_generic(c, exp_arg_typ), node->language, *arg); + if (_t43.state != 0 && _t43.err._typ != _IError_None___index) { + IError err = _t43.err; if (!v__ast__Type_alias_eq(targ, _const_v__ast__void_type)) { v__checker__Checker_error(c, str_intp(5, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = IError_name_table[err._typ]._method_msg(err._object)}}, {_SLIT(" in argument "), /*100 &int*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(" to `"), /*115 &string*/0xfe10, {.d_s = left_sym->name}}, {_SLIT("."), /*115 &string*/0xfe10, {.d_s = method_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), arg->pos); } @@ -57956,35 +58003,35 @@ v__ast__Type v__checker__Checker_method_call(v__checker__Checker* c, v__ast__Cal } node->expected_arg_types = earg_types; node->is_method = true; - _option_multi_return_v__ast__StructField_Array_v__ast__Type _t43 = v__ast__Table_find_field_from_embeds(c->table, left_sym, method_name); - if (_t43.state != 0) { /*or block*/ - IError err = _t43.err; - v__ast__Type _t44 = info.func.return_type; - return _t44; + _option_multi_return_v__ast__StructField_Array_v__ast__Type _t44 = v__ast__Table_find_field_from_embeds(c->table, left_sym, method_name); + if (_t44.state != 0) { /*or block*/ + IError err = _t44.err; + v__ast__Type _t45 = info.func.return_type; + return _t45; } - multi_return_v__ast__StructField_Array_v__ast__Type mr_56539 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t43.data); - node->from_embed_types = mr_56539.arg1; - v__ast__Type _t45 = info.func.return_type; - return _t45; + multi_return_v__ast__StructField_Array_v__ast__Type mr_56382 = (*(multi_return_v__ast__StructField_Array_v__ast__Type*)_t44.data); + node->from_embed_types = mr_56382.arg1; + v__ast__Type _t46 = info.func.return_type; + return _t46; } } if (!v__ast__Type_alias_eq(left_type, _const_v__ast__void_type)) { - Array_string _t46 = {0}; - Array_v__ast__Fn _t46_orig = left_sym->methods; - int _t46_len = _t46_orig.len; - _t46 = __new_array(0, _t46_len, sizeof(string)); + Array_string _t47 = {0}; + Array_v__ast__Fn _t47_orig = left_sym->methods; + int _t47_len = _t47_orig.len; + _t47 = __new_array(0, _t47_len, sizeof(string)); - for (int _t47 = 0; _t47 < _t46_len; ++_t47) { - v__ast__Fn it = ((v__ast__Fn*) _t46_orig.data)[_t47]; + for (int _t48 = 0; _t48 < _t47_len; ++_t48) { + v__ast__Fn it = ((v__ast__Fn*) _t47_orig.data)[_t48]; string ti = it.name; - array_push((array*)&_t46, &ti); + array_push((array*)&_t47, &ti); } - v__util__Suggestion suggestion = v__util__new_suggestion(method_name,_t46); + v__util__Suggestion suggestion = v__util__new_suggestion(method_name,_t47); v__checker__Checker_error(c, v__util__Suggestion_say(suggestion, unknown_method_msg), node->pos); } - v__ast__Type _t48 = _const_v__ast__void_type; - return _t48; + v__ast__Type _t49 = _const_v__ast__void_type; + return _t49; } VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_go_expr(v__checker__Checker* c, v__ast__GoExpr* node) { @@ -58316,7 +58363,7 @@ VV_LOCAL_SYMBOL v__ast__Type v__checker__Checker_array_builtin_method_call(v__ch if (string__eq(method_name, _SLIT("map"))) { v__checker__Checker_check_map_and_filter(c, true, elem_typ, *node); v__ast__TypeSymbol* arg_sym = v__ast__Table_sym(c->table, arg_type); - v__ast__Type ret_type = ((arg_sym->info._typ == 484 /* v.ast.FnType */) ? ((*arg_sym->info._v__ast__FnType).func.return_type) : (arg_type)); + v__ast__Type ret_type = ((arg_sym->info._typ == 484 /* v.ast.FnType */)? ((*arg_sym->info._v__ast__FnType).func.return_type) : (arg_type)); node->return_type = v__ast__Table_find_or_register_array(c->table, v__checker__Checker_unwrap_generic(c, ret_type)); if (v__ast__Type_has_flag(node->return_type, v__ast__TypeFlag__shared_f)) { node->return_type = v__ast__Type_deref(v__ast__Type_clear_flag(node->return_type, v__ast__TypeFlag__shared_f)); @@ -58501,7 +58548,7 @@ VV_LOCAL_SYMBOL void v__checker__Checker_for_in_stmt(v__checker__Checker* c, v__ v__checker__Checker_error(c, _SLIT("declare a key and a value variable when ranging a map: `for key, val in map {`\nuse `_` if you do not need the variable"), node->pos); } if (node->key_var.len > 0) { - v__ast__Type key_type = ((sym->kind == (v__ast__Kind__map)) ? (v__ast__TypeSymbol_map_info(sym).key_type) : (_const_v__ast__int_type)); + v__ast__Type key_type = ((sym->kind == (v__ast__Kind__map))? (v__ast__TypeSymbol_map_info(sym).key_type) : (_const_v__ast__int_type)); node->key_type = key_type; v__ast__Scope_update_var_type(node->scope, node->key_var, key_type); } @@ -59993,7 +60040,7 @@ void v__checker__Checker_return_stmt(v__checker__Checker* c, v__ast__Return* nod v__checker__Checker_error(c, str_intp(4, _MOV((StrIntpData[]){{_SLIT("fn `"), /*115 &string*/0xfe10, {.d_s = c->table->cur_fn->name}}, {_SLIT("` expects you to return a reference type `"), /*115 &string*/0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, exp_type)}}, {_SLIT("`, but you are returning `"), /*115 &string*/0xfe10, {.d_s = v__ast__Table_type_to_str(c->table, got_typ)}}, {_SLIT("` instead"), 0, { .d_c = 0 }}})), pos); } if (v__ast__Type_is_ptr(exp_type) && v__ast__Type_is_ptr(got_typ)) { - v__ast__Expr* r_expr = &(*(v__ast__Expr*)/*ee elem_sym */array_get(node->exprs, i)); + v__ast__Expr* r_expr = &(*(v__ast__Expr*)/*ee elem_sym */array_get(node->exprs, (*(int*)/*ee elem_sym */array_get(expr_idxs, i)))); if ((r_expr)->_typ == 307 /* v.ast.Ident */) { if (((*r_expr->_v__ast__Ident).obj)._typ == 365 /* v.ast.Var */) { v__ast__Var* obj = &(*(*r_expr->_v__ast__Ident).obj._v__ast__Var); @@ -64527,6 +64574,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_assert_single_expr(v__gen__c__Gen* g, v_ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_assign_stmt(v__gen__c__Gen* g, v__ast__AssignStmt node_) { bool v__gen__c__Gen_gen_assign_stmt_defer_0 = false; +bool v__gen__c__Gen_gen_assign_stmt_defer_1 = false; bool af; string type_to_free; string sref_name; @@ -64540,6 +64588,7 @@ string sref_name; v__ast__Type return_type = _const_v__ast__void_type; bool is_decl = node.op == v__token__Kind__decl_assign; g->assign_op = node.op; + v__gen__c__Gen_gen_assign_stmt_defer_0 = true; v__token__Kind op = (is_decl ? (v__token__Kind__assign) : (node.op)); v__ast__Expr right_expr = (*(v__ast__Expr*)/*ee elem_sym */array_get(node.right, 0)); if (right_expr._typ == 293 /* v.ast.CallExpr */) { @@ -64578,7 +64627,7 @@ string sref_name; v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT(" "), /*115 &string*/0xfe10, {.d_s = sref_name}}, {_SLIT(" = ("), 0, { .d_c = 0 }}}))); v__gen__c__Gen_expr(g, left0); v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("); // free "), /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT(" on re-assignment2"), 0, { .d_c = 0 }}}))); - v__gen__c__Gen_gen_assign_stmt_defer_0 = true; + v__gen__c__Gen_gen_assign_stmt_defer_1 = true; } else { af = false; } @@ -64592,12 +64641,17 @@ string sref_name; if (sym->kind == v__ast__Kind__multi_return) { v__gen__c__Gen_gen_multi_return_assign(g, (voidptr)&/*qq*/node, return_type); // Defer begin - if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + if (v__gen__c__Gen_gen_assign_stmt_defer_1) { if (af) { v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT("_free(&"), /*115 &string*/0xfe10, {.d_s = sref_name}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); } } // Defer end + // Defer begin + if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + g->assign_op = v__token__Kind__unknown; + } + // Defer end return; } } @@ -64843,12 +64897,17 @@ string sref_name; v__gen__c__Gen_expr(g, val); v__gen__c__Gen_writeln(g, _SLIT(");")); // Defer begin - if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + if (v__gen__c__Gen_gen_assign_stmt_defer_1) { if (af) { v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT("_free(&"), /*115 &string*/0xfe10, {.d_s = sref_name}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); } } // Defer end + // Defer begin + if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + g->assign_op = v__token__Kind__unknown; + } + // Defer end return; } else { v__gen__c__Gen_write(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT(" = "), /*115 &string*/0xfe10, {.d_s = styp}}, {_SLIT("_"), /*115 &string*/0xfe10, {.d_s = v__util__replace_op(extracted_op)}}, {_SLIT("("), 0, { .d_c = 0 }}}))); @@ -65023,12 +65082,17 @@ string sref_name; } } // Defer begin -if (v__gen__c__Gen_gen_assign_stmt_defer_0) { +if (v__gen__c__Gen_gen_assign_stmt_defer_1) { if (af) { v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = type_to_free}}, {_SLIT("_free(&"), /*115 &string*/0xfe10, {.d_s = sref_name}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); } } // Defer end +// Defer begin +if (v__gen__c__Gen_gen_assign_stmt_defer_0) { + g->assign_op = v__token__Kind__unknown; +} +// Defer end } VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_multi_return_assign(v__gen__c__Gen* g, v__ast__AssignStmt* node, v__ast__Type return_type) { @@ -67039,7 +67103,7 @@ strings__Builder fn_body; strings__Builder_write_string(&fn_body, str_intp(2, _MOV((StrIntpData[]){{_SLIT("tos2((byteptr)"), /*115 &string*/0xfe10, {.d_s = func}}, {_SLIT(")"), 0, { .d_c = 0 }}}))); } else { if (v__ast__Type_is_ptr(field.typ) && sym->kind == v__ast__Kind__struct_) { - funcprefix = /*f*/string__plus(funcprefix, _SLIT("(indent_count > 25) ? _SLIT(\"\") : ")); + funcprefix = /*f*/string__plus(funcprefix, _SLIT("(indent_count > 25)? _SLIT(\"\") : ")); } if (caller_should_free) { string tmpvar = v__gen__c__Gen_new_tmp_var(g); @@ -67073,8 +67137,8 @@ if (v__gen__c__Gen_gen_str_for_struct_defer_0) { } VV_LOCAL_SYMBOL multi_return_string_bool v__gen__c__struct_auto_str_func(v__ast__TypeSymbol* sym, v__ast__Type field_type, string fn_name, string field_name, bool has_custom_str, bool expects_ptr) { - multi_return_string_string mr_39682 = v__gen__c__deref_kind(expects_ptr, v__ast__Type_is_ptr(field_type), field_type); - string deref = mr_39682.arg0; + multi_return_string_string mr_39681 = v__gen__c__deref_kind(expects_ptr, v__ast__Type_is_ptr(field_type), field_type); + string deref = mr_39681.arg0; if (sym->kind == v__ast__Kind__enum_) { return (multi_return_string_bool){.arg0= str_intp(4, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = fn_name}}, {_SLIT("("), /*115 &string*/0xfe10, {.d_s = deref}}, {_SLIT("it."), /*115 &string*/0xfe10, {.d_s = v__gen__c__c_name(field_name)}}, {_SLIT(")"), 0, { .d_c = 0 }}})), .arg1=true}; } else if (v__gen__c__should_use_indent_func(sym->kind)) { @@ -71328,6 +71392,9 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_cast_expr(v__gen__c__Gen* g, v__ast__CastExp v__gen__c__Gen_expr(g, node.expr); v__gen__c__Gen_write(g, _SLIT("))")); } else if (sym->kind == v__ast__Kind__alias && v__ast__Table_final_sym(g->table, node.typ)->kind == v__ast__Kind__array_fixed) { + if ((node.expr)._typ == 287 /* v.ast.ArrayInit */ && g->assign_op != v__token__Kind__decl_assign) { + v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("("), /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, (*node.expr._v__ast__ArrayInit).typ)}}, {_SLIT(")"), 0, { .d_c = 0 }}}))); + } v__gen__c__Gen_expr(g, node.expr); } else if (v__ast__Type_alias_eq(node.expr_type, _const_v__ast__bool_type) && v__ast__Type_is_int(node.typ)) { string styp = v__gen__c__Gen_typ(g, node.typ); @@ -72241,9 +72308,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_146797 = v__gen__c__Gen_optional_type_name(g, field.typ); - string styp = mr_146797.arg0; - string base = mr_146797.arg1; + multi_return_string_string mr_146906 = v__gen__c__Gen_optional_type_name(g, field.typ); + string styp = mr_146906.arg0; + string base = mr_146906.arg1; sync__RwMutex_lock(&g->done_optionals->mtx); /*lock*/ { if (!Array_string_contains(g->done_optionals->val, base)) { @@ -72538,11 +72605,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["), /*115 &string*/0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._typ]._method_msg("), /*115 &string*/0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._object)"), 0, { .d_c = 0 }}})); if (g->pref->is_debug) { - multi_return_int_string_string_string mr_156580 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); - int paline = mr_156580.arg0; - string pafile = mr_156580.arg1; - string pamod = mr_156580.arg2; - string pafn = mr_156580.arg3; + multi_return_int_string_string_string mr_156689 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); + int paline = mr_156689.arg0; + string pafile = mr_156689.arg1; + string pamod = mr_156689.arg2; + string pafn = mr_156689.arg3; v__gen__c__Gen_writeln(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("panic_debug("), /*100 &int*/0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), /*115 &string*/0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), /*115 &string*/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( "), /*115 &string*/0xfe10, {.d_s = err_msg}}, {_SLIT(" );"), 0, { .d_c = 0 }}}))); @@ -72565,11 +72632,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["), /*115 &string*/0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._typ]._method_msg("), /*115 &string*/0xfe10, {.d_s = cvar_name}}, {_SLIT(".err._object)"), 0, { .d_c = 0 }}})); if (g->pref->is_debug) { - multi_return_int_string_string_string mr_157847 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); - int paline = mr_157847.arg0; - string pafile = mr_157847.arg1; - string pamod = mr_157847.arg2; - string pafn = mr_157847.arg3; + multi_return_int_string_string_string mr_157956 = v__gen__c__Gen_panic_debug_info(g, or_block.pos); + int paline = mr_157956.arg0; + string pafile = mr_157956.arg1; + string pamod = mr_157956.arg2; + string pafn = mr_157956.arg3; v__gen__c__Gen_writeln(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("panic_debug("), /*100 &int*/0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), /*115 &string*/0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), /*115 &string*/0xfe10, {.d_s = err_msg}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); } else { v__gen__c__Gen_writeln(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\tpanic_result_not_set("), /*115 &string*/0xfe10, {.d_s = err_msg}}, {_SLIT(");"), 0, { .d_c = 0 }}}))); @@ -72679,11 +72746,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_160457 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); - string hash_fn = mr_160457.arg0; - string key_eq_fn = mr_160457.arg1; - string clone_fn = mr_160457.arg2; - string free_fn = mr_160457.arg3; + multi_return_string_string_string_string mr_160566 = v__gen__c__Gen_map_fn_ptrs(g, *key_typ); + string hash_fn = mr_160566.arg0; + string key_eq_fn = mr_160566.arg1; + string clone_fn = mr_160566.arg2; + string free_fn = mr_160566.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(""))); @@ -73209,8 +73276,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)).name,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).pos,(*(v__ast__Param*)/*ee elem_sym */array_get(params, 0)).type_pos,.typ = v__ast__Type_set_nr_muls(st, 1),(*(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)).is_hidden,}) }); - multi_return_Array_string_Array_string_Array_bool mr_174939 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); - Array_string fargs = mr_174939.arg0; + multi_return_Array_string_Array_string_Array_bool mr_175048 = v__gen__c__Gen_fn_decl_params(g, params, ((voidptr)(0)), false); + Array_string fargs = mr_175048.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__")); @@ -73227,8 +73294,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){.params = __new_array(0, 0, sizeof(v__ast__Param)),.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,.usages = 0,.ctdefine_idx = 0,.source_fn = 0,.language = 0,.file_mode = 0,.is_variadic = 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,.is_conditional = 0,}),.arg1=__new_array_with_default(0, 0, sizeof(v__ast__Type), 0)}; } - multi_return_v__ast__Fn_Array_v__ast__Type mr_175403 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); - Array_v__ast__Type embed_types = mr_175403.arg1; + multi_return_v__ast__Fn_Array_v__ast__Type mr_175512 = (*(multi_return_v__ast__Fn_Array_v__ast__Type*)_t26.data); + Array_v__ast__Type embed_types = mr_175512.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, /*115 &string*/0xfe10, {.d_s = embed_sym->cname}}, {_SLIT("_"), /*115 &string*/0xfe10, {.d_s = method.name}}, {_SLIT0, 0, { .d_c = 0 }}})); @@ -73515,7 +73582,7 @@ VV_LOCAL_SYMBOL string v__gen__c__c_closure_helpers(v__pref__Preferences* pref) if (pref->os != v__pref__OS__windows) { strings__Builder_writeln(&builder, _SLIT("#include ")); } - strings__Builder_write_string(&builder, _SLIT("\n#ifdef _MSC_VER\n\011#define __RETURN_ADDRESS() _ReturnAddress()\n#elif defined(__TINYC__) && defined(_WIN32)\n\011#define __RETURN_ADDRESS() __builtin_return_address(0)\n#else\n\011#define __RETURN_ADDRESS() __builtin_extract_return_addr(__builtin_return_address(0))\n#endif\n\n#ifdef __V_amd64\n#ifdef _WIN32\nstatic const char __closure_thunk[] = {\n\0110x48, 0x89, 0x0d, 0xc1, 0xff, 0xff, 0xff, // mov qword ptr [rip - 63], rcx # <_orig_rcx>\n\0110x8f, 0x05, 0xc3, 0xff, 0xff, 0xff, // pop qword ptr [rip - 61] # <_orig_rbp>\n\0110xff, 0x15, 0xd5, 0xff, 0xff, 0xff, // call qword ptr [rip - 43] # \n\0110x48, 0x8b, 0x0d, 0xae, 0xff, 0xff, 0xff, // mov rcx, qword ptr [rip - 82] # <_orig_rcx>\n\0110xff, 0x15, 0xc0, 0xff, 0xff, 0xff, // call qword ptr [rip - 64] # \n\0110xff, 0x35, 0xaa, 0xff, 0xff, 0xff, // push qword ptr [rip - 86] # <_orig_rbp>\n\0110xc3 // ret\n};\n#else\nstatic const char __closure_thunk[] = {\n\0110x48, 0x89, 0x3d, 0xc1, 0xff, 0xff, 0xff, // mov qword ptr [rip - 63], rdi # <_orig_rdi>\n\0110x8f, 0x05, 0xc3, 0xff, 0xff, 0xff, // pop qword ptr [rip - 61] # <_orig_rbp>\n\0110xff, 0x15, 0xd5, 0xff, 0xff, 0xff, // call qword ptr [rip - 43] # \n\0110x48, 0x8b, 0x3d, 0xae, 0xff, 0xff, 0xff, // mov rdi, qword ptr [rip - 82] # <_orig_rdi>\n\0110xff, 0x15, 0xc0, 0xff, 0xff, 0xff, // call qword ptr [rip - 64] # \n\0110xff, 0x35, 0xaa, 0xff, 0xff, 0xff, // push qword ptr [rip - 86] # <_orig_rbp>\n\0110xc3 // ret\n};\n#endif\n#define __CLOSURE_WRAPPER_OFFSET 19\n#define __CLOSURE_UNWRAPPER_OFFSET 32\n#define __CLOSURE_WRAPPER_EXTRA_PARAM void* _t\n#define __CLOSURE_WRAPPER_EXTRA_PARAM_COMMA ,\n#elif defined(__V_x86)\nstatic char __closure_thunk[] = {\n 0xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n 0x58, // pop eax\n 0x8f, 0x40, 0xe3, // pop dword ptr [eax - 29] # <_orig_rbp>\n 0xff, 0x50, 0xef, // call dword ptr [eax - 17] # \n 0xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n 0x58, // pop eax\n 0xff, 0x50, 0xdf, // call dword ptr [eax - 33] # \n 0xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n 0x58, // pop eax\n 0xff, 0x70, 0xce, // push dword ptr [eax - 50] # <_orig_rbp>\n 0xc3 // ret\n};\n\n#define __CLOSURE_WRAPPER_OFFSET 12\n#define __CLOSURE_UNWRAPPER_OFFSET 21\n#define __CLOSURE_WRAPPER_EXTRA_PARAM void* _t\n#define __CLOSURE_WRAPPER_EXTRA_PARAM_COMMA ,\n\n#elif defined(__V_arm64)\nstatic char __closure_thunk[] = {\n\0110x10, 0x00, 0x00, 0x10, // adr x16, start\n\0110x08, 0x82, 0x1c, 0xf8, // str x8, _orig_x8\n\0110x1e, 0x02, 0x1d, 0xf8, // str x30, _orig_x30\n\0110xf0, 0xfe, 0xff, 0x58, // ldr x16, wrapper\n\0110x00, 0x02, 0x3f, 0xd6, // blr x16\n\0110x70, 0xff, 0xff, 0x10, // adr x16, start\n\0110x08, 0x82, 0x5c, 0xf8, // ldr x8, _orig_x8\n\0110x30, 0xfe, 0xff, 0x58, // ldr x16, unwrapper\n\0110x00, 0x02, 0x3f, 0xd6, // blr x16\n\0110xf0, 0xfe, 0xff, 0x10, // adr x16, start\n\0110x1e, 0x02, 0x5d, 0xf8, // ldr x30, _orig_x30\n\0110xc0, 0x03, 0x5f, 0xd6 // ret\n};\n#define __CLOSURE_WRAPPER_OFFSET 20\n#define __CLOSURE_UNWRAPPER_OFFSET 36\n#define __CLOSURE_WRAPPER_EXTRA_PARAM\n#define __CLOSURE_WRAPPER_EXTRA_PARAM_COMMA\n#elif defined(__V_arm32)\nstatic char __closure_thunk[] = {\n 0x24, 0x00, 0x0f, 0xe5, // str r0, orig_r0\n 0x24, 0xe0, 0x0f, 0xe5, // str lr, orig_lr\n 0x1c, 0xc0, 0x1f, 0xe5, // ldr ip, wrapper\n 0x3c, 0xff, 0x2f, 0xe1, // blx ip\n 0x34, 0x00, 0x1f, 0xe5, // ldr r0, orig_r0\n 0x2c, 0xc0, 0x1f, 0xe5, // ldr ip, unwrapper\n 0x3c, 0xff, 0x2f, 0xe1, // blx ip\n 0x3c, 0xe0, 0x1f, 0xe5, // ldr lr, orig_lr\n 0x1e, 0xff, 0x2f, 0xe1 // bx lr\n};\n#define __CLOSURE_WRAPPER_OFFSET 16\n#define __CLOSURE_UNWRAPPER_OFFSET 28\n#define __CLOSURE_WRAPPER_EXTRA_PARAM void* _t\n#define __CLOSURE_WRAPPER_EXTRA_PARAM_COMMA ,\n#endif\n\nstatic int _V_PAGE_SIZE = 4096; // pre-initialized to the most common value, in case _vinit is not called (in a DLL, for example)\n\nstatic inline void __closure_set_data(void* closure, void* data) {\n void** p = closure;\n p[-1] = data;\n}\n\nstatic inline void __closure_set_function(void* closure, void* f) {\n void** p = closure;\n p[-2] = f;\n}\n\nstatic inline void __closure_set_wrapper(void* closure, void* f) {\n void** p = closure;\n p[-3] = f;\n}\n\nstatic inline void __closure_set_unwrapper(void* closure, void* f) {\n void** p = closure;\n p[-4] = f;\n}\n\nstatic inline void __closure_set_base_ptr(void* closure, void* bp) {\n void** p = closure;\n p[-5] = bp;\n}\n\nstatic void* __closure_create(void* fn, void* wrapper, void* unwrapper, void* data) {\n#ifdef _WIN32\n\011SYSTEM_INFO si;\n\011GetNativeSystemInfo(&si);\n\011uint32_t page_size = si.dwPageSize;\n\011char* p = VirtualAlloc(NULL, page_size * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);\n\011if (p == NULL) return 0;\n#else\n\011uint32_t page_size = sysconf(_SC_PAGESIZE);\n\011int prot = PROT_READ | PROT_WRITE;\n\011int flags = MAP_ANONYMOUS | MAP_PRIVATE;\n\011char* p = mmap(0, page_size * 2, prot, flags, -1, 0);\n\011if (p == MAP_FAILED) return 0;\n#endif\n\n\011void* closure = p + page_size;\n\011memcpy(closure, __closure_thunk, sizeof(__closure_thunk));\n\n#ifdef _WIN32\n\011DWORD _tmp;\n\011VirtualProtect(closure, page_size, PAGE_EXECUTE_READ, &_tmp);\n#else\n\011mprotect(closure, page_size, PROT_READ | PROT_EXEC);\n#endif\n\n\011__closure_set_data(closure, data);\n\011__closure_set_function(closure, fn);\n\011__closure_set_wrapper(closure, wrapper);\n\011__closure_set_unwrapper(closure, unwrapper);\n\011__closure_set_base_ptr(closure, p);\n\011return closure;\n}\n")); + strings__Builder_write_string(&builder, _SLIT("\n#ifdef _MSC_VER\n\011#define __RETURN_ADDRESS() ((char*)_ReturnAddress())\n#elif defined(__TINYC__) && defined(_WIN32)\n\011#define __RETURN_ADDRESS() ((char*)__builtin_return_address(0))\n#else\n\011#define __RETURN_ADDRESS() ((char*)__builtin_extract_return_addr(__builtin_return_address(0)))\n#endif\n\n#ifdef __V_amd64\nstatic const char __closure_thunk[] = {\n\0110x8f, 0x05, 0xda, 0xff, 0xff, 0xff, // pop QWORD PTR [rip - 0x26] # <_orig_rbp>\n\0110xff, 0x15, 0xe4, 0xff, 0xff, 0xff, // call QWORD PTR [rip - 0x1C] # \n\0110xff, 0x25, 0xce, 0xff, 0xff, 0xff, // jmp QWORD PTR [rip - 0x32] # \n};\n#define __CLOSURE_DATA_OFFSET 20\n#elif defined(__V_x86)\nstatic char __closure_thunk[] = {\n\0110xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n\0110x59, // pop ecx\n\0110x8f, 0x41, 0xeb, // pop DWORD PTR [ecx - 21] # <_orig_rbp>\n\0110xff, 0x51, 0xf3, // call DWORD PTR [ecx - 13] # \n\0110xe8, 0x00, 0x00, 0x00, 0x00, // call 4\n\0110x59, // pop ecx\n\0110xff, 0x61, 0xdf, // jmp DWORD PTR [ecx - 33] # <_orig_rbp>\n};\n\n#define __CLOSURE_DATA_OFFSET 16\n#elif defined(__V_arm64)\nstatic char __closure_thunk[] = {\n\0110x10, 0x00, 0x00, 0x10, // adr x16, start\n\0110x1e, 0x02, 0x1e, 0xf8, // str x30, _orig_x30\n\0110x50, 0xff, 0xff, 0x58, // ldr x16, fn\n\0110x00, 0x02, 0x3f, 0xd6, // blr x16\n\0110x9e, 0xfe, 0xff, 0x58, // ldr x30, _orig_x30\n\0110xc0, 0x03, 0x5f, 0xd6 // ret\n};\n#define __CLOSURE_DATA_OFFSET 24\n#elif defined(__V_arm32)\nstatic char __closure_thunk[] = {\n\0110x18, 0xe0, 0x0f, 0xe5, // str lr, orig_lr\n\0110x14, 0xc0, 0x1f, 0xe5, // ldr ip, fn\n\0110x3c, 0xff, 0x2f, 0xe1, // blx ip\n\0110x24, 0xe0, 0x1f, 0xe5, // ldr lr, orig_lr\n\0110x1e, 0xff, 0x2f, 0xe1 // bx lr\n};\n#define __CLOSURE_DATA_OFFSET 16\n#endif\n\nstatic int _V_PAGE_SIZE = 4096; // pre-initialized to the most common value, in case _vinit is not called (in a DLL, for example)\n\nstatic inline void __closure_set_data(void* closure, void* data) {\n void** p = closure;\n p[-1] = data;\n}\n\nstatic inline void __closure_set_function(void* closure, void* f) {\n void** p = closure;\n p[-2] = f;\n}\n\nstatic void* __closure_create(void* fn, void* data) {\n#ifdef _WIN32\n\011SYSTEM_INFO si;\n\011GetNativeSystemInfo(&si);\n\011uint32_t page_size = si.dwPageSize;\n\011char* p = VirtualAlloc(NULL, page_size * 2, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);\n\011if (p == NULL) return 0;\n#else\n\011uint32_t page_size = sysconf(_SC_PAGESIZE);\n\011int prot = PROT_READ | PROT_WRITE;\n\011int flags = MAP_ANONYMOUS | MAP_PRIVATE;\n\011char* p = mmap(0, page_size * 2, prot, flags, -1, 0);\n\011if (p == MAP_FAILED) return 0;\n#endif\n\n\011void* closure = p + page_size;\n\011memcpy(closure, __closure_thunk, sizeof(__closure_thunk));\n\n#ifdef _WIN32\n\011DWORD _tmp;\n\011VirtualProtect(closure, page_size, PAGE_EXECUTE_READ, &_tmp);\n#else\n\011mprotect(closure, page_size, PROT_READ | PROT_EXEC);\n#endif\n\n\011__closure_set_data(closure, data);\n\011__closure_set_function(closure, fn);\n\011return closure;\n}\n")); string _t1 = strings__Builder_str(&builder); return _t1; } @@ -75035,8 +75102,7 @@ int ctmp; bool is_closure = v__ast__Scope_has_inherited_vars(node->scope); string cur_closure_ctx = _SLIT(""); if (is_closure) { - multi_return_string_string mr_5443 = v__gen__c__closure_ctx(*node); - cur_closure_ctx = mr_5443.arg0; + cur_closure_ctx = v__gen__c__closure_ctx(*node); strings__Builder_write_string(&g->definitions, cur_closure_ctx); strings__Builder_writeln(&g->definitions, _SLIT(";")); } @@ -75134,19 +75200,11 @@ int ctmp; v__gen__c__Gen_write(g, fn_header); } int arg_start_pos = g->out.len; - multi_return_Array_string_Array_string_Array_bool mr_8607 = v__gen__c__Gen_fn_decl_params(g, node->params, node->scope, node->is_variadic); - Array_string fargs = mr_8607.arg0; - Array_string fargtypes = mr_8607.arg1; - Array_bool heap_promoted = mr_8607.arg2; + multi_return_Array_string_Array_string_Array_bool mr_8604 = v__gen__c__Gen_fn_decl_params(g, node->params, node->scope, node->is_variadic); + Array_string fargs = mr_8604.arg0; + Array_string fargtypes = mr_8604.arg1; + Array_bool heap_promoted = mr_8604.arg2; if (is_closure) { - string s = str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = cur_closure_ctx}}, {_SLIT(" *"), /*115 &string*/0xfe10, {.d_s = _const_v__gen__c__closure_ctx}}, {_SLIT0, 0, { .d_c = 0 }}})); - if (node->params.len > 0) { - s = string__plus(_SLIT(", "), s); - } else { - strings__Builder_cut_to(&g->out, arg_start_pos); - } - strings__Builder_write_string(&g->definitions, s); - v__gen__c__Gen_write(g, s); g->nr_closures++; } string arg_str = strings__Builder_after(&g->out, arg_start_pos); @@ -75185,6 +75243,9 @@ int ctmp; } strings__Builder_writeln(&g->definitions, _SLIT(");")); v__gen__c__Gen_writeln(g, _SLIT(") {")); + if (is_closure) { + v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = cur_closure_ctx}}, {_SLIT("* "), /*115 &string*/0xfe10, {.d_s = _const_v__gen__c__closure_ctx}}, {_SLIT(" = *(void**)(__RETURN_ADDRESS() - __CLOSURE_DATA_OFFSET);"), 0, { .d_c = 0 }}}))); + } for (int i = 0; i < heap_promoted.len; ++i) { bool is_promoted = ((bool*)heap_promoted.data)[i]; if (is_promoted) { @@ -75357,8 +75418,9 @@ VV_LOCAL_SYMBOL _option_string v__gen__c__Gen_c_fn_name(v__gen__c__Gen* g, v__as return _t2; } -VV_LOCAL_SYMBOL multi_return_string_string v__gen__c__closure_ctx(v__ast__FnDecl node) { - return (multi_return_string_string){.arg0= str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct _V_"), /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("_Ctx"), 0, { .d_c = 0 }}})), .arg1= str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct _V_"), /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("_Args"), 0, { .d_c = 0 }}}))}; +VV_LOCAL_SYMBOL string v__gen__c__closure_ctx(v__ast__FnDecl node) { + string _t1 = str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct _V_"), /*115 &string*/0xfe10, {.d_s = node.name}}, {_SLIT("_Ctx"), 0, { .d_c = 0 }}})); + return _t1; } VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn(v__gen__c__Gen* g, v__ast__AnonFn* node) { @@ -75367,66 +75429,15 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn(v__gen__c__Gen* g, v__ast__AnonF v__gen__c__Gen_write(g, node->decl.name); return; } - multi_return_string_string mr_14693 = v__gen__c__closure_ctx(node->decl); - string ctx_struct = mr_14693.arg0; - string arg_struct = mr_14693.arg1; - v__gen__c__Gen_write(g, str_intp(6, _MOV((StrIntpData[]){{_SLIT("__closure_create("), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT(", "), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT("_wrapper, "), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT("_unwrapper, ("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT("*) memdup(&("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT("){"), 0, { .d_c = 0 }}}))); + string ctx_struct = v__gen__c__closure_ctx(node->decl); + v__gen__c__Gen_write(g, str_intp(4, _MOV((StrIntpData[]){{_SLIT("__closure_create("), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT(", ("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT("*) memdup(&("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT("){"), 0, { .d_c = 0 }}}))); g->indent++; for (int _t1 = 0; _t1 < node->inherited_vars.len; ++_t1) { v__ast__Param var = ((v__ast__Param*)node->inherited_vars.data)[_t1]; v__gen__c__Gen_writeln(g, str_intp(3, _MOV((StrIntpData[]){{_SLIT("."), /*115 &string*/0xfe10, {.d_s = var.name}}, {_SLIT(" = "), /*115 &string*/0xfe10, {.d_s = var.name}}, {_SLIT(","), 0, { .d_c = 0 }}}))); } g->indent--; - int ps = g->table->pointer_size; - int is_big_cutoff = (g->pref->os == v__pref__OS__windows || g->pref->arch == v__pref__Arch__arm32 ? (ps) : (ps * 2)); - multi_return_int_int mr_15314 = v__ast__Table_type_size(g->table, node->decl.return_type); - int rt_size = mr_15314.arg0; - bool is_big = rt_size > is_big_cutoff; v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT("}, sizeof("), /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT(")))"), 0, { .d_c = 0 }}}))); - strings__Builder sb = strings__new_builder(512); - string ret_styp = v__gen__c__Gen_typ(g, node->decl.return_type); - strings__Builder_write_string(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT(" VV_LOCAL_SYMBOL void "), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT("_wrapper("), 0, { .d_c = 0 }}}))); - if (is_big) { - strings__Builder_write_string(&sb, _SLIT("__CLOSURE_WRAPPER_EXTRA_PARAM ")); - if (node->decl.params.len > 0) { - strings__Builder_write_string(&sb, _SLIT("__CLOSURE_WRAPPER_EXTRA_PARAM_COMMA ")); - } - } - for (int i = 0; i < node->decl.params.len; ++i) { - v__ast__Param param = ((v__ast__Param*)node->decl.params.data)[i]; - if (i > 0) { - strings__Builder_write_string(&sb, _SLIT(", ")); - } - strings__Builder_write_string(&sb, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, param.typ)}}, {_SLIT(" a"), /*100 &int*/0xfe07, {.d_i32 = i + 1}}, {_SLIT0, 0, { .d_c = 0 }}}))); - } - strings__Builder_writeln(&sb, _SLIT(") {")); - if (node->decl.params.len > 0) { - strings__Builder_writeln(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT("void** closure_start = (void**)((char*)__RETURN_ADDRESS() - __CLOSURE_WRAPPER_OFFSET);\n "), /*115 &string*/0xfe10, {.d_s = arg_struct}}, {_SLIT("* args = closure_start[-5];"), 0, { .d_c = 0 }}}))); - for (int i = 0; i < node->decl.params.len; ++i) { - strings__Builder_writeln(&sb, str_intp(3, _MOV((StrIntpData[]){{_SLIT("\targs->a"), /*100 &int literal*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(" = a"), /*100 &int literal*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(";"), 0, { .d_c = 0 }}}))); - } - } - strings__Builder_writeln(&sb, _SLIT("}\n")); - strings__Builder_writeln(&sb, str_intp(3, _MOV((StrIntpData[]){{_SLIT(" VV_LOCAL_SYMBOL "), /*115 &string*/0xfe10, {.d_s = ret_styp}}, {_SLIT(" "), /*115 &string*/0xfe10, {.d_s = node->decl.name}}, {_SLIT("_unwrapper(void) {\n void** closure_start = (void**)((char*)__RETURN_ADDRESS() - __CLOSURE_UNWRAPPER_OFFSET);\n void* userdata = closure_start[-1];"), 0, { .d_c = 0 }}}))); - strings__Builder_write_string(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\t"), /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, node->decl.return_type)}}, {_SLIT(" (*fn)("), 0, { .d_c = 0 }}}))); - for (int i = 0; i < node->decl.params.len; ++i) { - v__ast__Param param = ((v__ast__Param*)node->decl.params.data)[i]; - strings__Builder_write_string(&sb, str_intp(3, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, param.typ)}}, {_SLIT(" a"), /*100 &int*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(", "), 0, { .d_c = 0 }}}))); - } - strings__Builder_writeln(&sb, _SLIT("void* userdata) = closure_start[-2];")); - if (node->decl.params.len > 0) { - strings__Builder_writeln(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\t"), /*115 &string*/0xfe10, {.d_s = arg_struct}}, {_SLIT("* args = closure_start[-5];"), 0, { .d_c = 0 }}}))); - } - if (node->decl.return_type == _const_v__ast__void_type_idx) { - strings__Builder_write_string(&sb, _SLIT("\tfn(")); - } else { - strings__Builder_write_string(&sb, _SLIT("\treturn fn(")); - } - for (int i = 0; i < node->decl.params.len; ++i) { - strings__Builder_write_string(&sb, str_intp(2, _MOV((StrIntpData[]){{_SLIT("args->a"), /*100 &int literal*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(", "), 0, { .d_c = 0 }}}))); - } - strings__Builder_writeln(&sb, _SLIT("userdata);\n}")); - array_push((array*)&g->anon_fn_definitions, _MOV((string[]){ string_clone(strings__Builder_str(&sb)) })); g->empty_line = false; } @@ -75437,9 +75448,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn_decl(v__gen__c__Gen* g, v__ast__ node->has_gen = true; strings__Builder builder = strings__new_builder(256); if (node->inherited_vars.len > 0) { - multi_return_string_string mr_17185 = v__gen__c__closure_ctx(node->decl); - string ctx_struct = mr_17185.arg0; - string arg_struct = mr_17185.arg1; + string ctx_struct = v__gen__c__closure_ctx(node->decl); strings__Builder_writeln(&builder, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = ctx_struct}}, {_SLIT(" {"), 0, { .d_c = 0 }}}))); for (int _t1 = 0; _t1 < node->inherited_vars.len; ++_t1) { v__ast__Param var = ((v__ast__Param*)node->inherited_vars.data)[_t1]; @@ -75447,14 +75456,6 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_gen_anon_fn_decl(v__gen__c__Gen* g, v__ast__ strings__Builder_writeln(&builder, str_intp(3, _MOV((StrIntpData[]){{_SLIT("\t"), /*115 &string*/0xfe10, {.d_s = styp}}, {_SLIT(" "), /*115 &string*/0xfe10, {.d_s = var.name}}, {_SLIT(";"), 0, { .d_c = 0 }}}))); } strings__Builder_writeln(&builder, _SLIT("};\n")); - if (node->decl.params.len > 0) { - strings__Builder_writeln(&builder, str_intp(2, _MOV((StrIntpData[]){{_SLIT0, /*115 &string*/0xfe10, {.d_s = arg_struct}}, {_SLIT(" {"), 0, { .d_c = 0 }}}))); - for (int i = 0; i < node->decl.params.len; ++i) { - v__ast__Param param = ((v__ast__Param*)node->decl.params.data)[i]; - strings__Builder_writeln(&builder, str_intp(3, _MOV((StrIntpData[]){{_SLIT("\t"), /*115 &string*/0xfe10, {.d_s = v__gen__c__Gen_typ(g, param.typ)}}, {_SLIT(" a"), /*100 &int*/0xfe07, {.d_i32 = i + 1}}, {_SLIT(";"), 0, { .d_c = 0 }}}))); - } - strings__Builder_writeln(&builder, _SLIT("};\n")); - } } int pos = g->out.len; bool was_anon_fn = g->anon_fn; @@ -76295,11 +76296,11 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_fn_call(v__gen__c__Gen* g, v__ast__CallExpr } if (!print_auto_str) { if (g->pref->is_debug && string__eq(node.name, _SLIT("panic"))) { - multi_return_int_string_string_string mr_41840 = v__gen__c__Gen_panic_debug_info(g, node.pos); - int paline = mr_41840.arg0; - string pafile = mr_41840.arg1; - string pamod = mr_41840.arg2; - string pafn = mr_41840.arg3; + multi_return_int_string_string_string mr_39701 = v__gen__c__Gen_panic_debug_info(g, node.pos); + int paline = mr_39701.arg0; + string pafile = mr_39701.arg1; + string pamod = mr_39701.arg2; + string pafn = mr_39701.arg3; v__gen__c__Gen_write(g, str_intp(5, _MOV((StrIntpData[]){{_SLIT("panic_debug("), /*100 &int*/0xfe07, {.d_i32 = paline}}, {_SLIT(", tos3(\""), /*115 &string*/0xfe10, {.d_s = pafile}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pamod}}, {_SLIT("\"), tos3(\""), /*115 &string*/0xfe10, {.d_s = pafn}}, {_SLIT("\"), "), 0, { .d_c = 0 }}}))); v__gen__c__Gen_call_args(g, node); v__gen__c__Gen_write(g, _SLIT(")")); @@ -77656,7 +77657,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_index_expr(v__gen__c__Gen* g, v__ast__IndexE if ((node.index)._typ == 325 /* v.ast.RangeExpr */) { v__gen__c__Gen_range_expr(g, node, (*node.index._v__ast__RangeExpr)); } else { - v__ast__TypeSymbol* sym = v__ast__Table_final_sym(g->table, node.left_type); + v__ast__TypeSymbol* sym = v__ast__Table_final_sym(g->table, v__gen__c__Gen_unwrap_generic(g, node.left_type)); if (sym->kind == v__ast__Kind__array) { v__gen__c__Gen_index_of_array(g, node, *sym); } else if (sym->kind == v__ast__Kind__array_fixed) { @@ -79765,7 +79766,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_match_expr_sumtype(v__gen__c__Gen* g, v__ast } } if (is_expr && tmp_var.len == 0) { - v__gen__c__Gen_write(g, _SLIT(") ? ")); + v__gen__c__Gen_write(g, _SLIT(")? ")); } else { v__gen__c__Gen_writeln(g, _SLIT(") {")); } @@ -80020,7 +80021,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_match_expr_classic(v__gen__c__Gen* g, v__ast }; } if (is_expr && tmp_var.len == 0) { - v__gen__c__Gen_write(g, _SLIT(") ? ")); + v__gen__c__Gen_write(g, _SLIT(")? ")); } else { v__gen__c__Gen_writeln(g, _SLIT(") {")); } @@ -80457,7 +80458,7 @@ VV_LOCAL_SYMBOL void v__gen__c__Gen_sql_write_orm_primitive(v__gen__c__Gen* g, v if ((expr)._typ == 311 /* v.ast.InfixExpr */) { v__gen__c__Gen_write(g, _SLIT("(orm__InfixType){")); v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".name = _SLIT(\""), /*115 &v.ast.Expr*/0xfe10, {.d_s = v__ast__Expr_str((*expr._v__ast__InfixExpr).left)}}, {_SLIT("\"),"), 0, { .d_c = 0 }}}))); - string kind = (((*expr._v__ast__InfixExpr).op == (v__token__Kind__plus)) ? (_SLIT("orm__MathOperationKind__add")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__minus)) ? (_SLIT("orm__MathOperationKind__sub")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__div)) ? (_SLIT("orm__MathOperationKind__div")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__mul)) ? (_SLIT("orm__MathOperationKind__mul")) : (_SLIT(""))); + string kind = (((*expr._v__ast__InfixExpr).op == (v__token__Kind__plus))? (_SLIT("orm__MathOperationKind__add")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__minus))? (_SLIT("orm__MathOperationKind__sub")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__div))? (_SLIT("orm__MathOperationKind__div")) : ((*expr._v__ast__InfixExpr).op == (v__token__Kind__mul))? (_SLIT("orm__MathOperationKind__mul")) : (_SLIT(""))); v__gen__c__Gen_write(g, str_intp(2, _MOV((StrIntpData[]){{_SLIT(".operator = "), /*115 &string*/0xfe10, {.d_s = kind}}, {_SLIT(","), 0, { .d_c = 0 }}}))); v__gen__c__Gen_write(g, _SLIT(".right = ")); v__gen__c__Gen_sql_expr_to_orm_primitive(g, (*expr._v__ast__InfixExpr).right); @@ -83859,9 +83860,9 @@ VV_LOCAL_SYMBOL v__ast__Stmt v__parser__Parser_partial_assign_stmt(v__parser__Pa _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t2, Array_v__ast__Comment); Array_v__ast__Comment right_comments = __new_array_with_default(0, 0, sizeof(v__ast__Comment), 0); Array_v__ast__Expr right = __new_array_with_default(0, left.len, sizeof(v__ast__Expr), 0); - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_4062 = v__parser__Parser_expr_list(p); - right = mr_4062.arg0; - right_comments = mr_4062.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_4041 = v__parser__Parser_expr_list(p); + right = mr_4041.arg0; + right_comments = mr_4041.arg1; _PUSH_MANY(&comments, (right_comments), _t3, Array_v__ast__Comment); Array_v__ast__Comment end_comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,})); bool has_cross_var = false; @@ -84058,9 +84059,9 @@ VV_LOCAL_SYMBOL v__ast__HashStmt v__parser__Parser_hash(v__parser__Parser* p) { VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__Parser* p) { v__ast__ComptimeCall *err_node = HEAP(v__ast__ComptimeCall, (((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,},.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = (string){.str=(byteptr)"", .is_lit=1},.left = {0},.args_var = (string){.str=(byteptr)"", .is_lit=1},.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = 0,.is_embed = 0,.is_env = 0,.is_pkgconfig = 0,}))); + v__token__Pos start_pos = v__token__Token_pos(&p->tok); v__parser__Parser_check(p, v__token__Kind__dollar); - v__token__Pos start_pos = v__token__Token_pos(&p->prev_tok); - string error_msg = _SLIT("only `$tmpl()`, `$env()`, `$embed_file()`, `$pkgconfig()` and `$vweb.html()` comptime functions are supported right now"); + string error_msg = _SLIT("only `$tmpl()`, `$env()`, `$embed_file()`, `$pkgconfig()`, `$vweb.html()`, `$compile_error()` and `$compile_warn()` comptime functions are supported right now"); if (p->peek_tok.kind == v__token__Kind__dot) { string name = v__parser__Parser_check_name(p); if (!string__eq(name, _SLIT("vweb"))) { @@ -84079,8 +84080,7 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ bool is_embed_file = string__eq(method_name, _SLIT("embed_file")); bool is_html = string__eq(method_name, _SLIT("html")); v__parser__Parser_check(p, v__token__Kind__lpar); - v__token__Pos spos = v__token__Token_pos(&p->tok); - if (string__eq(method_name, _SLIT("env"))) { + if (string__eq(method_name, _SLIT("env")) || string__eq(method_name, _SLIT("pkgconfig")) || string__eq(method_name, _SLIT("compile_error")) || string__eq(method_name, _SLIT("compile_warn"))) { string s = p->tok.lit; v__parser__Parser_check(p, v__token__Kind__string); v__parser__Parser_check(p, v__token__Kind__rpar); @@ -84093,45 +84093,19 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ .args_var = s, .env_value = (string){.str=(byteptr)"", .is_lit=1}, .scope = 0, - .pos = v__token__Pos_extend(spos, v__token__Token_pos(&p->prev_tok)), + .pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)), .method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,}, - .env_pos = spos, + .env_pos = start_pos, .left_type = 0, .result_type = 0, .has_parens = 0, .is_vweb = 0, .is_embed = 0, - .is_env = true, - .is_pkgconfig = 0, + .is_env = string__eq(method_name, _SLIT("env")), + .is_pkgconfig = string__eq(method_name, _SLIT("pkgconfig")), }); return _t3; } - if (string__eq(method_name, _SLIT("pkgconfig"))) { - string s = p->tok.lit; - v__parser__Parser_check(p, v__token__Kind__string); - v__parser__Parser_check(p, v__token__Kind__rpar); - v__ast__ComptimeCall _t4 = ((v__ast__ComptimeCall){ - .vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),}, - .embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,}, - .args = __new_array(0, 0, sizeof(v__ast__CallArg)), - .method_name = method_name, - .left = {0}, - .args_var = s, - .env_value = (string){.str=(byteptr)"", .is_lit=1}, - .scope = 0, - .pos = v__token__Pos_extend(spos, v__token__Token_pos(&p->prev_tok)), - .method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,}, - .env_pos = spos, - .left_type = 0, - .result_type = 0, - .has_parens = 0, - .is_vweb = 0, - .is_embed = 0, - .is_env = 0, - .is_pkgconfig = true, - }); - return _t4; - } string literal_string_param = (is_html ? (_SLIT("")) : (p->tok.lit)); string path_of_literal_string_param = string_replace(literal_string_param, _SLIT("/"), _const_os__path_separator); if (!is_html) { @@ -84149,23 +84123,23 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ if (is_embed_file) { string epath = path_of_literal_string_param; if ((epath).len == 0) { - v__parser__Parser_error_with_pos(p, _SLIT("supply a valid relative or absolute file path to the file to embed"), spos); - v__ast__ComptimeCall _t5 = (*(err_node)); - return _t5; + v__parser__Parser_error_with_pos(p, _SLIT("supply a valid relative or absolute file path to the file to embed"), start_pos); + v__ast__ComptimeCall _t4 = (*(err_node)); + return _t4; } if (!p->pref->is_fmt) { string abs_path = os__real_path(epath); if (!os__exists(abs_path)) { epath = os__real_path(os__join_path_single(os__dir(p->file_name), epath)); if (!os__exists(epath)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\""), /*115 &string*/0xfe10, {.d_s = epath}}, {_SLIT("\" does not exist so it cannot be embedded"), 0, { .d_c = 0 }}})), spos); - v__ast__ComptimeCall _t6 = (*(err_node)); - return _t6; + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\""), /*115 &string*/0xfe10, {.d_s = epath}}, {_SLIT("\" does not exist so it cannot be embedded"), 0, { .d_c = 0 }}})), start_pos); + v__ast__ComptimeCall _t5 = (*(err_node)); + return _t5; } if (!os__is_file(epath)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\""), /*115 &string*/0xfe10, {.d_s = epath}}, {_SLIT("\" is not a file so it cannot be embedded"), 0, { .d_c = 0 }}})), spos); - v__ast__ComptimeCall _t7 = (*(err_node)); - return _t7; + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("\""), /*115 &string*/0xfe10, {.d_s = epath}}, {_SLIT("\" is not a file so it cannot be embedded"), 0, { .d_c = 0 }}})), start_pos); + v__ast__ComptimeCall _t6 = (*(err_node)); + return _t6; } } else { epath = abs_path; @@ -84175,8 +84149,8 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ if (string__eq(embed_compression_type, _SLIT("zlib")) && (p->pref->is_prod || Array_string_contains(p->pref->compile_defines, _SLIT("debug_embed_file_in_prod")))) { v__parser__Parser_register_auto_import(p, _SLIT("v.preludes.embed_file.zlib")); } - v__ast__ComptimeCall _t8 = ((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = ((v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = literal_string_param,.apath = epath,.compression_type = embed_compression_type,.len = 0,.is_compressed = 0,}),.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = (string){.str=(byteptr)"", .is_lit=1},.left = {0},.args_var = (string){.str=(byteptr)"", .is_lit=1},.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)),.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = 0,.is_embed = true,.is_env = 0,.is_pkgconfig = 0,}); - return _t8; + v__ast__ComptimeCall _t7 = ((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = ((v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = literal_string_param,.apath = epath,.compression_type = embed_compression_type,.len = 0,.is_compressed = 0,}),.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = (string){.str=(byteptr)"", .is_lit=1},.left = {0},.args_var = (string){.str=(byteptr)"", .is_lit=1},.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)),.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = 0,.is_embed = true,.is_env = 0,.is_pkgconfig = 0,}); + return _t7; } Array_string fn_path = string_split(p->cur_fn_name, _SLIT("_")); string fn_path_joined = Array_string_join(fn_path, _const_os__path_separator); @@ -84200,23 +84174,23 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ } if (!os__exists(path)) { if (p->pref->is_fmt) { - v__ast__ComptimeCall _t9 = ((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,},.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = method_name,.left = {0},.args_var = literal_string_param,.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)),.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = true,.is_embed = 0,.is_env = 0,.is_pkgconfig = 0,}); - return _t9; + v__ast__ComptimeCall _t8 = ((v__ast__ComptimeCall){.vweb_tmpl = (v__ast__File){.nr_lines = 0,.nr_bytes = 0,.mod = (v__ast__Module){.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_skipped = 0,},.global_scope = 0,.is_test = 0,.is_generated = 0,.is_translated = 0,.idx = 0,.path = (string){.str=(byteptr)"", .is_lit=1},.path_base = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.imports = __new_array(0, 0, sizeof(v__ast__Import)),.auto_imports = __new_array(0, 0, sizeof(string)),.embedded_files = __new_array(0, 0, sizeof(v__ast__EmbeddedFile)),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.generic_fns = __new_array(0, 0, sizeof(v__ast__FnDecl*)),.global_labels = __new_array(0, 0, sizeof(string)),},.embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,},.args = __new_array(0, 0, sizeof(v__ast__CallArg)),.method_name = method_name,.left = {0},.args_var = literal_string_param,.env_value = (string){.str=(byteptr)"", .is_lit=1},.scope = 0,.pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)),.method_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.env_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.left_type = 0,.result_type = 0,.has_parens = 0,.is_vweb = true,.is_embed = 0,.is_env = 0,.is_pkgconfig = 0,}); + return _t8; } if (is_html) { v__parser__Parser_error(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("vweb HTML template \""), /*115 &string*/0xfe10, {.d_s = path}}, {_SLIT("\" not found"), 0, { .d_c = 0 }}}))); } else { v__parser__Parser_error(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("template file \""), /*115 &string*/0xfe10, {.d_s = path}}, {_SLIT("\" not found"), 0, { .d_c = 0 }}}))); } - v__ast__ComptimeCall _t10 = (*(err_node)); - return _t10; + v__ast__ComptimeCall _t9 = (*(err_node)); + return _t9; } } string tmp_fn_name = string__plus(string_replace(p->cur_fn_name, _SLIT("."), _SLIT("__")), int_str(start_pos.pos)); string v_code = v__parser__Parser_compile_template_file(p, path, tmp_fn_name); v__ast__File* file = v__parser__parse_comptime(tmpl_path, v_code, p->table, p->pref, p->scope); file->path = tmpl_path; - v__ast__ComptimeCall _t11 = ((v__ast__ComptimeCall){ + v__ast__ComptimeCall _t10 = ((v__ast__ComptimeCall){ .vweb_tmpl = *file, .embed_file = (v__ast__EmbeddedFile){.bytes = __new_array(0, 0, sizeof(u8)),.rpath = (string){.str=(byteptr)"", .is_lit=1},.apath = (string){.str=(byteptr)"", .is_lit=1},.compression_type = (string){.str=(byteptr)"", .is_lit=1},.len = 0,.is_compressed = 0,}, .args = __new_array(0, 0, sizeof(v__ast__CallArg)), @@ -84236,7 +84210,7 @@ VV_LOCAL_SYMBOL v__ast__ComptimeCall v__parser__Parser_comptime_call(v__parser__ .is_env = 0, .is_pkgconfig = 0, }); - return _t11; + return _t10; } VV_LOCAL_SYMBOL v__ast__ComptimeFor v__parser__Parser_comptime_for(v__parser__Parser* p) { @@ -84282,7 +84256,7 @@ VV_LOCAL_SYMBOL v__ast__ComptimeFor v__parser__Parser_comptime_for(v__parser__Pa VV_LOCAL_SYMBOL v__ast__AtExpr v__parser__Parser_at(v__parser__Parser* p) { string name = p->tok.lit; - v__token__AtKind kind = ((string__eq(name, _SLIT("@FN"))) ? (v__token__AtKind__fn_name) : (string__eq(name, _SLIT("@METHOD"))) ? (v__token__AtKind__method_name) : (string__eq(name, _SLIT("@MOD"))) ? (v__token__AtKind__mod_name) : (string__eq(name, _SLIT("@STRUCT"))) ? (v__token__AtKind__struct_name) : (string__eq(name, _SLIT("@FILE"))) ? (v__token__AtKind__file_path) : (string__eq(name, _SLIT("@LINE"))) ? (v__token__AtKind__line_nr) : (string__eq(name, _SLIT("@COLUMN"))) ? (v__token__AtKind__column_nr) : (string__eq(name, _SLIT("@VHASH"))) ? (v__token__AtKind__vhash) : (string__eq(name, _SLIT("@VMOD_FILE"))) ? (v__token__AtKind__vmod_file) : (string__eq(name, _SLIT("@VEXE"))) ? (v__token__AtKind__vexe_path) : (string__eq(name, _SLIT("@VEXEROOT"))) ? (v__token__AtKind__vexeroot_path) : (string__eq(name, _SLIT("@VMODROOT"))) ? (v__token__AtKind__vmodroot_path) : (string__eq(name, _SLIT("@VROOT"))) ? (v__token__AtKind__vroot_path) : (v__token__AtKind__unknown)); + v__token__AtKind kind = ((string__eq(name, _SLIT("@FN")))? (v__token__AtKind__fn_name) : (string__eq(name, _SLIT("@METHOD")))? (v__token__AtKind__method_name) : (string__eq(name, _SLIT("@MOD")))? (v__token__AtKind__mod_name) : (string__eq(name, _SLIT("@STRUCT")))? (v__token__AtKind__struct_name) : (string__eq(name, _SLIT("@FILE")))? (v__token__AtKind__file_path) : (string__eq(name, _SLIT("@LINE")))? (v__token__AtKind__line_nr) : (string__eq(name, _SLIT("@COLUMN")))? (v__token__AtKind__column_nr) : (string__eq(name, _SLIT("@VHASH")))? (v__token__AtKind__vhash) : (string__eq(name, _SLIT("@VMOD_FILE")))? (v__token__AtKind__vmod_file) : (string__eq(name, _SLIT("@VEXE")))? (v__token__AtKind__vexe_path) : (string__eq(name, _SLIT("@VEXEROOT")))? (v__token__AtKind__vexeroot_path) : (string__eq(name, _SLIT("@VMODROOT")))? (v__token__AtKind__vmodroot_path) : (string__eq(name, _SLIT("@VROOT")))? (v__token__AtKind__vroot_path) : (v__token__AtKind__unknown)); v__parser__Parser_next(p); v__ast__AtExpr _t1 = ((v__ast__AtExpr){.name = name,.pos = v__token__Token_pos(&p->tok),.kind = kind,.val = (string){.str=(byteptr)"", .is_lit=1},}); return _t1; @@ -84553,6 +84527,10 @@ v__ast__Expr v__parser__Parser_expr(v__parser__Parser* p, int precedence) { _option_v__ast__Expr _t2 = v__parser__Parser_check_expr(p, precedence); if (_t2.state != 0) { /*or block*/ IError err = _t2.err; + if (v__token__is_decl(p->tok.kind) && v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__Expr _t3 = v__ast__empty_expr(); + return _t3; + } *(v__ast__Expr*) _t2.data = v__ast__NodeError_to_sumtype_v__ast__Expr(ADDR(v__ast__NodeError, (v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid expression: unexpected "), /*115 &v.token.Token*/0xfe10, {.d_s = v__token__Token_str(p->tok)}}, {_SLIT0, 0, { .d_c = 0 }}})), v__token__Token_pos(&p->tok))))); } @@ -85947,10 +85925,11 @@ VV_LOCAL_SYMBOL v__ast__AnonFn v__parser__Parser_anon_fn(v__parser__Parser* p) { bool v__parser__Parser_anon_fn_defer_0 = false; v__token__Pos pos = v__token__Token_pos(&p->tok); v__parser__Parser_check(p, v__token__Kind__key_fn); - if (p->pref->is_script && p->tok.kind == v__token__Kind__name) { - v__parser__Parser_error_with_pos(p, _SLIT("function declarations in script mode should be before all script statements"), v__token__Token_pos(&p->tok)); - v__ast__AnonFn _t1 = ((v__ast__AnonFn){.decl = (v__ast__FnDecl){.receiver = (v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,},.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.params = __new_array(0, 0, sizeof(v__ast__Param)),.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.defer_stmts = __new_array(0, 0, sizeof(v__ast__DeferStmt)),.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.next_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.label_names = __new_array(0, 0, sizeof(string)),.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.source_file = 0,.scope = 0,.receiver_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.body_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,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_idx = 0,.ctdefine_idx = -1,.idx = 0,.return_type = 0,.ninstances = 0,.is_deprecated = 0,.is_pub = 0,.is_variadic = 0,.is_anon = 0,.is_noreturn = 0,.is_manualfree = 0,.is_main = 0,.is_test = 0,.is_conditional = 0,.is_exported = 0,.is_keep_alive = 0,.is_unsafe = 0,.is_markused = 0,.is_method = 0,.rec_mut = 0,.no_body = 0,.is_builtin = 0,.is_direct_arr = 0,.has_return = 0,.should_be_skipped = 0,.has_await = 0,},.inherited_vars = __new_array(0, 0, sizeof(v__ast__Param)),.typ = 0,.has_gen = 0,}); - return _t1; + if (p->tok.kind == v__token__Kind__name) { + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__AnonFn _t1 = ((v__ast__AnonFn){.decl = (v__ast__FnDecl){.receiver = (v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,},.generic_names = __new_array(0, 0, sizeof(string)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.params = __new_array(0, 0, sizeof(v__ast__Param)),.stmts = __new_array(0, 0, sizeof(v__ast__Stmt)),.defer_stmts = __new_array(0, 0, sizeof(v__ast__DeferStmt)),.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.next_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.label_names = __new_array(0, 0, sizeof(string)),.name = (string){.str=(byteptr)"", .is_lit=1},.short_name = (string){.str=(byteptr)"", .is_lit=1},.mod = (string){.str=(byteptr)"", .is_lit=1},.file = (string){.str=(byteptr)"", .is_lit=1},.source_file = 0,.scope = 0,.receiver_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_type_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.body_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,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.method_idx = 0,.ctdefine_idx = -1,.idx = 0,.return_type = 0,.ninstances = 0,.is_deprecated = 0,.is_pub = 0,.is_variadic = 0,.is_anon = 0,.is_noreturn = 0,.is_manualfree = 0,.is_main = 0,.is_test = 0,.is_conditional = 0,.is_exported = 0,.is_keep_alive = 0,.is_unsafe = 0,.is_markused = 0,.is_method = 0,.rec_mut = 0,.no_body = 0,.is_builtin = 0,.is_direct_arr = 0,.has_return = 0,.should_be_skipped = 0,.has_await = 0,},.inherited_vars = __new_array(0, 0, sizeof(v__ast__Param)),.typ = 0,.has_gen = 0,}); + return _t1; + } } bool old_inside_defer = p->inside_defer; p->inside_defer = false; @@ -85958,9 +85937,9 @@ bool v__parser__Parser_anon_fn_defer_0 = false; v__parser__Parser_anon_fn_defer_0 = true; p->scope->detached_from_parent = true; Array_v__ast__Param inherited_vars = (p->tok.kind == v__token__Kind__lsbr ? (v__parser__Parser_closure_vars(p)) : (__new_array_with_default(0, 0, sizeof(v__ast__Param), 0))); - multi_return_Array_v__ast__Param_bool_bool mr_18829 = v__parser__Parser_fn_args(p); - Array_v__ast__Param args = mr_18829.arg0; - bool is_variadic = mr_18829.arg2; + multi_return_Array_v__ast__Param_bool_bool mr_18748 = v__parser__Parser_fn_args(p); + Array_v__ast__Param args = mr_18748.arg0; + bool is_variadic = mr_18748.arg2; for (int _t2 = 0; _t2 < args.len; ++_t2) { v__ast__Param arg = ((v__ast__Param*)args.data)[_t2]; if (arg.name.len == 0 && v__ast__Table_sym(p->table, arg.typ)->kind != v__ast__Kind__placeholder) { @@ -87868,11 +87847,16 @@ v__ast__Type v__parser__Parser_parse_generic_inst_type(v__parser__Parser* p, str bool is_instance = false; for (;;) { if (!(p->tok.kind != v__token__Kind__eof)) break; + v__token__Pos type_pos = v__token__Token_pos(&p->tok); v__ast__Type gt = v__parser__Parser_parse_type(p); + type_pos = v__token__Pos_extend(type_pos, v__token__Token_pos(&p->prev_tok)); if (!v__ast__Type_has_flag(gt, v__ast__TypeFlag__generic)) { is_instance = true; } v__ast__TypeSymbol* gts = v__ast__Table_sym(p->table, gt); + if (!is_instance && gts->name.len > 1) { + v__parser__Parser_error_with_pos(p, _SLIT("generic struct parameter name needs to be exactly one char"), type_pos); + } bs_name = /*f*/string__plus(bs_name, gts->name); bs_cname = /*f*/string__plus(bs_cname, gts->cname); array_push((array*)&concrete_types, _MOV((v__ast__Type[]){ gt })); @@ -87937,7 +87921,7 @@ v__ast__Type v__parser__Parser_parse_generic_inst_type(v__parser__Parser* p, str v__ast__Stmt v__parser__parse_stmt(string text, v__ast__Table* table, v__ast__Scope* scope) { bool v__parser__parse_stmt_defer_0 = false; - v__parser__Parser p = ((v__parser__Parser){.imports = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.ast_imports = __new_array(0, 0, sizeof(v__ast__Import)),.used_imports = __new_array(0, 0, sizeof(string)),.auto_imports = __new_array(0, 0, sizeof(string)),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.vet_errors = __new_array(0, 0, sizeof(v__vet__Error)),.label_names = __new_array(0, 0, sizeof(string)),.global_labels = __new_array(0, 0, sizeof(string)),.defer_vars = __new_array(0, 0, sizeof(v__ast__Ident)),.struct_init_generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.if_cond_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.file_base = (string){.str=(byteptr)"", .is_lit=1},.file_name = (string){.str=(byteptr)"", .is_lit=1},.file_name_dir = (string){.str=(byteptr)"", .is_lit=1},.unique_prefix = (string){.str=(byteptr)"", .is_lit=1},.mod = (string){.str=(byteptr)"", .is_lit=1},.expr_mod = (string){.str=(byteptr)"", .is_lit=1},.cur_fn_name = (string){.str=(byteptr)"", .is_lit=1},.codegen_text = (string){.str=(byteptr)"", .is_lit=1},.pref = ((v__pref__Preferences*)memdup(&(v__pref__Preferences){.cache_manager = (v__vcache__CacheManager){.basepath = (string){.str=(byteptr)"", .is_lit=1},.original_vopts = (string){.str=(byteptr)"", .is_lit=1},.vopts = (string){.str=(byteptr)"", .is_lit=1},.k2cpath = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),},.profile_fns = __new_array(0, 0, sizeof(string)),.lookup_path = __new_array(0, 0, sizeof(string)),.run_only = __new_array(0, 0, sizeof(string)),.compile_defines = __new_array(0, 0, sizeof(string)),.compile_defines_all = __new_array(0, 0, sizeof(string)),.run_args = __new_array(0, 0, sizeof(string)),.printfn_list = __new_array(0, 0, sizeof(string)),.cleanup_files = __new_array(0, 0, sizeof(string)),.build_options = __new_array(0, 0, sizeof(string)),.test_runner = (string){.str=(byteptr)"", .is_lit=1},.profile_file = (string){.str=(byteptr)"", .is_lit=1},.dump_c_flags = (string){.str=(byteptr)"", .is_lit=1},.cflags = (string){.str=(byteptr)"", .is_lit=1},.ccompiler = (string){.str=(byteptr)"", .is_lit=1},.third_party_option = (string){.str=(byteptr)"", .is_lit=1},.bare_builtin_dir = (string){.str=(byteptr)"", .is_lit=1},.custom_prelude = (string){.str=(byteptr)"", .is_lit=1},.vroot = (string){.str=(byteptr)"", .is_lit=1},.out_name_c = (string){.str=(byteptr)"", .is_lit=1},.out_name = (string){.str=(byteptr)"", .is_lit=1},.path = (string){.str=(byteptr)"", .is_lit=1},.message_limit = 100,.checker_match_exhaustive_cutoff_limit = 12,.thread_stack_size = 8388608,.os = 0,.arch = 0,.backend = 0,.ccompiler_type = 0,.gc_mode = v__pref__GarbageCollectionMode__no_gc,.use_color = 0,.assert_failure_mode = 0,.build_mode = 0,.output_mode = v__pref__OutputMode__stdout,.is_verbose = 0,.is_glibc = 0,.is_musl = 0,.is_test = 0,.is_script = 0,.is_vsh = 0,.is_livemain = 0,.is_liveshared = 0,.is_shared = 0,.is_o = 0,.is_prof = 0,.is_prod = 0,.is_repl = 0,.is_run = 0,.is_debug = 0,.is_vlines = 0,.is_stats = 0,.is_fmt = 0,.is_vet = 0,.is_vweb = 0,.is_ios_simulator = 0,.is_apk = 0,.is_help = 0,.is_cstrict = 0,.profile_no_inline = 0,.translated = 0,.obfuscate = 0,.sanitize = 0,.sourcemap = 0,.sourcemap_inline = true,.sourcemap_src_included = 0,.show_cc = 0,.show_c_output = 0,.show_callgraph = 0,.show_depgraph = 0,.use_cache = 0,.retry_compilation = true,.m64 = 0,.building_v = 0,.autofree = 0,.compress = 0,.no_builtin = 0,.enable_globals = 0,.is_bare = 0,.no_preludes = 0,.output_cross_c = 0,.output_es5 = 0,.prealloc = 0,.print_v_files = 0,.skip_running = 0,.skip_warnings = 0,.warn_impure_v = 0,.warns_are_errors = 0,.fatal_errors = 0,.reuse_tmpc = 0,.no_rsp = 0,.no_std = 0,.no_parallel = 0,.only_check_syntax = 0,.check_only = 0,.experimental = 0,.skip_unused = 0,.show_timings = 0,.nofloat = 0,}, sizeof(v__pref__Preferences))),.scanner = v__scanner__new_scanner(text, v__scanner__CommentsMode__skip_comments, ((v__pref__Preferences*)memdup(&(v__pref__Preferences){.cache_manager = (v__vcache__CacheManager){.basepath = (string){.str=(byteptr)"", .is_lit=1},.original_vopts = (string){.str=(byteptr)"", .is_lit=1},.vopts = (string){.str=(byteptr)"", .is_lit=1},.k2cpath = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),},.profile_fns = __new_array(0, 0, sizeof(string)),.lookup_path = __new_array(0, 0, sizeof(string)),.run_only = __new_array(0, 0, sizeof(string)),.compile_defines = __new_array(0, 0, sizeof(string)),.compile_defines_all = __new_array(0, 0, sizeof(string)),.run_args = __new_array(0, 0, sizeof(string)),.printfn_list = __new_array(0, 0, sizeof(string)),.cleanup_files = __new_array(0, 0, sizeof(string)),.build_options = __new_array(0, 0, sizeof(string)),.test_runner = (string){.str=(byteptr)"", .is_lit=1},.profile_file = (string){.str=(byteptr)"", .is_lit=1},.dump_c_flags = (string){.str=(byteptr)"", .is_lit=1},.cflags = (string){.str=(byteptr)"", .is_lit=1},.ccompiler = (string){.str=(byteptr)"", .is_lit=1},.third_party_option = (string){.str=(byteptr)"", .is_lit=1},.bare_builtin_dir = (string){.str=(byteptr)"", .is_lit=1},.custom_prelude = (string){.str=(byteptr)"", .is_lit=1},.vroot = (string){.str=(byteptr)"", .is_lit=1},.out_name_c = (string){.str=(byteptr)"", .is_lit=1},.out_name = (string){.str=(byteptr)"", .is_lit=1},.path = (string){.str=(byteptr)"", .is_lit=1},.message_limit = 100,.checker_match_exhaustive_cutoff_limit = 12,.thread_stack_size = 8388608,.os = 0,.arch = 0,.backend = 0,.ccompiler_type = 0,.gc_mode = v__pref__GarbageCollectionMode__no_gc,.use_color = 0,.assert_failure_mode = 0,.build_mode = 0,.output_mode = v__pref__OutputMode__stdout,.is_verbose = 0,.is_glibc = 0,.is_musl = 0,.is_test = 0,.is_script = 0,.is_vsh = 0,.is_livemain = 0,.is_liveshared = 0,.is_shared = 0,.is_o = 0,.is_prof = 0,.is_prod = 0,.is_repl = 0,.is_run = 0,.is_debug = 0,.is_vlines = 0,.is_stats = 0,.is_fmt = 0,.is_vet = 0,.is_vweb = 0,.is_ios_simulator = 0,.is_apk = 0,.is_help = 0,.is_cstrict = 0,.profile_no_inline = 0,.translated = 0,.obfuscate = 0,.sanitize = 0,.sourcemap = 0,.sourcemap_inline = true,.sourcemap_src_included = 0,.show_cc = 0,.show_c_output = 0,.show_callgraph = 0,.show_depgraph = 0,.use_cache = 0,.retry_compilation = true,.m64 = 0,.building_v = 0,.autofree = 0,.compress = 0,.no_builtin = 0,.enable_globals = 0,.is_bare = 0,.no_preludes = 0,.output_cross_c = 0,.output_es5 = 0,.prealloc = 0,.print_v_files = 0,.skip_running = 0,.skip_warnings = 0,.warn_impure_v = 0,.warns_are_errors = 0,.fatal_errors = 0,.reuse_tmpc = 0,.no_rsp = 0,.no_std = 0,.no_parallel = 0,.only_check_syntax = 0,.check_only = 0,.experimental = 0,.skip_unused = 0,.show_timings = 0,.nofloat = 0,}, sizeof(v__pref__Preferences)))),.table = table,.scope = scope,.expr_level = 0,.n_asm = 0,.file_backend_mode = 0,.language = 0,.fn_language = 0,.comments_mode = v__scanner__CommentsMode__skip_comments,.inside_vlib_file = 0,.inside_test_file = true,.inside_if = 0,.inside_if_expr = 0,.inside_if_cond = 0,.inside_ct_if_expr = 0,.inside_or_expr = 0,.inside_for = 0,.inside_fn = 0,.inside_fn_return = 0,.inside_unsafe_fn = 0,.inside_str_interp = 0,.inside_array_lit = 0,.inside_in_array = 0,.inside_match = 0,.inside_select = 0,.inside_match_case = 0,.inside_match_body = 0,.inside_unsafe = 0,.inside_sum_type = 0,.inside_asm_template = 0,.inside_asm = 0,.inside_defer = 0,.inside_generic_params = 0,.inside_receiver_param = 0,.inside_struct_field_decl = 0,.or_is_handled = 0,.builtin_mod = 0,.is_manualfree = 0,.has_globals = 0,.is_generated = 0,.is_translated = 0,.is_amp = 0,.returns = 0,.is_stmt_ident = 0,.expecting_type = 0,.name_error = 0,.comptime_if_cond = 0,.should_abort = 0,}); + v__parser__Parser p = ((v__parser__Parser){.imports = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.imported_symbols = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),.tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,},.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.ast_imports = __new_array(0, 0, sizeof(v__ast__Import)),.used_imports = __new_array(0, 0, sizeof(string)),.auto_imports = __new_array(0, 0, sizeof(string)),.errors = __new_array(0, 0, sizeof(v__errors__Error)),.warnings = __new_array(0, 0, sizeof(v__errors__Warning)),.notices = __new_array(0, 0, sizeof(v__errors__Notice)),.vet_errors = __new_array(0, 0, sizeof(v__vet__Error)),.label_names = __new_array(0, 0, sizeof(string)),.global_labels = __new_array(0, 0, sizeof(string)),.defer_vars = __new_array(0, 0, sizeof(v__ast__Ident)),.struct_init_generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.if_cond_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.file_base = (string){.str=(byteptr)"", .is_lit=1},.file_name = (string){.str=(byteptr)"", .is_lit=1},.file_name_dir = (string){.str=(byteptr)"", .is_lit=1},.unique_prefix = (string){.str=(byteptr)"", .is_lit=1},.mod = (string){.str=(byteptr)"", .is_lit=1},.expr_mod = (string){.str=(byteptr)"", .is_lit=1},.cur_fn_name = (string){.str=(byteptr)"", .is_lit=1},.codegen_text = (string){.str=(byteptr)"", .is_lit=1},.pref = ((v__pref__Preferences*)memdup(&(v__pref__Preferences){.cache_manager = (v__vcache__CacheManager){.basepath = (string){.str=(byteptr)"", .is_lit=1},.original_vopts = (string){.str=(byteptr)"", .is_lit=1},.vopts = (string){.str=(byteptr)"", .is_lit=1},.k2cpath = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),},.profile_fns = __new_array(0, 0, sizeof(string)),.lookup_path = __new_array(0, 0, sizeof(string)),.run_only = __new_array(0, 0, sizeof(string)),.compile_defines = __new_array(0, 0, sizeof(string)),.compile_defines_all = __new_array(0, 0, sizeof(string)),.run_args = __new_array(0, 0, sizeof(string)),.printfn_list = __new_array(0, 0, sizeof(string)),.cleanup_files = __new_array(0, 0, sizeof(string)),.build_options = __new_array(0, 0, sizeof(string)),.test_runner = (string){.str=(byteptr)"", .is_lit=1},.profile_file = (string){.str=(byteptr)"", .is_lit=1},.dump_c_flags = (string){.str=(byteptr)"", .is_lit=1},.cflags = (string){.str=(byteptr)"", .is_lit=1},.ccompiler = (string){.str=(byteptr)"", .is_lit=1},.third_party_option = (string){.str=(byteptr)"", .is_lit=1},.bare_builtin_dir = (string){.str=(byteptr)"", .is_lit=1},.custom_prelude = (string){.str=(byteptr)"", .is_lit=1},.vroot = (string){.str=(byteptr)"", .is_lit=1},.out_name_c = (string){.str=(byteptr)"", .is_lit=1},.out_name = (string){.str=(byteptr)"", .is_lit=1},.path = (string){.str=(byteptr)"", .is_lit=1},.message_limit = 100,.checker_match_exhaustive_cutoff_limit = 12,.thread_stack_size = 8388608,.os = 0,.arch = 0,.backend = 0,.ccompiler_type = 0,.gc_mode = v__pref__GarbageCollectionMode__no_gc,.use_color = 0,.assert_failure_mode = 0,.build_mode = 0,.output_mode = v__pref__OutputMode__stdout,.is_verbose = 0,.is_glibc = 0,.is_musl = 0,.is_test = 0,.is_script = 0,.is_vsh = 0,.is_livemain = 0,.is_liveshared = 0,.is_shared = 0,.is_o = 0,.is_prof = 0,.is_prod = 0,.is_repl = 0,.is_run = 0,.is_debug = 0,.is_vlines = 0,.is_stats = 0,.is_fmt = 0,.is_vet = 0,.is_vweb = 0,.is_ios_simulator = 0,.is_apk = 0,.is_help = 0,.is_cstrict = 0,.profile_no_inline = 0,.translated = 0,.obfuscate = 0,.sanitize = 0,.sourcemap = 0,.sourcemap_inline = true,.sourcemap_src_included = 0,.show_cc = 0,.show_c_output = 0,.show_callgraph = 0,.show_depgraph = 0,.use_cache = 0,.retry_compilation = true,.m64 = 0,.building_v = 0,.autofree = 0,.compress = 0,.no_builtin = 0,.enable_globals = 0,.is_bare = 0,.no_preludes = 0,.output_cross_c = 0,.output_es5 = 0,.prealloc = 0,.print_v_files = 0,.skip_running = 0,.skip_warnings = 0,.warn_impure_v = 0,.warns_are_errors = 0,.fatal_errors = 0,.reuse_tmpc = 0,.no_rsp = 0,.no_std = 0,.no_parallel = 0,.only_check_syntax = 0,.check_only = 0,.experimental = 0,.skip_unused = 0,.show_timings = 0,.nofloat = 0,}, sizeof(v__pref__Preferences))),.scanner = v__scanner__new_scanner(text, v__scanner__CommentsMode__skip_comments, ((v__pref__Preferences*)memdup(&(v__pref__Preferences){.cache_manager = (v__vcache__CacheManager){.basepath = (string){.str=(byteptr)"", .is_lit=1},.original_vopts = (string){.str=(byteptr)"", .is_lit=1},.vopts = (string){.str=(byteptr)"", .is_lit=1},.k2cpath = new_map(sizeof(string), sizeof(string), &map_hash_string, &map_eq_string, &map_clone_string, &map_free_string),},.profile_fns = __new_array(0, 0, sizeof(string)),.lookup_path = __new_array(0, 0, sizeof(string)),.run_only = __new_array(0, 0, sizeof(string)),.compile_defines = __new_array(0, 0, sizeof(string)),.compile_defines_all = __new_array(0, 0, sizeof(string)),.run_args = __new_array(0, 0, sizeof(string)),.printfn_list = __new_array(0, 0, sizeof(string)),.cleanup_files = __new_array(0, 0, sizeof(string)),.build_options = __new_array(0, 0, sizeof(string)),.test_runner = (string){.str=(byteptr)"", .is_lit=1},.profile_file = (string){.str=(byteptr)"", .is_lit=1},.dump_c_flags = (string){.str=(byteptr)"", .is_lit=1},.cflags = (string){.str=(byteptr)"", .is_lit=1},.ccompiler = (string){.str=(byteptr)"", .is_lit=1},.third_party_option = (string){.str=(byteptr)"", .is_lit=1},.bare_builtin_dir = (string){.str=(byteptr)"", .is_lit=1},.custom_prelude = (string){.str=(byteptr)"", .is_lit=1},.vroot = (string){.str=(byteptr)"", .is_lit=1},.out_name_c = (string){.str=(byteptr)"", .is_lit=1},.out_name = (string){.str=(byteptr)"", .is_lit=1},.path = (string){.str=(byteptr)"", .is_lit=1},.message_limit = 100,.checker_match_exhaustive_cutoff_limit = 12,.thread_stack_size = 8388608,.os = 0,.arch = 0,.backend = 0,.ccompiler_type = 0,.gc_mode = v__pref__GarbageCollectionMode__no_gc,.use_color = 0,.assert_failure_mode = 0,.build_mode = 0,.output_mode = v__pref__OutputMode__stdout,.is_verbose = 0,.is_glibc = 0,.is_musl = 0,.is_test = 0,.is_script = 0,.is_vsh = 0,.is_livemain = 0,.is_liveshared = 0,.is_shared = 0,.is_o = 0,.is_prof = 0,.is_prod = 0,.is_repl = 0,.is_run = 0,.is_debug = 0,.is_vlines = 0,.is_stats = 0,.is_fmt = 0,.is_vet = 0,.is_vweb = 0,.is_ios_simulator = 0,.is_apk = 0,.is_help = 0,.is_cstrict = 0,.profile_no_inline = 0,.translated = 0,.obfuscate = 0,.sanitize = 0,.sourcemap = 0,.sourcemap_inline = true,.sourcemap_src_included = 0,.show_cc = 0,.show_c_output = 0,.show_callgraph = 0,.show_depgraph = 0,.use_cache = 0,.retry_compilation = true,.m64 = 0,.building_v = 0,.autofree = 0,.compress = 0,.no_builtin = 0,.enable_globals = 0,.is_bare = 0,.no_preludes = 0,.output_cross_c = 0,.output_es5 = 0,.prealloc = 0,.print_v_files = 0,.skip_running = 0,.skip_warnings = 0,.warn_impure_v = 0,.warns_are_errors = 0,.fatal_errors = 0,.reuse_tmpc = 0,.no_rsp = 0,.no_std = 0,.no_parallel = 0,.only_check_syntax = 0,.check_only = 0,.experimental = 0,.skip_unused = 0,.show_timings = 0,.nofloat = 0,}, sizeof(v__pref__Preferences)))),.table = table,.scope = scope,.expr_level = 0,.n_asm = 0,.file_backend_mode = 0,.language = 0,.fn_language = 0,.comments_mode = v__scanner__CommentsMode__skip_comments,.inside_vlib_file = 0,.inside_test_file = true,.inside_if = 0,.inside_if_expr = 0,.inside_if_cond = 0,.inside_ct_if_expr = 0,.inside_or_expr = 0,.inside_for = 0,.inside_fn = 0,.inside_fn_return = 0,.inside_unsafe_fn = 0,.inside_str_interp = 0,.inside_array_lit = 0,.inside_in_array = 0,.inside_match = 0,.inside_select = 0,.inside_match_case = 0,.inside_match_body = 0,.inside_unsafe = 0,.inside_sum_type = 0,.inside_asm_template = 0,.inside_asm = 0,.inside_defer = 0,.inside_generic_params = 0,.inside_receiver_param = 0,.inside_struct_field_decl = 0,.or_is_handled = 0,.builtin_mod = 0,.is_manualfree = 0,.has_globals = 0,.is_generated = 0,.is_translated = 0,.is_amp = 0,.returns = 0,.is_stmt_ident = 0,.expecting_type = 0,.name_error = 0,.comptime_if_cond = 0,.should_abort = 0,.script_mode = 0,}); v__parser__Parser_init_parse_fns(&p); v__util__timing_start(_SLIT("PARSE stmt")); v__parser__parse_stmt_defer_0 = true; @@ -87958,6 +87942,7 @@ v__ast__File* v__parser__parse_comptime(string tmpl_path, string text, v__ast__T .tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, + .script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), .ast_imports = __new_array(0, 0, sizeof(v__ast__Import)), .used_imports = __new_array(0, 0, sizeof(string)), @@ -88028,6 +88013,7 @@ v__ast__File* v__parser__parse_comptime(string tmpl_path, string text, v__ast__T .name_error = 0, .comptime_if_cond = 0, .should_abort = 0, + .script_mode = 0, }); v__ast__File* res = v__parser__Parser_parse(&p); v__parser__Parser_free_scanner(&p); @@ -88042,6 +88028,7 @@ v__ast__File* v__parser__parse_text(string text, string path, v__ast__Table* tab .tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, + .script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), .ast_imports = __new_array(0, 0, sizeof(v__ast__Import)), .used_imports = __new_array(0, 0, sizeof(string)), @@ -88112,6 +88099,7 @@ v__ast__File* v__parser__parse_text(string text, string path, v__ast__Table* tab .name_error = 0, .comptime_if_cond = 0, .should_abort = 0, + .script_mode = 0, }); v__parser__Parser_set_path(&p, path); v__ast__File* res = v__parser__Parser_parse(&p); @@ -88188,6 +88176,7 @@ v__ast__File* v__parser__parse_file(string path, v__ast__Table* table, v__scanne .tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, + .script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), .ast_imports = __new_array(0, 0, sizeof(v__ast__Import)), .used_imports = __new_array(0, 0, sizeof(string)), @@ -88258,6 +88247,7 @@ v__ast__File* v__parser__parse_file(string path, v__ast__Table* table, v__scanne .name_error = 0, .comptime_if_cond = 0, .should_abort = 0, + .script_mode = 0, }); v__parser__Parser_set_path(&p, path); v__ast__File* res = v__parser__Parser_parse(&p); @@ -88282,6 +88272,7 @@ multi_return_ref_v__ast__File_Array_v__vet__Error v__parser__parse_vet_file(stri .tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .prev_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .peek_tok = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, + .script_mode_start_token = (v__token__Token){.lit = (string){.str=(byteptr)"", .is_lit=1},.line_nr = 0,.col = 0,.pos = 0,.len = 0,.tidx = 0,}, .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), .ast_imports = __new_array(0, 0, sizeof(v__ast__Import)), .used_imports = __new_array(0, 0, sizeof(string)), @@ -88352,6 +88343,7 @@ multi_return_ref_v__ast__File_Array_v__vet__Error v__parser__parse_vet_file(stri .name_error = 0, .comptime_if_cond = 0, .should_abort = 0, + .script_mode = 0, }); v__parser__Parser_set_path(&p, path); if (string_contains_any_substr(p.scanner->text, new_array_from_c_array(2, 2, sizeof(string), _MOV((string[2]){_SLIT("\n "), _SLIT(" \n")})))) { @@ -88702,33 +88694,39 @@ v__ast__Stmt v__parser__Parser_top_stmt(v__parser__Parser* p) { return _t14; } else if (p->tok.kind == (v__token__Kind__dollar)) { + if (p->peek_tok.kind == v__token__Kind__eof) { + v__ast__Stmt _t15 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error(p, _SLIT("unexpected eof"))))); + return _t15; + } v__ast__IfExpr if_expr = v__parser__Parser_if_expr(p, true); - v__ast__Stmt _t15 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = if_expr.pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__IfExpr_to_sumtype_v__ast__Expr(&if_expr),.is_expr = 0,.typ = 0,})))); - return _t15; - } - else if (p->tok.kind == (v__token__Kind__hash)) { - v__ast__Stmt _t16 = v__ast__HashStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__HashStmt, (v__parser__Parser_hash(p)))); + v__ast__Stmt _t16 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (((v__ast__ExprStmt){.pos = if_expr.pos,.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.expr = v__ast__IfExpr_to_sumtype_v__ast__Expr(&if_expr),.is_expr = 0,.typ = 0,})))); return _t16; } - else if (p->tok.kind == (v__token__Kind__key_type)) { - v__ast__Stmt _t17 = v__ast__TypeDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__TypeDecl, (v__parser__Parser_type_decl(p)))); + else if (p->tok.kind == (v__token__Kind__hash)) { + v__ast__Stmt _t17 = v__ast__HashStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__HashStmt, (v__parser__Parser_hash(p)))); return _t17; } - else if (p->tok.kind == (v__token__Kind__key_enum)) { - v__ast__Stmt _t18 = v__ast__EnumDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__EnumDecl, (v__parser__Parser_enum_decl(p)))); + else if (p->tok.kind == (v__token__Kind__key_type)) { + v__ast__Stmt _t18 = v__ast__TypeDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__TypeDecl, (v__parser__Parser_type_decl(p)))); return _t18; } - else if (p->tok.kind == (v__token__Kind__key_union)) { - v__ast__Stmt _t19 = v__ast__StructDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__StructDecl, (v__parser__Parser_struct_decl(p)))); + else if (p->tok.kind == (v__token__Kind__key_enum)) { + v__ast__Stmt _t19 = v__ast__EnumDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__EnumDecl, (v__parser__Parser_enum_decl(p)))); return _t19; } - else if (p->tok.kind == (v__token__Kind__comment)) { - v__ast__Stmt _t20 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (v__parser__Parser_comment_stmt(p)))); + else if (p->tok.kind == (v__token__Kind__key_union)) { + v__ast__Stmt _t20 = v__ast__StructDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__StructDecl, (v__parser__Parser_struct_decl(p)))); return _t20; } + else if (p->tok.kind == (v__token__Kind__comment)) { + v__ast__Stmt _t21 = v__ast__ExprStmt_to_sumtype_v__ast__Stmt(ADDR(v__ast__ExprStmt, (v__parser__Parser_comment_stmt(p)))); + return _t21; + } else { p->inside_fn = true; if (p->pref->is_script && !p->pref->is_test) { + p->script_mode = true; + p->script_mode_start_token = p->tok; v__parser__Parser_open_scope(p); Array_v__ast__Stmt stmts = __new_array_with_default(0, 0, sizeof(v__ast__Stmt), 0); for (;;) { @@ -88736,7 +88734,8 @@ v__ast__Stmt v__parser__Parser_top_stmt(v__parser__Parser* p) { array_push((array*)&stmts, _MOV((v__ast__Stmt[]){ v__parser__Parser_stmt(p, false) })); } v__parser__Parser_close_scope(p); - v__ast__Stmt _t22 = v__ast__FnDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__FnDecl, (((v__ast__FnDecl){ + p->script_mode = false; + v__ast__Stmt _t23 = v__ast__FnDecl_to_sumtype_v__ast__Stmt(ADDR(v__ast__FnDecl, (((v__ast__FnDecl){ .receiver = (v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,}, .generic_names = __new_array(0, 0, sizeof(string)), .attrs = __new_array(0, 0, sizeof(v__ast__Attr)), @@ -88788,21 +88787,21 @@ v__ast__Stmt v__parser__Parser_top_stmt(v__parser__Parser* p) { .should_be_skipped = 0, .has_await = 0, })))); - return _t22; - } else if (p->pref->is_fmt) { - v__ast__Stmt _t23 = v__parser__Parser_stmt(p, false); return _t23; - } else { - v__ast__Stmt _t24 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error(p, string__plus(_SLIT("bad top level statement "), v__token__Token_str(p->tok)))))); + } else if (p->pref->is_fmt) { + v__ast__Stmt _t24 = v__parser__Parser_stmt(p, false); return _t24; + } else { + v__ast__Stmt _t25 = v__ast__NodeError_to_sumtype_v__ast__Stmt(ADDR(v__ast__NodeError, (v__parser__Parser_error(p, string__plus(_SLIT("bad top level statement "), v__token__Token_str(p->tok)))))); + return _t25; } }; if (p->should_abort) { break; } } - v__ast__Stmt _t25 = v__ast__empty_stmt(); - return _t25; + v__ast__Stmt _t26 = v__ast__empty_stmt(); + return _t26; } v__ast__Comment v__parser__Parser_check_comment(v__parser__Parser* p) { @@ -89607,7 +89606,7 @@ VV_LOCAL_SYMBOL Array_v__ast__AsmIO v__parser__Parser_asm_ios(v__parser__Parser* if (p->tok.kind == v__token__Kind__lpar) { constraint = (output ? (_SLIT("+r")) : (_SLIT("r"))); } else { - constraint = /*f*/string__plus(constraint, ((p->tok.kind == (v__token__Kind__assign)) ? (_SLIT("=")) : (p->tok.kind == (v__token__Kind__plus)) ? (_SLIT("+")) : (p->tok.kind == (v__token__Kind__mod)) ? (_SLIT("%")) : (p->tok.kind == (v__token__Kind__amp)) ? (_SLIT("&")) : (_SLIT("")))); + constraint = /*f*/string__plus(constraint, ((p->tok.kind == (v__token__Kind__assign))? (_SLIT("=")) : (p->tok.kind == (v__token__Kind__plus))? (_SLIT("+")) : (p->tok.kind == (v__token__Kind__mod))? (_SLIT("%")) : (p->tok.kind == (v__token__Kind__amp))? (_SLIT("&")) : (_SLIT("")))); if ((constraint).len != 0) { v__parser__Parser_next(p); } @@ -89964,9 +89963,9 @@ VV_LOCAL_SYMBOL v__ast__Stmt v__parser__Parser_parse_multi_expr(v__parser__Parse v__token__Pos pos = v__token__Token_pos(&tok); Array_v__ast__Ident defer_vars = p->defer_vars; p->defer_vars = __new_array_with_default(0, 0, sizeof(v__ast__Ident), 0); - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_48067 = v__parser__Parser_expr_list(p); - Array_v__ast__Expr left = mr_48067.arg0; - Array_v__ast__Comment left_comments = mr_48067.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_48309 = v__parser__Parser_expr_list(p); + Array_v__ast__Expr left = mr_48309.arg0; + Array_v__ast__Comment left_comments = mr_48309.arg1; if (!(p->inside_defer && p->tok.kind == v__token__Kind__decl_assign)) { _PUSH_MANY(&defer_vars, (p->defer_vars), _t1, Array_v__ast__Ident); } @@ -90380,7 +90379,7 @@ v__ast__Expr v__parser__Parser_name_expr(v__parser__Parser* p) { string name = v__parser__Parser_check_name(p); v__parser__Parser_check(p, v__token__Kind__dot); string field = v__parser__Parser_check_name(p); - v__ast__GenericKindField fkind = ((string__eq(field, _SLIT("name"))) ? (v__ast__GenericKindField__name) : (string__eq(field, _SLIT("typ"))) ? (v__ast__GenericKindField__typ) : (v__ast__GenericKindField__unknown)); + v__ast__GenericKindField fkind = ((string__eq(field, _SLIT("name")))? (v__ast__GenericKindField__name) : (string__eq(field, _SLIT("typ")))? (v__ast__GenericKindField__typ) : (v__ast__GenericKindField__unknown)); v__token__Pos_extend(pos, v__token__Token_pos(&p->tok)); v__ast__Expr _t21 = v__ast__SelectorExpr_to_sumtype_v__ast__Expr(ADDR(v__ast__SelectorExpr, (((v__ast__SelectorExpr){.from_embed_types = __new_array(0, 0, sizeof(v__ast__Type)),.field_name = field,.expr = v__ast__Ident_to_sumtype_v__ast__Expr(ADDR(v__ast__Ident, (((v__ast__Ident){.obj = {0},.mod = (string){.str=(byteptr)"", .is_lit=1},.name = name,.info = {0},.scope = p->scope,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.tok_kind = 0,.language = 0,.kind = 0,.comptime = 0,.is_mut = 0,})))),.scope = p->scope,.pos = pos,.mut_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.expr_type = 0,.typ = 0,.name_type = 0,.next_token = 0,.gkind_field = fkind,.is_mut = 0,})))); return _t21; @@ -91162,6 +91161,10 @@ VV_LOCAL_SYMBOL v__ast__ConstDecl v__parser__Parser_const_decl(v__parser__Parser v__parser__Parser_next(p); } v__token__Pos const_pos = v__token__Token_pos(&p->tok); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__ConstDecl _t2 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); + return _t2; + } v__parser__Parser_check(p, v__token__Kind__key_const); bool is_block = p->tok.kind == v__token__Kind__lpar; if (is_block) { @@ -91174,30 +91177,30 @@ VV_LOCAL_SYMBOL v__ast__ConstDecl v__parser__Parser_const_decl(v__parser__Parser comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,})); if (is_block && p->tok.kind == v__token__Kind__eof) { v__parser__Parser_error(p, _SLIT("unexpected eof, expecting \302\264)\302\264")); - v__ast__ConstDecl _t2 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); - return _t2; + v__ast__ConstDecl _t3 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); + return _t3; } if (p->tok.kind == v__token__Kind__rpar) { break; } v__token__Pos pos = v__token__Token_pos(&p->tok); string name = v__parser__Parser_check_name(p); - _PUSH_MANY(&end_comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t3, Array_v__ast__Comment); + _PUSH_MANY(&end_comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t4, Array_v__ast__Comment); if (v__util__contains_capital(name)) { v__parser__Parser_warn_with_pos(p, _SLIT("const names cannot contain uppercase letters, use snake_case instead"), pos); } string full_name = v__parser__Parser_prepend_mod(p, name); v__parser__Parser_check(p, v__token__Kind__assign); - _PUSH_MANY(&end_comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t4, Array_v__ast__Comment); + _PUSH_MANY(&end_comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t5, Array_v__ast__Comment); if (p->tok.kind == v__token__Kind__key_fn) { v__parser__Parser_error(p, _SLIT("const initializer fn literal is not a constant")); - v__ast__ConstDecl _t5 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); - return _t5; + v__ast__ConstDecl _t6 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); + return _t6; } if (p->tok.kind == v__token__Kind__eof) { v__parser__Parser_error(p, _SLIT("unexpected eof, expecting an expression")); - v__ast__ConstDecl _t6 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); - return _t6; + v__ast__ConstDecl _t7 = ((v__ast__ConstDecl){.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__ConstField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_block = 0,}); + return _t7; } v__ast__Expr expr = v__parser__Parser_expr(p, 0); v__ast__ConstField field = ((v__ast__ConstField){ @@ -91223,9 +91226,9 @@ VV_LOCAL_SYMBOL v__ast__ConstDecl v__parser__Parser_const_decl(v__parser__Parser if (is_block) { v__parser__Parser_check(p, v__token__Kind__rpar); } else { - _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,}))), _t8, Array_v__ast__Comment); + _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,}))), _t9, Array_v__ast__Comment); } - v__ast__ConstDecl _t9 = ((v__ast__ConstDecl){ + v__ast__ConstDecl _t10 = ((v__ast__ConstDecl){ .attrs = attrs, .fields = fields, .end_comments = comments, @@ -91233,7 +91236,7 @@ VV_LOCAL_SYMBOL v__ast__ConstDecl v__parser__Parser_const_decl(v__parser__Parser .is_pub = is_pub, .is_block = is_block, }); - return _t9; + return _t10; } VV_LOCAL_SYMBOL v__ast__Return v__parser__Parser_return_stmt(v__parser__Parser* p) { @@ -91244,9 +91247,9 @@ VV_LOCAL_SYMBOL v__ast__Return v__parser__Parser_return_stmt(v__parser__Parser* v__ast__Return _t1 = ((v__ast__Return){.pos = first_pos,.comments = comments,.exprs = __new_array(0, 0, sizeof(v__ast__Expr)),.types = __new_array(0, 0, sizeof(v__ast__Type)),}); return _t1; } - multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_84732 = v__parser__Parser_expr_list(p); - Array_v__ast__Expr exprs = mr_84732.arg0; - Array_v__ast__Comment comments2 = mr_84732.arg1; + multi_return_Array_v__ast__Expr_Array_v__ast__Comment mr_85049 = v__parser__Parser_expr_list(p); + Array_v__ast__Expr exprs = mr_85049.arg0; + Array_v__ast__Comment comments2 = mr_85049.arg1; _PUSH_MANY(&comments, (comments2), _t2, Array_v__ast__Comment); v__token__Pos end_pos = v__ast__Expr_pos((*(v__ast__Expr*)array_last(exprs))); v__ast__Return _t3 = ((v__ast__Return){.pos = v__token__Pos_extend(first_pos, end_pos),.comments = comments,.exprs = exprs,.types = __new_array(0, 0, sizeof(v__ast__Type)),}); @@ -91276,6 +91279,10 @@ VV_LOCAL_SYMBOL v__ast__GlobalDecl v__parser__Parser_global_decl(v__parser__Pars } v__token__Pos start_pos = v__token__Token_pos(&p->tok); v__parser__Parser_check(p, v__token__Kind__key_global); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__GlobalDecl _t3 = ((v__ast__GlobalDecl){.mod = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_block = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__GlobalField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),}); + return _t3; + } bool is_block = p->tok.kind == v__token__Kind__lpar; if (is_block) { v__parser__Parser_next(p); @@ -91290,8 +91297,8 @@ VV_LOCAL_SYMBOL v__ast__GlobalDecl v__parser__Parser_global_decl(v__parser__Pars } if (is_block && p->tok.kind == v__token__Kind__eof) { v__parser__Parser_error(p, _SLIT("unexpected eof, expecting `)`")); - v__ast__GlobalDecl _t3 = ((v__ast__GlobalDecl){.mod = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_block = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__GlobalField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),}); - return _t3; + v__ast__GlobalDecl _t4 = ((v__ast__GlobalDecl){.mod = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_block = 0,.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.fields = __new_array(0, 0, sizeof(v__ast__GlobalField)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),}); + return _t4; } if (p->tok.kind == v__token__Kind__rpar) { break; @@ -91370,7 +91377,7 @@ VV_LOCAL_SYMBOL v__ast__GlobalDecl v__parser__Parser_global_decl(v__parser__Pars if (is_block) { v__parser__Parser_check(p, v__token__Kind__rpar); } - v__ast__GlobalDecl _t5 = ((v__ast__GlobalDecl){ + v__ast__GlobalDecl _t6 = ((v__ast__GlobalDecl){ .mod = p->mod, .pos = v__token__Pos_extend(start_pos, v__token__Token_pos(&p->prev_tok)), .is_block = is_block, @@ -91378,7 +91385,7 @@ VV_LOCAL_SYMBOL v__ast__GlobalDecl v__parser__Parser_global_decl(v__parser__Pars .fields = fields, .end_comments = comments, }); - return _t5; + return _t6; } VV_LOCAL_SYMBOL v__ast__EnumDecl v__parser__Parser_enum_decl(v__parser__Parser* p) { @@ -91390,17 +91397,21 @@ VV_LOCAL_SYMBOL v__ast__EnumDecl v__parser__Parser_enum_decl(v__parser__Parser* } v__parser__Parser_check(p, v__token__Kind__key_enum); v__token__Pos end_pos = v__token__Token_pos(&p->tok); - string enum_name = v__parser__Parser_check_name(p); - if (enum_name.len == 1) { - v__parser__Parser_error_with_pos(p, _SLIT("single letter capital names are reserved for generic template types."), end_pos); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { v__ast__EnumDecl _t1 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); return _t1; } - if (_IN_MAP(ADDR(string, enum_name), ADDR(map, p->imported_symbols))) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register enum `"), /*115 &string*/0xfe10, {.d_s = enum_name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), end_pos); + string enum_name = v__parser__Parser_check_name(p); + if (enum_name.len == 1) { + v__parser__Parser_error_with_pos(p, _SLIT("single letter capital names are reserved for generic template types."), end_pos); v__ast__EnumDecl _t2 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); return _t2; } + if (_IN_MAP(ADDR(string, enum_name), ADDR(map, p->imported_symbols))) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register enum `"), /*115 &string*/0xfe10, {.d_s = enum_name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), end_pos); + v__ast__EnumDecl _t3 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); + return _t3; + } string name = v__parser__Parser_prepend_mod(p, enum_name); v__parser__Parser_check(p, v__token__Kind__lcbr); Array_v__ast__Comment enum_decl_comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,})); @@ -91436,15 +91447,15 @@ VV_LOCAL_SYMBOL v__ast__EnumDecl v__parser__Parser_enum_decl(v__parser__Parser* if (is_flag) { if (fields.len > 32) { v__parser__Parser_error(p, _SLIT("when an enum is used as bit field, it must have a max of 32 fields")); - v__ast__EnumDecl _t5 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); - return _t5; + v__ast__EnumDecl _t6 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); + return _t6; } - for (int _t6 = 0; _t6 < fields.len; ++_t6) { - v__ast__EnumField f = ((v__ast__EnumField*)fields.data)[_t6]; + for (int _t7 = 0; _t7 < fields.len; ++_t7) { + v__ast__EnumField f = ((v__ast__EnumField*)fields.data)[_t7]; if (f.has_expr) { v__parser__Parser_error_with_pos(p, _SLIT("when an enum is used as a bit field, you can not assign custom values"), f.pos); - v__ast__EnumDecl _t7 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); - return _t7; + v__ast__EnumDecl _t8 = ((v__ast__EnumDecl){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.fields = __new_array(0, 0, sizeof(v__ast__EnumField)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.is_pub = 0,.is_flag = 0,.is_multi_allowed = 0,}); + return _t8; } } string pubfn = (string__eq(p->mod, _SLIT("main")) ? (_SLIT("fn")) : (_SLIT("pub fn"))); @@ -91478,8 +91489,8 @@ VV_LOCAL_SYMBOL v__ast__EnumDecl v__parser__Parser_enum_decl(v__parser__Parser* .is_multi_allowed = is_multi_allowed, }); v__ast__Table_register_enum_decl(p->table, enum_decl); - v__ast__EnumDecl _t8 = enum_decl; - return _t8; + v__ast__EnumDecl _t9 = enum_decl; + return _t9; } VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* p) { @@ -91492,20 +91503,24 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* v__token__Pos end_pos = v__token__Token_pos(&p->tok); v__token__Pos decl_pos = v__token__Pos_extend(start_pos, end_pos); v__token__Pos name_pos = v__token__Token_pos(&p->tok); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__TypeDecl _t1 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_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)),.typ = 0,.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.variants = __new_array(0, 0, sizeof(v__ast__TypeNode)),})))); + return _t1; + } string name = v__parser__Parser_check_name(p); if (name.len == 1 && u8_is_capital(string_at(name, 0))) { v__parser__Parser_error_with_pos(p, _SLIT("single letter capital names are reserved for generic template types."), decl_pos); - v__ast__TypeDecl _t1 = v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__FnTypeDecl, (((v__ast__FnTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.typ = 0,.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)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),})))); - return _t1; + v__ast__TypeDecl _t2 = v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__FnTypeDecl, (((v__ast__FnTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.typ = 0,.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)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),})))); + return _t2; } if (_IN_MAP(ADDR(string, name), ADDR(map, p->imported_symbols))) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register alias `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), end_pos); - v__ast__TypeDecl _t2 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t2; + v__ast__TypeDecl _t3 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t3; } Array_v__ast__TypeNode sum_variants = __new_array_with_default(0, 0, sizeof(v__ast__TypeNode), 0); - multi_return_Array_v__ast__Type_Array_string mr_91001 = v__parser__Parser_parse_generic_types(p); - Array_v__ast__Type generic_types = mr_91001.arg0; + multi_return_Array_v__ast__Type_Array_string mr_91545 = v__parser__Parser_parse_generic_types(p); + Array_v__ast__Type generic_types = mr_91545.arg0; v__token__Pos decl_pos_with_generics = v__token__Pos_extend(decl_pos, v__token__Token_pos(&p->prev_tok)); v__parser__Parser_check(p, v__token__Kind__assign); v__token__Pos type_pos = v__token__Token_pos(&p->tok); @@ -91518,7 +91533,7 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,})); Array_v__ast__Attr attrs = p->attrs; p->attrs = __new_array_with_default(0, 0, sizeof(v__ast__Attr), 0); - v__ast__TypeDecl _t3 = v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__FnTypeDecl, (((v__ast__FnTypeDecl){ + v__ast__TypeDecl _t4 = v__ast__FnTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__FnTypeDecl, (((v__ast__FnTypeDecl){ .name = fn_name, .is_pub = is_pub, .typ = fn_type, @@ -91527,30 +91542,30 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* .comments = comments, .attrs = attrs, })))); - return _t3; + return _t4; } - _PUSH_MANY(&sum_variants, (v__parser__Parser_parse_sum_type_variants(p)), _t4, Array_v__ast__TypeNode); + _PUSH_MANY(&sum_variants, (v__parser__Parser_parse_sum_type_variants(p)), _t5, Array_v__ast__TypeNode); if (sum_variants.len > 1) { - for (int _t5 = 0; _t5 < sum_variants.len; ++_t5) { - v__ast__TypeNode variant = ((v__ast__TypeNode*)sum_variants.data)[_t5]; + for (int _t6 = 0; _t6 < sum_variants.len; ++_t6) { + v__ast__TypeNode variant = ((v__ast__TypeNode*)sum_variants.data)[_t6]; v__ast__TypeSymbol* variant_sym = v__ast__Table_sym(p->table, variant.typ); if (variant_sym->kind == v__ast__Kind__none_) { v__parser__Parser_error_with_pos(p, _SLIT("named sum type cannot have none as its variant"), variant.pos); - v__ast__TypeDecl _t6 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t6; + v__ast__TypeDecl _t7 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t7; } } - Array_v__ast__Type _t7 = {0}; - Array_v__ast__TypeNode _t7_orig = sum_variants; - int _t7_len = _t7_orig.len; - _t7 = __new_array(0, _t7_len, sizeof(v__ast__Type)); + Array_v__ast__Type _t8 = {0}; + Array_v__ast__TypeNode _t8_orig = sum_variants; + int _t8_len = _t8_orig.len; + _t8 = __new_array(0, _t8_len, sizeof(v__ast__Type)); - for (int _t8 = 0; _t8 < _t7_len; ++_t8) { - v__ast__TypeNode it = ((v__ast__TypeNode*) _t7_orig.data)[_t8]; + for (int _t9 = 0; _t9 < _t8_len; ++_t9) { + v__ast__TypeNode it = ((v__ast__TypeNode*) _t8_orig.data)[_t9]; v__ast__Type ti = it.typ; - array_push((array*)&_t7, &ti); + array_push((array*)&_t8, &ti); } - Array_v__ast__Type variant_types =_t7; + Array_v__ast__Type variant_types =_t8; string prepend_mod_name = v__parser__Parser_prepend_mod(p, name); int typ = v__ast__Table_register_sym(p->table, ((v__ast__TypeSymbol){ .methods = __new_array(0, 0, sizeof(v__ast__Fn)), @@ -91568,26 +91583,27 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* })); if (typ == _const_v__ast__invalid_type_idx) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register sum type `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); - v__ast__TypeDecl _t9 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.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)),.typ = 0,.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.variants = __new_array(0, 0, sizeof(v__ast__TypeNode)),})))); - return _t9; + v__ast__TypeDecl _t10 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.name_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)),.typ = 0,.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.variants = __new_array(0, 0, sizeof(v__ast__TypeNode)),})))); + return _t10; } comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,})); - v__ast__TypeDecl _t10 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){ + v__ast__TypeDecl _t11 = v__ast__SumTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__SumTypeDecl, (((v__ast__SumTypeDecl){ .name = name, .is_pub = is_pub, .pos = decl_pos, + .name_pos = name_pos, .comments = comments, .typ = typ, .generic_types = generic_types, .attrs = p->attrs, .variants = sum_variants, })))); - return _t10; + return _t11; } if (generic_types.len > 0) { v__parser__Parser_error_with_pos(p, _SLIT("generic type aliases are not yet implemented"), decl_pos_with_generics); - v__ast__TypeDecl _t11 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t11; + v__ast__TypeDecl _t12 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t12; } v__ast__Type parent_type = (*(v__ast__TypeNode*)/*ee elem_sym */array_get(sum_variants, 0)).typ; v__ast__TypeSymbol* parent_sym = v__ast__Table_sym(p->table, parent_type); @@ -91611,17 +91627,17 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* v__token__Pos type_end_pos = v__token__Token_pos(&p->prev_tok); if (idx == _const_v__ast__invalid_type_idx) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register alias `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); - v__ast__TypeDecl _t12 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t12; + v__ast__TypeDecl _t13 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t13; } if (idx == pidx) { v__token__Pos type_alias_pos = (*(v__ast__TypeNode*)/*ee elem_sym */array_get(sum_variants, 0)).pos; v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("a type alias can not refer to itself: "), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT0, 0, { .d_c = 0 }}})), v__token__Pos_extend(decl_pos, type_alias_pos)); - v__ast__TypeDecl _t13 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); - return _t13; + v__ast__TypeDecl _t14 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){.name = (string){.str=(byteptr)"", .is_lit=1},.is_pub = 0,.parent_type = 0,.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)),})))); + return _t14; } comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = true,.follow_up = 0,})); - v__ast__TypeDecl _t14 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){ + v__ast__TypeDecl _t15 = v__ast__AliasTypeDecl_to_sumtype_v__ast__TypeDecl(ADDR(v__ast__AliasTypeDecl, (((v__ast__AliasTypeDecl){ .name = name, .is_pub = is_pub, .parent_type = parent_type, @@ -91629,7 +91645,7 @@ VV_LOCAL_SYMBOL v__ast__TypeDecl v__parser__Parser_type_decl(v__parser__Parser* .type_pos = v__token__Pos_extend(type_pos, type_end_pos), .comments = comments, })))); - return _t14; + return _t15; } VV_LOCAL_SYMBOL v__ast__Assoc v__parser__Parser_assoc(v__parser__Parser* p) { @@ -91787,6 +91803,17 @@ bool v__parser__Parser_unsafe_stmt_defer_0 = false; return _t6; } +VV_LOCAL_SYMBOL bool v__parser__Parser_disallow_declarations_in_script_mode(v__parser__Parser* p) { + if (p->script_mode) { + v__parser__Parser_note_with_pos(p, _SLIT("script mode started here"), v__token__Token_pos(&p->script_mode_start_token)); + v__parser__Parser_error_with_pos(p, _SLIT("all definitions must occur before code in script mode"), v__token__Token_pos(&p->tok)); + bool _t1 = true; + return _t1; + } + bool _t2 = false; + return _t2; +} + VV_LOCAL_SYMBOL void v__parser__Parser_trace(v__parser__Parser* p, string fbase, string message) { if (string__eq(p->file_base, fbase)) { println( str_intp(3, _MOV((StrIntpData[]){{_SLIT("> p.trace | "), /*115 &string*/0x14fe10, {.d_s = fbase}}, {_SLIT(" | "), /*115 &string*/0xfe10, {.d_s = message}}, {_SLIT0, 0, { .d_c = 0 }}}))); @@ -92087,32 +92114,26 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } v__token__Pos name_pos = v__token__Token_pos(&p->tok); v__parser__Parser_check_for_impure_v(p, language, name_pos); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__StructDecl _t1 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + return _t1; + } string name = v__parser__Parser_check_name(p); if (name.len == 1 && u8_is_capital(string_at(name, 0))) { v__parser__Parser_error_with_pos(p, _SLIT("single letter capital names are reserved for generic template types."), name_pos); - v__ast__StructDecl _t1 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - return _t1; + v__ast__StructDecl _t2 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + return _t2; } if (string__eq(name, _SLIT("IError")) && !string__eq(p->mod, _SLIT("builtin"))) { v__parser__Parser_error_with_pos(p, _SLIT("cannot register struct `IError`, it is builtin interface type"), name_pos); } v__ast__Table_start_parsing_type(p->table, v__parser__Parser_prepend_mod(p, name)); v__parser__Parser_struct_decl_defer_0 = true; - multi_return_Array_v__ast__Type_Array_string mr_1547 = v__parser__Parser_parse_generic_types(p); - Array_v__ast__Type generic_types = mr_1547.arg0; + multi_return_Array_v__ast__Type_Array_string mr_1623 = v__parser__Parser_parse_generic_types(p); + Array_v__ast__Type generic_types = mr_1623.arg0; bool no_body = p->tok.kind != v__token__Kind__lcbr; if (language == v__ast__Language__v && no_body) { v__parser__Parser_error(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("`"), /*115 &string*/0xfe10, {.d_s = p->tok.lit}}, {_SLIT("` lacks body"), 0, { .d_c = 0 }}}))); - v__ast__StructDecl _t2 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - // Defer begin - if (v__parser__Parser_struct_decl_defer_0) { - v__ast__Table_reset_parsing_type(p->table); - } - // Defer end - return _t2; - } - if (language == v__ast__Language__v && !p->builtin_mod && !p->is_translated && name.len > 0 && !u8_is_capital(string_at(name, 0)) && !p->pref->translated && !p->is_translated) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct name `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("` must begin with capital letter"), 0, { .d_c = 0 }}})), name_pos); v__ast__StructDecl _t3 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -92121,8 +92142,8 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t3; } - if (name.len == 1) { - v__parser__Parser_error_with_pos(p, _SLIT("struct names must have more than one character"), name_pos); + if (language == v__ast__Language__v && !p->builtin_mod && !p->is_translated && name.len > 0 && !u8_is_capital(string_at(name, 0)) && !p->pref->translated && !p->is_translated) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("struct name `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("` must begin with capital letter"), 0, { .d_c = 0 }}})), name_pos); v__ast__StructDecl _t4 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -92131,8 +92152,8 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t4; } - if (_IN_MAP(ADDR(string, name), ADDR(map, p->imported_symbols))) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register struct `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), name_pos); + if (name.len == 1) { + v__parser__Parser_error_with_pos(p, _SLIT("struct names must have more than one character"), name_pos); v__ast__StructDecl _t5 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -92141,6 +92162,16 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t5; } + if (_IN_MAP(ADDR(string, name), ADDR(map, p->imported_symbols))) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register struct `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), name_pos); + v__ast__StructDecl _t6 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + // Defer begin + if (v__parser__Parser_struct_decl_defer_0) { + v__ast__Table_reset_parsing_type(p->table); + } + // Defer end + return _t6; + } string orig_name = name; if (language == v__ast__Language__c) { name = str_intp(2, _MOV((StrIntpData[]){{_SLIT("C."), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT0, 0, { .d_c = 0 }}})); @@ -92188,13 +92219,13 @@ bool v__parser__Parser_struct_decl_defer_0 = false; if (p->tok.kind == v__token__Kind__key_mut) { if (pub_mut_pos != -1) { v__parser__Parser_error(p, _SLIT("redefinition of `pub mut` section")); - v__ast__StructDecl _t7 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + v__ast__StructDecl _t8 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { v__ast__Table_reset_parsing_type(p->table); } // Defer end - return _t7; + return _t8; } v__parser__Parser_next(p); pub_mut_pos = ast_fields.len; @@ -92204,13 +92235,13 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } else { if (pub_pos != -1) { v__parser__Parser_error(p, _SLIT("redefinition of `pub` section")); - v__ast__StructDecl _t8 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + v__ast__StructDecl _t9 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { v__ast__Table_reset_parsing_type(p->table); } // Defer end - return _t8; + return _t9; } pub_pos = ast_fields.len; is_field_pub = true; @@ -92221,23 +92252,6 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } else if (p->tok.kind == v__token__Kind__key_mut) { if (mut_pos != -1) { v__parser__Parser_error(p, _SLIT("redefinition of `mut` section")); - v__ast__StructDecl _t9 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - // Defer begin - if (v__parser__Parser_struct_decl_defer_0) { - v__ast__Table_reset_parsing_type(p->table); - } - // Defer end - return _t9; - } - v__parser__Parser_next(p); - v__parser__Parser_check(p, v__token__Kind__colon); - mut_pos = ast_fields.len; - is_field_pub = false; - is_field_mut = true; - is_field_global = false; - } else if (p->tok.kind == v__token__Kind__key_global) { - if (global_pos != -1) { - v__parser__Parser_error(p, _SLIT("redefinition of `global` section")); v__ast__StructDecl _t10 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -92248,13 +92262,13 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } v__parser__Parser_next(p); v__parser__Parser_check(p, v__token__Kind__colon); - global_pos = ast_fields.len; - is_field_pub = true; + mut_pos = ast_fields.len; + is_field_pub = false; is_field_mut = true; - is_field_global = true; - } else if (p->tok.kind == v__token__Kind__key_module) { - if (module_pos != -1) { - v__parser__Parser_error(p, _SLIT("redefinition of `module` section")); + is_field_global = false; + } else if (p->tok.kind == v__token__Kind__key_global) { + if (global_pos != -1) { + v__parser__Parser_error(p, _SLIT("redefinition of `global` section")); v__ast__StructDecl _t11 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -92265,6 +92279,23 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } v__parser__Parser_next(p); v__parser__Parser_check(p, v__token__Kind__colon); + global_pos = ast_fields.len; + is_field_pub = true; + is_field_mut = true; + is_field_global = true; + } else if (p->tok.kind == v__token__Kind__key_module) { + if (module_pos != -1) { + v__parser__Parser_error(p, _SLIT("redefinition of `module` section")); + v__ast__StructDecl _t12 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + // Defer begin + if (v__parser__Parser_struct_decl_defer_0) { + v__ast__Table_reset_parsing_type(p->table); + } + // Defer end + return _t12; + } + v__parser__Parser_next(p); + v__parser__Parser_check(p, v__token__Kind__colon); module_pos = ast_fields.len; is_field_pub = false; is_field_mut = false; @@ -92292,21 +92323,10 @@ bool v__parser__Parser_struct_decl_defer_0 = false; if (is_embed) { type_pos = v__token__Token_pos(&p->tok); typ = v__parser__Parser_parse_type(p); - _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t13, Array_v__ast__Comment); + _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t14, Array_v__ast__Comment); type_pos = v__token__Pos_extend(type_pos, v__token__Token_pos(&p->prev_tok)); if (!is_on_top) { v__parser__Parser_error_with_pos(p, _SLIT("struct embedding must be declared at the beginning of the struct body"), type_pos); - v__ast__StructDecl _t14 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - // Defer begin - if (v__parser__Parser_struct_decl_defer_0) { - v__ast__Table_reset_parsing_type(p->table); - } - // Defer end - return _t14; - } - v__ast__TypeSymbol* sym = v__ast__Table_sym(p->table, typ); - if (Array_v__ast__Type_contains(embed_types, typ)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot embed `"), /*115 &string*/0xfe10, {.d_s = sym->name}}, {_SLIT("` more than once"), 0, { .d_c = 0 }}})), type_pos); v__ast__StructDecl _t15 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -92315,9 +92335,9 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t15; } - field_name = v__ast__TypeSymbol_embed_name(sym); - if (Array_string_contains(embed_field_names, field_name)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate field `"), /*115 &string*/0xfe10, {.d_s = field_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), type_pos); + v__ast__TypeSymbol* sym = v__ast__Table_sym(p->table, typ); + if (Array_v__ast__Type_contains(embed_types, typ)) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot embed `"), /*115 &string*/0xfe10, {.d_s = sym->name}}, {_SLIT("` more than once"), 0, { .d_c = 0 }}})), type_pos); v__ast__StructDecl _t16 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -92326,6 +92346,17 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t16; } + field_name = v__ast__TypeSymbol_embed_name(sym); + if (Array_string_contains(embed_field_names, field_name)) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate field `"), /*115 &string*/0xfe10, {.d_s = field_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), type_pos); + v__ast__StructDecl _t17 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + // Defer begin + if (v__parser__Parser_struct_decl_defer_0) { + v__ast__Table_reset_parsing_type(p->table); + } + // Defer end + return _t17; + } array_push((array*)&embed_field_names, _MOV((string[]){ string_clone(field_name) })); array_push((array*)&embed_types, _MOV((v__ast__Type[]){ typ })); array_push((array*)&embeds, _MOV((v__ast__Embed[]){ ((v__ast__Embed){.typ = typ,.pos = type_pos,.comments = comments,}) })); @@ -92342,18 +92373,18 @@ bool v__parser__Parser_struct_decl_defer_0 = false; typ = v__parser__Parser_parse_type(p); p->inside_struct_field_decl = false; if (v__ast__Type_idx(typ) == 0) { - v__ast__StructDecl _t21 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + v__ast__StructDecl _t22 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { v__ast__Table_reset_parsing_type(p->table); } // Defer end - return _t21; + return _t22; } type_pos = v__token__Token_pos(&p->prev_tok); field_pos = v__token__Pos_extend(field_start_pos, type_pos); } - _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t22, Array_v__ast__Comment); + _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t23, Array_v__ast__Comment); if (p->tok.kind == v__token__Kind__lsbr) { v__parser__Parser_attributes(p); } @@ -92371,7 +92402,7 @@ bool v__parser__Parser_struct_decl_defer_0 = false; } ; has_default_expr = true; - _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t23, Array_v__ast__Comment); + _PUSH_MANY(&comments, (v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,}))), _t24, Array_v__ast__Comment); } array_push((array*)&ast_fields, _MOV((v__ast__StructField[]){ ((v__ast__StructField){ .comments = comments, @@ -92444,18 +92475,6 @@ bool v__parser__Parser_struct_decl_defer_0 = false; }); if (v__ast__Table_has_deep_child_no_ref(p->table, &t, name)) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("invalid recursive struct `"), /*115 &string*/0xfe10, {.d_s = orig_name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), name_pos); - v__ast__StructDecl _t26 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); - // Defer begin - if (v__parser__Parser_struct_decl_defer_0) { - v__ast__Table_reset_parsing_type(p->table); - } - // Defer end - return _t26; - } - int ret = 0; - ret = v__ast__Table_register_sym(p->table, t); - if (ret == -1 && language != v__ast__Language__c) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register struct `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); v__ast__StructDecl _t27 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); // Defer begin if (v__parser__Parser_struct_decl_defer_0) { @@ -92464,8 +92483,20 @@ bool v__parser__Parser_struct_decl_defer_0 = false; // Defer end return _t27; } + int ret = 0; + ret = v__ast__Table_register_sym(p->table, t); + if (ret == -1 && language != v__ast__Language__c) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register struct `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); + v__ast__StructDecl _t28 = ((v__ast__StructDecl){.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.end_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.embeds = __new_array(0, 0, sizeof(v__ast__Embed)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.name = (string){.str=(byteptr)"", .is_lit=1},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.mut_pos = 0,.pub_pos = 0,.pub_mut_pos = 0,.global_pos = 0,.module_pos = 0,.language = 0,.is_pub = 0,.is_union = 0,}); + // Defer begin + if (v__parser__Parser_struct_decl_defer_0) { + v__ast__Table_reset_parsing_type(p->table); + } + // Defer end + return _t28; + } p->expr_mod = _SLIT(""); - v__ast__StructDecl _t28 = ((v__ast__StructDecl){ + v__ast__StructDecl _t29 = ((v__ast__StructDecl){ .generic_types = generic_types, .attrs = attrs, .end_comments = end_comments, @@ -92487,7 +92518,7 @@ bool v__parser__Parser_struct_decl_defer_0 = false; v__ast__Table_reset_parsing_type(p->table); } // Defer end - return _t28; + return _t29; } VV_LOCAL_SYMBOL v__ast__StructInit v__parser__Parser_struct_init(v__parser__Parser* p, string typ_str, bool short_syntax) { @@ -92597,6 +92628,10 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser } v__token__Pos name_pos = v__token__Token_pos(&p->tok); v__parser__Parser_check_for_impure_v(p, language, name_pos); + if (v__parser__Parser_disallow_declarations_in_script_mode(p)) { + v__ast__InterfaceDecl _t1 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t1; + } string modless_name = v__parser__Parser_check_name(p); if (string__eq(modless_name, _SLIT("IError")) && !string__eq(p->mod, _SLIT("builtin"))) { v__parser__Parser_error_with_pos(p, _SLIT("cannot register interface `IError`, it is builtin interface type"), name_pos); @@ -92607,14 +92642,14 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser } else { interface_name = v__parser__Parser_prepend_mod(p, modless_name); } - multi_return_Array_v__ast__Type_Array_string mr_13116 = v__parser__Parser_parse_generic_types(p); - Array_v__ast__Type generic_types = mr_13116.arg0; + multi_return_Array_v__ast__Type_Array_string mr_13271 = v__parser__Parser_parse_generic_types(p); + Array_v__ast__Type generic_types = mr_13271.arg0; v__parser__Parser_check(p, v__token__Kind__lcbr); Array_v__ast__Comment pre_comments = v__parser__Parser_eat_comments(p, ((v__parser__EatCommentsConfig){.same_line = 0,.follow_up = 0,})); if (_IN_MAP(ADDR(string, modless_name), ADDR(map, p->imported_symbols))) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register interface `"), /*115 &string*/0xfe10, {.d_s = interface_name}}, {_SLIT("`, this type was already imported"), 0, { .d_c = 0 }}})), name_pos); - v__ast__InterfaceDecl _t1 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); - return _t1; + v__ast__InterfaceDecl _t2 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t2; } int reg_idx = v__ast__Table_register_sym(p->table, ((v__ast__TypeSymbol){ .methods = __new_array(0, 0, sizeof(v__ast__Fn)), @@ -92632,8 +92667,8 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser })); if (reg_idx == -1) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot register interface `"), /*115 &string*/0xfe10, {.d_s = interface_name}}, {_SLIT("`, another type with this name exists"), 0, { .d_c = 0 }}})), name_pos); - v__ast__InterfaceDecl _t2 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); - return _t2; + v__ast__InterfaceDecl _t3 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t3; } v__ast__Type typ = v__ast__new_type(reg_idx); v__ast__TypeSymbol* ts = v__ast__Table_sym(p->table, typ); @@ -92681,8 +92716,8 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser if (p->tok.kind == v__token__Kind__key_mut) { if (is_mut) { v__parser__Parser_error_with_pos(p, _SLIT("redefinition of `mut` section"), v__token__Token_pos(&p->tok)); - v__ast__InterfaceDecl _t5 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); - return _t5; + v__ast__InterfaceDecl _t6 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t6; } v__parser__Parser_next(p); v__parser__Parser_check(p, v__token__Kind__colon); @@ -92695,19 +92730,19 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser string name = v__parser__Parser_check_name(p); if (string__eq(name, _SLIT("type_name")) || string__eq(name, _SLIT("type_idx"))) { v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("cannot override built-in method `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), method_start_pos); - v__ast__InterfaceDecl _t6 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); - return _t6; - } - if (v__ast__TypeSymbol_has_method(ts, name)) { - v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate method `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), method_start_pos); v__ast__InterfaceDecl _t7 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); return _t7; } - multi_return_Array_v__ast__Param_bool_bool mr_16252 = v__parser__Parser_fn_args(p); - Array_v__ast__Param args2 = mr_16252.arg0; - bool is_variadic = mr_16252.arg2; + if (v__ast__TypeSymbol_has_method(ts, name)) { + v__parser__Parser_error_with_pos(p, str_intp(2, _MOV((StrIntpData[]){{_SLIT("duplicate method `"), /*115 &string*/0xfe10, {.d_s = name}}, {_SLIT("`"), 0, { .d_c = 0 }}})), method_start_pos); + v__ast__InterfaceDecl _t8 = ((v__ast__InterfaceDecl){.field_names = __new_array(0, 0, sizeof(string)),.pre_comments = __new_array(0, 0, sizeof(v__ast__Comment)),.generic_types = __new_array(0, 0, sizeof(v__ast__Type)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.methods = __new_array(0, 0, sizeof(v__ast__FnDecl)),.fields = __new_array(0, 0, sizeof(v__ast__StructField)),.embeds = __new_array(0, 0, sizeof(v__ast__InterfaceEmbedding)),.name = (string){.str=(byteptr)"", .is_lit=1},.name_pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.pos = (v__token__Pos){.len = 0,.line_nr = 0,.pos = 0,.col = 0,.last_line = 0,},.typ = 0,.mut_pos = 0,.language = 0,.is_pub = 0,.are_embeds_expanded = 0,}); + return _t8; + } + multi_return_Array_v__ast__Param_bool_bool mr_16407 = v__parser__Parser_fn_args(p); + Array_v__ast__Param args2 = mr_16407.arg0; + bool is_variadic = mr_16407.arg2; Array_v__ast__Param args = new_array_from_c_array(1, 1, sizeof(v__ast__Param), _MOV((v__ast__Param[1]){((v__ast__Param){.name = _SLIT("x"),.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,},.typ = typ,.is_mut = is_mut,.is_auto_rec = 0,.is_hidden = true,})})); - _PUSH_MANY(&args, (args2), _t8, Array_v__ast__Param); + _PUSH_MANY(&args, (args2), _t9, Array_v__ast__Param); v__ast__FnDecl method = ((v__ast__FnDecl){ .receiver = (v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.name = (string){.str=(byteptr)"", .is_lit=1},.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,},.i = 0,.default_expr_typ = 0,.typ = 0,.has_default_expr = 0,.is_pub = 0,.is_mut = 0,.is_global = 0,.is_volatile = 0,}, .generic_names = __new_array(0, 0, sizeof(string)), @@ -92837,17 +92872,17 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser array_push((array*)&info.fields, _MOV((v__ast__StructField[]){ ((v__ast__StructField){.comments = __new_array(0, 0, sizeof(v__ast__Comment)),.attrs = __new_array(0, 0, sizeof(v__ast__Attr)),.default_val = (string){.str=(byteptr)"", .is_lit=1},.default_expr = {0},.name = field_name,.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,},.i = 0,.default_expr_typ = 0,.typ = field_typ,.has_default_expr = 0,.is_pub = true,.is_mut = is_mut,.is_global = 0,.is_volatile = 0,}) })); } } - Array_v__ast__Type _t14 = {0}; - Array_v__ast__InterfaceEmbedding _t14_orig = embeds; - int _t14_len = _t14_orig.len; - _t14 = __new_array(0, _t14_len, sizeof(v__ast__Type)); + Array_v__ast__Type _t15 = {0}; + Array_v__ast__InterfaceEmbedding _t15_orig = embeds; + int _t15_len = _t15_orig.len; + _t15 = __new_array(0, _t15_len, sizeof(v__ast__Type)); - for (int _t15 = 0; _t15 < _t14_len; ++_t15) { - v__ast__InterfaceEmbedding it = ((v__ast__InterfaceEmbedding*) _t14_orig.data)[_t15]; + for (int _t16 = 0; _t16 < _t15_len; ++_t16) { + v__ast__InterfaceEmbedding it = ((v__ast__InterfaceEmbedding*) _t15_orig.data)[_t16]; v__ast__Type ti = it.typ; - array_push((array*)&_t14, &ti); + array_push((array*)&_t15, &ti); } - info.embeds =_t14; + info.embeds =_t15; ts->info = v__ast__Interface_to_sumtype_v__ast__TypeInfo(&info); v__parser__Parser_top_level_statement_end(p); v__parser__Parser_check(p, v__token__Kind__rcbr); @@ -92870,8 +92905,8 @@ VV_LOCAL_SYMBOL v__ast__InterfaceDecl v__parser__Parser_interface_decl(v__parser .are_embeds_expanded = 0, }); v__ast__Table_register_interface(p->table, res); - v__ast__InterfaceDecl _t16 = res; - return _t16; + v__ast__InterfaceDecl _t17 = res; + return _t17; } VV_LOCAL_SYMBOL void v__parser__State_update(v__parser__State* state, string line) { @@ -96925,7 +96960,7 @@ void _vinit(int ___argc, voidptr ___argv) { { // Initializations for module v.ast.walker : } { // Initializations for module v.parser : - _const_v__parser__supported_comptime_calls = new_array_from_c_array(5, 5, sizeof(string), _MOV((string[5]){_SLIT("html"), _SLIT("tmpl"), _SLIT("env"), _SLIT("embed_file"), _SLIT("pkgconfig")})); + _const_v__parser__supported_comptime_calls = new_array_from_c_array(7, 7, sizeof(string), _MOV((string[7]){_SLIT("html"), _SLIT("tmpl"), _SLIT("env"), _SLIT("embed_file"), _SLIT("pkgconfig"), _SLIT("compile_error"), _SLIT("compile_warn")})); _const_v__parser__comptime_types = new_array_from_c_array(8, 8, sizeof(string), _MOV((string[8]){_SLIT("Map"), _SLIT("Array"), _SLIT("Int"), _SLIT("Float"), _SLIT("Struct"), _SLIT("Interface"), _SLIT("Enum"), _SLIT("Sumtype")})); _const_v__parser__valid_tokens_inside_types = new_array_from_c_array(7, 7, sizeof(v__token__Kind), _MOV((v__token__Kind[7]){v__token__Kind__lsbr, v__token__Kind__rsbr, v__token__Kind__name, v__token__Kind__dot, v__token__Kind__comma, v__token__Kind__key_fn, v__token__Kind__lt})); codegen_files = __new_array_with_default(0, 0, sizeof(v__ast__File*), 0); // 3global