62 lines
1.6 KiB
WebAssembly Text Format
62 lines
1.6 KiB
WebAssembly Text Format
(module
|
|
(import
|
|
"gyehoek"
|
|
"write"
|
|
(func $gh-write (param (ref eq))))
|
|
(import
|
|
"gyehoek"
|
|
"to-bool"
|
|
(func $gh-to-bool (param (ref eq)) (result i32)))
|
|
(type $heap-object (sub (struct (field $hash (mut i32)))))
|
|
(type $cont-type (func (param i32)))
|
|
(type $cont-stack-type (array (mut (ref null $cont-type))))
|
|
(global $cont-stack-top (mut i32) (i32.const 0))
|
|
(global
|
|
$cont-stack
|
|
(ref $cont-stack-type)
|
|
(array.new_default $cont-stack-type (i32.const 128)))
|
|
(type $arg-array-type (array (mut (ref null eq))))
|
|
(global
|
|
$arg-array
|
|
(ref $arg-array-type)
|
|
(array.new_default $arg-array-type (i32.const 32)))
|
|
(global $result (mut (ref null eq)) (ref.null eq))
|
|
(func
|
|
$halt
|
|
(param i32)
|
|
(global.get $arg-array)
|
|
(i32.const 0)
|
|
(array.get $arg-array-type)
|
|
ref.as_non_null
|
|
(global.set $result))
|
|
(func
|
|
$scm-entry
|
|
(param i32)
|
|
(local (ref eq) (ref eq) (ref eq) (ref eq) (ref eq))
|
|
(i32.const 3)
|
|
ref.i31
|
|
(call $gh-to-bool)
|
|
(if
|
|
(then
|
|
(global.get $arg-array)
|
|
(global.get 0)
|
|
(i32.const 777)
|
|
(i32.const 1)
|
|
i32.shl
|
|
ref.i31
|
|
(array.set $arg-array-type)
|
|
(return_call $halt (i32.const 1)))
|
|
(else
|
|
(global.get $arg-array)
|
|
(global.get 0)
|
|
(i32.const 555)
|
|
(i32.const 1)
|
|
i32.shl
|
|
ref.i31
|
|
(array.set $arg-array-type)
|
|
(return_call $halt (i32.const 1)))))
|
|
(func
|
|
(export "main")
|
|
(call $scm-entry (i32.const 0))
|
|
(call $gh-write (ref.as_non_null (global.get $result)))))
|