@@ -16,10 +16,10 @@ fn (mut g Gen) array_init(node ast.ArrayInit, var_name string) {
16
16
g.go_back (1 ) // delete the `&` already generated in `prefix_expr()
17
17
}
18
18
if g.is_shared {
19
- shared_styp = g.typ (array_type.typ.set_flag (.shared_f))
19
+ shared_styp = g.styp (array_type.typ.set_flag (.shared_f))
20
20
g.writeln ('(${shared_styp} *)__dup_shared_array(&(${shared_styp} ){.mtx = {0}, .val =' )
21
21
} else if is_amp {
22
- array_styp = g.typ (array_type.typ)
22
+ array_styp = g.styp (array_type.typ)
23
23
g.write ('HEAP(${array_styp} , ' )
24
24
}
25
25
len := node.exprs.len
@@ -33,7 +33,7 @@ fn (mut g Gen) array_init(node ast.ArrayInit, var_name string) {
33
33
g.array_init_with_fields (node, elem_type, is_amp, shared_styp, var_name)
34
34
} else {
35
35
// `[1, 2, 3]`
36
- elem_styp := g.typ (elem_type.typ)
36
+ elem_styp := g.styp (elem_type.typ)
37
37
noscan := g.check_noscan (elem_type.typ)
38
38
if elem_type.unaliased_sym.kind == .function {
39
39
g.write ('new_array_from_c_array(${len} , ${len} , sizeof(voidptr), _MOV((voidptr[${len} ]){' )
@@ -93,8 +93,8 @@ fn (mut g Gen) fixed_array_init(node ast.ArrayInit, array_type Type, var_name st
93
93
g.past_tmp_var_done (past)
94
94
}
95
95
96
- ret_typ_str := g.typ (node.typ)
97
- elem_typ_str := g.typ (node.elem_type)
96
+ ret_typ_str := g.styp (node.typ)
97
+ elem_typ_str := g.styp (node.elem_type)
98
98
if var_name == '' {
99
99
g.write ('${ret_typ_str} ${past.tmp_var} =' )
100
100
}
@@ -137,7 +137,7 @@ fn (mut g Gen) fixed_array_init(node ast.ArrayInit, array_type Type, var_name st
137
137
return
138
138
}
139
139
if g.inside_struct_init && g.inside_cast {
140
- ret_typ_str := g.typ (node.typ)
140
+ ret_typ_str := g.styp (node.typ)
141
141
g.write ('(${ret_typ_str} )' )
142
142
}
143
143
elem_sym := g.table.final_sym (node.elem_type)
@@ -262,7 +262,7 @@ fn (mut g Gen) array_init_with_fields(node ast.ArrayInit, elem_type Type, is_amp
262
262
defer {
263
263
g.inside_lambda = prev_inside_lambda
264
264
}
265
- elem_styp := g.typ (elem_type.typ)
265
+ elem_styp := g.styp (elem_type.typ)
266
266
noscan := g.check_noscan (elem_type.typ)
267
267
is_default_array := elem_type.unaliased_sym.kind == .array && node.has_init
268
268
is_default_map := elem_type.unaliased_sym.kind == .map && node.has_init
@@ -275,8 +275,8 @@ fn (mut g Gen) array_init_with_fields(node ast.ArrayInit, elem_type Type, is_amp
275
275
g.past_tmp_var_done (past)
276
276
}
277
277
278
- ret_typ := g.typ (node.typ)
279
- elem_typ := g.typ (node.elem_type)
278
+ ret_typ := g.styp (node.typ)
279
+ elem_typ := g.styp (node.elem_type)
280
280
if var_name == '' {
281
281
g.write ('${ret_typ} ${past.tmp_var} =' )
282
282
}
@@ -472,13 +472,13 @@ fn (mut g Gen) gen_array_map(node ast.CallExpr) {
472
472
g.past_tmp_var_done (past)
473
473
}
474
474
475
- ret_typ := g.typ (node.return_type)
475
+ ret_typ := g.styp (node.return_type)
476
476
ret_sym := g.table.final_sym (node.return_type)
477
477
inp_sym := g.table.final_sym (node.receiver_type)
478
478
ret_info := ret_sym.info as ast.Array
479
- mut ret_elem_type := g.typ (ret_info.elem_type)
479
+ mut ret_elem_type := g.styp (ret_info.elem_type)
480
480
inp_info := inp_sym.info as ast.Array
481
- inp_elem_type := g.typ (inp_info.elem_type)
481
+ inp_elem_type := g.styp (inp_info.elem_type)
482
482
if inp_sym.kind != .array {
483
483
verror ('map() requires an array' )
484
484
}
@@ -600,7 +600,7 @@ fn (mut g Gen) gen_array_sorted(node ast.CallExpr) {
600
600
defer {
601
601
g.past_tmp_var_done (past)
602
602
}
603
- atype := g.typ (node.return_type)
603
+ atype := g.styp (node.return_type)
604
604
sym := g.table.final_sym (node.return_type)
605
605
info := sym.info as ast.Array
606
606
depth := g.get_array_depth (info.elem_type)
@@ -645,7 +645,7 @@ fn (mut g Gen) gen_array_sort(node ast.CallExpr) {
645
645
info := rec_sym.info as ast.Array
646
646
// `users.sort(a.age > b.age)`
647
647
// Generate a comparison function for a custom type
648
- elem_stype := g.typ (info.elem_type)
648
+ elem_stype := g.styp (info.elem_type)
649
649
mut compare_fn := 'compare_${g.unique_file_path_hash} _${elem_stype.replace('*', '_ptr')} '
650
650
mut comparison_type := g.unwrap (ast.void_type)
651
651
mut left_expr, mut right_expr := '' , ''
@@ -715,12 +715,12 @@ fn (mut g Gen) gen_array_sort(node ast.CallExpr) {
715
715
g.array_sort_fn << compare_fn
716
716
}
717
717
718
- stype_arg := g.typ (info.elem_type)
718
+ stype_arg := g.styp (info.elem_type)
719
719
g.definitions.writeln ('VV_LOCAL_SYMBOL ${g.static_modifier} int ${compare_fn} (${stype_arg} * a, ${stype_arg} * b) {' )
720
720
c_condition := if comparison_type.sym.has_method ('<' ) {
721
- '${g.typ (comparison_type.typ)} __lt(${left_expr} , ${right_expr} )'
721
+ '${g.styp (comparison_type.typ)} __lt(${left_expr} , ${right_expr} )'
722
722
} else if comparison_type.unaliased_sym.has_method ('<' ) {
723
- '${g.typ (comparison_type.unaliased)} __lt(${left_expr} , ${right_expr} )'
723
+ '${g.styp (comparison_type.unaliased)} __lt(${left_expr} , ${right_expr} )'
724
724
} else if use_lambda {
725
725
'${lambda_fn_name} (a, b)'
726
726
} else {
@@ -768,8 +768,8 @@ fn (mut g Gen) gen_array_filter(node ast.CallExpr) {
768
768
verror ('filter() requires an array' )
769
769
}
770
770
info := sym.info as ast.Array
771
- styp := g.typ (node.return_type)
772
- elem_type_str := g.typ (info.elem_type)
771
+ styp := g.styp (node.return_type)
772
+ elem_type_str := g.styp (info.elem_type)
773
773
noscan := g.check_noscan (info.elem_type)
774
774
has_infix_left_var_name := g.write_prepared_tmp_value (past.tmp_var, node, styp, '{0}' )
775
775
g.writeln ('${past.tmp_var} = __new_array${noscan} (0, ${past.tmp_var} _len, sizeof(${elem_type_str} ));\n ' )
@@ -852,7 +852,7 @@ fn (mut g Gen) gen_array_filter(node ast.CallExpr) {
852
852
fn (mut g Gen) gen_array_insert (node ast.CallExpr) {
853
853
left_sym := g.table.final_sym (node.left_type)
854
854
left_info := left_sym.info as ast.Array
855
- elem_type_str := g.typ (left_info.elem_type)
855
+ elem_type_str := g.styp (left_info.elem_type)
856
856
arg2_sym := g.table.final_sym (node.args[1 ].typ)
857
857
is_arg2_array := arg2_ sym.kind == .array
858
858
&& g.table.unaliased_type (node.args[1 ].typ.clear_flag (.variadic)) == g.table.unaliased_type (node.left_type)
@@ -889,7 +889,7 @@ fn (mut g Gen) gen_array_insert(node ast.CallExpr) {
889
889
fn (mut g Gen) gen_array_prepend (node ast.CallExpr) {
890
890
left_sym := g.table.final_sym (node.left_type)
891
891
left_info := left_sym.info as ast.Array
892
- elem_type_str := g.typ (left_info.elem_type)
892
+ elem_type_str := g.styp (left_info.elem_type)
893
893
arg_sym := g.table.final_sym (node.args[0 ].typ)
894
894
is_arg_array := arg_sym.kind == .array
895
895
&& g.table.unaliased_type (node.args[0 ].typ) == g.table.unaliased_type (node.left_type)
@@ -917,7 +917,7 @@ fn (mut g Gen) gen_array_prepend(node ast.CallExpr) {
917
917
fn (mut g Gen) get_array_contains_method (typ ast.Type) string {
918
918
t := g.table.final_sym (g.unwrap_generic (typ).set_nr_muls (0 )).idx
919
919
g.array_contains_types << t
920
- return g.typ (ast.idx_to_type (t)) + '_contains'
920
+ return g.styp (ast.idx_to_type (t)) + '_contains'
921
921
}
922
922
923
923
fn (mut g Gen) gen_array_contains_methods () {
@@ -933,7 +933,7 @@ fn (mut g Gen) gen_array_contains_methods() {
933
933
}
934
934
done << t
935
935
mut fn_builder := strings.new_builder (512 )
936
- mut left_type_str := g.typ (t)
936
+ mut left_type_str := g.styp (t)
937
937
fn_name := '${left_type_str} _contains'
938
938
939
939
$if new_int ? {
@@ -952,7 +952,7 @@ fn (mut g Gen) gen_array_contains_methods() {
952
952
953
953
if left_final_sym.kind == .array {
954
954
elem_type := (left_final_sym.info as ast.Array ).elem_type
955
- mut elem_type_str := g.typ (elem_type)
955
+ mut elem_type_str := g.styp (elem_type)
956
956
elem_kind := g.table.sym (elem_type).kind
957
957
elem_is_not_ptr := elem_type.nr_muls () == 0
958
958
if elem_kind == .function {
@@ -991,7 +991,7 @@ fn (mut g Gen) gen_array_contains_methods() {
991
991
left_info := left_final_sym.info as ast.ArrayFixed
992
992
size := left_info.size
993
993
elem_type := left_info.elem_type
994
- mut elem_type_str := g.typ (elem_type)
994
+ mut elem_type_str := g.styp (elem_type)
995
995
elem_kind := g.table.sym (elem_type).kind
996
996
elem_is_not_ptr := elem_type.nr_muls () == 0
997
997
if elem_kind == .function {
@@ -1067,11 +1067,11 @@ fn (mut g Gen) gen_array_contains(left_type ast.Type, left ast.Expr, right_type
1067
1067
if g.is_cc_msvc {
1068
1068
stmts := g.go_before_last_stmt ().trim_space ()
1069
1069
tmp_var := g.new_tmp_var ()
1070
- g.write ('${g.typ (right_type)} ${tmp_var} = ${g.expr_string(right)} ;' )
1070
+ g.write ('${g.styp (right_type)} ${tmp_var} = ${g.expr_string(right)} ;' )
1071
1071
g.write (stmts)
1072
1072
g.write (tmp_var)
1073
1073
} else {
1074
- g.write ('(${g.typ (right.typ)} )' )
1074
+ g.write ('(${g.styp (right.typ)} )' )
1075
1075
g.expr (right)
1076
1076
}
1077
1077
} else {
@@ -1083,7 +1083,7 @@ fn (mut g Gen) gen_array_contains(left_type ast.Type, left ast.Expr, right_type
1083
1083
fn (mut g Gen) get_array_index_method (typ ast.Type) string {
1084
1084
t := g.unwrap_generic (typ).set_nr_muls (0 )
1085
1085
g.array_index_types << t
1086
- return g.typ (t) + '_index'
1086
+ return g.styp (t) + '_index'
1087
1087
}
1088
1088
1089
1089
fn (mut g Gen) gen_array_index_methods () {
@@ -1094,13 +1094,13 @@ fn (mut g Gen) gen_array_index_methods() {
1094
1094
}
1095
1095
done << t
1096
1096
final_left_sym := g.table.final_sym (t)
1097
- mut left_type_str := g.typ (t)
1097
+ mut left_type_str := g.styp (t)
1098
1098
fn_name := '${left_type_str} _index'
1099
1099
mut fn_builder := strings.new_builder (512 )
1100
1100
1101
1101
if final_left_sym.kind == .array {
1102
1102
info := final_left_sym.info as ast.Array
1103
- mut elem_type_str := g.typ (info.elem_type)
1103
+ mut elem_type_str := g.styp (info.elem_type)
1104
1104
elem_sym := g.table.sym (info.elem_type)
1105
1105
if elem_sym.kind == .function {
1106
1106
left_type_str = 'Array_voidptr'
@@ -1145,7 +1145,7 @@ fn (mut g Gen) gen_array_index_methods() {
1145
1145
}
1146
1146
} else if final_left_sym.kind == .array_fixed {
1147
1147
info := final_left_sym.info as ast.ArrayFixed
1148
- mut elem_type_str := g.typ (info.elem_type)
1148
+ mut elem_type_str := g.styp (info.elem_type)
1149
1149
elem_sym := g.table.sym (info.elem_type)
1150
1150
if elem_sym.kind == .function {
1151
1151
elem_type_str = 'voidptr'
@@ -1223,11 +1223,11 @@ fn (mut g Gen) gen_array_index(node ast.CallExpr) {
1223
1223
if g.is_cc_msvc {
1224
1224
stmts := g.go_before_last_stmt ().trim_space ()
1225
1225
tmp_var := g.new_tmp_var ()
1226
- g.write ('${g.typ (node.args[0].typ)} ${tmp_var} = ${g.expr_string(node.args[0].expr)} ;' )
1226
+ g.write ('${g.styp (node.args[0].typ)} ${tmp_var} = ${g.expr_string(node.args[0].expr)} ;' )
1227
1227
g.write (stmts)
1228
1228
g.write (tmp_var)
1229
1229
} else {
1230
- g.write ('(${g.typ (node.args[0].typ)} )' )
1230
+ g.write ('(${g.styp (node.args[0].typ)} )' )
1231
1231
g.expr (node.args[0 ].expr)
1232
1232
}
1233
1233
} else {
@@ -1268,8 +1268,8 @@ fn (mut g Gen) gen_array_any(node ast.CallExpr) {
1268
1268
1269
1269
sym := g.table.final_sym (node.left_type)
1270
1270
info := sym.info as ast.Array
1271
- // styp := g.typ (node.return_type)
1272
- elem_type_str := g.typ (info.elem_type)
1271
+ // styp := g.styp (node.return_type)
1272
+ elem_type_str := g.styp (info.elem_type)
1273
1273
has_infix_left_var_name := g.write_prepared_tmp_value (past.tmp_var, node, 'bool' ,
1274
1274
'false' )
1275
1275
@@ -1357,8 +1357,8 @@ fn (mut g Gen) gen_array_all(node ast.CallExpr) {
1357
1357
1358
1358
sym := g.table.final_sym (node.left_type)
1359
1359
info := sym.info as ast.Array
1360
- // styp := g.typ (node.return_type)
1361
- elem_type_str := g.typ (info.elem_type)
1360
+ // styp := g.styp (node.return_type)
1361
+ elem_type_str := g.styp (info.elem_type)
1362
1362
1363
1363
has_infix_left_var_name := g.write_prepared_tmp_value (past.tmp_var, node, 'bool' ,
1364
1364
'true' )
@@ -1455,7 +1455,7 @@ fn (mut g Gen) write_prepared_tmp_value(tmp string, node &ast.CallExpr, tmp_styp
1455
1455
} else {
1456
1456
node.left_type
1457
1457
}
1458
- g.write ('${g.typ (left_type)} ${tmp} _orig = ' )
1458
+ g.write ('${g.styp (left_type)} ${tmp} _orig = ' )
1459
1459
if ! node.left_type.has_flag (.shared_f) && node.left_type.is_ptr () {
1460
1460
g.write ('*' )
1461
1461
}
0 commit comments