mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
generics: generic methods, cast to T
This commit is contained in:
committed by
Alexander Medvednikov
parent
7d02eccbce
commit
280c7d396c
@@ -247,11 +247,9 @@ fn (table mut Table) fn_gen_name(f &Fn) string {
|
||||
return name
|
||||
}
|
||||
|
||||
fn (p mut Parser) gen_method_call(receiver_type, ftyp string, cgen_name string,
|
||||
receiver Var,method_ph int)
|
||||
{
|
||||
fn (p mut Parser) gen_method_call(receiver &Var, receiver_type string, cgen_name string, ftyp string) string {
|
||||
//mut cgen_name := p.table.fn_gen_name(f)
|
||||
mut method_call := cgen_name + '('
|
||||
mut method_call := cgen_name + ' ('
|
||||
// if receiver is key_mut or a ref (&), generate & for the first arg
|
||||
if receiver.ref || (receiver.is_mut && !receiver_type.contains('*')) {
|
||||
method_call += '& /* ? */'
|
||||
@@ -268,12 +266,11 @@ fn (p mut Parser) gen_method_call(receiver_type, ftyp string, cgen_name string,
|
||||
// array_int => int
|
||||
cast = receiver_type.all_after('array_')
|
||||
cast = '*($cast*) '
|
||||
}else{
|
||||
} else {
|
||||
cast = '(voidptr) '
|
||||
}
|
||||
}
|
||||
p.cgen.set_placeholder(method_ph, '$cast $method_call')
|
||||
//return method_call
|
||||
return '$cast $method_call'
|
||||
}
|
||||
|
||||
fn (p mut Parser) gen_array_at(typ_ string, is_arr0 bool, fn_ph int) {
|
||||
|
||||
Reference in New Issue
Block a user