Function Outputs

Status: implemented

  • A function is written by the graph outputs, the FunctionalScript, EDAG and Rust ones (output). JSON and DataJS have no function value, so they refuse a function in the selected result, even inside an array or object. A function used only during initialization or exported under an unselected name does not block data output: const f = (a, b) => 1; export default [f.length]; writes [2] as JSON.

Examples

The compiler demo has no programs for this page yet: its accepted and refused examples are a follow-up.

The demo on this page runs sample.f.js, this page's example as a function of one number — a function as a value: its length, and a call of it — with every output fjs compile makes of it: the expression graph (EDAG), the Rust and the WebAssembly that Rust builds to. Its Run button calls the default export with 0 and 2, as JavaScript and as WebAssembly, and shows what each call returned or threw.

const f = (a, b) => a + b;
export default (...a) => [f.length, f(a[0], 1)];

Reference

Demo

In FunctionalScript

fjs compile accepts this module, and it runs as JavaScript and as WebAssembly alike.

A FunctionalScript module and what fjs compile makes of it: the expression graph it lowers to, the Rust it compiles to on the NaNVM runtime, and the WebAssembly that Rust builds to. Run calls its default export with 0, then 2, first as the JavaScript it already is and then as WebAssembly, and shows what each call returned or threw and how long one call takes, timed over 1000 calls.

FunctionalScript source:

/**
 * The example of [`README.md`](./README.md) (Function Outputs) as a function
 * of one number, for the page's WASM demo: a function as a value: its
 * `length`, and a call of it.
 *
 * @module
 */

/** @type {(a: number, b: number) => number} */
const f = (a, b) => a + b;
/** @type {(...a: readonly number[]) => unknown} */
export default (...a) => [f.length, f(a[0], 1)];

Expression graph (EDAG) that fjs compile lowers it to:

=>lengthframe 0body0=>[]=>lengthbody2+[]01+leftrightarg 0arg 1.objkeyframe 0"length"()callee...frame 0[][]01.1.objidxrest0

The same graph, as fjs compile writes it to a .edag.data.js file:

const $0=["frame",0];export default ["{}",[[":","default",["=>",0,[["=>",2,[],["+",["arg",0],["arg",1]]]],["[]",[[".",$0,"length"],["()",$0,[[".",["rest"],0],1]]]]]]]];

Rust that fjs compile writes from it, on the NaNVM runtime:

// @generated by `fjs compile`. Do not edit: recompile the source module instead.

use nanvm_lib::vm::unstable::{f64_any, string_any, string_key};
use nanvm_lib::vm::{Any, Array, IStaticFunction, ToAny, ToArray, ToObject};

#[rustfmt::skip]
#[allow(clippy::if_same_then_else)]
pub fn module<A: IStaticFunction>(_runtime: Any<A>) -> Result<Any<A>, Any<A>> {
    let _b3: Any<A> = A::static_function(|_self, _args| { _args.argument(0) + _args.argument(1) }, 2, Array::default(), Some("($0,$1)=>$0+$1")).to_any();
    Ok([(string_key("default"), A::static_function(|_self, _args| {
        let _b468: Any<A> = _args.rest(0).to_any();
        Ok([(Any::dot(A::frame(_self)[0].clone(), string_any("length")).end())?, (Any::call(A::frame(_self)[0].clone(), [(Any::dot(_b468.clone(), f64_any(0x0000000000000000)).end())?, f64_any(0x3ff0000000000000)].to_array().to_any()))?].to_array().to_any())
    }, 0, [_b3.clone()].to_array(), Some("(...$1)=>[$0.length,$0($1[0],1)]")).to_any())].to_object().to_any())
}

