mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
cgen: minor cleanups in method_call() (#19068)
This commit is contained in:
parent
357ac0bb5a
commit
6045a1db02
@ -1188,12 +1188,12 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
|||||||
}
|
}
|
||||||
mut typ_sym := g.table.sym(unwrapped_rec_type)
|
mut typ_sym := g.table.sym(unwrapped_rec_type)
|
||||||
// non-option alias type that undefined this method (not include `str`) need to use parent type
|
// non-option alias type that undefined this method (not include `str`) need to use parent type
|
||||||
if !left_type.has_flag(.option) && typ_sym.kind == .alias && node.name != 'str'
|
if !left_type.has_flag(.option) && mut typ_sym.info is ast.Alias && node.name != 'str'
|
||||||
&& !typ_sym.has_method(node.name) {
|
&& !typ_sym.has_method(node.name) {
|
||||||
unwrapped_rec_type = (typ_sym.info as ast.Alias).parent_type
|
unwrapped_rec_type = typ_sym.info.parent_type
|
||||||
typ_sym = g.table.sym(unwrapped_rec_type)
|
typ_sym = g.table.sym(unwrapped_rec_type)
|
||||||
} else if typ_sym.kind == .array && !typ_sym.has_method(node.name) && node.name != 'str' {
|
} else if mut typ_sym.info is ast.Array && !typ_sym.has_method(node.name) && node.name != 'str' {
|
||||||
typ := g.table.unaliased_type((typ_sym.info as ast.Array).elem_type)
|
typ := g.table.unaliased_type(typ_sym.info.elem_type)
|
||||||
typ_idx := g.table.find_type_idx(g.table.array_name(typ))
|
typ_idx := g.table.find_type_idx(g.table.array_name(typ))
|
||||||
if typ_idx > 0 {
|
if typ_idx > 0 {
|
||||||
unwrapped_rec_type = ast.Type(typ_idx)
|
unwrapped_rec_type = ast.Type(typ_idx)
|
||||||
@ -1206,7 +1206,7 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
|||||||
}
|
}
|
||||||
rec_cc_type := g.cc_type(unwrapped_rec_type, false)
|
rec_cc_type := g.cc_type(unwrapped_rec_type, false)
|
||||||
mut receiver_type_name := util.no_dots(rec_cc_type)
|
mut receiver_type_name := util.no_dots(rec_cc_type)
|
||||||
if typ_sym.kind == .interface_ && (typ_sym.info as ast.Interface).defines_method(node.name) {
|
if mut typ_sym.info is ast.Interface && typ_sym.info.defines_method(node.name) {
|
||||||
// Speaker_name_table[s._interface_idx].speak(s._object)
|
// Speaker_name_table[s._interface_idx].speak(s._object)
|
||||||
$if debug_interface_method_call ? {
|
$if debug_interface_method_call ? {
|
||||||
eprintln('>>> interface typ_sym.name: ${typ_sym.name} | receiver_type_name: ${receiver_type_name} | pos: ${node.pos}')
|
eprintln('>>> interface typ_sym.name: ${typ_sym.name} | receiver_type_name: ${receiver_type_name} | pos: ${node.pos}')
|
||||||
@ -1312,11 +1312,10 @@ fn (mut g Gen) method_call(node ast.CallExpr) {
|
|||||||
mut name := util.no_dots('${receiver_type_name}_${node.name}')
|
mut name := util.no_dots('${receiver_type_name}_${node.name}')
|
||||||
mut array_depth := -1
|
mut array_depth := -1
|
||||||
mut noscan := ''
|
mut noscan := ''
|
||||||
if left_sym.kind == .array {
|
if left_sym.info is ast.Array {
|
||||||
needs_depth := node.name in ['clone', 'repeat']
|
needs_depth := node.name in ['clone', 'repeat']
|
||||||
if needs_depth {
|
if needs_depth {
|
||||||
elem_type := (left_sym.info as ast.Array).elem_type
|
array_depth = g.get_array_depth(left_sym.info.elem_type)
|
||||||
array_depth = g.get_array_depth(elem_type)
|
|
||||||
}
|
}
|
||||||
maybe_noscan := needs_depth
|
maybe_noscan := needs_depth
|
||||||
|| node.name in ['pop', 'push', 'push_many', 'reverse', 'grow_cap', 'grow_len']
|
|| node.name in ['pop', 'push', 'push_many', 'reverse', 'grow_cap', 'grow_len']
|
||||||
|
Loading…
Reference in New Issue
Block a user