@@ -7,126 +7,6 @@ import v.ast
7
7
import v.util
8
8
import v.token
9
9
10
- fn (mut g Gen) resolve_var_method_conflict (var_name string , val ast.Expr) string {
11
- mut method_call := ast.CallExpr{}
12
- mut has_method_call := false
13
- mut receiver_type := ast.Type (0 )
14
- mut method_name := ''
15
- match val {
16
- ast.ArrayInit {
17
- if var_name == 'new_array_from_c_array_noscan' {
18
- return '_var_${var_name} '
19
- }
20
- }
21
- ast.MapInit {
22
- if var_name == 'new_map_noscan_key_value' {
23
- return '_var_${var_name} '
24
- }
25
- }
26
- ast.CallExpr {
27
- if val.is_method {
28
- method_call = val
29
- has_method_call = true
30
- }
31
- }
32
- ast.UnsafeExpr {
33
- if val.expr is ast.CallExpr {
34
- call_expr := val.expr as ast.CallExpr
35
- if call_expr.is_method {
36
- method_call = call_expr
37
- has_method_call = true
38
- }
39
- } else if val.expr is ast.IndexExpr {
40
- index_expr := val.expr as ast.IndexExpr
41
- left_type := g.unwrap_generic (index_expr.left_type)
42
- left_sym := g.table.sym (left_type)
43
- type_name := left_sym.kind.str ()
44
- if (index_expr.index is ast.RangeExpr && var_name == '${type_name} _slice' )
45
- || var_name in ['${type_name} _get' , '${type_name} _at' ] {
46
- return '_var_${var_name} '
47
- }
48
- }
49
- }
50
- ast.InfixExpr {
51
- receiver_type = val.left_type
52
- method_name = match val.op {
53
- .eq { '_eq' }
54
- .ne { '_ne' }
55
- .lt { '_lt' }
56
- .le { '_le' }
57
- .gt { '_gt' }
58
- .ge { '_ge' }
59
- .plus { '_plus' }
60
- .minus { '_minus' }
61
- .mul { '_mul' }
62
- .div { '_div' }
63
- .mod { '_mod' }
64
- else { '' }
65
- }
66
- has_method_call = method_name != '' && receiver_type != 0
67
- }
68
- ast.IndexExpr {
69
- left_type := g.unwrap_generic (val.left_type)
70
- left_sym := g.table.sym (left_type)
71
- type_name := left_sym.kind.str ()
72
- if (val.index is ast.RangeExpr && var_name == '${type_name} _slice' )
73
- || var_name in ['${type_name} _get' , '${type_name} _at' ] {
74
- return '_var_${var_name} '
75
- }
76
- }
77
- else {}
78
- }
79
- if has_method_call {
80
- mut left_type := ast.Type (0 )
81
- if method_call.left_type != 0 {
82
- left_type = g.unwrap_generic (method_call.left_type)
83
- method_name = method_call.name
84
- } else if receiver_type != 0 {
85
- left_type = g.unwrap_generic (receiver_type)
86
- }
87
- if left_type != 0 {
88
- left_sym := g.table.sym (left_type)
89
- final_left_sym := g.table.final_sym (left_type)
90
- if var_name == '${left_sym.cname} _${method_name} ' {
91
- return '_var_${var_name} '
92
- }
93
- if final_left_sym.kind == .array && ! (left_sym.kind == .alias
94
- && left_sym.has_method (method_name)) {
95
- actual_method_name := match method_name {
96
- 'repeat' {
97
- 'repeat_to_depth'
98
- }
99
- 'clone' {
100
- 'clone_to_depth'
101
- }
102
- 'pop_left' {
103
- 'pop_left_noscan'
104
- }
105
- 'pop' {
106
- 'pop_noscan'
107
- }
108
- else {
109
- method_name
110
- }
111
- }
112
- if var_name == 'array_${actual_method_name} ' {
113
- return '_var_${var_name} '
114
- }
115
- }
116
- if final_left_sym.kind == .map && ! (left_sym.kind == .alias
117
- && left_sym.has_method (method_name)) {
118
- if method_name in ['clone' , 'move' ] && var_name == 'map_${method_name} ' {
119
- return '_var_${var_name} '
120
- }
121
- if method_name in ['keys' , 'values' ] && var_name == 'map_${method_name} ' {
122
- return '_var_${var_name} '
123
- }
124
- }
125
- }
126
- }
127
- return var_name
128
- }
129
-
130
10
fn (mut g Gen) expr_with_opt_or_block (expr ast.Expr, expr_typ ast.Type, var_expr ast.Expr, ret_typ ast.Type,
131
11
in_heap bool ) {
132
12
gen_or := expr is ast.Ident && expr.or_expr.kind != .absent
@@ -425,14 +305,6 @@ fn (mut g Gen) assign_stmt(node_ ast.AssignStmt) {
425
305
is_va_list = left_sym.language == .c && left_sym.name == 'C.va_list'
426
306
if mut left is ast.Ident {
427
307
ident = left
428
- if is_decl && i < node.right.len {
429
- resolved_name := g.resolve_var_method_conflict (ident.name, node.right[i])
430
- if resolved_name != ident.name {
431
- g.transformed_var_names[ident.name] = resolved_name
432
- ident.name = resolved_name
433
- node.left[i] = ident
434
- }
435
- }
436
308
g.curr_var_name << ident.name
437
309
// id_info := ident.var_info()
438
310
// var_type = id_info.typ
0 commit comments