fix V.js methods and duplicate .str() in arrays
parent
b6fa252fc9
commit
8d2111169a
|
@ -272,6 +272,9 @@ fn (p mut Parser) comptime_method_call(typ Type) {
|
|||
}
|
||||
|
||||
fn (p mut Parser) gen_array_str(typ Type) {
|
||||
if typ.has_method('str') {
|
||||
return
|
||||
}
|
||||
p.add_method(typ.name, Fn{
|
||||
name: 'str'
|
||||
typ: 'string'
|
||||
|
|
|
@ -888,7 +888,7 @@ fn (p mut Parser) fn_call_args(f mut Fn) {
|
|||
// Receiver is the first arg
|
||||
// Skip the receiver, because it was already generated in the expression
|
||||
if i == 0 && f.is_method {
|
||||
if f.args.len > 1 && !p.is_js {
|
||||
if f.args.len > 1 { // && !p.is_js {
|
||||
p.gen(',')
|
||||
}
|
||||
continue
|
||||
|
|
|
@ -28,7 +28,8 @@ fn (p mut Parser) gen_fn_decl(f Fn, typ, _str_args string) {
|
|||
}
|
||||
name := p.table.fn_gen_name(f)
|
||||
if f.is_method {
|
||||
p.genln('\n${f.receiver_typ}.prototype.${name} = function($str_args) {')
|
||||
//p.genln('\n${f.receiver_typ}.prototype.${name} = function($str_args) {')
|
||||
p.genln('function ${f.receiver_typ}_$name($str_args) {')
|
||||
} else {
|
||||
p.genln('/** @return { $typ } **/\nfunction $name($str_args) {')
|
||||
}
|
||||
|
@ -100,7 +101,9 @@ fn (p mut Parser) gen_method_call(receiver &Var, receiver_type string,
|
|||
|
||||
//mut cgen_name := p.table.fn_gen_name(f)
|
||||
//mut method_call := cgen_name + '('
|
||||
p.gen('.' + cgen_name.all_after('_') + '(')
|
||||
//p.gen('/*2*/.' + cgen_name.all_after('_') + '(')
|
||||
t := receiver_type.replace('*', '')
|
||||
p.cgen.set_placeholder(method_ph, '${t}_$cgen_name(')
|
||||
//p.cgen.set_placeholder(method_ph, '$cast kKE $method_call')
|
||||
//return method_call
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue