gen/checker: copy ptr & flag info in unwrap_generic
parent
30e0bda434
commit
3c4e4d4825
|
@ -1749,7 +1749,9 @@ fn (mut c Checker) stmts(stmts []ast.Stmt) {
|
||||||
|
|
||||||
pub fn (mut c Checker) unwrap_generic(typ table.Type) table.Type {
|
pub fn (mut c Checker) unwrap_generic(typ table.Type) table.Type {
|
||||||
if typ.idx() == table.t_type_idx {
|
if typ.idx() == table.t_type_idx {
|
||||||
return c.cur_generic_type
|
// return c.cur_generic_type
|
||||||
|
// its more efficient to set the id rather than to copy flags/nr_muls
|
||||||
|
return typ.set_idx(c.cur_generic_type)
|
||||||
}
|
}
|
||||||
return typ
|
return typ
|
||||||
}
|
}
|
||||||
|
|
|
@ -243,7 +243,7 @@ fn (mut g Gen) fn_args(args []table.Arg, is_variadic bool) ([]string, []string)
|
||||||
no_names := args.len > 0 && args[0].name == 'arg_1'
|
no_names := args.len > 0 && args[0].name == 'arg_1'
|
||||||
for i, arg in args {
|
for i, arg in args {
|
||||||
caname := c_name(arg.name)
|
caname := c_name(arg.name)
|
||||||
typ := g.unwrap_generic(arg.typ).set_nr_muls(arg.typ.nr_muls())
|
typ := g.unwrap_generic(arg.typ)
|
||||||
arg_type_sym := g.table.get_type_symbol(typ)
|
arg_type_sym := g.table.get_type_symbol(typ)
|
||||||
mut arg_type_name := g.typ(typ) // arg_type_sym.name.replace('.', '__')
|
mut arg_type_name := g.typ(typ) // arg_type_sym.name.replace('.', '__')
|
||||||
// if arg.name == 'xxx' {
|
// if arg.name == 'xxx' {
|
||||||
|
@ -330,7 +330,9 @@ fn (mut g Gen) call_expr(node ast.CallExpr) {
|
||||||
|
|
||||||
pub fn (mut g Gen) unwrap_generic(typ table.Type) table.Type {
|
pub fn (mut g Gen) unwrap_generic(typ table.Type) table.Type {
|
||||||
if typ.idx() == table.t_type_idx {
|
if typ.idx() == table.t_type_idx {
|
||||||
return g.cur_generic_type
|
// return g.cur_generic_type
|
||||||
|
// its more efficient to set the id rather than to copy flags/nr_muls
|
||||||
|
return typ.set_idx(g.cur_generic_type)
|
||||||
}
|
}
|
||||||
return typ
|
return typ
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,12 @@ pub fn (t Type) is_ptr() bool {
|
||||||
return (int(t) >> 16) & 0xff > 0
|
return (int(t) >> 16) & 0xff > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// set idx on `t` and return it
|
||||||
|
[inline]
|
||||||
|
pub fn (t Type) set_idx(idx int) Type {
|
||||||
|
return (((int(t) >> 24) & 0xff) << 24) | (((int(t) >> 16) & 0xff) << 16) | (u16(idx) & 0xffff)
|
||||||
|
}
|
||||||
|
|
||||||
// set nr_muls on `t` and return it
|
// set nr_muls on `t` and return it
|
||||||
[inline]
|
[inline]
|
||||||
pub fn (t Type) set_nr_muls(nr_muls int) Type {
|
pub fn (t Type) set_nr_muls(nr_muls int) Type {
|
||||||
|
@ -112,11 +118,12 @@ pub fn (t Type) clear_flag(flag TypeFlag) Type {
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear all flags
|
// clear all flags
|
||||||
|
[inline]
|
||||||
pub fn (t Type) clear_flags() Type {
|
pub fn (t Type) clear_flags() Type {
|
||||||
return 0 | (((int(t) >> 16) & 0xff) << 16) | (u16(t) & 0xffff)
|
return 0 | (((int(t) >> 16) & 0xff) << 16) | (u16(t) & 0xffff)
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if `flag` is set in `t`
|
// return true if `flag` is set on `t`
|
||||||
[inline]
|
[inline]
|
||||||
pub fn (t Type) has_flag(flag TypeFlag) bool {
|
pub fn (t Type) has_flag(flag TypeFlag) bool {
|
||||||
return (((int(t) >> 24) & 0xff) >> int(flag)) & 1 == 1
|
return (((int(t) >> 24) & 0xff) >> int(flag)) & 1 == 1
|
||||||
|
|
Loading…
Reference in New Issue