@@ -0,0 +1,2 @@
|
||||
ret > ExitSuccess
|
||||
out > #<procedure>
|
||||
@@ -0,0 +1,78 @@
|
||||
(module
|
||||
(import
|
||||
"gyehoek"
|
||||
"write"
|
||||
(func $gh-write (param (ref eq))))
|
||||
(import
|
||||
"gyehoek"
|
||||
"truthy?"
|
||||
(func $gh-truthy? (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))))
|
||||
(type
|
||||
$closure
|
||||
(sub
|
||||
$heap-object
|
||||
(struct
|
||||
(field $hash (mut i32))
|
||||
(field $code (ref $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
|
||||
(param i32)
|
||||
(local (ref eq) (ref eq) (ref eq) (ref eq) (ref eq))
|
||||
(global.get $arg-array)
|
||||
(i32.const 0)
|
||||
(array.get $arg-array-type)
|
||||
ref.as_non_null
|
||||
(local.set 1)
|
||||
(global.get $arg-array)
|
||||
(global.get 0)
|
||||
(local.get 1)
|
||||
(array.set $arg-array-type)
|
||||
(i32.const 1)
|
||||
(global.get $cont-stack)
|
||||
(global.get $cont-stack-top)
|
||||
(array.get $cont-stack-type)
|
||||
ref.as_non_null
|
||||
(global.get $cont-stack-top)
|
||||
(i32.const 1)
|
||||
i32.sub
|
||||
(global.set $cont-stack-top)
|
||||
(return_call_ref $cont-type))
|
||||
(elem declare funcref (ref.func 3))
|
||||
(func
|
||||
$scm-entry
|
||||
(param i32)
|
||||
(local (ref eq) (ref eq) (ref eq) (ref eq) (ref eq))
|
||||
(i32.const 0)
|
||||
(ref.func 3)
|
||||
(struct.new $closure)
|
||||
(local.set 1)
|
||||
(global.get $arg-array)
|
||||
(global.get 0)
|
||||
(local.get 1)
|
||||
(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)))))
|
||||
Reference in New Issue
Block a user