diff --git a/vlib/builtin/string_interpolation.v b/vlib/builtin/string_interpolation.v index cdc28f756d..6f4a7c6e3f 100644 --- a/vlib/builtin/string_interpolation.v +++ b/vlib/builtin/string_interpolation.v @@ -721,12 +721,12 @@ pub const si_g64_code = '0xfe0f' @[inline] pub fn str_intp_sq(in_str string) string { - return 'str_intp(2, _MOV((StrIntpData[]){{_SLIT("\'"), ${si_s_code}, {.d_s = ${in_str}}},{_SLIT("\'"), 0, {.d_c = 0 }}}))' + return 'str_intp(2, _MOV((StrIntpData[]){{_S("\'"), ${si_s_code}, {.d_s = ${in_str}}},{_S("\'"), 0, {.d_c = 0 }}}))' } @[inline] pub fn str_intp_rune(in_str string) string { - return 'str_intp(2, _MOV((StrIntpData[]){{_SLIT("\`"), ${si_s_code}, {.d_s = ${in_str}}},{_SLIT("\`"), 0, {.d_c = 0 }}}))' + return 'str_intp(2, _MOV((StrIntpData[]){{_S("\`"), ${si_s_code}, {.d_s = ${in_str}}},{_S("\`"), 0, {.d_c = 0 }}}))' } @[inline] @@ -752,12 +752,12 @@ pub fn str_intp_sub(base_str string, in_str string) string { st_str := base_str[..index] if index + 2 < base_str.len { en_str := base_str[index + 2..] - res_str := 'str_intp(2, _MOV((StrIntpData[]){{_SLIT("${st_str}"), ${si_s_code}, {.d_s = ${in_str} }},{_SLIT("${en_str}"), 0, {.d_c = 0}}}))' + res_str := 'str_intp(2, _MOV((StrIntpData[]){{_S("${st_str}"), ${si_s_code}, {.d_s = ${in_str} }},{_S("${en_str}"), 0, {.d_c = 0}}}))' st_str.free() en_str.free() return res_str } - res2_str := 'str_intp(1, _MOV((StrIntpData[]){{_SLIT("${st_str}"), ${si_s_code}, {.d_s = ${in_str} }}}))' + res2_str := 'str_intp(1, _MOV((StrIntpData[]){{_S("${st_str}"), ${si_s_code}, {.d_s = ${in_str} }}}))' st_str.free() return res2_str } diff --git a/vlib/v/gen/c/array.v b/vlib/v/gen/c/array.v index cb17fcff13..920b15f901 100644 --- a/vlib/v/gen/c/array.v +++ b/vlib/v/gen/c/array.v @@ -338,7 +338,7 @@ fn (mut g Gen) array_init_with_fields(node ast.ArrayInit, elem_type Type, is_amp g.write2('(${elem_styp}[]){', g.type_default(node.elem_type)) g.write('}[0], ${depth})') } else if node.has_len && node.elem_type == ast.string_type { - g.write2('&(${elem_styp}[]){', '_SLIT("")') + g.write2('&(${elem_styp}[]){', '_S("")') g.write('})') } else if node.has_len && elem_type.unaliased_sym.kind in [.array, .map] { g.write2('(voidptr)&(${elem_styp}[]){', g.type_default(node.elem_type)) @@ -447,7 +447,7 @@ fn (mut g Gen) array_init_with_fields(node ast.ArrayInit, elem_type Type, is_amp g.expr_with_opt(ast.None{}, ast.none_type, node.elem_type) g.write(')') } else if node.has_len && node.elem_type == ast.string_type { - g.write2('&(${elem_styp}[]){', '_SLIT("")') + g.write2('&(${elem_styp}[]){', '_S("")') g.write('})') } else if node.has_len && elem_type.unaliased_sym.kind in [.struct, .array, .map] { g.write2('(voidptr)&(${elem_styp}[]){', g.type_default(node.elem_type)) @@ -743,7 +743,7 @@ fn (mut g Gen) gen_array_sort(node ast.CallExpr) { verror('.sort() is an array method or a fixed array method') } if g.pref.is_bare { - g.writeln('bare_panic(_SLIT("sort does not work with -freestanding"))') + g.writeln('bare_panic(_S("sort does not work with -freestanding"))') return } left_is_array := rec_sym.kind == .array @@ -825,7 +825,7 @@ fn (mut g Gen) gen_array_sort(node ast.CallExpr) { } stype_arg := g.styp(elem_type) - g.sort_fn_definitions.writeln('VV_LOCAL_SYMBOL ${g.static_modifier} int ${compare_fn}(${stype_arg}* a, ${stype_arg}* b) {') + g.sort_fn_definitions.writeln('VV_LOC ${g.static_modifier} int ${compare_fn}(${stype_arg}* a, ${stype_arg}* b) {') c_condition := if comparison_type.sym.has_method('<') { '${g.styp(comparison_type.typ)}__lt(${left_expr}, ${right_expr})' } else if comparison_type.unaliased_sym.has_method('<') { @@ -1159,7 +1159,7 @@ fn (mut g Gen) gen_array_contains_methods() { left_type_str = 'Array_voidptr' elem_type_str = 'voidptr' } - g.type_definitions.writeln('${g.static_non_parallel}bool ${fn_name}(${left_type_str} a, ${elem_type_str} v); // auto') + g.type_definitions.writeln('${g.static_non_parallel}bool ${fn_name}(${left_type_str} a, ${elem_type_str} v);') fn_builder.writeln('${g.static_non_parallel}bool ${fn_name}(${left_type_str} a, ${elem_type_str} v) {') fn_builder.writeln('\tfor (int i = 0; i < a.len; ++i) {') if elem_kind == .string { @@ -1201,7 +1201,7 @@ fn (mut g Gen) gen_array_contains_methods() { if elem_kind == .function { elem_type_str = 'voidptr' } - g.type_definitions.writeln('${g.static_non_parallel}bool ${fn_name}(${left_type_str} a, ${elem_type_str} v); // auto') + g.type_definitions.writeln('${g.static_non_parallel}bool ${fn_name}(${left_type_str} a, ${elem_type_str} v);') fn_builder.writeln('${g.static_non_parallel}bool ${fn_name}(${left_type_str} a, ${elem_type_str} v) {') fn_builder.writeln('\tfor (int i = 0; i < ${size}; ++i) {') if elem_kind == .string { @@ -1307,7 +1307,7 @@ fn (mut g Gen) gen_array_index_methods() { left_type_str = 'Array_voidptr' elem_type_str = 'voidptr' } - g.type_definitions.writeln('${g.static_non_parallel}int ${fn_name}(${left_type_str} a, ${elem_type_str} v); // auto') + g.type_definitions.writeln('${g.static_non_parallel}int ${fn_name}(${left_type_str} a, ${elem_type_str} v);') fn_builder.writeln('${g.static_non_parallel}int ${fn_name}(${left_type_str} a, ${elem_type_str} v) {') fn_builder.writeln('\t${elem_type_str}* pelem = a.data;') fn_builder.writeln('\tfor (int i = 0; i < a.len; ++i, ++pelem) {') @@ -1351,7 +1351,7 @@ fn (mut g Gen) gen_array_index_methods() { if elem_sym.kind == .function { elem_type_str = 'voidptr' } - g.type_definitions.writeln('${g.static_non_parallel}int ${fn_name}(${left_type_str} a, ${elem_type_str} v); // auto') + g.type_definitions.writeln('${g.static_non_parallel}int ${fn_name}(${left_type_str} a, ${elem_type_str} v);') fn_builder.writeln('${g.static_non_parallel}int ${fn_name}(${left_type_str} a, ${elem_type_str} v) {') fn_builder.writeln('\tfor (int i = 0; i < ${info.size}; ++i) {') if elem_sym.kind == .string { diff --git a/vlib/v/gen/c/assert.v b/vlib/v/gen/c/assert.v index 8083bf2df9..763d33b15e 100644 --- a/vlib/v/gen/c/assert.v +++ b/vlib/v/gen/c/assert.v @@ -125,7 +125,7 @@ fn (mut g Gen) gen_assert_postfailure_mode(node ast.AssertStmt) { } g.writeln2('\t// TODO', '\t// Maybe print all vars in a test function if it fails?') if g.pref.assert_failure_mode != .continues { - g.writeln('\t_v_panic(_SLIT("Assertion failed..."));') + g.writeln('\t_v_panic(_S("Assertion failed..."));') } } @@ -173,7 +173,7 @@ fn (mut g Gen) gen_assert_metainfo(node ast.AssertStmt, kind AssertMetainfoKind) } } ast.CallExpr { - g.writeln('\t${metaname}.op = _SLIT("call");') + g.writeln('\t${metaname}.op = _S("call");') } else {} } diff --git a/vlib/v/gen/c/assign.v b/vlib/v/gen/c/assign.v index 2c444a0fc3..9388557009 100644 --- a/vlib/v/gen/c/assign.v +++ b/vlib/v/gen/c/assign.v @@ -27,7 +27,7 @@ fn (mut g Gen) expr_with_opt_or_block(expr ast.Expr, expr_typ ast.Type, var_expr } g.writeln('if (${c_name(expr_var)}.state != 0) { // assign') if expr is ast.Ident && expr.or_expr.kind == .propagate_option { - g.writeln('\tpanic_option_not_set(_SLIT("none"));') + g.writeln('\tpanic_option_not_set(_S("none"));') } else { g.inside_or_block = true defer { @@ -63,7 +63,7 @@ fn (mut g Gen) expr_opt_with_alias(expr ast.Expr, expr_typ ast.Type, ret_typ ast ret_var := g.new_tmp_var() ret_styp := g.styp(ret_typ).replace('*', '_ptr') - g.writeln('${ret_styp} ${ret_var} = {.state=2, .err=_const_none__, .data={EMPTY_STRUCT_INITIALIZATION}};') + g.writeln('${ret_styp} ${ret_var} = {.state=2, .err=_const_none__, .data={E_STRUCT}};') if expr !is ast.None { is_option_expr := expr_typ.has_flag(.option) diff --git a/vlib/v/gen/c/auto_eq_methods.v b/vlib/v/gen/c/auto_eq_methods.v index 309c7b5c5b..475cced8bd 100644 --- a/vlib/v/gen/c/auto_eq_methods.v +++ b/vlib/v/gen/c/auto_eq_methods.v @@ -60,7 +60,7 @@ fn (mut g Gen) gen_sumtype_equality_fn(left_type ast.Type) string { g.generated_eq_fns << left_no_ptr info := left.sym.sumtype_info() - g.definitions.writeln('bool ${ptr_styp}_sumtype_eq(${ptr_styp} a, ${ptr_styp} b); // auto') + g.definitions.writeln('bool ${ptr_styp}_sumtype_eq(${ptr_styp} a, ${ptr_styp} b);') left_typ := g.read_field(left_type, '_typ', 'a') right_typ := g.read_field(left_type, '_typ', 'b') @@ -184,7 +184,7 @@ fn (mut g Gen) gen_struct_equality_fn(left_type ast.Type) string { g.generated_eq_fns << left_no_ptr info := left.sym.struct_info() - g.definitions.writeln('bool ${fn_name}_struct_eq(${ptr_styp} a, ${ptr_styp} b); // auto') + g.definitions.writeln('bool ${fn_name}_struct_eq(${ptr_styp} a, ${ptr_styp} b);') mut fn_builder := strings.new_builder(512) defer { @@ -293,7 +293,7 @@ fn (mut g Gen) gen_alias_equality_fn(left_type ast.Type) string { g.generated_eq_fns << left_no_ptr info := left.sym.info as ast.Alias - g.definitions.writeln('bool ${ptr_styp}_alias_eq(${ptr_styp} a, ${ptr_styp} b); // auto') + g.definitions.writeln('bool ${ptr_styp}_alias_eq(${ptr_styp} a, ${ptr_styp} b);') mut fn_builder := strings.new_builder(512) fn_builder.writeln('inline bool ${ptr_styp}_alias_eq(${ptr_styp} a, ${ptr_styp} b) {') @@ -354,7 +354,7 @@ fn (mut g Gen) gen_array_equality_fn(left_type ast.Type) string { elem := g.unwrap(left.sym.array_info().elem_type) ptr_elem_styp := g.styp(elem.typ) - g.definitions.writeln('bool ${ptr_styp}_arr_eq(${ptr_styp} a, ${ptr_styp} b); // auto') + g.definitions.writeln('bool ${ptr_styp}_arr_eq(${ptr_styp} a, ${ptr_styp} b);') mut fn_builder := strings.new_builder(512) fn_builder.writeln('inline bool ${ptr_styp}_arr_eq(${ptr_styp} a, ${ptr_styp} b) {') @@ -442,7 +442,7 @@ fn (mut g Gen) gen_fixed_array_equality_fn(left_type ast.Type) string { if elem_info.is_fn_ret { arg_styp = ptr_styp[3..] // removes the _v_ prefix for returning fixed array } - g.definitions.writeln('bool ${ptr_styp}_arr_eq(${arg_styp} a, ${arg_styp} b); // auto') + g.definitions.writeln('bool ${ptr_styp}_arr_eq(${arg_styp} a, ${arg_styp} b);') is_option := left_type.has_flag(.option) left := if is_option { 'a.data' } else { 'a' } @@ -516,7 +516,7 @@ fn (mut g Gen) gen_map_equality_fn(left_type ast.Type) string { value := g.unwrap(left.sym.map_info().value_type) ptr_value_styp := g.styp(value.typ) - g.definitions.writeln('bool ${ptr_styp}_map_eq(${ptr_styp} a, ${ptr_styp} b); // auto') + g.definitions.writeln('bool ${ptr_styp}_map_eq(${ptr_styp} a, ${ptr_styp} b);') left_len := g.read_map_field_from_option(left.typ, 'len', 'a') right_len := g.read_map_field_from_option(left.typ, 'len', 'b') @@ -545,7 +545,7 @@ fn (mut g Gen) gen_map_equality_fn(left_type ast.Type) string { } match kind { .string { - fn_builder.writeln('\t\tif (!fast_string_eq(*(string*)map_get(${b}, k, &(string[]){_SLIT("")}), v)) {') + fn_builder.writeln('\t\tif (!fast_string_eq(*(string*)map_get(${b}, k, &(string[]){_S("")}), v)) {') } .sum_type { eq_fn := g.gen_sumtype_equality_fn(value.typ) @@ -608,7 +608,7 @@ fn (mut g Gen) gen_interface_equality_fn(left_type ast.Type) string { g.generated_eq_fns << left_no_ptr info := left.sym.info - g.definitions.writeln('${g.static_non_parallel}bool ${ptr_styp}_interface_eq(${ptr_styp} a, ${ptr_styp} b); // auto') + g.definitions.writeln('${g.static_non_parallel}bool ${ptr_styp}_interface_eq(${ptr_styp} a, ${ptr_styp} b);') mut fn_builder := strings.new_builder(512) defer { diff --git a/vlib/v/gen/c/auto_free_methods.v b/vlib/v/gen/c/auto_free_methods.v index 7437e9fde0..889c85be5b 100644 --- a/vlib/v/gen/c/auto_free_methods.v +++ b/vlib/v/gen/c/auto_free_methods.v @@ -84,7 +84,7 @@ fn (mut g Gen) gen_free_method(typ ast.Type) string { } fn (mut g Gen) gen_free_for_interface(sym ast.TypeSymbol, info ast.Interface, styp string, fn_name string) { - g.definitions.writeln('${g.static_non_parallel}void ${fn_name}(${styp}* it); // auto') + g.definitions.writeln('${g.static_non_parallel}void ${fn_name}(${styp}* it);') mut fn_builder := strings.new_builder(128) defer { g.auto_fn_definitions << fn_builder.str() @@ -106,7 +106,7 @@ fn (mut g Gen) gen_free_for_interface(sym ast.TypeSymbol, info ast.Interface, st } fn (mut g Gen) gen_free_for_struct(typ ast.Type, info ast.Struct, styp string, fn_name string) { - g.definitions.writeln('${g.static_non_parallel}void ${fn_name}(${styp}* it); // auto') + g.definitions.writeln('${g.static_non_parallel}void ${fn_name}(${styp}* it);') mut fn_builder := strings.new_builder(128) defer { g.auto_fn_definitions << fn_builder.str() @@ -176,7 +176,7 @@ fn (mut g Gen) gen_type_name_for_free_call(typ ast.Type) string { } fn (mut g Gen) gen_free_for_array(info ast.Array, styp string, fn_name string) { - g.definitions.writeln('${g.static_non_parallel}void ${fn_name}(${styp}* it); // auto') + g.definitions.writeln('${g.static_non_parallel}void ${fn_name}(${styp}* it);') mut fn_builder := strings.new_builder(128) defer { g.auto_fn_definitions << fn_builder.str() @@ -201,7 +201,7 @@ fn (mut g Gen) gen_free_for_array(info ast.Array, styp string, fn_name string) { } fn (mut g Gen) gen_free_for_map(typ ast.Type, styp string, fn_name string) { - g.definitions.writeln('${g.static_non_parallel}void ${fn_name}(${styp}* it); // auto') + g.definitions.writeln('${g.static_non_parallel}void ${fn_name}(${styp}* it);') mut fn_builder := strings.new_builder(128) defer { g.auto_fn_definitions << fn_builder.str() diff --git a/vlib/v/gen/c/auto_str_methods.v b/vlib/v/gen/c/auto_str_methods.v index f0bd0cfc35..966a0afc6c 100644 --- a/vlib/v/gen/c/auto_str_methods.v +++ b/vlib/v/gen/c/auto_str_methods.v @@ -45,14 +45,14 @@ fn (mut g Gen) gen_str_default(sym ast.TypeSymbol, styp string, str_fn_name stri } else { verror('could not generate string method for type `${styp}`') } - g.definitions.writeln('string ${str_fn_name}(${styp} it); // auto') + g.definitions.writeln('string ${str_fn_name}(${styp} it);') g.auto_str_funcs.writeln('string ${str_fn_name}(${styp} it) {') if convertor == 'bool' { - g.auto_str_funcs.writeln('\tstring tmp1 = string__plus(_SLIT("${styp}("), (${convertor})it ? _SLIT("true") : _SLIT("false"));') + g.auto_str_funcs.writeln('\tstring tmp1 = string__plus(_S("${styp}("), (${convertor})it ? _S("true") : _S("false"));') } else { - g.auto_str_funcs.writeln('\tstring tmp1 = string__plus(_SLIT("${styp}("), tos3(${typename_}_str((${convertor})it).str));') + g.auto_str_funcs.writeln('\tstring tmp1 = string__plus(_S("${styp}("), tos3(${typename_}_str((${convertor})it).str));') } - g.auto_str_funcs.writeln('\tstring tmp2 = string__plus(tmp1, _SLIT(")"));') + g.auto_str_funcs.writeln('\tstring tmp2 = string__plus(tmp1, _S(")"));') g.auto_str_funcs.writeln('\tstring_free(&tmp1);') g.auto_str_funcs.writeln('\treturn tmp2;') g.auto_str_funcs.writeln('}') @@ -196,9 +196,9 @@ fn (mut g Gen) gen_str_for_option(typ ast.Type, styp string, str_fn_name string) sym_has_str_method, expects_ptr, _ := sym.str_method_info() parent_str_fn_name := g.get_str_fn(parent_type) - g.definitions.writeln('string ${str_fn_name}(${styp} it); // auto') + g.definitions.writeln('string ${str_fn_name}(${styp} it);') g.auto_str_funcs.writeln('string ${str_fn_name}(${styp} it) { return indent_${str_fn_name}(it, 0); }') - g.definitions.writeln('string indent_${str_fn_name}(${styp} it, int indent_count); // auto') + g.definitions.writeln('string indent_${str_fn_name}(${styp} it, int indent_count);') g.auto_str_funcs.writeln('string indent_${str_fn_name}(${styp} it, int indent_count) {') g.auto_str_funcs.writeln('\tstring res;') g.auto_str_funcs.writeln('\tif (it.state == 0) {') @@ -230,7 +230,7 @@ fn (mut g Gen) gen_str_for_option(typ ast.Type, styp string, str_fn_name string) } g.auto_str_funcs.writeln('\t\treturn ${str_intp_sub('Option(%%)', 'res')};') g.auto_str_funcs.writeln('\t}') - g.auto_str_funcs.writeln('\treturn _SLIT("Option(none)");') + g.auto_str_funcs.writeln('\treturn _S("Option(none)");') g.auto_str_funcs.writeln('}') } @@ -243,9 +243,9 @@ fn (mut g Gen) gen_str_for_result(typ ast.Type, styp string, str_fn_name string) sym_has_str_method, _, _ := sym.str_method_info() parent_str_fn_name := g.get_str_fn(parent_type) - g.definitions.writeln('string ${str_fn_name}(${styp} it); // auto') + g.definitions.writeln('string ${str_fn_name}(${styp} it);') g.auto_str_funcs.writeln('string ${str_fn_name}(${styp} it) { return indent_${str_fn_name}(it, 0); }') - g.definitions.writeln('string indent_${str_fn_name}(${styp} it, int indent_count); // auto') + g.definitions.writeln('string indent_${str_fn_name}(${styp} it, int indent_count);') g.auto_str_funcs.writeln('string indent_${str_fn_name}(${styp} it, int indent_count) {') g.auto_str_funcs.writeln('\tstring res;') g.auto_str_funcs.writeln('\tif (!it.is_error) {') @@ -280,13 +280,13 @@ fn (mut g Gen) gen_str_for_alias(info ast.Alias, styp string, str_fn_name string is_c_struct := parent_sym.is_c_struct() && str_method_expects_ptr arg_def := if is_c_struct { '${styp}* it' } else { '${styp} it' } - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${arg_def}); // auto') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${arg_def});') g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${arg_def}) { return indent_${str_fn_name}(it, 0); }') - g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${arg_def}, int indent_count); // auto') + g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${arg_def}, int indent_count);') g.auto_str_funcs.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${arg_def}, int indent_count) {') old := g.reset_tmp_count() defer { g.tmp_count = old } - g.auto_str_funcs.writeln('\tstring indents = string_repeat(_SLIT(" "), indent_count);') + g.auto_str_funcs.writeln('\tstring indents = string_repeat(_S(" "), indent_count);') if str_method_expects_ptr { it_arg := if is_c_struct { 'it' } else { '&it' } g.auto_str_funcs.writeln('\tstring tmp_ds = ${parent_str_fn_name}(${it_arg});') @@ -296,8 +296,8 @@ fn (mut g Gen) gen_str_for_alias(info ast.Alias, styp string, str_fn_name string } g.auto_str_funcs.writeln('\tstring res = str_intp(3, _MOV((StrIntpData[]){ {_SLIT0, ${si_s_code}, {.d_s = indents }}, - {_SLIT("${clean_type_v_type_name}("), ${si_s_code}, {.d_s = tmp_ds }}, - {_SLIT(")"), 0, {.d_c = 0 }} + {_S("${clean_type_v_type_name}("), ${si_s_code}, {.d_s = tmp_ds }}, + {_S(")"), 0, {.d_c = 0 }} }));') g.auto_str_funcs.writeln('\tstring_free(&indents);') g.auto_str_funcs.writeln('\tstring_free(&tmp_ds);') @@ -309,11 +309,11 @@ fn (mut g Gen) gen_str_for_multi_return(info ast.MultiReturn, styp string, str_f $if trace_autostr ? { eprintln('> gen_str_for_multi_return: ${info.types} | ${styp} | ${str_fn_name}') } - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} a); // auto') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} a);') mut fn_builder := strings.new_builder(512) fn_builder.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} a) {') fn_builder.writeln('\tstrings__Builder sb = strings__new_builder(2 + ${info.types.len} * 10);') - fn_builder.writeln('\tstrings__Builder_write_string(&sb, _SLIT("("));') + fn_builder.writeln('\tstrings__Builder_write_string(&sb, _S("("));') for i, typ in info.types { sym := g.table.sym(typ) is_arg_ptr := typ.is_ptr() @@ -337,14 +337,14 @@ fn (mut g Gen) gen_str_for_multi_return(info ast.MultiReturn, styp string, str_f fn_builder.writeln('\tstrings__Builder_write_string(&sb, ${arg_str_fn_name}());') } else { deref, deref_label := deref_kind(str_method_expects_ptr, is_arg_ptr, typ) - fn_builder.writeln('\t\tstrings__Builder_write_string(&sb, _SLIT("${deref_label}"));') + fn_builder.writeln('\t\tstrings__Builder_write_string(&sb, _S("${deref_label}"));') fn_builder.writeln('\tstrings__Builder_write_string(&sb, ${arg_str_fn_name}( ${deref} a.arg${i}));') } if i != info.types.len - 1 { - fn_builder.writeln('\tstrings__Builder_write_string(&sb, _SLIT(", "));') + fn_builder.writeln('\tstrings__Builder_write_string(&sb, _S(", "));') } } - fn_builder.writeln('\tstrings__Builder_write_string(&sb, _SLIT(")"));') + fn_builder.writeln('\tstrings__Builder_write_string(&sb, _S(")"));') fn_builder.writeln('\tstring res = strings__Builder_str(&sb);') fn_builder.writeln('\tstrings__Builder_free(&sb);') fn_builder.writeln('\treturn res;') @@ -357,19 +357,19 @@ fn (mut g Gen) gen_str_for_enum(info ast.Enum, styp string, str_fn_name string) eprintln('> gen_str_for_enum: ${info} | ${styp} | ${str_fn_name}') } s := util.no_dots(styp) - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} it); // auto') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} it);') g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} it) { /* gen_str_for_enum */') // Enums tagged with `@[flag]` are special in that they can be a combination of enum values if info.is_flag { clean_name := util.strip_main_name(styp.replace('__', '.')) - g.auto_str_funcs.writeln('\tstring ret = _SLIT("${clean_name}{");') + g.auto_str_funcs.writeln('\tstring ret = _S("${clean_name}{");') g.auto_str_funcs.writeln('\tint first = 1;') g.auto_str_funcs.writeln('\tu64 zit = (u64)it;') for i, val in info.vals { mask := u64(1) << i - g.auto_str_funcs.writeln('\tif (zit & 0x${mask:016x}U) {if (!first) {ret = string__plus(ret, _SLIT(" | "));} ret = string__plus(ret, _SLIT(".${val}")); first = 0;}') + g.auto_str_funcs.writeln('\tif (zit & 0x${mask:016x}U) {if (!first) {ret = string__plus(ret, _S(" | "));} ret = string__plus(ret, _S(".${val}")); first = 0;}') } - g.auto_str_funcs.writeln('\tret = string__plus(ret, _SLIT("}"));') + g.auto_str_funcs.writeln('\tret = string__plus(ret, _S("}"));') g.auto_str_funcs.writeln('\treturn ret;') } else { g.auto_str_funcs.writeln('\tswitch(it) {') @@ -381,9 +381,9 @@ fn (mut g Gen) gen_str_for_enum(info ast.Enum, styp string, str_fn_name string) } else if info.is_multi_allowed { seen << val } - g.auto_str_funcs.writeln('\t\tcase ${s}__${val}: return _SLIT("${val}");') + g.auto_str_funcs.writeln('\t\tcase ${s}__${val}: return _S("${val}");') } - g.auto_str_funcs.writeln('\t\tdefault: return _SLIT("unknown enum value");') + g.auto_str_funcs.writeln('\t\tdefault: return _S("unknown enum value");') g.auto_str_funcs.writeln('\t}') } g.auto_str_funcs.writeln('}') @@ -394,9 +394,9 @@ fn (mut g Gen) gen_str_for_interface(info ast.Interface, styp string, typ_str st eprintln('> gen_str_for_interface: ${info.types} | ${styp} | ${str_fn_name}') } // _str() functions should have a single argument, the indenting ones take 2: - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x); // auto') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x);') g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x) { return indent_${str_fn_name}(x, 0); }') - g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} x, int indent_count); // auto') + g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} x, int indent_count);') mut fn_builder := strings.new_builder(512) clean_interface_v_type_name := util.strip_main_name(typ_str) fn_builder.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} x, int indent_count) { /* gen_str_for_interface */') @@ -417,8 +417,8 @@ fn (mut g Gen) gen_str_for_interface(info ast.Interface, styp string, typ_str st } val += ')' res := 'str_intp(2, _MOV((StrIntpData[]){ - {_SLIT("${clean_interface_v_type_name}(\'"), ${si_s_code}, {.d_s = ${val}}}, - {_SLIT("\')"), 0, {.d_c = 0 }} + {_S("${clean_interface_v_type_name}(\'"), ${si_s_code}, {.d_s = ${val}}}, + {_S("\')"), 0, {.d_c = 0 }} }))' fn_builder.write_string2('\tif (x._typ == _${styp}_${sub_sym.cname}_index)', ' return ${res};') @@ -430,18 +430,18 @@ fn (mut g Gen) gen_str_for_interface(info ast.Interface, styp string, typ_str st } val += ')' res := 'str_intp(2, _MOV((StrIntpData[]){ - {_SLIT("${clean_interface_v_type_name}("), ${si_s_code}, {.d_s = ${val}}}, - {_SLIT(")"), 0, {.d_c = 0 }} + {_S("${clean_interface_v_type_name}("), ${si_s_code}, {.d_s = ${val}}}, + {_S(")"), 0, {.d_c = 0 }} }))' fn_builder.write_string2('\tif (x._typ == _${styp}_${sub_sym.cname}_index)', ' return ${res};\n') } else { fn_builder.write_string2('\tif (x._typ == _${styp}_${sub_sym.cname}_index)', - ' return _SLIT("");\n') + ' return _S("");\n') } } } - fn_builder.writeln('\treturn _SLIT("unknown interface value");') + fn_builder.writeln('\treturn _S("unknown interface value");') fn_builder.writeln('}') g.auto_fn_definitions << fn_builder.str() } @@ -451,9 +451,9 @@ fn (mut g Gen) gen_str_for_union_sum_type(info ast.SumType, styp string, typ_str eprintln('> gen_str_for_union_sum_type: ${info.variants} | ${styp} | ${str_fn_name}') } // _str() functions should have a single argument, the indenting ones take 2: - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x); // auto') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x);') g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x) { return indent_${str_fn_name}(x, 0); }') - g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} x, int indent_count); // auto') + g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} x, int indent_count);') mut fn_builder := strings.new_builder(512) fn_builder.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} x, int indent_count) {') mut clean_sum_type_v_type_name := '' @@ -492,8 +492,8 @@ fn (mut g Gen) gen_str_for_union_sum_type(info ast.SumType, styp string, typ_str } val += ')' res := 'str_intp(2, _MOV((StrIntpData[]){ - {_SLIT("${clean_sum_type_v_type_name}(\'"), ${si_s_code}, {.d_s = ${val}}}, - {_SLIT("\')"), 0, {.d_c = 0 }} + {_S("${clean_sum_type_v_type_name}(\'"), ${si_s_code}, {.d_s = ${val}}}, + {_S("\')"), 0, {.d_c = 0 }} }))' fn_builder.write_string('\t\tcase ${int(typ)}: return ${res};\n') } else { @@ -504,13 +504,13 @@ fn (mut g Gen) gen_str_for_union_sum_type(info ast.SumType, styp string, typ_str } val += ')' res := 'str_intp(2, _MOV((StrIntpData[]){ - {_SLIT("${clean_sum_type_v_type_name}("), ${si_s_code}, {.d_s = ${val}}}, - {_SLIT(")"), 0, {.d_c = 0 }} + {_S("${clean_sum_type_v_type_name}("), ${si_s_code}, {.d_s = ${val}}}, + {_S(")"), 0, {.d_c = 0 }} }))' fn_builder.write_string('\t\tcase ${int(typ)}: return ${res};\n') } } - fn_builder.writeln('\t\tdefault: return _SLIT("unknown sum type value");') + fn_builder.writeln('\t\tdefault: return _S("unknown sum type value");') fn_builder.writeln('\t}') fn_builder.writeln('}') g.auto_fn_definitions << fn_builder.str() @@ -552,8 +552,8 @@ fn (mut g Gen) gen_str_for_fn_type(info ast.FnType, styp string, str_fn_name str $if trace_autostr ? { eprintln('> gen_str_for_fn_type: ${info.func.name} | ${styp} | ${str_fn_name}') } - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(); // auto') - g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}() { return _SLIT("${g.fn_decl_str(info)}");}') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}();') + g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}() { return _S("${g.fn_decl_str(info)}");}') } fn (mut g Gen) gen_str_for_chan(info ast.Chan, styp string, str_fn_name string) { @@ -561,8 +561,8 @@ fn (mut g Gen) gen_str_for_chan(info ast.Chan, styp string, str_fn_name string) eprintln('> gen_str_for_chan: ${info.elem_type.debug()} | ${styp} | ${str_fn_name}') } elem_type_name := util.strip_main_name(g.table.get_type_name(g.unwrap_generic(info.elem_type))) - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x); // auto') - g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x) { return sync__Channel_auto_str(x, _SLIT("${elem_type_name}")); }') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x);') + g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} x) { return sync__Channel_auto_str(x, _S("${elem_type_name}")); }') } fn (mut g Gen) gen_str_for_thread(info ast.Thread, styp string, str_fn_name string) { @@ -571,7 +571,7 @@ fn (mut g Gen) gen_str_for_thread(info ast.Thread, styp string, str_fn_name stri } ret_type_name := util.strip_main_name(g.table.get_type_name(info.return_type)) g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} _); // auto}') - g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} _) { return _SLIT("thread(${ret_type_name})");}') + g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} _) { return _S("thread(${ret_type_name})");}') } @[inline] @@ -610,12 +610,12 @@ fn (mut g Gen) gen_str_for_array(info ast.Array, styp string, str_fn_name string sym_has_str_method, str_method_expects_ptr, _ := sym.str_method_info() elem_str_fn_name := g.get_str_fn(typ) - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} a); // auto') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} a);') g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} a) { return indent_${str_fn_name}(a, 0);}') - g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} a, int indent_count); // auto') + g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} a, int indent_count);') g.auto_str_funcs.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} a, int indent_count) {') g.auto_str_funcs.writeln('\tstrings__Builder sb = strings__new_builder(2 + a.len * 10);') - g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _SLIT("["));') + g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _S("["));') g.auto_str_funcs.writeln('\tfor (int i = 0; i < a.len; ++i) {') if sym.kind == .function { g.auto_str_funcs.writeln('\t\tstring x = ${elem_str_fn_name}();') @@ -630,11 +630,11 @@ fn (mut g Gen) gen_str_for_array(info ast.Array, styp string, str_fn_name string if is_elem_ptr { deref, deref_label := deref_kind(str_method_expects_ptr, is_elem_ptr, typ) - g.auto_str_funcs.writeln('\t\tstring x = _SLIT("nil");') + g.auto_str_funcs.writeln('\t\tstring x = _S("nil");') if !typ.has_flag(.option) { g.auto_str_funcs.writeln('\t\tif (it != 0) {') } - g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _SLIT("${deref_label}"));') + g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _S("${deref_label}"));') g.auto_str_funcs.writeln('\t\t\tx = ${elem_str_fn_name}(${deref}it);') if !typ.has_flag(.option) { g.auto_str_funcs.writeln('\t\t}') @@ -655,15 +655,15 @@ fn (mut g Gen) gen_str_for_array(info ast.Array, styp string, str_fn_name string } } else if sym.kind == .rune { // Rune are managed at this level as strings - g.auto_str_funcs.writeln('\t\tstring x = str_intp(2, _MOV((StrIntpData[]){{_SLIT("\`"), ${si_s_code}, {.d_s = ${elem_str_fn_name}(it) }}, {_SLIT("\`"), 0, {.d_c = 0 }}}));\n') + g.auto_str_funcs.writeln('\t\tstring x = str_intp(2, _MOV((StrIntpData[]){{_S("\`"), ${si_s_code}, {.d_s = ${elem_str_fn_name}(it) }}, {_S("\`"), 0, {.d_c = 0 }}}));\n') } else if sym.kind == .string { if typ.has_flag(.option) { func := g.get_str_fn(typ) g.auto_str_funcs.writeln('\t\tstring x = ${func}(it);\n') } else if is_elem_ptr { - g.auto_str_funcs.writeln('\t\tstring x = str_intp(2, _MOV((StrIntpData[]){{_SLIT("&\'"), ${si_s_code}, {.d_s = *it }}, {_SLIT("\'"), 0, {.d_c = 0 }}}));\n') + g.auto_str_funcs.writeln('\t\tstring x = str_intp(2, _MOV((StrIntpData[]){{_S("&\'"), ${si_s_code}, {.d_s = *it }}, {_S("\'"), 0, {.d_c = 0 }}}));\n') } else { - g.auto_str_funcs.writeln('\t\tstring x = str_intp(2, _MOV((StrIntpData[]){{_SLIT("\'"), ${si_s_code}, {.d_s = it }}, {_SLIT("\'"), 0, {.d_c = 0 }}}));\n') + g.auto_str_funcs.writeln('\t\tstring x = str_intp(2, _MOV((StrIntpData[]){{_S("\'"), ${si_s_code}, {.d_s = it }}, {_S("\'"), 0, {.d_c = 0 }}}));\n') } } else { // There is a custom .str() method, so use it. @@ -671,17 +671,17 @@ fn (mut g Gen) gen_str_for_array(info ast.Array, styp string, str_fn_name string // `fn (x T) str() {` or `fn (x &T) str() {`, and convert accordingly deref, deref_label := deref_kind(str_method_expects_ptr, is_elem_ptr, typ) if is_elem_ptr { - g.auto_str_funcs.writeln('\t\tstring x = _SLIT("nil");') + g.auto_str_funcs.writeln('\t\tstring x = _S("nil");') if !typ.has_flag(.option) { g.auto_str_funcs.writeln('\t\tif (it != 0) {') } - g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _SLIT("${deref_label}"));') + g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _S("${deref_label}"));') g.auto_str_funcs.writeln('\t\t\tx = ${elem_str_fn_name}(${deref}it);') if !typ.has_flag(.option) { g.auto_str_funcs.writeln('\t\t}') } } else { - g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, _SLIT("${deref_label}"));') + g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, _S("${deref_label}"));') g.auto_str_funcs.writeln('\t\tstring x = ${elem_str_fn_name}(${deref}it);') } } @@ -692,10 +692,10 @@ fn (mut g Gen) gen_str_for_array(info ast.Array, styp string, str_fn_name string g.auto_str_funcs.writeln('\t\tstring_free(&x);') } g.auto_str_funcs.writeln('\t\tif (i < a.len-1) {') - g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _SLIT(", "));') + g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _S(", "));') g.auto_str_funcs.writeln('\t\t}') g.auto_str_funcs.writeln('\t}') - g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _SLIT("]"));') + g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _S("]"));') g.auto_str_funcs.writeln('\tstring res = strings__Builder_str(&sb);') g.auto_str_funcs.writeln('\tstrings__Builder_free(&sb);') g.auto_str_funcs.writeln('\treturn res;') @@ -717,12 +717,12 @@ fn (mut g Gen) gen_str_for_array_fixed(info ast.ArrayFixed, styp string, str_fn_ elem_str_fn_name := g.get_str_fn(typ) def_arg := if info.is_fn_ret { '${g.styp(typ)} a[${info.size}]' } else { '${styp} a' } - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${def_arg}); // auto') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${def_arg});') g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${def_arg}) { return indent_${str_fn_name}(a, 0);}') - g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${def_arg}, int indent_count); // auto') + g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${def_arg}, int indent_count);') g.auto_str_funcs.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${def_arg}, int indent_count) {') g.auto_str_funcs.writeln('\tstrings__Builder sb = strings__new_builder(2 + ${info.size} * 10);') - g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _SLIT("["));') + g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _S("["));') g.auto_str_funcs.writeln('\tfor (int i = 0; i < ${info.size}; ++i) {') if sym.kind == .function { g.auto_str_funcs.writeln('\t\tstring x = ${elem_str_fn_name}();') @@ -731,9 +731,9 @@ fn (mut g Gen) gen_str_for_array_fixed(info ast.ArrayFixed, styp string, str_fn_ deref, deref_label := deref_kind(str_method_expects_ptr, is_elem_ptr, typ) if should_use_indent_func(sym.kind) && !sym_has_str_method { if is_elem_ptr { - g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, _SLIT("${deref_label}"));') + g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, _S("${deref_label}"));') g.auto_str_funcs.writeln('\t\tif ( 0 == a[i] ) {') - g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _SLIT("0"));') + g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _S("0"));') g.auto_str_funcs.writeln('\t\t}else{') g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, ${elem_str_fn_name}(${deref}a[i]));') g.auto_str_funcs.writeln('\t\t}') @@ -759,10 +759,10 @@ fn (mut g Gen) gen_str_for_array_fixed(info ast.ArrayFixed, styp string, str_fn_ } } g.auto_str_funcs.writeln('\t\tif (i < ${info.size - 1}) {') - g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _SLIT(", "));') + g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _S(", "));') g.auto_str_funcs.writeln('\t\t}') g.auto_str_funcs.writeln('\t}') - g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _SLIT("]"));') + g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _S("]"));') g.auto_str_funcs.writeln('\tstring res = strings__Builder_str(&sb);') g.auto_str_funcs.writeln('\tstrings__Builder_free(&sb);') g.auto_str_funcs.writeln('\treturn res;') @@ -813,16 +813,16 @@ fn (mut g Gen) gen_str_for_map(info ast.Map, styp string, str_fn_name string) { g.get_str_fn(val_typ) } - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} m); // auto') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} m);') g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${styp} m) { return indent_${str_fn_name}(m, 0);}') - g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} m, int indent_count); // auto') + g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} m, int indent_count);') g.auto_str_funcs.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${styp} m, int indent_count) { /* gen_str_for_map */') g.auto_str_funcs.writeln('\tstrings__Builder sb = strings__new_builder(2 + m.key_values.len * 10);') - g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _SLIT("{"));') + g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _S("{"));') g.auto_str_funcs.writeln('\tbool is_first = true;') g.auto_str_funcs.writeln('\tfor (int i = 0; i < m.key_values.len; ++i) {') g.auto_str_funcs.writeln('\t\tif (!DenseArray_has_index(&m.key_values, i)) { continue; }') - g.auto_str_funcs.writeln('\t\telse if (!is_first) { strings__Builder_write_string(&sb, _SLIT(", ")); }') + g.auto_str_funcs.writeln('\t\telse if (!is_first) { strings__Builder_write_string(&sb, _S(", ")); }') if key_sym.kind == .string { g.auto_str_funcs.writeln('\t\tstring key = *(string*)DenseArray_key(&m.key_values, i);') @@ -837,11 +837,11 @@ fn (mut g Gen) gen_str_for_map(info ast.Map, styp string, str_fn_name string) { } else { g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, ${key_str_fn_name}(key));') } - g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, _SLIT(": "));') + g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, _S(": "));') _, str_method_expects_ptr, _ := val_sym.str_method_info() _, deref_label := deref_kind(str_method_expects_ptr, val_typ.is_ptr(), val_typ) if deref_label != '' { - g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _SLIT("${deref_label}"));') + g.auto_str_funcs.writeln('\t\t\tstrings__Builder_write_string(&sb, _S("${deref_label}"));') } if val_sym.kind == .function { g.auto_str_funcs.writeln('\t\tstrings__Builder_write_string(&sb, ${elem_str_fn_name}());') @@ -886,7 +886,7 @@ fn (mut g Gen) gen_str_for_map(info ast.Map, styp string, str_fn_name string) { } g.auto_str_funcs.writeln('\t\tis_first = false;') g.auto_str_funcs.writeln('\t}') - g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _SLIT("}"));') + g.auto_str_funcs.writeln('\tstrings__Builder_write_string(&sb, _S("}"));') g.auto_str_funcs.writeln('\tstring res = strings__Builder_str(&sb);') g.auto_str_funcs.writeln('\tstrings__Builder_free(&sb);') g.auto_str_funcs.writeln('\treturn res;') @@ -948,9 +948,9 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin // _str() functions should have a single argument, the indenting ones take 2: is_c_struct := lang == .c arg_def := if is_c_struct { '${styp}* it' } else { '${styp} it' } - g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${arg_def}); // auto') + g.definitions.writeln('${g.static_non_parallel}string ${str_fn_name}(${arg_def});') g.auto_str_funcs.writeln('${g.static_non_parallel}string ${str_fn_name}(${arg_def}) { return indent_${str_fn_name}(it, 0);}') - g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${arg_def}, int indent_count); // auto') + g.definitions.writeln('${g.static_non_parallel}string indent_${str_fn_name}(${arg_def}, int indent_count);') mut fn_builder := strings.new_builder(512) defer { g.auto_fn_definitions << fn_builder.str() @@ -961,12 +961,12 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin clean_struct_v_type_name := if info.is_anon { 'struct ' } else { util.strip_main_name(typ_str) } // generate ident / indent length = 4 spaces if info.fields.len == 0 { - fn_builder.writeln('\treturn _SLIT("${clean_struct_v_type_name}{}");') + fn_builder.writeln('\treturn _S("${clean_struct_v_type_name}{}");') fn_builder.writeln('}') return } - fn_builder.writeln('\tstring indents = string_repeat(_SLIT(" "), indent_count);') + fn_builder.writeln('\tstring indents = string_repeat(_S(" "), indent_count);') mut fn_body_surrounder := util.new_surrounder(info.fields.len) mut fn_body := strings.new_builder(info.fields.len * 256) @@ -993,7 +993,7 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin return } fn_body.writeln('\tstring res = str_intp( ${(info.fields.len - field_skips.len) * 4 + 3}, _MOV((StrIntpData[]){') - fn_body.writeln('\t\t{_SLIT("${clean_struct_v_type_name}{\\n"), 0, {.d_c=0}},') + fn_body.writeln('\t\t{_S("${clean_struct_v_type_name}{\\n"), 0, {.d_c=0}},') allow_circular := info.attrs.any(it.name == 'autostr' && it.arg == 'allowrecurse') mut is_first := true @@ -1034,10 +1034,10 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin if is_first { // first field doesn't need \n - fn_body.write_string('\t\t{_SLIT0, ${si_s_code}, {.d_s=indents}}, {_SLIT(" ${field.name}: ${ptr_amp}${prefix}"), 0, {.d_c=0}}, ') + fn_body.write_string('\t\t{_SLIT0, ${si_s_code}, {.d_s=indents}}, {_S(" ${field.name}: ${ptr_amp}${prefix}"), 0, {.d_c=0}}, ') is_first = false } else { - fn_body.write_string('\t\t{_SLIT("\\n"), ${si_s_code}, {.d_s=indents}}, {_SLIT(" ${field.name}: ${ptr_amp}${prefix}"), 0, {.d_c=0}}, ') + fn_body.write_string('\t\t{_S("\\n"), ${si_s_code}, {.d_s=indents}}, {_S(" ${field.name}: ${ptr_amp}${prefix}"), 0, {.d_c=0}}, ') } // custom methods management @@ -1061,12 +1061,12 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin } // with floats we use always the g representation: if is_opt_field { - fn_body.write_string('{_SLIT("${quote_str}"), ${si_s_code}, {.d_s=') + fn_body.write_string('{_S("${quote_str}"), ${si_s_code}, {.d_s=') } else if sym.kind !in [.f32, .f64] { - fn_body.write_string('{_SLIT("${quote_str}"), ${int(base_fmt)}, {.${data_str(base_fmt)}=') + fn_body.write_string('{_S("${quote_str}"), ${int(base_fmt)}, {.${data_str(base_fmt)}=') } else { g_fmt := '0x' + (u32(base_fmt) | u32(0x7F) << 9).hex() - fn_body.write_string('{_SLIT("${quote_str}"), ${g_fmt}, {.${data_str(base_fmt)}=') + fn_body.write_string('{_S("${quote_str}"), ${g_fmt}, {.${data_str(base_fmt)}=') } mut funcprefix := '' @@ -1089,7 +1089,7 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin } else { funcprefix += 'isnil(${it_field_name})' } - funcprefix += ' ? _SLIT("nil") : ' + funcprefix += ' ? _S("nil") : ' // struct, floats and ints have a special case through the _str function if !ftyp_noshared.has_flag(.option) && sym.kind !in [.struct, .alias, .enum, .sum_type, .map, .interface] @@ -1110,12 +1110,12 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin if is_field_array { if is_opt_field { arr_styp := g.base_type(field.typ) - fn_body.write_string('${it_field_name}.state != 2 && (*(${arr_styp}*)${it_field_name}.data).len > 0 ? ${funcprefix}_SLIT("[]") : ${funcprefix}_SLIT("[]")') + fn_body.write_string('${it_field_name}.state != 2 && (*(${arr_styp}*)${it_field_name}.data).len > 0 ? ${funcprefix}_S("[]") : ${funcprefix}_S("[]")') } else { - fn_body.write_string('${it_field_name}.len > 0 ? ${funcprefix}_SLIT("[]") : ${funcprefix}_SLIT("[]")') + fn_body.write_string('${it_field_name}.len > 0 ? ${funcprefix}_S("[]") : ${funcprefix}_S("[]")') } } else { - fn_body.write_string('${funcprefix}_SLIT("")') + fn_body.write_string('${funcprefix}_S("")') } } else { // manage C charptr @@ -1123,7 +1123,7 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin fn_body.write_string('tos4((byteptr)${func})') } else { if field.typ.is_ptr() && sym.kind in [.struct, .interface] { - funcprefix += '(indent_count > 25)? _SLIT("") : ' + funcprefix += '(indent_count > 25)? _S("") : ' } // eprintln('>>> caller_should_free: ${caller_should_free:6s} | funcprefix: $funcprefix | func: $func') if caller_should_free { @@ -1137,9 +1137,9 @@ fn (mut g Gen) gen_str_for_struct(info ast.Struct, lang ast.Language, styp strin } } - fn_body.writeln('}}, {_SLIT("${quote_str}"), 0, {.d_c=0}},') + fn_body.writeln('}}, {_S("${quote_str}"), 0, {.d_c=0}},') } - fn_body.writeln('\t\t{_SLIT("\\n"), ${si_s_code}, {.d_s=indents}}, {_SLIT("}"), 0, {.d_c=0}},') + fn_body.writeln('\t\t{_S("\\n"), ${si_s_code}, {.d_s=indents}}, {_S("}"), 0, {.d_c=0}},') fn_body.writeln('\t}));') } @@ -1205,7 +1205,7 @@ fn struct_auto_str_func(sym &ast.TypeSymbol, lang ast.Language, _field_type ast. method_str = 'it${op}${final_field_name}${sufix}' } if sym.kind == .bool { - return '${method_str} ? _SLIT("true") : _SLIT("false")', false + return '${method_str} ? _S("true") : _S("false")', false } else if (field_type.is_int_valptr() || field_type.is_float_valptr()) && !expects_ptr { // ptr int can be "nil", so this needs to be casted to a string if sym.kind == .f32 { @@ -1289,7 +1289,7 @@ fn (mut g Gen) gen_enum_static_from_string(fn_name string, mod_enum_name string, enum_field_vals := g.table.get_enum_field_vals(mod_enum_name) mut fn_builder := strings.new_builder(512) - g.definitions.writeln('${g.static_non_parallel}${option_enum_styp} ${fn_name}(string name); // auto') + g.definitions.writeln('${g.static_non_parallel}${option_enum_styp} ${fn_name}(string name);') fn_builder.writeln('${g.static_non_parallel}${option_enum_styp} ${fn_name}(string name) {') fn_builder.writeln('\t${option_enum_styp} t1;') @@ -1297,7 +1297,7 @@ fn (mut g Gen) gen_enum_static_from_string(fn_name string, mod_enum_name string, fn_builder.writeln('\tint inx = 0;') fn_builder.writeln('\tarray field_names = __new_array_with_default(0, 0, sizeof(string), 0);') for field_name in enum_field_names { - fn_builder.writeln('\tarray_push((array*)&field_names, _MOV((string[]){ _SLIT("${field_name}") }));') + fn_builder.writeln('\tarray_push((array*)&field_names, _MOV((string[]){ _S("${field_name}") }));') } fn_builder.writeln('\tarray field_vals = __new_array_with_default(0, 0, sizeof(i64), 0);') for field_val in enum_field_vals { @@ -1314,7 +1314,7 @@ fn (mut g Gen) gen_enum_static_from_string(fn_name string, mod_enum_name string, fn_builder.writeln('\t\t_option_ok(&(${enum_styp}[]){ (*(i64*)array_get(field_vals, inx)) }, (_option*)&t1, sizeof(${enum_styp}));') fn_builder.writeln('\t\treturn t1;') fn_builder.writeln('\t} else {') - fn_builder.writeln('\t\treturn (${option_enum_styp}){ .state=2, .err=_const_none__, .data={EMPTY_STRUCT_INITIALIZATION} };') + fn_builder.writeln('\t\treturn (${option_enum_styp}){ .state=2, .err=_const_none__, .data={E_STRUCT} };') fn_builder.writeln('\t}') fn_builder.writeln('}') g.auto_fn_definitions << fn_builder.str() diff --git a/vlib/v/gen/c/cgen.v b/vlib/v/gen/c/cgen.v index 7104123690..9821721912 100644 --- a/vlib/v/gen/c/cgen.v +++ b/vlib/v/gen/c/cgen.v @@ -1278,7 +1278,7 @@ fn (mut g Gen) expr_string(expr ast.Expr) string { fn (mut g Gen) expr_string_opt(typ ast.Type, expr ast.Expr) string { expr_str := g.expr_string(expr) if expr is ast.None { - return '(${g.styp(typ)}){.state=2, .err=${expr_str}, .data={EMPTY_STRUCT_INITIALIZATION}}' + return '(${g.styp(typ)}){.state=2, .err=${expr_str}, .data={E_STRUCT}}' } return expr_str } @@ -1492,7 +1492,7 @@ fn (mut g Gen) register_thread_void_wait_call() { } else { g.gowrappers.writeln('\tint stat = pthread_join(thread, (void **)NULL);') } - g.gowrappers.writeln('\tif (stat != 0) { _v_panic(_SLIT("unable to join thread")); }') + g.gowrappers.writeln('\tif (stat != 0) { _v_panic(_S("unable to join thread")); }') if g.pref.os == .windows { g.gowrappers.writeln('\tCloseHandle(thread);') } @@ -1608,7 +1608,7 @@ fn (mut g Gen) write_chan_pop_option_fns() { static inline ${opt_el_type} __Option_${styp}_popval(${styp} ch) { ${opt_el_type} _tmp = {0}; if (sync__Channel_try_pop_priv(ch, _tmp.data, false)) { - return (${opt_el_type}){ .state = 2, .err = _v_error(_SLIT("channel closed")), .data = {EMPTY_STRUCT_INITIALIZATION} }; + return (${opt_el_type}){ .state = 2, .err = _v_error(_S("channel closed")), .data = {E_STRUCT} }; } return _tmp; }') @@ -1630,7 +1630,7 @@ fn (mut g Gen) write_chan_push_option_fns() { g.channel_definitions.writeln(' static inline ${option_name}_void __Option_${styp}_pushval(${styp} ch, ${el_type} e) { if (sync__Channel_try_push_priv(ch, &e, false)) { - return (${option_name}_void){ .state = 2, .err = _v_error(_SLIT("channel closed")), .data = {EMPTY_STRUCT_INITIALIZATION} }; + return (${option_name}_void){ .state = 2, .err = _v_error(_S("channel closed")), .data = {E_STRUCT} }; } return (${option_name}_void){0}; }') @@ -2427,7 +2427,11 @@ fn (mut g Gen) stmt(node ast.Stmt) { if !node.is_unsafe { g.writeln('{') } else { - g.writeln('{ // Unsafe block') + if g.pref.is_prod { + g.writeln('{') + } else { + g.writeln('{ // Unsafe block') + } } g.stmts(node.stmts) g.writeln('}') @@ -2634,7 +2638,11 @@ fn (mut g Gen) stmt(node ast.Stmt) { fn (mut g Gen) write_defer_stmts() { for i := g.defer_stmts.len - 1; i >= 0; i-- { defer_stmt := g.defer_stmts[i] - g.writeln2('// Defer begin', 'if (${g.defer_flag_var(defer_stmt)}) {') + if !g.pref.is_prod { + g.writeln('// Defer begin') + } + g.writeln('if (${g.defer_flag_var(defer_stmt)}) {') + // g.indent++ if defer_stmt.ifdef.len > 0 { g.writeln(defer_stmt.ifdef) @@ -2644,7 +2652,10 @@ fn (mut g Gen) write_defer_stmts() { g.stmts(defer_stmt.stmts) } // g.indent-- - g.writeln2('}', '// Defer end') + g.writeln('}') + if !g.pref.is_prod { + g.writeln('// Defer end') + } } } @@ -2824,7 +2835,7 @@ fn (mut g Gen) call_cfn_for_casting_expr(fname string, expr ast.Expr, exp ast.Ty } } if got_styp == 'none' && !g.cur_fn.return_type.has_flag(.option) { - g.write('(none){EMPTY_STRUCT_INITIALIZATION}') + g.write('(none){E_STRUCT}') } else if is_comptime_variant { ctyp := g.type_resolver.get_ct_type_or_default('${g.comptime.comptime_for_variant_var}.typ', ast.void_type) @@ -3116,9 +3127,9 @@ fn cestring(s string) string { return s.replace('\\', '\\\\').replace('"', "'") } -// ctoslit returns a '_SLIT("$s")' call, where s is properly escaped. +// ctoslit returns a '_S("$s")' call, where s is properly escaped. fn ctoslit(s string) string { - return '_SLIT("' + cescape_nonascii(cestring(s)) + '")' + return '_S("' + cescape_nonascii(cestring(s)) + '")' } fn (mut g Gen) gen_attrs(attrs []ast.Attr) { @@ -3787,7 +3798,7 @@ fn (mut g Gen) expr(node_ ast.Expr) { is_unwrapped = !g.inside_assign } g.writeln('if (${expr_str}.state != 0) {') - g.writeln2('\tpanic_option_not_set(_SLIT("none"));', '}') + g.writeln2('\tpanic_option_not_set(_S("none"));', '}') g.write(cur_line) if is_unwrapped { typ := g.type_resolver.typeof_type(node.expr, node.typ) @@ -3912,7 +3923,10 @@ fn (mut g Gen) expr(node_ ast.Expr) { typ := g.unwrap_generic(node.typ) sym := g.table.sym(typ) sidx := g.type_sidx(typ) - g.write('${sidx} /* ${sym.name} */') + g.write('${sidx}') + if !g.pref.is_prod { + g.write(' /* ${sym.name} */') + } } ast.TypeOf { g.typeof_expr(node) @@ -3961,7 +3975,7 @@ fn (mut g Gen) type_name(raw_type ast.Type) { } else { s = g.table.type_to_str(g.unwrap_generic(typ)) } - g.write('_SLIT("${util.strip_main_name(s)}")') + g.write('_S("${util.strip_main_name(s)}")') } fn (mut g Gen) typeof_expr(node ast.TypeOf) { @@ -3979,13 +3993,13 @@ fn (mut g Gen) typeof_expr(node ast.TypeOf) { } else if sym.kind == .array_fixed { fixed_info := sym.info as ast.ArrayFixed typ_name := g.table.get_type_name(fixed_info.elem_type) - g.write('_SLIT("[${fixed_info.size}]${util.strip_main_name(typ_name)}")') + g.write('_S("[${fixed_info.size}]${util.strip_main_name(typ_name)}")') } else if sym.kind == .function { info := sym.info as ast.FnType - g.write('_SLIT("${g.fn_decl_str(info)}")') + g.write('_S("${g.fn_decl_str(info)}")') } else if typ.has_flag(.variadic) { varg_elem_type_sym := g.table.sym(g.table.value_type(typ)) - g.write('_SLIT("...${util.strip_main_name(varg_elem_type_sym.name)}")') + g.write('_S("...${util.strip_main_name(varg_elem_type_sym.name)}")') } else { g.type_name(typ) } @@ -4528,7 +4542,7 @@ fn (mut g Gen) debugger_stmt(node ast.DebuggerStmt) { continue } if obj is ast.Var && g.check_var_scope(obj, node.pos.pos) { - keys.write_string('_SLIT("${obj.name}")') + keys.write_string('_S("${obj.name}")') var_typ := if obj.ct_type_var != .no_comptime { g.type_resolver.get_type(ast.Ident{ obj: obj }) } else if obj.smartcasts.len > 0 { @@ -4536,7 +4550,7 @@ fn (mut g Gen) debugger_stmt(node ast.DebuggerStmt) { } else { obj.typ } - values.write_string('{.typ=_SLIT("${g.table.type_to_str(g.unwrap_generic(var_typ))}"),.value=') + values.write_string('{.typ=_S("${g.table.type_to_str(g.unwrap_generic(var_typ))}"),.value=') obj_sym := g.table.sym(obj.typ) cast_sym := g.table.sym(var_typ) @@ -4649,7 +4663,7 @@ fn (mut g Gen) debugger_stmt(node ast.DebuggerStmt) { g.writeln('}),') g.write2('\t\t_MOV((v__debug__DebugContextVar[${vars.len}]){', values.str()) g.writeln('}));') - g.writeln('\tv__debug__Debugger_interact(&g_debugger, (v__debug__DebugContextInfo){.is_anon=${is_anon},.is_generic=${is_generic},.is_method=${is_method},.receiver_typ_name=_SLIT("${receiver_type}"),.line=${paline},.file=_SLIT("${pafile}"),.mod=_SLIT("${pamod}"),.fn_name=_SLIT("${pafn}"),.scope=_scope});') + g.writeln('\tv__debug__Debugger_interact(&g_debugger, (v__debug__DebugContextInfo){.is_anon=${is_anon},.is_generic=${is_generic},.is_method=${is_method},.receiver_typ_name=_S("${receiver_type}"),.line=${paline},.file=_S("${pafile}"),.mod=_S("${pamod}"),.fn_name=_S("${pafn}"),.scope=_scope});') g.write('}') } @@ -4716,7 +4730,11 @@ fn (mut g Gen) enum_decl(node ast.EnumDecl) { } else { cur_enum_expr } - g.enum_typedefs.writeln(', // ${cur_value}') + if g.pref.is_prod { + g.enum_typedefs.writeln(',') + } else { + g.enum_typedefs.writeln(', // ${cur_value}') + } cur_enum_offset++ } packed_attribute := if !g.is_cc_msvc && node.typ != ast.int_type { @@ -5549,7 +5567,7 @@ fn (mut g Gen) gen_result_error(target_type ast.Type, expr ast.Expr) { styp := g.styp(g.unwrap_generic(target_type)) g.write('(${styp}){ .is_error=true, .err=') g.expr(expr) - g.write(', .data={EMPTY_STRUCT_INITIALIZATION} }') + g.write(', .data={E_STRUCT} }') } // NB: remove this when option has no errors anymore @@ -5561,7 +5579,7 @@ fn (mut g Gen) gen_option_error(target_type ast.Type, expr ast.Expr) { } else { g.expr(expr) } - g.write(', .data={EMPTY_STRUCT_INITIALIZATION} }') + g.write(', .data={E_STRUCT} }') } fn (mut g Gen) hash_stmt_guarded_include(node ast.HashStmt) string { @@ -6036,7 +6054,7 @@ fn (mut g Gen) return_stmt(node ast.Return) { tmp_var := g.expr_with_fixed_array(expr0, type0, fn_ret_type) g.writeln('${ret_typ} ${tmpvar} = ${tmp_var};') } else { - g.writeln('${ret_typ} ${tmpvar} = (${ret_typ}){ .state=0, .err=_const_none__, .data={EMPTY_STRUCT_INITIALIZATION} };') + g.writeln('${ret_typ} ${tmpvar} = (${ret_typ}){ .state=0, .err=_const_none__, .data={E_STRUCT} };') if expr0 is ast.StructInit { g.write('memcpy(${tmpvar}.data, ') tmp_var := g.expr_with_opt(expr0, type0, fn_ret_type) @@ -6372,7 +6390,7 @@ fn (mut g Gen) write_init_function() { g.write_debug_calls_typeof_functions() if g.pref.trace_calls && g.pref.should_trace_fn_name('_vinit') { - g.writeln('\tv__trace_calls__on_call(_SLIT("_vinit"));') + g.writeln('\tv__trace_calls__on_call(_S("_vinit"));') } if g.use_segfault_handler && !g.pref.is_shared { @@ -6479,7 +6497,7 @@ fn (mut g Gen) write_init_function() { fn_vcleanup_start_pos := g.out.len g.writeln('void _vcleanup(void) {') if g.pref.trace_calls && g.pref.should_trace_fn_name('_vcleanup') { - g.writeln('\tv__trace_calls__on_call(_SLIT("_vcleanup"));') + g.writeln('\tv__trace_calls__on_call(_S("_vcleanup"));') } if g.is_autofree { // g.writeln('puts("cleaning up...");') @@ -6639,17 +6657,20 @@ fn (mut g Gen) write_types(symbols []&ast.TypeSymbol) { } struct_names[name] = true g.typedefs.writeln('typedef struct ${name} ${name};') - g.type_definitions.writeln('') - g.type_definitions.writeln('// Union sum type ${name} = ') mut idxs := []int{} - for variant in sym.info.variants { - if variant in idxs { - continue + if !g.pref.is_prod { + // Do not print union sum type coment in prod mode + g.type_definitions.writeln('') + g.type_definitions.writeln('// Union sum type ${name} = ') + for variant in sym.info.variants { + if variant in idxs { + continue + } + g.type_definitions.writeln('// | ${variant:4d} = ${g.styp(variant.idx_type())}') + idxs << variant } - g.type_definitions.writeln('// | ${variant:4d} = ${g.styp(variant.idx_type())}') - idxs << variant + idxs.clear() } - idxs.clear() g.type_definitions.writeln('struct ${name} {') g.type_definitions.writeln('\tunion {') for variant in sym.info.variants { @@ -7103,7 +7124,7 @@ fn (mut g Gen) or_block(var_name string, or_block ast.OrExpr, return_type ast.Ty err_msg := 'IError_name_table[${cvar_name}${tmp_op}err._typ]._method_msg(${cvar_name}${tmp_op}err._object)' if g.pref.is_debug { paline, pafile, pamod, pafn := g.panic_debug_info(or_block.pos) - g.writeln('panic_debug(${paline}, tos3("${pafile}"), tos3("${pamod}"), tos3("${pafn}"), ${err_msg}.len == 0 ? _SLIT("option not set ()") : ${err_msg});') + g.writeln('panic_debug(${paline}, tos3("${pafile}"), tos3("${pamod}"), tos3("${pafn}"), ${err_msg}.len == 0 ? _S("option not set ()") : ${err_msg});') } else { g.writeln('\tpanic_option_not_set( ${err_msg} );') } @@ -7154,16 +7175,16 @@ fn c_fn_name(name_ string) string { fn (mut g Gen) type_default_sumtype(typ_ ast.Type, sym ast.TypeSymbol) string { if typ_.has_flag(.option) { - return '(${g.styp(typ_)}){.state=2, .err=_const_none__, .data={EMPTY_STRUCT_INITIALIZATION}}' + return '(${g.styp(typ_)}){.state=2, .err=_const_none__, .data={E_STRUCT}}' } first_typ := g.unwrap_generic((sym.info as ast.SumType).variants[0]) first_sym := g.table.sym(first_typ) first_styp := g.styp(first_typ) first_field := g.get_sumtype_variant_name(first_typ, first_sym) default_str := if first_typ.has_flag(.option) { - '(${first_styp}){.state=2, .err=_const_none__, .data={EMPTY_STRUCT_INITIALIZATION}}' + '(${first_styp}){.state=2, .err=_const_none__, .data={E_STRUCT}}' } else if first_sym.info is ast.Struct && first_sym.info.is_empty_struct() { - '{EMPTY_STRUCT_INITIALIZATION}' + '{E_STRUCT}' } else { g.type_default_no_sumtype(first_typ) } @@ -7187,7 +7208,7 @@ fn (mut g Gen) type_default(typ_ ast.Type) string { fn (mut g Gen) type_default_impl(typ_ ast.Type, decode_sumtype bool) string { typ := g.unwrap_generic(typ_) if typ.has_flag(.option) { - return '(${g.styp(typ)}){.state=2, .err=_const_none__, .data={EMPTY_STRUCT_INITIALIZATION}}' + return '(${g.styp(typ)}){.state=2, .err=_const_none__, .data={E_STRUCT}}' } if typ.has_flag(.result) { return '{0}' @@ -7207,7 +7228,7 @@ fn (mut g Gen) type_default_impl(typ_ ast.Type, decode_sumtype bool) string { } .array_fixed { if sym.is_empty_struct_array() { - return '{EMPTY_STRUCT_INITIALIZATION}' + return '{E_STRUCT}' } return '{0}' } @@ -7340,7 +7361,7 @@ fn (mut g Gen) type_default_impl(typ_ ast.Type, decode_sumtype bool) string { } else { zero_str := if field_sym.language == .v && field_sym.info is ast.Struct && field_sym.info.is_empty_struct() { - '{EMPTY_STRUCT_INITIALIZATION}' + '{E_STRUCT}' } else if field_sym.kind == .sum_type { if decode_sumtype { g.type_default_sumtype(field.typ, field_sym) @@ -7613,14 +7634,14 @@ fn (mut g Gen) as_cast(node ast.AsCast) { fn (g &Gen) as_cast_name_table() string { if g.as_cast_type_names.len == 0 { - return 'new_array_from_c_array(1, 1, sizeof(VCastTypeIndexName), _MOV((VCastTypeIndexName[1]){(VCastTypeIndexName){.tindex = 0,.tname = _SLIT("unknown")}}));\n' + return 'new_array_from_c_array(1, 1, sizeof(VCastTypeIndexName), _MOV((VCastTypeIndexName[1]){(VCastTypeIndexName){.tindex = 0,.tname = _S("unknown")}}));\n' } mut name_ast := strings.new_builder(1024) casts_len := g.as_cast_type_names.len + 1 name_ast.writeln('new_array_from_c_array(${casts_len}, ${casts_len}, sizeof(VCastTypeIndexName), _MOV((VCastTypeIndexName[${casts_len}]){') - name_ast.writeln('\t\t (VCastTypeIndexName){.tindex = 0, .tname = _SLIT("unknown")}') + name_ast.writeln('\t\t (VCastTypeIndexName){.tindex = 0, .tname = _S("unknown")}') for key, value in g.as_cast_type_names { - name_ast.writeln('\t\t, (VCastTypeIndexName){.tindex = ${key}, .tname = _SLIT("${value}")}') + name_ast.writeln('\t\t, (VCastTypeIndexName){.tindex = ${key}, .tname = _S("${value}")}') } name_ast.writeln('\t}));\n') return name_ast.str() @@ -7688,7 +7709,9 @@ fn (mut g Gen) interface_table() string { } mut cast_functions := strings.new_builder(100) mut methods_wrapper := strings.new_builder(100) - methods_wrapper.writeln('// Methods wrapper for interface "${interface_name}"') + if !g.pref.is_prod { + methods_wrapper.writeln('// Methods wrapper for interface "${interface_name}"') + } mut already_generated_mwrappers := map[string]int{} iinidx_minimum_base := 1000 // Note: NOT 0, to avoid map entries set to 0 later, so `if already_generated_mwrappers[name] > 0 {` works. mut current_iinidx := iinidx_minimum_base @@ -7753,8 +7776,12 @@ fn (mut g Gen) interface_table() string { cast_struct.write_string('\t}') cast_struct_str := cast_struct.str() + if !g.pref.is_prod { + cast_functions.writeln(' +// Casting functions for converting "${cctype}" to interface "${interface_name}"') + } + cast_functions.writeln(' -// Casting functions for converting "${cctype}" to interface "${interface_name}" static inline ${interface_name} I_${cctype}_to_Interface_${interface_name}(${cctype}* x) { return ${cast_struct_str}; }') @@ -7975,7 +8002,9 @@ return ${cast_shared_struct_str}; } conversion_functions.writeln2('\treturn (${vsym.cname}){0};', '}') } - sb.writeln('// ^^^ number of types for interface ${interface_name}: ${current_iinidx - iinidx_minimum_base}') + if !g.pref.is_prod { + sb.writeln('// ^^^ number of types for interface ${interface_name}: ${current_iinidx - iinidx_minimum_base}') + } if iname_table_length == 0 { methods_struct.writeln('') } else { diff --git a/vlib/v/gen/c/cheaders.v b/vlib/v/gen/c/cheaders.v index 1577c8ba0a..63a06059e2 100644 --- a/vlib/v/gen/c/cheaders.v +++ b/vlib/v/gen/c/cheaders.v @@ -312,7 +312,7 @@ ${static_non_parallel}void* __closure_create(void* fn, void* data) { const c_common_macros = ' #define EMPTY_VARG_INITIALIZATION 0 #define EMPTY_STRUCT_DECLARATION -#define EMPTY_STRUCT_INITIALIZATION +#define E_STRUCT // Due to a tcc bug, the length of an array needs to be specified, but GCC crashes if it is... #define EMPTY_ARRAY_OF_ELEMS(x,n) (x[]) #define TCCSKIP(x) x @@ -392,9 +392,9 @@ const c_common_macros = ' #ifdef _MSC_VER #undef __V_GCC__ #undef EMPTY_STRUCT_DECLARATION - #undef EMPTY_STRUCT_INITIALIZATION + #undef E_STRUCT #define EMPTY_STRUCT_DECLARATION unsigned char _dummy_pad - #define EMPTY_STRUCT_INITIALIZATION 0 + #define E_STRUCT 0 #endif #ifndef _WIN32 @@ -411,9 +411,9 @@ const c_common_macros = ' #ifdef __TINYC__ #define _Atomic volatile #undef EMPTY_STRUCT_DECLARATION - #undef EMPTY_STRUCT_INITIALIZATION + #undef E_STRUCT #define EMPTY_STRUCT_DECLARATION unsigned char _dummy_pad - #define EMPTY_STRUCT_INITIALIZATION 0 + #define E_STRUCT 0 #undef EMPTY_ARRAY_OF_ELEMS #define EMPTY_ARRAY_OF_ELEMS(x,n) (x[n]) #undef __NOINLINE @@ -444,8 +444,8 @@ const c_common_macros = ' #define OPTION_CAST(x) (x) #if defined(_WIN32) || defined(__CYGWIN__) - #define VV_EXPORTED_SYMBOL extern __declspec(dllexport) - #define VV_LOCAL_SYMBOL static + #define VV_EXP extern __declspec(dllexport) + #define VV_LOC static #else // 4 < gcc < 5 is used by some older Ubuntu LTS and Centos versions, // and does not support __has_attribute(visibility) ... @@ -454,18 +454,18 @@ const c_common_macros = ' #endif #if (defined(__GNUC__) && (__GNUC__ >= 4)) || (defined(__clang__) && __has_attribute(visibility)) #ifdef ARM - #define VV_EXPORTED_SYMBOL extern __attribute__((externally_visible,visibility("default"))) + #define VV_EXP extern __attribute__((externally_visible,visibility("default"))) #else - #define VV_EXPORTED_SYMBOL extern __attribute__((visibility("default"))) + #define VV_EXP extern __attribute__((visibility("default"))) #endif #if defined(__clang__) && (defined(_VUSECACHE) || defined(_VBUILDMODULE)) - #define VV_LOCAL_SYMBOL static + #define VV_LOC static #else - #define VV_LOCAL_SYMBOL __attribute__ ((visibility ("hidden"))) + #define VV_LOC __attribute__ ((visibility ("hidden"))) #endif #else - #define VV_EXPORTED_SYMBOL extern - #define VV_LOCAL_SYMBOL static + #define VV_EXP extern + #define VV_LOC static #endif #endif @@ -569,7 +569,7 @@ const c_helper_macros = '//============================== HELPER C MACROS ====== // _SLIT0 is used as NULL string for literal arguments // `"" s` is used to enforce a string literal argument #define _SLIT0 (string){.str=(byteptr)(""), .len=0, .is_lit=1} -#define _SLIT(s) ((string){.str=(byteptr)("" s), .len=(sizeof(s)-1), .is_lit=1}) +#define _S(s) ((string){.str=(byteptr)("" s), .len=(sizeof(s)-1), .is_lit=1}) #define _SLEN(s, n) ((string){.str=(byteptr)("" s), .len=n, .is_lit=1}) // optimized way to compare literal strings #define _SLIT_EQ(sptr, slen, lit) (slen == sizeof("" lit)-1 && !vmemcmp(sptr, "" lit, slen)) @@ -603,8 +603,8 @@ void _vcleanup(void); #ifdef _WIN32 // workaround for windows, export _vinit_caller/_vcleanup_caller, let dl.open()/dl.close() call it // NOTE: This is hardcoded in vlib/dl/dl_windows.c.v! - VV_EXPORTED_SYMBOL void _vinit_caller(); - VV_EXPORTED_SYMBOL void _vcleanup_caller(); + VV_EXP void _vinit_caller(); + VV_EXP void _vcleanup_caller(); #endif #define sigaction_size sizeof(sigaction); #define _ARR_LEN(a) ( (sizeof(a)) / (sizeof(a[0])) ) diff --git a/vlib/v/gen/c/cmain.v b/vlib/v/gen/c/cmain.v index b9407922b3..d712c6cfa3 100644 --- a/vlib/v/gen/c/cmain.v +++ b/vlib/v/gen/c/cmain.v @@ -325,8 +325,8 @@ pub fn (mut g Gen) gen_c_main_for_tests() { testfn := unsafe { g.table.fns[tname] } lnum := testfn.pos.line_nr + 1 g.writeln('\tmain__VTestFnMetaInfo_free(test_runner.fn_test_info);') - g.writeln('\tstring tcname_${tnumber} = _SLIT("${tcname}");') - g.writeln('\tstring tcmod_${tnumber} = _SLIT("${testfn.mod}");') + g.writeln('\tstring tcname_${tnumber} = _S("${tcname}");') + g.writeln('\tstring tcmod_${tnumber} = _S("${testfn.mod}");') g.writeln('\tstring tcfile_${tnumber} = ${ctoslit(testfn.file)};') g.writeln('\t*(test_runner.fn_test_info) = main__vtest_new_metainfo(tcname_${tnumber}, tcmod_${tnumber}, tcfile_${tnumber}, ${lnum});') g.writeln('\t_vtrunner._method_fn_start(_vtobj);') @@ -397,7 +397,7 @@ pub fn (mut g Gen) gen_c_main_trace_calls_hook() { // gen_dll_main create DllMain() for windows .dll pub fn (mut g Gen) gen_dll_main() { - g.writeln('VV_EXPORTED_SYMBOL BOOL DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved) { + g.writeln('VV_EXP BOOL DllMain(HINSTANCE hinst,DWORD fdwReason,LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH : { #if defined(_VGCBOEHM) diff --git a/vlib/v/gen/c/comptime.v b/vlib/v/gen/c/comptime.v index 51bd61bd22..560a4a4667 100644 --- a/vlib/v/gen/c/comptime.v +++ b/vlib/v/gen/c/comptime.v @@ -54,14 +54,14 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) { // $env('ENV_VAR_NAME') // TODO: deprecate after support for $d() is stable val := util.cescaped_path(os.getenv(node.args_var)) - g.write('_SLIT("${val}")') + g.write('_S("${val}")') return } if node.method_name == 'd' { // $d('some_string',), affected by `-d some_string=actual_value` val := util.cescaped_path(node.compile_value) if node.result_type == ast.string_type { - g.write('_SLIT("${val}")') + g.write('_S("${val}")') } else if node.result_type == ast.char_type { g.write("'${val}'") } else { @@ -174,7 +174,7 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) { if !has_decompose { // do not generate anything if the argument lengths don't match g.writeln('/* skipping ${sym.name}.${m.name} due to mismatched arguments list: node.args=${node.args.len} m.params=${m.params.len} */') - // Adding a println(_SLIT(...)) like this breaks options + // Adding a println(_S(...)) like this breaks options return } } @@ -278,7 +278,7 @@ fn (mut g Gen) comptime_call(mut node ast.ComptimeCall) { if j > 0 { g.write(' else ') } - g.write('if (string__eq(${node.method_name}, _SLIT("${method.name}"))) ') + g.write('if (string__eq(${node.method_name}, _S("${method.name}"))) ') } g.write('${g.cc_type(left_type, false)}_${method.name}(${amp} ') g.expr(node.left) @@ -298,7 +298,7 @@ fn cgen_attrs(attrs []ast.Attr) []string { if attr.kind == .string { s = escape_quotes(s) } - res << '_SLIT("${s}")' + res << '_S("${s}")' } return res } @@ -306,10 +306,10 @@ fn cgen_attrs(attrs []ast.Attr) []string { fn (mut g Gen) comptime_at(node ast.AtExpr) { if node.kind == .vmod_file { val := cescape_nonascii(util.smart_quote(node.val, false)) - g.write('_SLIT("${val}")') + g.write('_S("${val}")') } else { val := node.val.replace('\\', '\\\\') - g.write('_SLIT("${val}")') + g.write('_S("${val}")') } } @@ -867,7 +867,7 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) { g.comptime.comptime_for_method = unsafe { &method } g.comptime.comptime_for_method_var = node.val_var g.writeln('/* method ${i} */ {') - g.writeln('\t${node.val_var}.name = _SLIT("${method.name}");') + g.writeln('\t${node.val_var}.name = _S("${method.name}");') if method.attrs.len == 0 { g.writeln('\t${node.val_var}.attrs = __new_array_with_default(0, 0, sizeof(string), 0);') } else { @@ -885,7 +885,7 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) { // Skip receiver arg for j, arg in method.params[1..] { typ := arg.typ.idx() - g.write('{${typ.str()}, _SLIT("${arg.name}")}') + g.write('{${typ.str()}, _S("${arg.name}")}') if j < len - 1 { g.write(', ') } @@ -947,7 +947,7 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) { g.comptime.comptime_for_field_value = field g.comptime.comptime_for_field_type = field.typ g.writeln('/* field ${i} */ {') - g.writeln('\t${node.val_var}.name = _SLIT("${field.name}");') + g.writeln('\t${node.val_var}.name = _S("${field.name}");') if field.attrs.len == 0 { g.writeln('\t${node.val_var}.attrs = __new_array_with_default(0, 0, sizeof(string), 0);') } else { @@ -998,7 +998,7 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) { g.type_resolver.update_ct_type('${node.val_var}.typ', node.typ) g.writeln('/* enum vals ${i} */ {') - g.writeln('\t${node.val_var}.name = _SLIT("${val}");') + g.writeln('\t${node.val_var}.name = _S("${val}");') g.write('\t${node.val_var}.value = ') if g.pref.translated && node.typ.is_number() { g.writeln('_const_main__${val};') @@ -1028,10 +1028,9 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) { for attr in attrs { g.writeln('/* attribute ${i} */ {') - g.writeln('\t${node.val_var}.name = _SLIT("${attr.name}");') + g.writeln('\t${node.val_var}.name = _S("${attr.name}");') g.writeln('\t${node.val_var}.has_arg = ${attr.has_arg};') - g.writeln('\t${node.val_var}.arg = _SLIT("${util.smart_quote(attr.arg, - false)}");') + g.writeln('\t${node.val_var}.arg = _S("${util.smart_quote(attr.arg, false)}");') g.writeln('\t${node.val_var}.kind = AttributeKind__${attr.kind};') g.stmts(node.stmts) g.writeln('}') @@ -1071,7 +1070,7 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) { g.writeln('/* method param ${i} */ {') g.writeln('\t${node.val_var}.typ = ${int(param.typ)};') - g.writeln('\t${node.val_var}.name = _SLIT("${param.name}");') + g.writeln('\t${node.val_var}.name = _S("${param.name}");') g.stmts(node.stmts) g.writeln('}') i++ diff --git a/vlib/v/gen/c/consts_and_globals.v b/vlib/v/gen/c/consts_and_globals.v index e92febfb9b..5df83f2a5e 100644 --- a/vlib/v/gen/c/consts_and_globals.v +++ b/vlib/v/gen/c/consts_and_globals.v @@ -225,12 +225,12 @@ fn (mut g Gen) const_decl_precomputed(mod string, name string, field_name string } string { escaped_val := util.smart_quote(ct_value, false) - // g.const_decl_write_precomputed(line_nr, styp, cname, '_SLIT("$escaped_val")') + // g.const_decl_write_precomputed(line_nr, styp, cname, '_S("$escaped_val")') // TODO: ^ the above for strings, cause: // `error C2099: initializer is not a constant` errors in MSVC, // so fall back to the delayed initialisation scheme: init := if typ == ast.string_type { - '_SLIT("${escaped_val}")' + '_S("${escaped_val}")' } else { '(${styp})"${escaped_val}"' } @@ -441,7 +441,7 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) { attributes += 'VHIDDEN ' } if node.attrs.contains('export') { - attributes += 'VV_EXPORTED_SYMBOL ' + attributes += 'VV_EXP ' } if attr := node.attrs.find_first('_linker_section') { attributes += '__attribute__ ((section ("${attr.arg}"))) ' @@ -515,7 +515,7 @@ fn (mut g Gen) global_decl(node ast.GlobalDecl) { default_initializer := g.type_default(field.typ) if default_initializer == '{0}' && should_init { def_builder.write_string(' = {0}') - } else if default_initializer == '{EMPTY_STRUCT_INITIALIZATION}' && should_init { + } else if default_initializer == '{E_STRUCT}' && should_init { init = '\tmemcpy(${field.name}, (${styp}){${default_initializer}}, sizeof(${styp})); // global 4' } else { if field.name !in ['as_cast_type_indexes', 'g_memory_block', 'global_allocator'] { diff --git a/vlib/v/gen/c/dumpexpr.v b/vlib/v/gen/c/dumpexpr.v index c9ce2c96b6..3fb80afe78 100644 --- a/vlib/v/gen/c/dumpexpr.v +++ b/vlib/v/gen/c/dumpexpr.v @@ -183,10 +183,10 @@ fn (mut g Gen) dump_expr_definitions() { if dump_sym.kind == .function && !is_option { surrounder.add('\tstring value = ${to_string_fn_name}();', '\tstring_free(&value);') } else if dump_sym.kind == .none { - surrounder.add('\tstring value = _SLIT("none");', '\tstring_free(&value);') + surrounder.add('\tstring value = _S("none");', '\tstring_free(&value);') } else if is_ptr { if typ.has_flag(.option) { - surrounder.add('\tstring value = isnil(&dump_arg.data) ? _SLIT("nil") : ${to_string_fn_name}(${deref}dump_arg);', + surrounder.add('\tstring value = isnil(&dump_arg.data) ? _S("nil") : ${to_string_fn_name}(${deref}dump_arg);', '\tstring_free(&value);') } else { prefix := if dump_sym.is_c_struct() { @@ -194,7 +194,7 @@ fn (mut g Gen) dump_expr_definitions() { } else { deref } - surrounder.add('\tstring value = (dump_arg == NULL) ? _SLIT("nil") : ${to_string_fn_name}(${prefix}dump_arg);', + surrounder.add('\tstring value = (dump_arg == NULL) ? _S("nil") : ${to_string_fn_name}(${prefix}dump_arg);', '\tstring_free(&value);') } } else { @@ -236,7 +236,7 @@ fn (mut g Gen) dump_expr_definitions() { if is_fixed_arr_ret { tmp_var := g.new_tmp_var() init_str := if dump_sym.is_empty_struct_array() { - '{EMPTY_STRUCT_INITIALIZATION}' + '{E_STRUCT}' } else { '{0}' } diff --git a/vlib/v/gen/c/embed.v b/vlib/v/gen/c/embed.v index db931f54c6..6359a73a1a 100644 --- a/vlib/v/gen/c/embed.v +++ b/vlib/v/gen/c/embed.v @@ -128,7 +128,7 @@ fn (mut g Gen) gen_embedded_metadata() { g.embedded_data.writeln('\t\t\tbreak;') g.embedded_data.writeln('\t\t} // case ${ef_idx}') } - g.embedded_data.writeln('\t\tdefault: _v_panic(_SLIT("unknown embed file"));') + g.embedded_data.writeln('\t\tdefault: _v_panic(_S("unknown embed file"));') g.embedded_data.writeln('\t} // switch') g.embedded_data.writeln('\treturn res;') g.embedded_data.writeln('}') diff --git a/vlib/v/gen/c/fn.v b/vlib/v/gen/c/fn.v index 736f30cdf2..5b1bf6bf4c 100644 --- a/vlib/v/gen/c/fn.v +++ b/vlib/v/gen/c/fn.v @@ -285,8 +285,8 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) { } trace_fn_ret_type := g.styp(call_fn.return_type) - g.write('VV_LOCAL_SYMBOL ${trace_fn_ret_type} ${c_name(trace_fn)}(') - g.definitions.write_string('VV_LOCAL_SYMBOL ${trace_fn_ret_type} ${c_name(trace_fn)}(') + g.write('VV_LOC ${trace_fn_ret_type} ${c_name(trace_fn)}(') + g.definitions.write_string('VV_LOC ${trace_fn_ret_type} ${c_name(trace_fn)}(') if call_fn.is_fn_var { sig := g.fn_var_signature(call_fn.func.return_type, call_fn.func.params.map(it.typ), @@ -306,21 +306,21 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) { && call_fn.name !in ['v.debug.add_after_call', 'v.debug.add_before_call', 'v.debug.remove_after_call', 'v.debug.remove_before_call'] if g.pref.is_callstack { if g.cur_fn.is_method || g.cur_fn.is_static_type_method { - g.writeln('\tarray_push((array*)&g_callstack, _MOV((v__debug__FnTrace[]){ ((v__debug__FnTrace){.name = _SLIT("${g.table.type_to_str(g.cur_fn.receiver.typ)}.${g.cur_fn.name.all_after_last('__static__')}"),.file = _SLIT("${call_fn.file}"),.line = ${call_fn.line},}) }));') + g.writeln('\tarray_push((array*)&g_callstack, _MOV((v__debug__FnTrace[]){ ((v__debug__FnTrace){.name = _S("${g.table.type_to_str(g.cur_fn.receiver.typ)}.${g.cur_fn.name.all_after_last('__static__')}"),.file = _S("${call_fn.file}"),.line = ${call_fn.line},}) }));') } else { - g.writeln('\tarray_push((array*)&g_callstack, _MOV((v__debug__FnTrace[]){ ((v__debug__FnTrace){.name = _SLIT("${g.cur_fn.name}"),.file = _SLIT("${call_fn.file}"),.line = ${call_fn.line},}) }));') + g.writeln('\tarray_push((array*)&g_callstack, _MOV((v__debug__FnTrace[]){ ((v__debug__FnTrace){.name = _S("${g.cur_fn.name}"),.file = _S("${call_fn.file}"),.line = ${call_fn.line},}) }));') } } if call_fn.return_type == 0 || call_fn.return_type == ast.void_type { if add_trace_hook { g.writeln('\tif (!g_trace.in_hook) {') - g.writeln('\t\tv__debug__before_call_hook(_SLIT("${call_fn.name}"));') + g.writeln('\t\tv__debug__before_call_hook(_S("${call_fn.name}"));') g.writeln('\t}') } g.writeln('\t${c_name(call_fn.name)}(${orig_fn_args});') if add_trace_hook { g.writeln('\tif (!g_trace.in_hook) {') - g.writeln('\t\tv__debug__after_call_hook(_SLIT("${call_fn.name}"));') + g.writeln('\t\tv__debug__after_call_hook(_S("${call_fn.name}"));') g.writeln('\t}') } if g.pref.is_callstack { @@ -329,7 +329,7 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) { } else { if add_trace_hook { g.writeln('\tif (!g_trace.in_hook) {') - g.writeln('\t\tv__debug__before_call_hook(_SLIT("${call_fn.name}"));') + g.writeln('\t\tv__debug__before_call_hook(_S("${call_fn.name}"));') g.writeln('\t}') } g.writeln('\t${g.styp(call_fn.return_type)} ret = ${c_name(call_fn.name)}(${orig_fn_args});') @@ -338,7 +338,7 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) { } if add_trace_hook { g.writeln('\tif (!g_trace.in_hook) {') - g.writeln('\t\tv__debug__after_call_hook(_SLIT("${call_fn.name}"));') + g.writeln('\t\tv__debug__after_call_hook(_S("${call_fn.name}"));') g.writeln('\t}') } g.writeln('\treturn ret;') @@ -356,8 +356,8 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) { if is_liveshared { if g.pref.os == .windows { g.export_funcs << impl_fn_name - g.definitions.write_string('VV_EXPORTED_SYMBOL ${type_name} ${impl_fn_name}(') - g.write('VV_EXPORTED_SYMBOL ${type_name} ${impl_fn_name}(') + g.definitions.write_string('VV_EXP ${type_name} ${impl_fn_name}(') + g.write('VV_EXP ${type_name} ${impl_fn_name}(') } else { g.definitions.write_string('${type_name} ${impl_fn_name}(') g.write('${type_name} ${impl_fn_name}(') @@ -374,9 +374,9 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) { // If we are building vlib/builtin, we need all private functions like array_get // to be public, so that all V programs can access them. if !(node.is_anon && g.pref.parallel_cc) { - g.write('VV_LOCAL_SYMBOL ') - // g.definitions.write_string('${g.static_modifier} VV_LOCAL_SYMBOL ') - g.definitions.write_string('VV_LOCAL_SYMBOL ') + g.write('VV_LOC ') + // g.definitions.write_string('${g.static_modifier} VV_LOC ') + g.definitions.write_string('VV_LOC ') } } } @@ -529,7 +529,7 @@ fn (mut g Gen) gen_fn_decl(node &ast.FnDecl, skip bool) { g.writeln('// export alias: ${attr.arg} -> ${name}') g.export_funcs << attr.arg export_alias := '${weak}${type_name} ${fn_attrs}${attr.arg}(${arg_str})' - g.definitions.writeln('VV_EXPORTED_SYMBOL ${export_alias}; // exported fn ${node.name}') + g.definitions.writeln('VV_EXP ${export_alias}; // exported fn ${node.name}') g.writeln('${export_alias} {') g.write2('\treturn ${name}(', fargs.join(', ')) g.writeln2(');', '}') diff --git a/vlib/v/gen/c/index.v b/vlib/v/gen/c/index.v index 85983baadd..427926e715 100644 --- a/vlib/v/gen/c/index.v +++ b/vlib/v/gen/c/index.v @@ -336,7 +336,7 @@ fn (mut g Gen) index_of_array(node ast.IndexExpr, sym ast.TypeSymbol) { g.writeln('if (${tmp_opt_ptr}) {') g.writeln('\t*((${elem_type_str}*)&${tmp_opt}.data) = *((${elem_type_str}*)${tmp_opt_ptr});') g.writeln('} else {') - g.writeln('\t${tmp_opt}.state = 2; ${tmp_opt}.err = _v_error(_SLIT("array index out of range"));') + g.writeln('\t${tmp_opt}.state = 2; ${tmp_opt}.err = _v_error(_S("array index out of range"));') g.writeln('}') if !node.is_option { g.or_block(tmp_opt, node.or_expr, elem_type) @@ -552,7 +552,7 @@ fn (mut g Gen) index_of_map(node ast.IndexExpr, sym ast.TypeSymbol) { g.writeln('\t*((${val_type_str}*)&${tmp_opt}.data) = *((${val_type_str}*)${tmp_opt_ptr});') } g.writeln('} else {') - g.writeln('\t${tmp_opt}.state = 2; ${tmp_opt}.err = _v_error(_SLIT("map key does not exist"));') + g.writeln('\t${tmp_opt}.state = 2; ${tmp_opt}.err = _v_error(_S("map key does not exist"));') g.writeln('}') if !node.is_option { g.or_block(tmp_opt, node.or_expr, val_type) diff --git a/vlib/v/gen/c/json.v b/vlib/v/gen/c/json.v index e0272e391f..cf40af0899 100644 --- a/vlib/v/gen/c/json.v +++ b/vlib/v/gen/c/json.v @@ -59,7 +59,7 @@ fn (mut g Gen) gen_jsons() { mut init_styp := '${styp} res' if utyp.has_flag(.option) { none_str := g.expr_string(ast.None{}) - init_styp += ' = (${styp}){ .state=2, .err=${none_str}, .data={EMPTY_STRUCT_INITIALIZATION} }' + init_styp += ' = (${styp}){ .state=2, .err=${none_str}, .data={E_STRUCT} }' } else { if !utyp.is_ptr() { init_styp += ' = ' @@ -111,9 +111,9 @@ ${dec_fn_dec} { vmemcpy(buf, prevline_ptr, (maxchars < maxcontext_chars ? maxchars : maxcontext_chars)); } string msg; - msg = _SLIT("failed to decode JSON string"); + msg = _S("failed to decode JSON string"); if (buf[0] != \'\\0\') { - msg = string__plus(msg, _SLIT(": ")); + msg = string__plus(msg, _S(": ")); } return (${result_name}_${ret_styp}){.is_error = true,.err = _v_error(string__plus(msg, tos2(buf))),.data = {0}}; } @@ -222,9 +222,9 @@ fn (mut g Gen) gen_enum_to_str(utyp ast.Type, sym ast.TypeSymbol, enum_var strin ast.Attr{} } if attr.has_arg { - enc.writeln('${result_var} = json__encode_string(_SLIT("${attr.arg}")); break;') + enc.writeln('${result_var} = json__encode_string(_S("${attr.arg}")); break;') } else { - enc.writeln('${result_var} = json__encode_string(_SLIT("${val}")); break;') + enc.writeln('${result_var} = json__encode_string(_S("${val}")); break;') } } enc.writeln('${ident}}') @@ -241,12 +241,12 @@ fn (mut g Gen) gen_str_to_enum(utyp ast.Type, sym ast.TypeSymbol, val_var string ast.Attr{} } if k == 0 { - dec.write_string('${ident}if (string__eq(_SLIT("${val}"), ${val_var})') + dec.write_string('${ident}if (string__eq(_S("${val}"), ${val_var})') } else { - dec.write_string('${ident}else if (string__eq(_SLIT("${val}"), ${val_var})') + dec.write_string('${ident}else if (string__eq(_S("${val}"), ${val_var})') } if attr.has_arg { - dec.write_string(' || string__eq(_SLIT("${attr.arg}"), ${val_var})') + dec.write_string(' || string__eq(_S("${attr.arg}"), ${val_var})') } dec.write_string(')\t') if is_option { @@ -642,7 +642,7 @@ fn (mut g Gen) gen_prim_type_validation(name string, typ ast.Type, tmp string, i return } dec.writeln('\t\tif (!(${type_check})) {') - dec.writeln('\t\t\treturn (${ret_styp}){ .is_error = true, .err = _v_error(string__plus(_SLIT("type mismatch for field \'${name}\', expecting `${g.table.type_to_str(typ)}` type, got: "), json__json_print(jsonroot_${tmp}))), .data = {0} };') + dec.writeln('\t\t\treturn (${ret_styp}){ .is_error = true, .err = _v_error(string__plus(_S("type mismatch for field \'${name}\', expecting `${g.table.type_to_str(typ)}` type, got: "), json__json_print(jsonroot_${tmp}))), .data = {0} };') dec.writeln('\t\t}') } @@ -994,7 +994,7 @@ fn gen_js_get(styp string, tmp string, name string, mut dec strings.Builder, is_ dec.writeln('\tcJSON *jsonroot_${tmp} = js_get(root, "${name}");') if is_required { dec.writeln('\tif (jsonroot_${tmp} == 0) {') - dec.writeln('\t\treturn (${result_name}_${styp}){ .is_error = true, .err = _v_error(_SLIT("expected field \'${name}\' is missing")), .data = {0} };') + dec.writeln('\t\treturn (${result_name}_${styp}){ .is_error = true, .err = _v_error(_S("expected field \'${name}\' is missing")), .data = {0} };') dec.writeln('\t}') } } @@ -1098,7 +1098,7 @@ fn (mut g Gen) decode_array(utyp ast.Type, value_type ast.Type, fixed_array_size return ' if(root && !cJSON_IsArray(root) && !cJSON_IsNull(root)) { - return (${result_name}_${ret_styp}){.is_error = true, .err = _v_error(string__plus(_SLIT("Json element is not an array: "), json__json_print(root))), .data = {0}}; + return (${result_name}_${ret_styp}){.is_error = true, .err = _v_error(string__plus(_S("Json element is not an array: "), json__json_print(root))), .data = {0}}; } ${res_str} const cJSON *jsval = NULL; @@ -1167,7 +1167,7 @@ fn (mut g Gen) decode_map(utyp ast.Type, key_type ast.Type, value_type ast.Type, if utyp.has_flag(.option) { return ' if(!cJSON_IsObject(root) && !cJSON_IsNull(root)) { - return (${result_name}_${ustyp}){ .is_error = true, .err = _v_error(string__plus(_SLIT("Json element is not an object: "), json__json_print(root))), .data = {0}}; + return (${result_name}_${ustyp}){ .is_error = true, .err = _v_error(string__plus(_S("Json element is not an object: "), json__json_print(root))), .data = {0}}; } _option_ok(&(${g.base_type(utyp)}[]) { new_map(sizeof(${styp}), sizeof(${styp_v}), ${hash_fn}, ${key_eq_fn}, ${clone_fn}, ${free_fn}) }, (${option_name}*)&res, sizeof(${g.base_type(utyp)})); cJSON *jsval = NULL; @@ -1181,7 +1181,7 @@ fn (mut g Gen) decode_map(utyp ast.Type, key_type ast.Type, value_type ast.Type, } else { return ' if(!cJSON_IsObject(root) && !cJSON_IsNull(root)) { - return (${result_name}_${ustyp}){ .is_error = true, .err = _v_error(string__plus(_SLIT("Json element is not an object: "), json__json_print(root))), .data = {0}}; + return (${result_name}_${ustyp}){ .is_error = true, .err = _v_error(string__plus(_S("Json element is not an object: "), json__json_print(root))), .data = {0}}; } res = new_map(sizeof(${styp}), sizeof(${styp_v}), ${hash_fn}, ${key_eq_fn}, ${clone_fn}, ${free_fn}); cJSON *jsval = NULL; diff --git a/vlib/v/gen/c/orm.v b/vlib/v/gen/c/orm.v index df7ad5c74b..9b41cc0e3b 100644 --- a/vlib/v/gen/c/orm.v +++ b/vlib/v/gen/c/orm.v @@ -145,7 +145,7 @@ fn (mut g Gen) write_orm_create_table(node ast.SqlStmtLine, table_name string, c g.writeln('${result_name}_void ${result_var_name} = orm__Connection_name_table[${connection_var_name}._typ]._method_create(') g.indent++ g.writeln('${connection_var_name}._object, // Connection object') - g.writeln('_SLIT("${table_name}"),') + g.writeln('_S("${table_name}"),') g.writeln('new_array_from_c_array(${node.fields.len}, ${node.fields.len}, sizeof(orm__TableField),') g.indent++ @@ -164,7 +164,7 @@ fn (mut g Gen) write_orm_create_table(node ast.SqlStmtLine, table_name string, c } g.writeln('(orm__TableField){') g.indent++ - g.writeln('.name = _SLIT("${field.name}"),') + g.writeln('.name = _S("${field.name}"),') g.writeln('.typ = ${typ}, // `${sym.name}`') g.writeln('.is_arr = ${sym.kind == .array}, ') g.writeln('.nullable = ${final_field_typ.has_flag(.option)},') @@ -180,11 +180,11 @@ fn (mut g Gen) write_orm_create_table(node ast.SqlStmtLine, table_name string, c g.indent++ name1 := util.smart_quote(attr.name, false) name := cescape_nonascii(name1) - g.write(' .name = _SLIT("${name}"),') + g.write(' .name = _S("${name}"),') g.write(' .has_arg = ${attr.has_arg},') arg1 := util.smart_quote(attr.arg, false) arg := cescape_nonascii(arg1) - g.write(' .arg = _SLIT("${arg}"),') + g.write(' .arg = _S("${arg}"),') g.write(' .kind = ${int(attr.kind)},') g.indent-- g.write('},') @@ -218,7 +218,7 @@ fn (mut g Gen) write_orm_drop_table(table_name string, connection_var_name strin g.writeln('${result_name}_void ${result_var_name} = orm__Connection_name_table[${connection_var_name}._typ]._method_drop(') g.indent++ g.writeln('${connection_var_name}._object, // Connection object') - g.writeln('_SLIT("${table_name}")') + g.writeln('_S("${table_name}")') g.indent-- g.writeln(');') } @@ -239,7 +239,7 @@ fn (mut g Gen) write_orm_update(node &ast.SqlStmtLine, table_name string, connec g.writeln('${result_name}_void ${result_var_name} = orm__Connection_name_table[${connection_var_name}._typ]._method_update(') g.indent++ g.writeln('${connection_var_name}._object, // Connection object') - g.writeln('_SLIT("${table_name}"),') + g.writeln('_S("${table_name}"),') g.writeln('(orm__QueryData){') g.indent++ g.writeln('.kinds = __new_array_with_default_noscan(0, 0, sizeof(orm__OperationKind), 0),') @@ -253,7 +253,7 @@ fn (mut g Gen) write_orm_update(node &ast.SqlStmtLine, table_name string, connec g.writeln('_MOV((string[${node.updated_columns.len}]){') g.indent++ for field in node.updated_columns { - g.writeln('_SLIT("${field}"),') + g.writeln('_S("${field}"),') } g.indent-- g.writeln('})') @@ -290,7 +290,7 @@ fn (mut g Gen) write_orm_delete(node &ast.SqlStmtLine, table_name string, connec g.writeln('${result_name}_void ${result_var_name} = orm__Connection_name_table[${connection_var_name}._typ]._method__v_delete(') g.indent++ g.writeln('${connection_var_name}._object, // Connection object') - g.writeln('_SLIT("${table_name}"),') + g.writeln('_S("${table_name}"),') g.write_orm_where(node.where_expr) g.indent-- g.writeln(');') @@ -381,7 +381,7 @@ fn (mut g Gen) write_orm_insert_with_last_ids(node ast.SqlStmtLine, connection_v g.writeln('${result_name}_void ${res} = orm__Connection_name_table[${connection_var_name}._typ]._method_insert(') g.indent++ g.writeln('${connection_var_name}._object, // Connection object') - g.writeln('_SLIT("${table_name}"),') + g.writeln('_S("${table_name}"),') g.writeln('(orm__QueryData){') g.indent++ g.writeln('.fields = new_array_from_c_array(${fields.len}, ${fields.len}, sizeof(string),') @@ -391,7 +391,7 @@ fn (mut g Gen) write_orm_insert_with_last_ids(node ast.SqlStmtLine, connection_v g.writeln('_MOV((string[${fields.len}]){ ') g.indent++ for f in fields { - g.writeln('_SLIT("${g.get_orm_column_name_from_struct_field(f)}"),') + g.writeln('_S("${g.get_orm_column_name_from_struct_field(f)}"),') } g.indent-- g.writeln('})') @@ -593,7 +593,7 @@ fn (mut g Gen) write_orm_primitive(t ast.Type, expr ast.Expr) { if expr is ast.InfixExpr { g.writeln('orm__infix_to_primitive((orm__InfixType){') g.indent++ - g.write('.name = _SLIT("${expr.left}"),') + g.write('.name = _S("${expr.left}"),') mut kind := match expr.op { .plus { 'orm__MathOperationKind__add' @@ -661,7 +661,7 @@ fn (mut g Gen) write_orm_where(where_expr ast.Expr) { g.writeln('_MOV((string[${fields.len}]){') g.indent++ for field in fields { - g.writeln('_SLIT("${field}"),') + g.writeln('_S("${field}"),') } g.indent-- g.writeln('})') @@ -889,13 +889,13 @@ fn (mut g Gen) write_orm_select(node ast.SqlExpr, connection_var_name string, re g.writeln('${connection_var_name}._object, // Connection object') g.writeln('(orm__SelectConfig){') g.indent++ - g.writeln('.table = _SLIT("${escaped_table_name}"),') + g.writeln('.table = _S("${escaped_table_name}"),') g.writeln('.is_count = ${node.is_count},') g.writeln('.has_where = ${node.has_where},') g.writeln('.has_order = ${node.has_order},') if node.has_order { - g.write('.order = _SLIT("') + g.write('.order = _S("') if node.order_expr is ast.Ident { field := g.get_orm_current_table_field(node.order_expr.name) or { verror('field "${node.order_expr.name}" does not exist on "${g.sql_table_name}"') @@ -916,7 +916,7 @@ fn (mut g Gen) write_orm_select(node ast.SqlExpr, connection_var_name string, re g.writeln('.has_offset = ${node.has_offset},') if primary_field.name != '' { - g.writeln('.primary = _SLIT("${primary_field.name}"),') + g.writeln('.primary = _S("${primary_field.name}"),') } select_fields := fields.filter(g.table.sym(it.typ).kind != .array) @@ -927,7 +927,7 @@ fn (mut g Gen) write_orm_select(node ast.SqlExpr, connection_var_name string, re g.writeln('_MOV((string[${select_fields.len}]){') g.indent++ for field in select_fields { - g.writeln('_SLIT("${g.get_orm_column_name_from_struct_field(field)}"),') + g.writeln('_S("${g.get_orm_column_name_from_struct_field(field)}"),') final_field_typ := g.table.final_type(field.typ) sym := g.table.sym(final_field_typ) if sym.name == 'time.Time' { @@ -1035,7 +1035,7 @@ fn (mut g Gen) write_orm_select(node ast.SqlExpr, connection_var_name string, re typ_str = g.styp(info.elem_type) base_typ := g.base_type(node.typ) if node.typ.has_flag(.option) { - g.writeln('${unwrapped_c_typ} ${tmp}_array = { .state = 2, .err = _const_none__, .data = {EMPTY_STRUCT_INITIALIZATION} };') + g.writeln('${unwrapped_c_typ} ${tmp}_array = { .state = 2, .err = _const_none__, .data = {E_STRUCT} };') g.writeln('_option_ok(&(${base_typ}[]) { __new_array(0, ${select_unwrapped_result_var_name}.len, sizeof(${typ_str})) }, (_option *)&${tmp}_array, sizeof(${base_typ}));') } else { g.writeln('${unwrapped_c_typ} ${tmp}_array = __new_array(0, ${select_unwrapped_result_var_name}.len, sizeof(${typ_str}));') @@ -1098,7 +1098,7 @@ fn (mut g Gen) write_orm_select(node ast.SqlExpr, connection_var_name string, re g.writeln('if (!${sub_result_var}.is_error)') g.writeln('\t_option_ok(${sub_result_var}.data, (_option *)&${field_var}, sizeof(${unwrapped_field_c_typ}));') g.writeln('else') - g.writeln('\t${field_var} = (${field_c_typ}){ .state = 2, .err = _const_none__, .data = {EMPTY_STRUCT_INITIALIZATION} };') + g.writeln('\t${field_var} = (${field_c_typ}){ .state = 2, .err = _const_none__, .data = {E_STRUCT} };') } else { g.writeln('if (!${sub_result_var}.is_error)') g.writeln('\t${field_var} = *(${field_c_typ}*)${sub_result_var}.data;') @@ -1166,7 +1166,7 @@ fn (mut g Gen) write_orm_select(node ast.SqlExpr, connection_var_name string, re prim_var := g.new_tmp_var() g.writeln('orm__Primitive *${prim_var} = &${array_get_call_code};') g.writeln('if (${prim_var}->_typ == ${g.table.find_type_idx('orm.Null')})') - g.writeln('\t${field_var} = (${field_c_typ}){ .state = 2, .err = _const_none__, .data = {EMPTY_STRUCT_INITIALIZATION} };') + g.writeln('\t${field_var} = (${field_c_typ}){ .state = 2, .err = _const_none__, .data = {E_STRUCT} };') g.writeln('else') g.writeln('\t_option_ok(${prim_var}->_${sym.cname}, (_option *)&${field_var}, sizeof(${sym.cname}));') diff --git a/vlib/v/gen/c/reflection.v b/vlib/v/gen/c/reflection.v index b138e9dc05..6f5376e892 100644 --- a/vlib/v/gen/c/reflection.v +++ b/vlib/v/gen/c/reflection.v @@ -19,7 +19,7 @@ fn (mut g Gen) reflection_string(str string) int { @[inline] fn (mut g Gen) gen_reflection_strings() { for str, idx in g.reflection_strings { - g.writeln('\t${cprefix}add_string(_SLIT("${str}"), ${idx});') + g.writeln('\t${cprefix}add_string(_S("${str}"), ${idx});') } } @@ -37,7 +37,7 @@ fn (g &Gen) gen_functionarg_array(type_name string, node ast.Fn) string { } mut out := 'new_array_from_c_array(${node.params.len},${node.params.len},sizeof(${type_name}),' out += '_MOV((${type_name}[${node.params.len}]){' - out += node.params.map('((${type_name}){.name=_SLIT("${it.name}"),.typ=${int(it.typ)},.is_mut=${it.is_mut}})').join(',') + out += node.params.map('((${type_name}){.name=_S("${it.name}"),.typ=${int(it.typ)},.is_mut=${it.is_mut}})').join(',') out += '}))' return out } @@ -63,8 +63,8 @@ fn (mut g Gen) gen_function_array(nodes []ast.Fn) string { fn (mut g Gen) gen_reflection_fn(node ast.Fn) string { mut arg_str := '((${cprefix}Function){' v_name := node.name.all_after_last('.') - arg_str += '.mod_name=_SLIT("${node.mod}"),' - arg_str += '.name=_SLIT("${v_name}"),' + arg_str += '.mod_name=_S("${node.mod}"),' + arg_str += '.name=_S("${v_name}"),' arg_str += '.args=${g.gen_functionarg_array(cprefix + 'FunctionArg', node)},' arg_str += '.file_idx=${g.reflection_string(util.cescaped_path(node.file))},' arg_str += '.line_start=${node.pos.line_nr},' @@ -84,7 +84,7 @@ fn (mut g Gen) gen_reflection_sym(tsym ast.TypeSymbol) string { name := tsym.name.all_after_last('.') info := g.gen_reflection_sym_info(tsym) methods := g.gen_function_array(tsym.methods) - return '(${cprefix}TypeSymbol){.name=_SLIT("${name}"),.mod=_SLIT("${tsym.mod}"),.idx=${tsym.idx},.parent_idx=${tsym.parent_idx},.language=${cprefix}VLanguage__${tsym.language},.kind=${cprefix}VKind__${kind_name},.info=${info},.methods=${methods}}' + return '(${cprefix}TypeSymbol){.name=_S("${name}"),.mod=_S("${tsym.mod}"),.idx=${tsym.idx},.parent_idx=${tsym.parent_idx},.language=${cprefix}VLanguage__${tsym.language},.kind=${cprefix}VKind__${kind_name},.info=${info},.methods=${methods}}' } // gen_attrs_array generates C code for []Attr @@ -96,9 +96,9 @@ fn (g &Gen) gen_attrs_array(attrs []ast.Attr) string { mut out := 'new_array_from_c_array(${attrs.len},${attrs.len},sizeof(string),' out += '_MOV((string[${attrs.len}]){' out += attrs.map(if it.has_arg { - '_SLIT("${it.name}=${escape_quotes(it.arg)}")' + '_S("${it.name}=${escape_quotes(it.arg)}")' } else { - '_SLIT("${it.name}")' + '_S("${it.name}")' }).join(',') out += '}))' return out @@ -112,7 +112,7 @@ fn (g &Gen) gen_fields_array(fields []ast.StructField) string { } mut out := 'new_array_from_c_array(${fields.len},${fields.len},sizeof(${cprefix}StructField),' out += '_MOV((${cprefix}StructField[${fields.len}]){' - out += fields.map('((${cprefix}StructField){.name=_SLIT("${it.name}"),.typ=${int(it.typ)},.attrs=${g.gen_attrs_array(it.attrs)},.is_pub=${it.is_pub},.is_mut=${it.is_mut}})').join(',') + out += fields.map('((${cprefix}StructField){.name=_S("${it.name}"),.typ=${int(it.typ)},.attrs=${g.gen_attrs_array(it.attrs)},.is_pub=${it.is_pub},.is_mut=${it.is_mut}})').join(',') out += '}))' return out } @@ -132,7 +132,7 @@ fn (g &Gen) gen_string_array(strs []string) string { if strs.len == 0 { return g.gen_empty_array('string') } - items := strs.map('_SLIT("${it}")').join(',') + items := strs.map('_S("${it}")').join(',') return 'new_array_from_c_array(${strs.len},${strs.len},sizeof(string),_MOV((string[${strs.len}]){${items}}))' } @@ -183,7 +183,7 @@ fn (mut g Gen) gen_reflection_sym_info(tsym ast.TypeSymbol) string { info := tsym.info as ast.Interface methods := g.gen_function_array(info.methods) fields := g.gen_fields_array(info.fields) - s := 'ADDR(${cprefix}Interface,(((${cprefix}Interface){.name=_SLIT("${name}"),.methods=${methods},.fields=${fields},.is_generic=${info.is_generic}})))' + s := 'ADDR(${cprefix}Interface,(((${cprefix}Interface){.name=_S("${name}"),.methods=${methods},.fields=${fields},.is_generic=${info.is_generic}})))' return '(${cprefix}TypeInfo){._${cprefix}Interface=memdup(${s},sizeof(${cprefix}Interface)),._typ=${g.table.find_type_idx('v.reflection.Interface')}}' } .alias { @@ -207,7 +207,7 @@ fn (mut g Gen) gen_reflection_sym_info(tsym ast.TypeSymbol) string { fn (mut g Gen) gen_reflection_data() { // modules declaration for mod_name in g.table.modules { - g.writeln('\t${cprefix}add_module(_SLIT("${mod_name}"));') + g.writeln('\t${cprefix}add_module(_S("${mod_name}"));') } // type symbols declaration @@ -219,7 +219,7 @@ fn (mut g Gen) gen_reflection_data() { // types declaration for full_name, idx in g.table.type_idxs { name := full_name.all_after_last('.') - g.writeln('\t${cprefix}add_type((${cprefix}Type){.name=_SLIT("${name}"),.idx=${idx}});') + g.writeln('\t${cprefix}add_type((${cprefix}Type){.name=_S("${name}"),.idx=${idx}});') } // func declaration (methods come from struct methods) diff --git a/vlib/v/gen/c/spawn_and_go.v b/vlib/v/gen/c/spawn_and_go.v index 09ae190476..60910c4a74 100644 --- a/vlib/v/gen/c/spawn_and_go.v +++ b/vlib/v/gen/c/spawn_and_go.v @@ -421,10 +421,10 @@ fn (mut g Gen) create_waiter_handler(call_ret_type ast.Type, s_ret_typ string, g g.gowrappers.writeln('\tret_ptr = thread.ret_ptr;') } } else { - g.gowrappers.writeln('\tif ((unsigned long int)thread == 0) { _v_panic(_SLIT("unable to join thread")); }') + g.gowrappers.writeln('\tif ((unsigned long int)thread == 0) { _v_panic(_S("unable to join thread")); }') g.gowrappers.writeln('\tint stat = pthread_join(thread, (void **)${c_ret_ptr_ptr});') } - g.gowrappers.writeln('\tif (stat != 0) { _v_panic(_SLIT("unable to join thread")); }') + g.gowrappers.writeln('\tif (stat != 0) { _v_panic(_S("unable to join thread")); }') if g.pref.os == .windows { if call_ret_type == ast.void_type { g.gowrappers.writeln('\tCloseHandle(thread);') diff --git a/vlib/v/gen/c/str.v b/vlib/v/gen/c/str.v index 37c6bc80f8..3b178c7160 100644 --- a/vlib/v/gen/c/str.v +++ b/vlib/v/gen/c/str.v @@ -11,7 +11,7 @@ fn (mut g Gen) string_literal(node ast.StringLiteral) { g.write2('"', escaped_val) g.write('"') } else { - g.write2('_SLIT("', escaped_val) + g.write2('_S("', escaped_val) g.write('")') } } @@ -27,7 +27,7 @@ fn (mut g Gen) string_inter_literal_sb_optimized(call_expr ast.CallExpr) { escaped_val := cescape_nonascii(util.smart_quote(val, false)) g.write('strings__Builder_write_string(&') g.expr(call_expr.left) - g.write2(', _SLIT("', escaped_val) + g.write2(', _S("', escaped_val) g.writeln('"));') if i >= node.exprs.len { break @@ -88,7 +88,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) { g.expr(expr) } else if typ == ast.bool_type { g.expr(expr) - g.write(' ? _SLIT("true") : _SLIT("false")') + g.write(' ? _S("true") : _S("false")') } else if sym.kind == .none || typ == ast.void_type.set_flag(.option) { if expr is ast.CallExpr { stmt_str := g.go_before_last_stmt() @@ -96,7 +96,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) { g.writeln(';') g.write(stmt_str) } - g.write('_SLIT("")') + g.write('_S("")') } else if sym.kind == .enum { if expr !is ast.EnumVal { str_fn_name := g.get_str_fn(typ) @@ -107,7 +107,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) { g.enum_expr(expr) g.write(')') } else { - g.write('_SLIT("') + g.write('_S("') g.enum_expr(expr) g.write('")') } @@ -133,7 +133,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) { } if is_ptr && !is_var_mut { ref_str := '&'.repeat(typ.nr_muls()) - g.write('str_intp(1, _MOV((StrIntpData[]){{_SLIT("${ref_str}"), ${si_s_code} ,{.d_s = isnil(') + g.write('str_intp(1, _MOV((StrIntpData[]){{_S("${ref_str}"), ${si_s_code} ,{.d_s = isnil(') if typ.has_flag(.option) { g.write('*(${g.base_type(exp_typ)}*)&') if temp_var_needed { @@ -141,7 +141,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) { } else { g.expr(expr) } - g.write('.data) ? _SLIT("Option(&nil)") : ') + g.write('.data) ? _S("Option(&nil)") : ') } else { inside_interface_deref_old := g.inside_interface_deref g.inside_interface_deref = false @@ -153,7 +153,7 @@ fn (mut g Gen) gen_expr_to_string(expr ast.Expr, etype ast.Type) { } else { g.expr(expr) } - g.write(') ? _SLIT("nil") : ') + g.write(') ? _S("nil") : ') } } g.write2(str_fn_name, '(') diff --git a/vlib/v/gen/c/str_intp.v b/vlib/v/gen/c/str_intp.v index 7459056cda..3a342221b0 100644 --- a/vlib/v/gen/c/str_intp.v +++ b/vlib/v/gen/c/str_intp.v @@ -262,7 +262,7 @@ fn (mut g Gen) string_inter_literal(node ast.StringInterLiteral) { escaped_val = escaped_val.replace('\0', '\\0') if escaped_val.len > 0 { - g.write2('{_SLIT("', escaped_val) + g.write2('{_S("', escaped_val) g.write('"), ') } else { g.write('{_SLIT0, ') diff --git a/vlib/v/gen/c/struct.v b/vlib/v/gen/c/struct.v index b51dfd2e43..99531e4c50 100644 --- a/vlib/v/gen/c/struct.v +++ b/vlib/v/gen/c/struct.v @@ -378,7 +378,7 @@ fn (mut g Gen) struct_init(node ast.StructInit) { if nr_fields > 0 { g.write('0') } else { - g.write('EMPTY_STRUCT_INITIALIZATION') + g.write('E_STRUCT') } } diff --git a/vlib/v/gen/c/testdata/alias_char_ptr_to_ptr.c.must_have b/vlib/v/gen/c/testdata/alias_char_ptr_to_ptr.c.must_have index e4ea955d3d..509e64cd04 100644 --- a/vlib/v/gen/c/testdata/alias_char_ptr_to_ptr.c.must_have +++ b/vlib/v/gen/c/testdata/alias_char_ptr_to_ptr.c.must_have @@ -1,8 +1,8 @@ -VV_LOCAL_SYMBOL string main__get_two(void) { +VV_LOC string main__get_two(void) { char* s = main__return_text_two(); return cstring_to_vstring(s); } -VV_LOCAL_SYMBOL string main__get_one(void) { +VV_LOC string main__get_one(void) { main__ALcharptr s = main__return_text_one(); return cstring_to_vstring(s); } \ No newline at end of file diff --git a/vlib/v/gen/c/testdata/assert_fncalls.c.must_have b/vlib/v/gen/c/testdata/assert_fncalls.c.must_have index ec6c6e46e6..1eb2f0a918 100644 --- a/vlib/v/gen/c/testdata/assert_fncalls.c.must_have +++ b/vlib/v/gen/c/testdata/assert_fncalls.c.must_have @@ -1,9 +1,9 @@ int _t1 = main__fn_returning_array().len; if (!(_t1 == 1)) { -v_assert_meta_info__t2.src = _SLIT("fn_returning_array().len == 1"); -v_assert_meta_info__t2.llabel = _SLIT("fn_returning_array().len"); +v_assert_meta_info__t2.src = _S("fn_returning_array().len == 1"); +v_assert_meta_info__t2.llabel = _S("fn_returning_array().len"); int _t3 = main__fn_returning_struct().x; if (!(_t3 == 123)) { -v_assert_meta_info__t4.src = _SLIT("fn_returning_struct().x == 123"); -v_assert_meta_info__t4.llabel = _SLIT("fn_returning_struct().x"); +v_assert_meta_info__t4.src = _S("fn_returning_struct().x == 123"); +v_assert_meta_info__t4.llabel = _S("fn_returning_struct().x"); diff --git a/vlib/v/gen/c/testdata/c_ident_for_ptr_arg.c.must_have b/vlib/v/gen/c/testdata/c_ident_for_ptr_arg.c.must_have index edf4e93563..98e7bb1e20 100644 --- a/vlib/v/gen/c/testdata/c_ident_for_ptr_arg.c.must_have +++ b/vlib/v/gen/c/testdata/c_ident_for_ptr_arg.c.must_have @@ -1 +1 @@ -int (*real_open) (charptr , int , int ) = ((main__RealOpen)((dl__sym((voidptr)RTLD_NEXT, _SLIT("open"))))); \ No newline at end of file +int (*real_open) (charptr , int , int ) = ((main__RealOpen)((dl__sym((voidptr)RTLD_NEXT, _S("open"))))); \ No newline at end of file diff --git a/vlib/v/gen/c/testdata/c_varargs.c.must_have b/vlib/v/gen/c/testdata/c_varargs.c.must_have index 76b0018a5a..6c9912425d 100644 --- a/vlib/v/gen/c/testdata/c_varargs.c.must_have +++ b/vlib/v/gen/c/testdata/c_varargs.c.must_have @@ -1,2 +1,2 @@ -VV_LOCAL_SYMBOL void main__t2(voidptr fmt, ... ); -VV_LOCAL_SYMBOL void main__t2(voidptr fmt, ... ) { \ No newline at end of file +VV_LOC void main__t2(voidptr fmt, ... ); +VV_LOC void main__t2(voidptr fmt, ... ) { \ No newline at end of file diff --git a/vlib/v/gen/c/testdata/comptime_if_attribute_in_test2.c.must_have b/vlib/v/gen/c/testdata/comptime_if_attribute_in_test2.c.must_have index d216f3d536..d4b6333269 100644 --- a/vlib/v/gen/c/testdata/comptime_if_attribute_in_test2.c.must_have +++ b/vlib/v/gen/c/testdata/comptime_if_attribute_in_test2.c.must_have @@ -1 +1 @@ -println(_SLIT("this should be in the c code")); \ No newline at end of file +println(_S("this should be in the c code")); \ No newline at end of file diff --git a/vlib/v/gen/c/testdata/const_references.c.must_have b/vlib/v/gen/c/testdata/const_references.c.must_have index 11a2cb8b9f..3c668be0ac 100644 --- a/vlib/v/gen/c/testdata/const_references.c.must_have +++ b/vlib/v/gen/c/testdata/const_references.c.must_have @@ -1,3 +1,3 @@ -VV_LOCAL_SYMBOL int main__a_const_accepting_fn(int* x, const int* const_x); -VV_LOCAL_SYMBOL int main__a_const_accepting_fn(int* x, const int* const_x) { +VV_LOC int main__a_const_accepting_fn(int* x, const int* const_x); +VV_LOC int main__a_const_accepting_fn(int* x, const int* const_x) { main__a_const_accepting_fn(&a, &b) diff --git a/vlib/v/gen/c/testdata/embed.c.must_have b/vlib/v/gen/c/testdata/embed.c.must_have index 2ed41aeafd..fd0fa52540 100644 --- a/vlib/v/gen/c/testdata/embed.c.must_have +++ b/vlib/v/gen/c/testdata/embed.c.must_have @@ -14,4 +14,4 @@ string v__embed_file__EmbedFileData_to_string(v__embed_file__EmbedFileData* orig v__embed_file__EmbedFileIndexEntry* v__embed_file__find_index_entry_by_path(voidptr start, string path, string algo) { v__embed_file__EmbedFileData my_source = _v_embed_file_metadata( -res.path = _SLIT("embed.vv"); +res.path = _S("embed.vv"); diff --git a/vlib/v/gen/c/testdata/embed_with_prod.c.must_have b/vlib/v/gen/c/testdata/embed_with_prod.c.must_have index cfbd09e28f..ca42b98d0d 100644 --- a/vlib/v/gen/c/testdata/embed_with_prod.c.must_have +++ b/vlib/v/gen/c/testdata/embed_with_prod.c.must_have @@ -25,6 +25,6 @@ string v__embed_file__EmbedFileData_to_string(v__embed_file__EmbedFileData* orig v__embed_file__EmbedFileIndexEntry* v__embed_file__find_index_entry_by_path(voidptr start, string path, string algo) { v__embed_file__EmbedFileData my_source = _v_embed_file_metadata( -res.path = _SLIT("embed.vv"); -res.apath = _SLIT(""); -res.uncompressed = v__embed_file__find_index_entry_by_path((voidptr)_v_embed_file_index, _SLIT("embed.vv"), _SLIT("none"))->data; +res.path = _S("embed.vv"); +res.apath = _S(""); +res.uncompressed = v__embed_file__find_index_entry_by_path((voidptr)_v_embed_file_index, _S("embed.vv"), _S("none"))->data; diff --git a/vlib/v/gen/c/testdata/embed_with_prod_and_several_decoders.c.must_have b/vlib/v/gen/c/testdata/embed_with_prod_and_several_decoders.c.must_have index 0bb1da985a..412dea0687 100644 --- a/vlib/v/gen/c/testdata/embed_with_prod_and_several_decoders.c.must_have +++ b/vlib/v/gen/c/testdata/embed_with_prod_and_several_decoders.c.must_have @@ -2,10 +2,10 @@ {0, { .str=(byteptr)("embed.vv"), .len=8, .is_lit=1 }, { .str=(byteptr)("zlib"), .len=4, .is_lit=1 }, (byteptr)_v_embed_blob_0}, {1, { .str=(byteptr)("embed.vv"), .len=8, .is_lit=1 }, { .str=(byteptr)("none"), .len=4, .is_lit=1 }, (byteptr)_v_embed_blob_1}, -VV_LOCAL_SYMBOL void v__preludes__embed_file__zlib__init(void); -VV_LOCAL_SYMBOL _result_Array_u8 v__preludes__embed_file__zlib__ZLibDecoder_decompress(v__preludes__embed_file__zlib__ZLibDecoder _d1, Array_u8 data) { +VV_LOC void v__preludes__embed_file__zlib__init(void); +VV_LOC _result_Array_u8 v__preludes__embed_file__zlib__ZLibDecoder_decompress(v__preludes__embed_file__zlib__ZLibDecoder _d1, Array_u8 data) { return compress__zlib__decompress(data); -res.compressed = v__embed_file__find_index_entry_by_path((voidptr)_v_embed_file_index, _SLIT("embed.vv"), _SLIT("zlib"))->data; -res.compression_type = _SLIT("zlib"); -res.uncompressed = v__embed_file__find_index_entry_by_path((voidptr)_v_embed_file_index, _SLIT("embed.vv"), _SLIT("none"))->data; +res.compressed = v__embed_file__find_index_entry_by_path((voidptr)_v_embed_file_index, _S("embed.vv"), _S("zlib"))->data; +res.compression_type = _S("zlib"); +res.uncompressed = v__embed_file__find_index_entry_by_path((voidptr)_v_embed_file_index, _S("embed.vv"), _S("none"))->data; diff --git a/vlib/v/gen/c/testdata/embed_with_prod_zlib.c.must_have b/vlib/v/gen/c/testdata/embed_with_prod_zlib.c.must_have index f211c0baf1..a38b6a9736 100644 --- a/vlib/v/gen/c/testdata/embed_with_prod_zlib.c.must_have +++ b/vlib/v/gen/c/testdata/embed_with_prod_zlib.c.must_have @@ -25,6 +25,6 @@ string v__embed_file__EmbedFileData_to_string(v__embed_file__EmbedFileData* orig v__embed_file__EmbedFileIndexEntry* v__embed_file__find_index_entry_by_path(voidptr start, string path, string algo) { v__embed_file__EmbedFileData my_source = _v_embed_file_metadata( -res.path = _SLIT("embed.vv"); -res.apath = _SLIT(""); -res.compressed = v__embed_file__find_index_entry_by_path((voidptr)_v_embed_file_index, _SLIT("embed.vv"), _SLIT("zlib"))->data; +res.path = _S("embed.vv"); +res.apath = _S(""); +res.compressed = v__embed_file__find_index_entry_by_path((voidptr)_v_embed_file_index, _S("embed.vv"), _S("zlib"))->data; diff --git a/vlib/v/gen/c/testdata/export_and_weak.c.must_have b/vlib/v/gen/c/testdata/export_and_weak.c.must_have index 5d46f1cbb4..e15258f1d8 100644 --- a/vlib/v/gen/c/testdata/export_and_weak.c.must_have +++ b/vlib/v/gen/c/testdata/export_and_weak.c.must_have @@ -1,12 +1,12 @@ -VV_LOCAL_SYMBOL int main__my_other_fn(void); -VV_EXPORTED_SYMBOL VWEAK int wxyz(void); // exported fn main.my_other_fn +VV_LOC int main__my_other_fn(void); +VV_EXP VWEAK int wxyz(void); // exported fn main.my_other_fn VWEAK int wxyz(void) { -VV_LOCAL_SYMBOL int main__my_other_fn(void) { +VV_LOC int main__my_other_fn(void) { -VV_LOCAL_SYMBOL int main__my_fn(void); -VV_EXPORTED_SYMBOL int abcd(void); // exported fn main.my_fn +VV_LOC int main__my_fn(void); +VV_EXP int abcd(void); // exported fn main.my_fn int abcd(void) { -VV_LOCAL_SYMBOL int main__my_fn(void) { +VV_LOC int main__my_fn(void) { println(int_str(main__my_fn())); println(int_str(main__my_other_fn())); diff --git a/vlib/v/gen/c/testdata/fixed_arr_compare.c.must_have b/vlib/v/gen/c/testdata/fixed_arr_compare.c.must_have index cdde45f46c..2dc2e44be0 100644 --- a/vlib/v/gen/c/testdata/fixed_arr_compare.c.must_have +++ b/vlib/v/gen/c/testdata/fixed_arr_compare.c.must_have @@ -1,4 +1,4 @@ -bool Array_u8_contains(Array_u8 a, u8 v); // auto -string Array_fixed_int_2_str(Array_fixed_int_2 a); // auto -string indent_Array_fixed_int_2_str(Array_fixed_int_2 a, int indent_count); // auto -bool Array_fixed_int_2_arr_eq(Array_fixed_int_2 a, Array_fixed_int_2 b); // auto +bool Array_u8_contains(Array_u8 a, u8 v); +string Array_fixed_int_2_str(Array_fixed_int_2 a); +string indent_Array_fixed_int_2_str(Array_fixed_int_2 a, int indent_count); +bool Array_fixed_int_2_arr_eq(Array_fixed_int_2 a, Array_fixed_int_2 b); diff --git a/vlib/v/gen/c/testdata/global_export_nix.c.must_have b/vlib/v/gen/c/testdata/global_export_nix.c.must_have index e8e39bcf9d..3eb6d5ab23 100644 --- a/vlib/v/gen/c/testdata/global_export_nix.c.must_have +++ b/vlib/v/gen/c/testdata/global_export_nix.c.must_have @@ -1 +1 @@ -string VV_EXPORTED_SYMBOL global_exported = _SLIT("barqux"); \ No newline at end of file +string VV_EXP global_exported = _S("barqux"); \ No newline at end of file diff --git a/vlib/v/gen/c/testdata/globals_with_weak_tag.c.must_have b/vlib/v/gen/c/testdata/globals_with_weak_tag.c.must_have index 985c9f268e..8dd68e4e51 100644 --- a/vlib/v/gen/c/testdata/globals_with_weak_tag.c.must_have +++ b/vlib/v/gen/c/testdata/globals_with_weak_tag.c.must_have @@ -2,8 +2,8 @@ u64 VWEAK abc = ((u64)(1U)); // global u64 xyz = ((u64)(2U)); // global u64 VWEAK weak_1 = ((u64)(4U)); // global u64 VWEAK weak_2 = ((u64)(5U)); // global -VV_LOCAL_SYMBOL int main__a_weak_function(void); -VV_LOCAL_SYMBOL void main__main(void); +VV_LOC int main__a_weak_function(void); +VV_LOC void main__main(void); -VWEAK VV_LOCAL_SYMBOL int main__a_weak_function(void) { +VWEAK VV_LOC int main__a_weak_function(void) { diff --git a/vlib/v/gen/c/testdata/if_else_return.c.must_have b/vlib/v/gen/c/testdata/if_else_return.c.must_have index 4dfd5ec3ca..14dc1b71c2 100644 --- a/vlib/v/gen/c/testdata/if_else_return.c.must_have +++ b/vlib/v/gen/c/testdata/if_else_return.c.must_have @@ -1,9 +1,9 @@ -VV_LOCAL_SYMBOL _result_string main__empty(string s) { +VV_LOC _result_string main__empty(string s) { _result_string _t2; /* if prepend */ if ((s).len != 0) { _result_ok(&(string[]) { s }, (_result*)(&_t2), sizeof(string)); } else { -return (_result_string){ .is_error=true, .err=_v_error(_SLIT("empty")), .data={EMPTY_STRUCT_INITIALIZATION} }; +return (_result_string){ .is_error=true, .err=_v_error(_S("empty")), .data={E_STRUCT} }; } return _t1; -} \ No newline at end of file +} diff --git a/vlib/v/gen/c/testdata/linker_section_nix.c.must_have b/vlib/v/gen/c/testdata/linker_section_nix.c.must_have index 3e5aa11ac1..db1d63a480 100644 --- a/vlib/v/gen/c/testdata/linker_section_nix.c.must_have +++ b/vlib/v/gen/c/testdata/linker_section_nix.c.must_have @@ -1 +1 @@ -VV_LOCAL_SYMBOL void main__test(void) __attribute__ ((section ("foo"))); \ No newline at end of file +VV_LOC void main__test(void) __attribute__ ((section ("foo"))); \ No newline at end of file diff --git a/vlib/v/gen/c/testdata/platform_wrapper_emscripten.c.must_have b/vlib/v/gen/c/testdata/platform_wrapper_emscripten.c.must_have index 9b699eedd9..e53842fdcd 100644 --- a/vlib/v/gen/c/testdata/platform_wrapper_emscripten.c.must_have +++ b/vlib/v/gen/c/testdata/platform_wrapper_emscripten.c.must_have @@ -1,8 +1,8 @@ #if defined(CUSTOM_DEFINE_emscripten) -println(_SLIT("> inside then branch of if emscripten")); +println(_S("> inside then branch of if emscripten")); #if defined(__EMSCRIPTEN__) -println(_SLIT("> inside then branch of if wasm32_emscripten")); +println(_S("> inside then branch of if wasm32_emscripten")); v__gen__c__testdata__platform_wrapper__fn_defined_in_wasm32_emscripten(); diff --git a/vlib/v/gen/c/testdata/struct_fn_member_print.c.must_have b/vlib/v/gen/c/testdata/struct_fn_member_print.c.must_have index 5be043d7b1..4a55e62e5b 100644 --- a/vlib/v/gen/c/testdata/struct_fn_member_print.c.must_have +++ b/vlib/v/gen/c/testdata/struct_fn_member_print.c.must_have @@ -1,3 +1,3 @@ string main__MyStruct_str(main__MyStruct it) { return indent_main__MyStruct_str(it, 0);} -string main__Function_str() { return _SLIT("fn (int)");} +string main__Function_str() { return _S("fn (int)");} string _t1 = main__Function_str(); diff --git a/vlib/v/tests/consts/const_fixed_array_of_string_value_msvc_test.v b/vlib/v/tests/consts/const_fixed_array_of_string_value_msvc_test.v index 8d4abb3089..6059f0dc97 100644 --- a/vlib/v/tests/consts/const_fixed_array_of_string_value_msvc_test.v +++ b/vlib/v/tests/consts/const_fixed_array_of_string_value_msvc_test.v @@ -1,6 +1,6 @@ // for issue 20287 // msvc does not support the "_SLIT" macro for fixed array of string values immediate initialization: -// Array_fixed_string_5 _const_main__escaped_chars = {(_SLIT("\\b")), (_SLIT("\\f")), (_SLIT("\\n")), (_SLIT("\\r")), (_SLIT("\\t"))}; +// Array_fixed_string_5 _const_main__escaped_chars = {(_S("\\b")), (_S("\\f")), (_S("\\n")), (_S("\\r")), (_S("\\t"))}; // error C2099: initializer is not a constant const escaped_chars = [(r'\b'), (r'\f'), (r'\n'), (r'\r'), (r'\t')]!