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

v.gen.js: fix method calls and other codegen parts, rand module compiles (#11205)

This commit is contained in:
playX
2021-08-18 11:33:37 +03:00
committed by GitHub
parent c51f83efba
commit 0121c8b4fd
9 changed files with 301 additions and 130 deletions

View File

@ -4,3 +4,35 @@ module builtin
pub fn js_throw(s any) {
#throw (s instanceof Error ? s : new Error(s))
}
pub fn println(s any) {
$if js_freestanding {
#print(s.toString())
} $else {
#console.log(s.toString())
}
}
pub fn print(s any) {
$if js_node {
#$process.stdout.write(s.toString())
} $else {
panic('Cannot `print` in a browser, use `println` instead')
}
}
pub fn eprintln(s any) {
$if js_freestanding {
#print(s.toString())
} $else {
#console.error(s.toString())
}
}
pub fn eprint(s any) {
$if js_node {
#$process.stderr.write(s.toString())
} $else {
panic('Cannot `eprint` in a browser, use `println` instead')
}
}