mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 20:43:40 +00:00
wasm: add support for js.FuncOf
This commit is contained in:
@@ -49,3 +49,7 @@ func lookupPanic() {
|
||||
func slicePanic() {
|
||||
runtimePanic("slice out of range")
|
||||
}
|
||||
|
||||
func blockingPanic() {
|
||||
runtimePanic("trying to do blocking operation in exported function")
|
||||
}
|
||||
|
||||
@@ -37,9 +37,16 @@ func putchar(c byte) {
|
||||
resource_write(stdout, &c, 1)
|
||||
}
|
||||
|
||||
var handleEvent func()
|
||||
|
||||
//go:linkname setEventHandler syscall/js.setEventHandler
|
||||
func setEventHandler(fn func()) {
|
||||
// TODO
|
||||
handleEvent = fn
|
||||
}
|
||||
|
||||
//go:export resume
|
||||
func resume() {
|
||||
handleEvent()
|
||||
}
|
||||
|
||||
//go:export go_scheduler
|
||||
|
||||
@@ -120,6 +120,9 @@ func setTaskPromisePtr(task *coroutine, value unsafe.Pointer) {
|
||||
// getTaskPromisePtr is a helper function to get the current .ptr field from a
|
||||
// coroutine promise.
|
||||
func getTaskPromisePtr(task *coroutine) unsafe.Pointer {
|
||||
if task == nil {
|
||||
blockingPanic()
|
||||
}
|
||||
return task.promise().ptr
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user