Skip to content

Truly independent web browser

718 B
Raw Blame
;; Exceptions thrown by WebAssembly and by host functions, caught by WebAssembly.
(module
  (tag $error (import "host" "error") (param i32))
  (func $host_throw (import "host" "throw") (param i32))
  (func $thrower (param i32)
    (throw $error (local.get 0)))
  (func (export "catch_own") (param i32) (result i32)
    (block $caught (result i32)
      (try_table (catch $error $caught)
        (call $thrower (local.get 0)))
      (i32.const -1)))
  (func (export "catch_host") (param i32) (result i32)
    (block $caught (result i32)
      (try_table (catch $error $caught)
        (call $host_throw (local.get 0)))
      (i32.const -1)))
  (func (export "uncaught") (param i32)
    (call $thrower (local.get 0)))
)