vfmt: keep JS object name (#7462)
parent
178ddfe9c0
commit
fb0c4556fd
|
@ -43,12 +43,14 @@ pub fn (node &FnDecl) stringify(t &table.Table, cur_mod string) string {
|
|||
receiver = '($node.receiver.name $m$name) '
|
||||
*/
|
||||
}
|
||||
mut name := if node.is_anon { '' } else { node.name.after('.') }
|
||||
mut name := if node.is_anon { '' } else { node.name.after_char(`.`) }
|
||||
if !node.is_method {
|
||||
if node.language == .c {
|
||||
name = 'C.$name'
|
||||
} else if node.language == .js {
|
||||
name = 'JS.$name'
|
||||
}
|
||||
}
|
||||
f.write('fn $receiver$name')
|
||||
if name in ['+', '-', '*', '/', '%'] {
|
||||
f.write(' ')
|
||||
|
|
|
@ -1502,6 +1502,8 @@ pub fn (mut f Fmt) call_expr(node ast.CallExpr) {
|
|||
f.write_language_prefix(node.language)
|
||||
if node.left is ast.AnonFn {
|
||||
f.fn_decl(node.left.decl)
|
||||
} else if node.language != .v {
|
||||
f.write('${node.name.after_char(`.`)}')
|
||||
} else {
|
||||
mut name := f.short_module(node.name)
|
||||
f.mark_module_as_used(name)
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
fn (v JS.String) toString() JS.String
|
||||
|
||||
fn JS.Math.abs(f64) f64
|
||||
|
||||
fn main() {
|
||||
JS.Math.abs(0)
|
||||
}
|
Loading…
Reference in New Issue