js: implement more functions for JS backend (#12167)

This commit is contained in:
playX 2021-10-13 09:40:14 +03:00 committed by GitHub
parent ade5774313
commit d373eba79b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 134 additions and 3 deletions

View file

@ -2,8 +2,11 @@ module builtin
// used to generate JS throw statements.
[noreturn]
pub fn js_throw(s any) {
#throw s
for {}
}
#let globalPrint;
@ -46,6 +49,7 @@ pub fn eprint(s string) {
// Exits the process in node, and halts execution in the browser
// because `process.exit` is undefined. Workaround for not having
// a 'real' way to exit in the browser.
[noreturn]
pub fn exit(c int) {
JS.process.exit(c)
js_throw('exit($c)')