1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

gen: named imported structs operator overloading and str methods (#6433)

This commit is contained in:
Henrixounez
2020-09-20 19:51:14 +02:00
committed by GitHub
parent 6bf1865678
commit e429a77de2
13 changed files with 163 additions and 25 deletions

View File

@@ -8,8 +8,12 @@ import v.util
// already generated styp, reuse it
fn (mut g Gen) gen_str_for_type_with_styp(typ table.Type, styp string) string {
sym := g.table.get_type_symbol(typ)
str_fn_name := styp_to_str_fn_name(styp)
mut sym := g.table.get_type_symbol(typ)
mut str_fn_name := styp_to_str_fn_name(styp)
if sym.info is table.Alias {
sym = g.table.get_type_symbol((sym.info as table.Alias).parent_type)
str_fn_name = styp_to_str_fn_name(sym.name.replace('.', '__'))
}
sym_has_str_method, str_method_expects_ptr, str_nr_args := sym.str_method_info()
// generate for type
if sym_has_str_method && str_method_expects_ptr && str_nr_args == 1 {