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

js: port more methods (os, builtin) (#12238)

This commit is contained in:
playX
2021-10-20 16:02:21 +03:00
committed by GitHub
parent 7c1fff3495
commit 57c79770b3
6 changed files with 83 additions and 8 deletions

View File

@@ -83,6 +83,10 @@ fn js_stacktrace() string {
return stacktrace
}
pub fn print_backtrace() {
println(js_stacktrace())
}
// Check for nil value
pub fn isnil(val voidptr) bool {
res := false

View File

@@ -6,6 +6,7 @@ module builtin
fn (a any) toString()
[noreturn]
pub fn panic(s string) {
eprintln('V panic: $s\n$js_stacktrace()')
exit(1)

View File

@@ -155,3 +155,35 @@ pub fn (b []byte) hex() string {
}
return hex
}
pub fn (i int) hex2() string {
return '0x' + i.hex()
}
pub fn (i i8) hex2() string {
return '0x' + i.hex()
}
pub fn (i i16) hex2() string {
return '0x' + i.hex()
}
pub fn (i i64) hex2() string {
return '0x' + i.hex()
}
pub fn (i byte) hex2() string {
return '0x' + i.hex()
}
pub fn (i u16) hex2() string {
return '0x' + i.hex()
}
pub fn (i u32) hex2() string {
return '0x' + i.hex()
}
pub fn (i u64) hex2() string {
return '0x' + i.hex()
}

View File

@@ -910,3 +910,10 @@ pub fn (s string) index(search string) ?int {
}
return res
}
pub fn (_rune string) utf32_code() int {
res := 0
#res.val = s.str.charCodeAt()
return res
}