WebAssembly text (WAT) of the functions compiled from this source, without the NaNVM runtime:

  (func $nanvm_demos::samples::function_outputs::module::<nanvm_lib::naive::Naive> (;647;) (type 1) (param i32 i32)
    (local i32 i32 i32 i32 i32)
    global.get $__stack_pointer
    i32.const 128
    i32.sub
    local.tee 2
    global.set $__stack_pointer
    local.get 2
    i32.const 0
    i32.store8 offset=64
    local.get 2
    i32.const 24
    i32.add
    local.get 2
    i32.const 64
    i32.add
    call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::iter::sources::empty::Empty<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, core::result::Result<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>::to_rc_slice"
    local.get 2
    local.get 2
    i32.load offset=28
    local.tee 3
    i32.store offset=84
    local.get 2
    local.get 2
    i32.load offset=24
    local.tee 4
    i32.store offset=80
    block ;; label = @1
      block ;; label = @2
        local.get 2
        i32.load8_u offset=64
        i32.const 1
        i32.ne
        br_if 0 (;@2;)
        local.get 4
        local.get 4
        i32.load
        i32.const -1
        i32.add
        local.tee 0
        i32.store
        local.get 0
        br_if 1 (;@1;)
        local.get 2
        i32.const 80
        i32.add
        call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
        br 1 (;@1;)
      end
      local.get 4
      i32.eqz
      br_if 0 (;@1;)
      local.get 2
      i32.const 187
      i32.const 2
      local.get 4
      local.get 3
      i32.const 1066408
      i32.const 14
      call $<nanvm_lib::naive::function::Function>::new
      local.tee 4
      i32.store offset=36
      local.get 2
      i32.const 7
      i32.store8 offset=32
      local.get 2
      i32.const 0
      i32.store16 offset=60
      local.get 2
      i32.const 1066166
      i32.store offset=56
      local.get 2
      i32.const 1066159
      i32.store offset=52
      local.get 2
      i32.const 80
      i32.add
      local.get 2
      i32.const 52
      i32.add
      call $"core::iter::adapters::try_process::<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>, u16, core::result::Result<core::convert::Infallible, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, <core::result::Result<alloc::rc::Rc<[u16]>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as core::iter::traits::collect::FromIterator<core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>>::from_iter<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>>::{closure#0}, alloc::rc::Rc<[u16]>>"
      block ;; label = @2
        block ;; label = @3
          block ;; label = @4
            block ;; label = @5
              local.get 2
              i32.load8_u offset=80
              local.tee 3
              i32.const 255
              i32.ne
              br_if 0 (;@5;)
              local.get 2
              i32.load offset=88
              local.set 5
              local.get 2
              i32.load offset=84
              local.set 6
              local.get 4
              local.get 4
              i32.load
              i32.const 1
              i32.add
              local.tee 3
              i32.store
              local.get 3
              i32.eqz
              br_if 1 (;@4;)
              local.get 2
              i32.const 0
              i32.store8 offset=52
              local.get 2
              i64.const 0
              i64.store offset=96
              local.get 2
              local.get 4
              i32.store offset=92
              local.get 2
              i32.const 7
              i32.store8 offset=88
              local.get 2
              i64.const 4294967296
              i64.store offset=80
              local.get 2
              local.get 2
              i32.const 52
              i32.add
              i32.store offset=104
              local.get 2
              i32.const 16
              i32.add
              local.get 2
              i32.const 80
              i32.add
              call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::array::iter::IntoIter<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, 1>, core::result::Result<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>::to_rc_slice"
              local.get 2
              local.get 2
              i32.load offset=20
              local.tee 3
              i32.store offset=68
              local.get 2
              local.get 2
              i32.load offset=16
              local.tee 4
              i32.store offset=64
              block ;; label = @6
                local.get 2
                i32.load8_u offset=52
                i32.const 1
                i32.ne
                br_if 0 (;@6;)
                local.get 4
                local.get 4
                i32.load
                i32.const -1
                i32.add
                local.tee 0
                i32.store
                local.get 0
                br_if 4 (;@2;)
                local.get 2
                i32.const 64
                i32.add
                call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
                br 4 (;@2;)
              end
              local.get 4
              i32.eqz
              br_if 3 (;@2;)
              i32.const 188
              i32.const 0
              local.get 4
              local.get 3
              i32.const 1066422
              i32.const 32
              call $<nanvm_lib::naive::function::Function>::new
              local.set 4
              local.get 2
              i32.const 0
              i32.store8 offset=52
              local.get 2
              local.get 4
              i32.store offset=100
              local.get 2
              i32.const 7
              i32.store8 offset=96
              local.get 2
              local.get 5
              i32.store offset=92
              local.get 2
              local.get 6
              i32.store offset=88
              local.get 2
              i64.const 4294967296
              i64.store offset=80
              local.get 2
              local.get 2
              i32.const 52
              i32.add
              i32.store offset=112
              local.get 2
              i32.const 8
              i32.add
              local.get 2
              i32.const 80
              i32.add
              call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::array::iter::IntoIter<(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>), 1>, core::result::Result<(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>), ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>)>>::to_rc_slice"
              local.get 2
              local.get 2
              i32.load offset=12
              local.tee 3
              i32.store offset=68
              local.get 2
              local.get 2
              i32.load offset=8
              local.tee 4
              i32.store offset=64
              block ;; label = @6
                local.get 2
                i32.load8_u offset=52
                i32.const 1
                i32.ne
                br_if 0 (;@6;)
                local.get 4
                local.get 4
                i32.load
                i32.const -1
                i32.add
                local.tee 0
                i32.store
                local.get 0
                br_if 3 (;@3;)
                local.get 2
                i32.const 64
                i32.add
                call $"<alloc::rc::Rc<[(nanvm_lib::vm::string::String<nanvm_lib::naive::Naive>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>)]>>::drop_slow"
                br 3 (;@3;)
              end
              local.get 4
              i32.eqz
              br_if 2 (;@3;)
              local.get 0
              local.get 3
              i32.store offset=16
              local.get 0
              local.get 4
              i32.store offset=12
              local.get 0
              i32.const 5
              i32.store8 offset=8
              local.get 0
              i64.const 0
              i64.store
              local.get 2
              i32.const 32
              i32.add
              call $"#func639 core::ptr::drop_glue::<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>"
              local.get 1
              call $"#func639 core::ptr::drop_glue::<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>"
              local.get 2
              i32.const 128
              i32.add
              global.set $__stack_pointer
              return
            end
            local.get 2
            local.get 2
            i32.load8_u offset=83
            i32.store8 offset=67
            local.get 2
            local.get 2
            i32.load16_u offset=81 align=1
            i32.store16 offset=65 align=1
            local.get 2
            local.get 2
            i32.load offset=92
            i32.store offset=76
            local.get 2
            local.get 2
            i64.load offset=84 align=4
            i64.store offset=68 align=4
            local.get 2
            local.get 3
            i32.store8 offset=64
            i32.const 1065572
            i32.const 43
            local.get 2
            i32.const 64
            i32.add
            i32.const 1065556
            i32.const 1065616
            call $core::result::unwrap_failed
          end
          unreachable
        end
        i32.const 1057428
        i32.const 43
        local.get 2
        i32.const 127
        i32.add
        i32.const 1057412
        i32.const 1057472
        call $core::result::unwrap_failed
        unreachable
      end
      i32.const 1057428
      i32.const 43
      local.get 2
      i32.const 127
      i32.add
      i32.const 1057412
      i32.const 1057472
      call $core::result::unwrap_failed
      unreachable
    end
    i32.const 1057428
    i32.const 43
    local.get 2
    i32.const 127
    i32.add
    i32.const 1057412
    i32.const 1057472
    call $core::result::unwrap_failed
    unreachable
  )
  (func $"<nanvm_demos::samples::function_outputs::module<nanvm_lib::naive::Naive>::{closure#0} as core::ops::function::FnOnce<(&nanvm_lib::naive::function::Function, nanvm_lib::vm::array::Array<nanvm_lib::naive::Naive>)>>::call_once" (;648;) (type 4) (param i32 i32 i32 i32)
    (local i32)
    global.get $__stack_pointer
    i32.const 48
    i32.sub
    local.tee 4
    global.set $__stack_pointer
    local.get 4
    local.get 3
    i32.store offset=12
    local.get 4
    local.get 2
    i32.store offset=8
    local.get 4
    i32.const 16
    i32.add
    local.get 4
    i32.const 8
    i32.add
    i32.const 0
    call $<nanvm_lib::vm::array::Array<nanvm_lib::naive::Naive>>::argument
    local.get 4
    i32.const 32
    i32.add
    local.get 4
    i32.const 8
    i32.add
    i32.const 1
    call $<nanvm_lib::vm::array::Array<nanvm_lib::naive::Naive>>::argument
    local.get 0
    local.get 4
    i32.const 16
    i32.add
    local.get 4
    i32.const 32
    i32.add
    call $"<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive> as core::ops::arith::Add>::add"
    local.get 4
    i32.load offset=8
    local.tee 3
    local.get 3
    i32.load
    i32.const -1
    i32.add
    local.tee 3
    i32.store
    block ;; label = @1
      local.get 3
      br_if 0 (;@1;)
      local.get 4
      i32.const 8
      i32.add
      call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
    end
    local.get 4
    i32.const 48
    i32.add
    global.set $__stack_pointer
  )
  (func $"<nanvm_demos::samples::function_outputs::module<nanvm_lib::naive::Naive>::{closure#1} as core::ops::function::FnOnce<(&nanvm_lib::naive::function::Function, nanvm_lib::vm::array::Array<nanvm_lib::naive::Naive>)>>::call_once" (;649;) (type 4) (param i32 i32 i32 i32)
    (local i32 i32 i32 i64 i32 i64 i64 i64)
    global.get $__stack_pointer
    i32.const 304
    i32.sub
    local.tee 4
    global.set $__stack_pointer
    local.get 1
    i32.load
    local.set 1
    local.get 4
    local.get 3
    i32.store offset=20
    local.get 4
    local.get 2
    i32.store offset=16
    local.get 2
    local.get 2
    i32.load
    i32.const 1
    i32.add
    local.tee 5
    i32.store
    block ;; label = @1
      local.get 5
      i32.eqz
      br_if 0 (;@1;)
      local.get 4
      local.get 3
      i32.store offset=32
      local.get 4
      local.get 2
      i32.store offset=28
      local.get 4
      i32.const 6
      i32.store8 offset=24
      block ;; label = @2
        block ;; label = @3
          block ;; label = @4
            local.get 1
            i32.load offset=16
            i32.eqz
            br_if 0 (;@4;)
            block ;; label = @5
              block ;; label = @6
                block ;; label = @7
                  block ;; label = @8
                    block ;; label = @9
                      block ;; label = @10
                        block ;; label = @11
                          block ;; label = @12
                            local.get 1
                            i32.load offset=12
                            local.tee 5
                            i32.load8_u offset=8
                            local.tee 6
                            br_table 6 (;@6;) 6 (;@6;) 0 (;@12;) 1 (;@11;) 2 (;@10;) 3 (;@9;) 4 (;@8;) 5 (;@7;) 6 (;@6;)
                          end
                          local.get 5
                          i64.load offset=16
                          local.set 7
                          br 9 (;@2;)
                        end
                        local.get 5
                        i32.load offset=12
                        local.tee 3
                        local.get 3
                        i32.load
                        i32.const 1
                        i32.add
                        local.tee 8
                        i32.store
                        local.get 8
                        i32.eqz
                        br_if 9 (;@1;)
                        br 7 (;@3;)
                      end
                      local.get 5
                      i32.load offset=12
                      local.tee 3
                      local.get 3
                      i32.load
                      i32.const 1
                      i32.add
                      local.tee 8
                      i32.store
                      local.get 8
                      i32.eqz
                      br_if 8 (;@1;)
                      local.get 5
                      i64.load8_u offset=20
                      i64.const 32
                      i64.shl
                      local.get 5
                      i64.load32_u offset=16
                      i64.or
                      local.set 7
                      br 7 (;@2;)
                    end
                    local.get 5
                    i32.load offset=12
                    local.tee 3
                    local.get 3
                    i32.load
                    i32.const 1
                    i32.add
                    local.tee 8
                    i32.store
                    local.get 8
                    br_if 5 (;@3;)
                    br 7 (;@1;)
                  end
                  local.get 5
                  i32.load offset=12
                  local.tee 3
                  local.get 3
                  i32.load
                  i32.const 1
                  i32.add
                  local.tee 8
                  i32.store
                  local.get 8
                  br_if 4 (;@3;)
                  br 6 (;@1;)
                end
                local.get 5
                i32.load offset=12
                local.tee 3
                local.get 3
                i32.load
                i32.const 1
                i32.add
                local.tee 5
                i32.store
                local.get 5
                i32.eqz
                br_if 5 (;@1;)
                br 1 (;@5;)
              end
              local.get 5
              i32.load8_u offset=9
              local.set 5
            end
            br 2 (;@2;)
          end
          i32.const 0
          i32.const 0
          i32.const 1063408
          call $core::panicking::panic_bounds_check
          unreachable
        end
        local.get 5
        i64.load32_u offset=16
        local.set 7
      end
      local.get 4
      local.get 7
      i64.store offset=232
      local.get 4
      local.get 3
      i32.store offset=228
      local.get 4
      local.get 5
      i32.store8 offset=225
      local.get 4
      local.get 6
      i32.store8 offset=224
      local.get 4
      i32.const 0
      i32.store16 offset=168
      local.get 4
      i32.const 1067680
      i32.store offset=164
      local.get 4
      i32.const 1067674
      i32.store offset=160
      local.get 4
      i32.const 248
      i32.add
      local.get 4
      i32.const 160
      i32.add
      call $"core::iter::adapters::try_process::<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>, u16, core::result::Result<core::convert::Infallible, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>, <core::result::Result<alloc::rc::Rc<[u16]>, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as core::iter::traits::collect::FromIterator<core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>>::from_iter<core::iter::adapters::map::Map<core::str::iter::EncodeUtf16, core::result::Result<u16, nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::Ok>>::{closure#0}, alloc::rc::Rc<[u16]>>"
      block ;; label = @2
        block ;; label = @3
          block ;; label = @4
            block ;; label = @5
              block ;; label = @6
                block ;; label = @7
                  block ;; label = @8
                    block ;; label = @9
                      block ;; label = @10
                        block ;; label = @11
                          local.get 4
                          i32.load8_u offset=248
                          local.tee 3
                          i32.const 255
                          i32.ne
                          br_if 0 (;@11;)
                          local.get 4
                          local.get 4
                          i64.load offset=252 align=4
                          i64.store offset=196 align=4
                          local.get 4
                          i32.const 3
                          i32.store8 offset=192
                          local.get 4
                          i32.const 160
                          i32.add
                          local.get 4
                          i32.const 224
                          i32.add
                          local.get 4
                          i32.const 192
                          i32.add
                          call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::new
                          block ;; label = @12
                            local.get 4
                            i32.load8_u offset=160
                            i32.const 255
                            i32.ne
                            br_if 0 (;@12;)
                            local.get 0
                            local.get 4
                            i64.load offset=176
                            i64.store offset=16
                            local.get 0
                            local.get 4
                            i64.load offset=168
                            i64.store offset=8
                            local.get 0
                            i64.const 1
                            i64.store
                            br 5 (;@7;)
                          end
                          local.get 4
                          local.get 4
                          i64.load offset=184
                          i64.store offset=272
                          local.get 4
                          local.get 4
                          i64.load offset=176
                          i64.store offset=264
                          local.get 4
                          local.get 4
                          i64.load offset=168
                          i64.store offset=256
                          local.get 4
                          local.get 4
                          i64.load offset=160
                          i64.store offset=248
                          local.get 4
                          i32.const 192
                          i32.add
                          local.get 4
                          i32.const 248
                          i32.add
                          call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::own
                          block ;; label = @12
                            block ;; label = @13
                              local.get 4
                              i32.load8_u offset=192
                              i32.const 255
                              i32.eq
                              br_if 0 (;@13;)
                              local.get 4
                              local.get 4
                              i64.load offset=200
                              i64.store offset=80
                              local.get 4
                              local.get 4
                              i64.load offset=192
                              i64.store offset=72
                              br 1 (;@12;)
                            end
                            local.get 4
                            i32.const 256
                            i32.store16 offset=72
                          end
                          local.get 4
                          i32.const 248
                          i32.add
                          call $"#func562 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                          local.get 4
                          i32.const 264
                          i32.add
                          call $"#func562 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                          local.get 1
                          i32.load offset=16
                          i32.eqz
                          br_if 1 (;@10;)
                          block ;; label = @12
                            block ;; label = @13
                              block ;; label = @14
                                block ;; label = @15
                                  block ;; label = @16
                                    block ;; label = @17
                                      block ;; label = @18
                                        block ;; label = @19
                                          local.get 1
                                          i32.load offset=12
                                          local.tee 1
                                          i32.load8_u offset=8
                                          local.tee 5
                                          br_table 6 (;@13;) 6 (;@13;) 0 (;@19;) 1 (;@18;) 2 (;@17;) 3 (;@16;) 4 (;@15;) 5 (;@14;) 6 (;@13;)
                                        end
                                        local.get 1
                                        i64.load offset=16
                                        local.set 7
                                        br 10 (;@8;)
                                      end
                                      local.get 1
                                      i32.load offset=12
                                      local.tee 3
                                      local.get 3
                                      i32.load
                                      i32.const 1
                                      i32.add
                                      local.tee 6
                                      i32.store
                                      local.get 6
                                      i32.eqz
                                      br_if 16 (;@1;)
                                      br 8 (;@9;)
                                    end
                                    local.get 1
                                    i32.load offset=12
                                    local.tee 3
                                    local.get 3
                                    i32.load
                                    i32.const 1
                                    i32.add
                                    local.tee 6
                                    i32.store
                                    local.get 6
                                    i32.eqz
                                    br_if 15 (;@1;)
                                    local.get 1
                                    i64.load8_u offset=20
                                    i64.const 32
                                    i64.shl
                                    local.get 1
                                    i64.load32_u offset=16
                                    i64.or
                                    local.set 7
                                    br 8 (;@8;)
                                  end
                                  local.get 1
                                  i32.load offset=12
                                  local.tee 3
                                  local.get 3
                                  i32.load
                                  i32.const 1
                                  i32.add
                                  local.tee 6
                                  i32.store
                                  local.get 6
                                  i32.eqz
                                  br_if 14 (;@1;)
                                  br 6 (;@9;)
                                end
                                local.get 1
                                i32.load offset=12
                                local.tee 3
                                local.get 3
                                i32.load
                                i32.const 1
                                i32.add
                                local.tee 6
                                i32.store
                                local.get 6
                                i32.eqz
                                br_if 13 (;@1;)
                                br 5 (;@9;)
                              end
                              local.get 1
                              i32.load offset=12
                              local.tee 3
                              local.get 3
                              i32.load
                              i32.const 1
                              i32.add
                              local.tee 1
                              i32.store
                              local.get 1
                              i32.eqz
                              br_if 12 (;@1;)
                              br 1 (;@12;)
                            end
                            local.get 1
                            i32.load8_u offset=9
                            local.set 1
                          end
                          br 3 (;@8;)
                        end
                        local.get 4
                        local.get 4
                        i32.load8_u offset=251
                        i32.store8 offset=195
                        local.get 4
                        local.get 4
                        i32.load16_u offset=249 align=1
                        i32.store16 offset=193 align=1
                        local.get 4
                        local.get 4
                        i32.load offset=260
                        i32.store offset=204
                        local.get 4
                        local.get 4
                        i64.load offset=252 align=4
                        i64.store offset=196 align=4
                        local.get 4
                        local.get 3
                        i32.store8 offset=192
                        i32.const 1065572
                        i32.const 43
                        local.get 4
                        i32.const 192
                        i32.add
                        i32.const 1065556
                        i32.const 1065616
                        call $core::result::unwrap_failed
                        unreachable
                      end
                      i32.const 0
                      i32.const 0
                      i32.const 1063408
                      call $core::panicking::panic_bounds_check
                      unreachable
                    end
                    local.get 1
                    i64.load32_u offset=16
                    local.set 7
                  end
                  local.get 4
                  local.get 7
                  i64.store offset=120
                  local.get 4
                  local.get 3
                  i32.store offset=116
                  local.get 4
                  local.get 1
                  i32.store8 offset=113
                  local.get 4
                  local.get 5
                  i32.store8 offset=112
                  block ;; label = @8
                    block ;; label = @9
                      block ;; label = @10
                        block ;; label = @11
                          block ;; label = @12
                            block ;; label = @13
                              block ;; label = @14
                                block ;; label = @15
                                  block ;; label = @16
                                    block ;; label = @17
                                      local.get 4
                                      i32.load8_u offset=24
                                      local.tee 3
                                      br_table 6 (;@11;) 6 (;@11;) 0 (;@17;) 1 (;@16;) 2 (;@15;) 3 (;@14;) 4 (;@13;) 5 (;@12;) 6 (;@11;)
                                    end
                                    local.get 4
                                    i64.load offset=32
                                    local.set 7
                                    br 8 (;@8;)
                                  end
                                  local.get 4
                                  i32.load offset=28
                                  local.tee 1
                                  local.get 1
                                  i32.load
                                  i32.const 1
                                  i32.add
                                  local.tee 5
                                  i32.store
                                  local.get 5
                                  i32.eqz
                                  br_if 14 (;@1;)
                                  br 6 (;@9;)
                                end
                                local.get 4
                                i32.load offset=28
                                local.tee 1
                                local.get 1
                                i32.load
                                i32.const 1
                                i32.add
                                local.tee 5
                                i32.store
                                local.get 5
                                i32.eqz
                                br_if 13 (;@1;)
                                local.get 4
                                i64.load8_u offset=36
                                i64.const 32
                                i64.shl
                                local.get 4
                                i64.load32_u offset=32
                                i64.or
                                local.set 7
                                br 6 (;@8;)
                              end
                              local.get 4
                              i32.load offset=28
                              local.tee 1
                              local.get 1
                              i32.load
                              i32.const 1
                              i32.add
                              local.tee 5
                              i32.store
                              local.get 5
                              i32.eqz
                              br_if 12 (;@1;)
                              br 4 (;@9;)
                            end
                            local.get 4
                            i32.load offset=28
                            local.tee 1
                            local.get 1
                            i32.load
                            i32.const 1
                            i32.add
                            local.tee 5
                            i32.store
                            local.get 5
                            i32.eqz
                            br_if 11 (;@1;)
                            br 3 (;@9;)
                          end
                          local.get 4
                          i32.load offset=28
                          local.tee 1
                          local.get 1
                          i32.load
                          i32.const 1
                          i32.add
                          local.tee 5
                          i32.store
                          local.get 5
                          i32.eqz
                          br_if 10 (;@1;)
                          br 1 (;@10;)
                        end
                        local.get 4
                        i32.load8_u offset=25
                        local.set 5
                      end
                      br 1 (;@8;)
                    end
                    local.get 4
                    i64.load32_u offset=32
                    local.set 7
                  end
                  local.get 4
                  local.get 7
                  i64.store offset=232
                  local.get 4
                  local.get 1
                  i32.store offset=228
                  local.get 4
                  local.get 5
                  i32.store8 offset=225
                  local.get 4
                  local.get 3
                  i32.store8 offset=224
                  local.get 4
                  i64.const 0
                  i64.store offset=256
                  local.get 4
                  i32.const 2
                  i32.store8 offset=248
                  local.get 4
                  i32.const 192
                  i32.add
                  local.get 4
                  i32.const 224
                  i32.add
                  local.get 4
                  i32.const 248
                  i32.add
                  call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::new
                  block ;; label = @8
                    block ;; label = @9
                      local.get 4
                      i32.load8_u offset=192
                      i32.const 255
                      i32.ne
                      br_if 0 (;@9;)
                      local.get 0
                      local.get 4
                      i64.load offset=208
                      i64.store offset=16
                      local.get 0
                      local.get 4
                      i64.load offset=200
                      i64.store offset=8
                      local.get 0
                      i64.const 1
                      i64.store
                      local.get 4
                      i32.const 112
                      i32.add
                      call $"#func639 core::ptr::drop_glue::<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>"
                      br 1 (;@8;)
                    end
                    local.get 4
                    local.get 4
                    i64.load offset=216
                    i64.store offset=272
                    local.get 4
                    local.get 4
                    i64.load offset=208
                    i64.store offset=264
                    local.get 4
                    local.get 4
                    i64.load offset=200
                    i64.store offset=256
                    local.get 4
                    local.get 4
                    i64.load offset=192
                    i64.store offset=248
                    local.get 4
                    i32.const 224
                    i32.add
                    local.get 4
                    i32.const 248
                    i32.add
                    call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::own
                    i32.const 1
                    local.set 1
                    i32.const 0
                    local.set 3
                    block ;; label = @9
                      local.get 4
                      i32.load8_u offset=224
                      local.tee 5
                      i32.const 255
                      i32.eq
                      br_if 0 (;@9;)
                      local.get 4
                      local.get 4
                      i64.load offset=226 align=2
                      i64.store offset=144
                      local.get 4
                      local.get 4
                      i64.load offset=232 align=2
                      i64.store offset=150 align=2
                      local.get 4
                      i32.load8_u offset=225
                      local.set 1
                      local.get 5
                      local.set 3
                    end
                    local.get 4
                    i32.const 248
                    i32.add
                    call $"#func562 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                    local.get 4
                    i32.const 264
                    i32.add
                    call $"#func562 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                    local.get 4
                    i32.const 0
                    i32.store8 offset=247
                    local.get 4
                    local.get 1
                    i32.store8 offset=257
                    local.get 4
                    local.get 3
                    i32.store8 offset=256
                    local.get 4
                    i64.const 8589934592
                    i64.store offset=248
                    local.get 4
                    local.get 4
                    i64.load offset=144
                    i64.store offset=258 align=2
                    local.get 4
                    local.get 4
                    i64.load offset=150 align=2
                    i64.store offset=264 align=2
                    local.get 4
                    i64.const 4607182418800017408
                    i64.store offset=280
                    local.get 4
                    i32.const 2
                    i32.store8 offset=272
                    local.get 4
                    local.get 4
                    i32.const 247
                    i32.add
                    i32.store offset=288
                    local.get 4
                    i32.const 8
                    i32.add
                    local.get 4
                    i32.const 248
                    i32.add
                    call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::array::iter::IntoIter<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, 2>, core::result::Result<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>::to_rc_slice"
                    local.get 4
                    local.get 4
                    i32.load offset=12
                    local.tee 5
                    i32.store offset=228
                    local.get 4
                    local.get 4
                    i32.load offset=8
                    local.tee 1
                    i32.store offset=224
                    block ;; label = @9
                      local.get 4
                      i32.load8_u offset=247
                      i32.const 1
                      i32.ne
                      br_if 0 (;@9;)
                      local.get 1
                      local.get 1
                      i32.load
                      i32.const -1
                      i32.add
                      local.tee 2
                      i32.store
                      local.get 2
                      br_if 7 (;@2;)
                      local.get 4
                      i32.const 224
                      i32.add
                      call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
                      br 7 (;@2;)
                    end
                    local.get 1
                    i32.eqz
                    br_if 6 (;@2;)
                    local.get 4
                    i32.const 96
                    i32.add
                    local.set 3
                    local.get 4
                    local.get 5
                    i32.store offset=136
                    local.get 4
                    local.get 1
                    i32.store offset=132
                    local.get 4
                    i32.const 6
                    i32.store8 offset=128
                    local.get 4
                    i32.const 88
                    i32.add
                    local.get 4
                    i32.const 112
                    i32.add
                    local.get 4
                    i32.const 128
                    i32.add
                    call $<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::call
                    local.get 4
                    i64.load offset=88
                    i64.const 1
                    i64.ne
                    br_if 2 (;@6;)
                    local.get 0
                    i64.const 1
                    i64.store
                    local.get 0
                    local.get 3
                    i64.load offset=8
                    i64.store offset=16
                    local.get 0
                    local.get 3
                    i64.load
                    i64.store offset=8
                  end
                  local.get 4
                  i32.const 72
                  i32.add
                  call $"#func639 core::ptr::drop_glue::<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>"
                end
                local.get 4
                i32.const 24
                i32.add
                call $"#func639 core::ptr::drop_glue::<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>"
                local.get 2
                local.get 2
                i32.load
                i32.const -1
                i32.add
                local.tee 1
                i32.store
                local.get 1
                i32.eqz
                br_if 1 (;@5;)
                br 2 (;@4;)
              end
              local.get 4
              local.get 4
              i64.load offset=72
              local.tee 7
              i64.store offset=40
              local.get 4
              local.get 4
              i64.load offset=80
              local.tee 9
              i64.store offset=48
              local.get 4
              local.get 3
              i64.load offset=8
              local.tee 10
              i64.store offset=64
              local.get 4
              local.get 3
              i64.load
              local.tee 11
              i64.store offset=56
              local.get 4
              i32.const 0
              i32.store8 offset=128
              local.get 4
              i64.const 8589934592
              i64.store offset=248
              local.get 4
              local.get 7
              i64.store offset=256
              local.get 4
              local.get 9
              i64.store offset=264
              local.get 4
              local.get 11
              i64.store offset=272
              local.get 4
              local.get 10
              i64.store offset=280
              local.get 4
              local.get 4
              i32.const 128
              i32.add
              i32.store offset=288
              local.get 4
              local.get 4
              i32.const 248
              i32.add
              call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::array::iter::IntoIter<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, 2>, core::result::Result<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>>::to_rc_slice"
              local.get 4
              local.get 4
              i32.load offset=4
              local.tee 3
              i32.store offset=228
              local.get 4
              local.get 4
              i32.load
              local.tee 1
              i32.store offset=224
              block ;; label = @6
                local.get 4
                i32.load8_u offset=128
                i32.const 1
                i32.ne
                br_if 0 (;@6;)
                local.get 1
                local.get 1
                i32.load
                i32.const -1
                i32.add
                local.tee 2
                i32.store
                local.get 2
                br_if 3 (;@3;)
                local.get 4
                i32.const 224
                i32.add
                call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
                br 3 (;@3;)
              end
              local.get 1
              i32.eqz
              br_if 2 (;@3;)
              local.get 0
              local.get 3
              i32.store offset=16
              local.get 0
              local.get 1
              i32.store offset=12
              local.get 0
              i32.const 6
              i32.store8 offset=8
              local.get 0
              i64.const 0
              i64.store
              local.get 4
              i32.const 24
              i32.add
              call $"#func639 core::ptr::drop_glue::<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>"
              local.get 2
              local.get 2
              i32.load
              i32.const -1
              i32.add
              local.tee 1
              i32.store
              local.get 1
              br_if 1 (;@4;)
            end
            local.get 4
            i32.const 16
            i32.add
            call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
          end
          local.get 4
          i32.const 304
          i32.add
          global.set $__stack_pointer
          return
        end
        i32.const 1057428
        i32.const 43
        local.get 4
        i32.const 303
        i32.add
        i32.const 1057412
        i32.const 1057472
        call $core::result::unwrap_failed
        unreachable
      end
      i32.const 1057428
      i32.const 43
      local.get 4
      i32.const 303
      i32.add
      i32.const 1057412
      i32.const 1057472
      call $core::result::unwrap_failed
      unreachable
    end
    unreachable
  )

Emergent Testing

Idle. Press Run to start the suite.

  • ./proof.f.mjs