; This runtime is emitted by Bel, inside each standalone module. ; 0=nil, 1=t; symbol payloads end in 001, characters end in 010. ; Allocated pair handles are aligned addresses starting at 4096. (def wasm-list-runtime () '("(memory (export \"memory\") 1 16) (global $heap (mut i32) (i32.const 4096)) (func $pairp (param $x i32) (result i32) (i32.and (i32.and (i32.ge_u (local.get $x) (i32.const 4096)) (i32.lt_u (local.get $x) (global.get $heap))) (i32.eqz (i32.and (local.get $x) (i32.const 7))))) (func $valid (param $x i32) (result i32) (if (result i32) (i32.or (i32.eqz (local.get $x)) (i32.or (i32.eq (i32.and (local.get $x) (i32.const 7)) (i32.const 1)) (i32.or (i32.eq (i32.and (local.get $x) (i32.const 7)) (i32.const 2)) (call $pairp (local.get $x))))) (then (local.get $x)) (else unreachable))) (func $join (export \"join\") (param $a i32) (param $d i32) (result i32) (local $p i32) (local $end i32) (drop (call $valid (local.get $a))) (drop (call $valid (local.get $d))) (local.set $p (global.get $heap)) (local.set $end (i32.add (local.get $p) (i32.const 8))) (if (i32.gt_u (local.get $end) (i32.mul (memory.size) (i32.const 65536))) (then (if (i32.eq (memory.grow (i32.const 1)) (i32.const -1)) (then unreachable)))) (i32.store (local.get $p) (local.get $a)) (i32.store offset=4 (local.get $p) (local.get $d)) (global.set $heap (local.get $end)) (local.get $p)) (func $car (param $x i32) (result i32) (if (result i32) (i32.eqz (local.get $x)) (then (i32.const 0)) (else (if (result i32) (call $pairp (local.get $x)) (then (i32.load (local.get $x))) (else unreachable))))) (func $cdr (param $x i32) (result i32) (if (result i32) (i32.eqz (local.get $x)) (then (i32.const 0)) (else (if (result i32) (call $pairp (local.get $x)) (then (i32.load offset=4 (local.get $x))) (else unreachable))))) (func $id (param $a i32) (param $b i32) (result i32) (i32.eq (local.get $a) (local.get $b))) (func $type (param $x i32) (result i32) (drop (call $valid (local.get $x))) (if (result i32) (call $pairp (local.get $x)) (then (i32.const 9)) (else (if (result i32) (i32.eq (i32.and (local.get $x) (i32.const 7)) (i32.const 2)) (then (i32.const 25)) (else (i32.const 17))))))"))