Number Conversion

Status: implemented

export default (...a) => [Number(a[0]), Number("0x10"), Number(1n)];

Number(exp) converts its operand to a number, exactly as JavaScript's Number does when called. A number is itself. A string is read as a numeric literal, the whitespace around it ignored: Number("0x10") is 16, Number(" 4 ") is 4, Number("") is 0, and Number("x") is NaN. null is 0, undefined is NaN, and a boolean is 1 or 0. A bigint is the nearest number — Number(1n) is 1, and Number(2n ** 64n) is 18446744073709552000, rounded as JavaScript rounds it. An array and an object are made primitive as the operators make them: an array by joining its elements, so Number([7]) is 7 and Number([1, 2]) is NaN; an object through its own valueOf or toString, called as JavaScript calls them, and "[object Object]" otherwise, so Number({}) is NaN. A function converts to its text, which is no number. Where a valueOf or a toString throws, so does the conversion (failure is one outcome).

It is the language's conversion to a number: unary + is not FunctionalScript syntax, and where the EDAG has it the two differ, + throwing on a bigint (operators). It is the EDAG's own ['Number', exp], which graph outputs preserve and every executor answers; the front end folds nothing, Number("1") reaching the graph as a node, as ~1 does. The conversion is a value like any other: an operand, -Number("1") and Number(a) * 2; a base, Number(a).x; and a callee, however little calling a number is worth. The FunctionalScript writer spells it back as it is written, the operand an argument, Number(1+2).

Number is a reserved word, one of the names global names reserves, with Array, Object (built-in static functions) and String (string conversion) — fjs/js/keywords' reservedGlobals, a list beside the keywords rather than among them, since JavaScript has no such keyword. A module cannot bind it, as a const, a parameter or an import's local name (shared values), and it is no value: it stands as the callee of a call and as the namespace of the four predicates the language admits, Number.isInteger, Number.isSafeInteger, Number.isNaN and Number.isFinite, and the numeric constant Number.MAX_SAFE_INTEGER, read unguarded (built-in static functions), and is a compilation error (reserved word) anywhere else — bare, const f = Number;, or as the namespace of any other member, Number.parseFloat(x), each an admission of its own (built-ins). The constant is desugared to its value (static members). A key or a property name is not a reference, so { Number: 1 } and o.Number mean what they mean in JavaScript. Number() is 0, as in JavaScript, and reaches the graph as the literal, folded as -1 is. The conversion is an operator, not a function (operators and functions), so Number() and Number(x) are all the call shapes it has: every other is refused by design (Number takes one argument), Number(a, b) and Number(...a) among them. So is the guarded call Number?.(x), refused at the word (reserved word): a guard asks whether a value is nullish, and an operator is no value, so the expression asks nothing — JavaScript, whose Number is never nullish, reads it as Number(x).

The word is reserved for the guarantee undefined, NaN and Infinity already have (numbers): a global word means one thing wherever it stands. Number(x) is the conversion in every module, so a reader, an agent or a tool reads it without resolving a scope, where a JavaScript module that binds the word — const Number = x => x;, the shadowing JavaScript's linters flag — makes every Number(…) after it something else. And it keeps the language free to grow: a member of the namespace admitted later, Number.parseFloat say (built-ins), cannot change what an existing module means, since no module could have bound the word (global names). The one JavaScript spelling it costs, a module rebinding a standard global, is refused at compile time rather than read another way.

It is also the one key computed at run time, a[Number(i)] (property access).

Examples

The compiler demo offers the programs number in module.f.js, each with its real output.

The demo on this page runs sample.f.js, this page's example as a function of one number — Number(exp) of a string, a hexadecimal string, a bigint and the empty string — 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 7 and 0.5, as JavaScript and as WebAssembly, and shows what each call returned or threw.

export default (...a) => [Number(String(a[0])), Number("0x10"), Number(1n), Number("") + a[0]];

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 7, then 0.5, 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) (Number Conversion) as a
 * function of one number, for the page's WASM demo: `Number(exp)` of a
 * string, a hexadecimal string, a `bigint` and the empty string.
 *
 * @module
 */

/** @type {(...a: readonly number[]) => unknown} */
export default (...a) => [Number(String(a[0])), Number("0x10"), Number(1n), Number("") + a[0]];

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

=>lengthbody0[][]0123NumberoperandNumberoperand"0x10"Numberoperand1n+leftrightStringoperandNumberoperand"".objidxrest0.objidxrest0

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

const $0=["rest"];export default ["{}",[[":","default",["=>",0,[],["[]",[["Number",["String",[".",$0,0]]],["Number","0x10"],["Number",1n],["+",["Number",""],[".",$0,0]]]]]]]];

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::{bigint_any, 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>> {
    Ok([(string_key("default"), A::static_function(|_self, _args| {
        let _b468: Any<A> = _args.rest(0).to_any();
        Ok([(Any::number(((Any::dot(_b468.clone(), f64_any(0x0000000000000000)).end())?.to_string().map(|v| v.to_any()))?))?, (Any::number(string_any("0x10")))?, (Any::number(bigint_any(1)))?, ((Any::number(string_any("")))? + (Any::dot(_b468.clone(), f64_any(0x0000000000000000)).end())?)?].to_array().to_any())
    }, 0, Array::default(), Some("(...$0)=>[Number(String($0[0])),Number(\"0x10\"),Number(1n),Number(\"\")+$0[0]]")).to_any())].to_object().to_any())
}

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

  (func $nanvm_demos::samples::number_conversion::module::<nanvm_lib::naive::Naive> (;200;) (type 1) (param i32 i32)
    (local i32 i32 i32 i32 i32)
    global.get $__stack_pointer
    i32.const 96
    i32.sub
    local.tee 2
    global.set $__stack_pointer
    local.get 2
    i32.const 0
    i32.store16 offset=28
    local.get 2
    i32.const 1056027
    i32.store offset=24
    local.get 2
    i32.const 1056020
    i32.store offset=20
    local.get 2
    i32.const 48
    i32.add
    local.get 2
    i32.const 20
    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 = @1
      block ;; label = @2
        block ;; label = @3
          local.get 2
          i32.load8_u offset=48
          local.tee 3
          i32.const 255
          i32.ne
          br_if 0 (;@3;)
          local.get 2
          i32.load offset=56
          local.set 4
          local.get 2
          i32.load offset=52
          local.set 5
          local.get 2
          i32.const 0
          i32.store8 offset=32
          local.get 2
          i32.const 8
          i32.add
          local.get 2
          i32.const 32
          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=12
          local.tee 6
          i32.store offset=52
          local.get 2
          local.get 2
          i32.load offset=8
          local.tee 3
          i32.store offset=48
          block ;; label = @4
            local.get 2
            i32.load8_u offset=32
            i32.const 1
            i32.ne
            br_if 0 (;@4;)
            local.get 3
            local.get 3
            i32.load
            i32.const -1
            i32.add
            local.tee 0
            i32.store
            local.get 0
            br_if 3 (;@1;)
            local.get 2
            i32.const 48
            i32.add
            call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
            br 3 (;@1;)
          end
          local.get 3
          i32.eqz
          br_if 2 (;@1;)
          i32.const 27
          i32.const 0
          local.get 3
          local.get 6
          i32.const 1056027
          i32.const 75
          call $"<nanvm_lib::naive::Naive as nanvm_lib::vm::internal::IVm>::static_function"
          local.set 3
          local.get 2
          i32.const 0
          i32.store8 offset=20
          local.get 2
          local.get 3
          i32.store offset=68
          local.get 2
          i32.const 7
          i32.store8 offset=64
          local.get 2
          local.get 4
          i32.store offset=60
          local.get 2
          local.get 5
          i32.store offset=56
          local.get 2
          i64.const 4294967296
          i64.store offset=48
          local.get 2
          local.get 2
          i32.const 20
          i32.add
          i32.store offset=80
          local.get 2
          local.get 2
          i32.const 48
          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=4
          local.tee 4
          i32.store offset=36
          local.get 2
          local.get 2
          i32.load
          local.tee 3
          i32.store offset=32
          block ;; label = @4
            local.get 2
            i32.load8_u offset=20
            i32.const 1
            i32.ne
            br_if 0 (;@4;)
            local.get 3
            local.get 3
            i32.load
            i32.const -1
            i32.add
            local.tee 0
            i32.store
            local.get 0
            br_if 2 (;@2;)
            local.get 2
            i32.const 32
            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 2 (;@2;)
          end
          local.get 3
          i32.eqz
          br_if 1 (;@2;)
          local.get 0
          local.get 4
          i32.store offset=16
          local.get 0
          local.get 3
          i32.store offset=12
          local.get 0
          i32.const 5
          i32.store8 offset=8
          local.get 0
          i64.const 0
          i64.store
          local.get 1
          call $"#func195 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
          local.get 2
          i32.const 96
          i32.add
          global.set $__stack_pointer
          return
        end
        local.get 2
        local.get 2
        i32.load8_u offset=51
        i32.store8 offset=35
        local.get 2
        local.get 2
        i32.load16_u offset=49 align=1
        i32.store16 offset=33 align=1
        local.get 2
        local.get 2
        i32.load offset=60
        i32.store offset=44
        local.get 2
        local.get 2
        i64.load offset=52 align=4
        i64.store offset=36 align=4
        local.get 2
        local.get 3
        i32.store8 offset=32
        i32.const 1057960
        i32.const 43
        local.get 2
        i32.const 32
        i32.add
        i32.const 1057944
        i32.const 1058004
        call $core::result::unwrap_failed
        unreachable
      end
      i32.const 1064316
      i32.const 43
      local.get 2
      i32.const 95
      i32.add
      i32.const 1064300
      i32.const 1064360
      call $core::result::unwrap_failed
      unreachable
    end
    i32.const 1064316
    i32.const 43
    local.get 2
    i32.const 95
    i32.add
    i32.const 1064300
    i32.const 1064360
    call $core::result::unwrap_failed
    unreachable
  )
  (func $"<nanvm_demos::samples::number_conversion::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" (;201;) (type 4) (param i32 i32 i32 i32)
    (local i32 i32 i64 i32)
    global.get $__stack_pointer
    i32.const 448
    i32.sub
    local.tee 4
    global.set $__stack_pointer
    local.get 4
    local.get 3
    i32.store offset=28
    local.get 4
    local.get 2
    i32.store offset=24
    block ;; label = @1
      block ;; label = @2
        block ;; label = @3
          block ;; label = @4
            block ;; label = @5
              block ;; label = @6
                block ;; label = @7
                  local.get 2
                  i32.load
                  local.tee 5
                  i32.const -1
                  i32.eq
                  br_if 0 (;@7;)
                  local.get 4
                  local.get 3
                  i32.store offset=40
                  local.get 4
                  local.get 2
                  i32.store offset=36
                  local.get 4
                  i32.const 6
                  i32.store8 offset=32
                  local.get 2
                  local.get 5
                  i32.const 2
                  i32.add
                  local.tee 5
                  i32.store
                  local.get 5
                  i32.eqz
                  br_if 0 (;@7;)
                  local.get 4
                  local.get 2
                  i32.store offset=380
                  local.get 4
                  i32.const 6
                  i32.store8 offset=376
                  local.get 4
                  local.get 3
                  i64.extend_i32_u
                  i64.store offset=384
                  local.get 4
                  i64.const 0
                  i64.store offset=416
                  local.get 4
                  i32.const 2
                  i32.store8 offset=408
                  local.get 4
                  i32.const 328
                  i32.add
                  local.get 4
                  i32.const 376
                  i32.add
                  local.get 4
                  i32.const 408
                  i32.add
                  call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::new
                  block ;; label = @8
                    local.get 4
                    i32.load8_u offset=328
                    i32.const 255
                    i32.ne
                    br_if 0 (;@8;)
                    local.get 0
                    local.get 4
                    i64.load offset=344
                    i64.store offset=16
                    local.get 0
                    local.get 4
                    i64.load offset=336
                    i64.store offset=8
                    local.get 0
                    i64.const 1
                    i64.store
                    br 5 (;@3;)
                  end
                  local.get 4
                  local.get 4
                  i64.load offset=352
                  i64.store offset=432
                  local.get 4
                  local.get 4
                  i64.load offset=344
                  i64.store offset=424
                  local.get 4
                  local.get 4
                  i64.load offset=336
                  i64.store offset=416
                  local.get 4
                  local.get 4
                  i64.load offset=328
                  i64.store offset=408
                  local.get 4
                  i32.const 376
                  i32.add
                  local.get 4
                  i32.const 408
                  i32.add
                  call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::own
                  block ;; label = @8
                    block ;; label = @9
                      local.get 4
                      i32.load8_u offset=376
                      i32.const 255
                      i32.eq
                      br_if 0 (;@9;)
                      local.get 4
                      local.get 4
                      i64.load offset=384
                      i64.store offset=368
                      local.get 4
                      local.get 4
                      i64.load offset=376
                      i64.store offset=360
                      br 1 (;@8;)
                    end
                    local.get 4
                    i32.const 256
                    i32.store16 offset=360
                  end
                  local.get 4
                  i32.const 408
                  i32.add
                  call $"#func693 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                  local.get 4
                  i32.const 424
                  i32.add
                  call $"#func693 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                  local.get 4
                  i32.const 312
                  i32.add
                  local.get 4
                  i32.const 360
                  i32.add
                  call $<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>::dispatch::<nanvm_lib::vm::primitive_dispatch::ViaPrimitive<nanvm_lib::vm::string_coercion::StringCoercion>>
                  block ;; label = @8
                    local.get 4
                    i32.load8_u offset=312
                    local.tee 3
                    i32.const 255
                    i32.eq
                    br_if 0 (;@8;)
                    local.get 0
                    local.get 4
                    i32.load8_u offset=315
                    i32.store8 offset=11
                    local.get 0
                    local.get 4
                    i32.load16_u offset=313 align=1
                    i32.store16 offset=9 align=1
                    local.get 4
                    i64.load offset=316 align=4
                    local.set 6
                    local.get 0
                    local.get 4
                    i32.load offset=324
                    i32.store offset=20
                    local.get 0
                    local.get 6
                    i64.store offset=12 align=4
                    local.get 0
                    local.get 3
                    i32.store8 offset=8
                    local.get 0
                    i64.const 1
                    i64.store
                    br 5 (;@3;)
                  end
                  local.get 4
                  i32.const 128
                  i32.add
                  i32.const 8
                  i32.add
                  local.set 3
                  local.get 4
                  local.get 4
                  i64.load offset=316 align=4
                  i64.store offset=156 align=4
                  local.get 4
                  i32.const 3
                  i32.store8 offset=152
                  local.get 4
                  i32.const 128
                  i32.add
                  local.get 4
                  i32.const 152
                  i32.add
                  call $<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::number
                  block ;; label = @8
                    local.get 4
                    i64.load offset=128
                    i64.const 1
                    i64.ne
                    br_if 0 (;@8;)
                    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
                    br 5 (;@3;)
                  end
                  local.get 4
                  local.get 3
                  i64.load offset=8
                  i64.store offset=120
                  local.get 4
                  local.get 3
                  i64.load
                  i64.store offset=112
                  local.get 4
                  i32.const 0
                  i32.store16 offset=320
                  local.get 4
                  i32.const 1056284
                  i32.store offset=316
                  local.get 4
                  i32.const 1056280
                  i32.store offset=312
                  local.get 4
                  i32.const 408
                  i32.add
                  local.get 4
                  i32.const 312
                  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]>>"
                  local.get 4
                  i32.load8_u offset=408
                  local.tee 3
                  i32.const 255
                  i32.ne
                  br_if 1 (;@6;)
                  local.get 4
                  i32.const 184
                  i32.add
                  i32.const 8
                  i32.add
                  local.set 3
                  local.get 4
                  local.get 4
                  i64.load offset=412 align=4
                  i64.store offset=380 align=4
                  local.get 4
                  i32.const 3
                  i32.store8 offset=376
                  local.get 4
                  i32.const 184
                  i32.add
                  local.get 4
                  i32.const 376
                  i32.add
                  call $<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::number
                  block ;; label = @8
                    block ;; label = @9
                      block ;; label = @10
                        local.get 4
                        i64.load offset=184
                        i64.const 1
                        i64.ne
                        br_if 0 (;@10;)
                        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
                        br 1 (;@9;)
                      end
                      local.get 4
                      local.get 3
                      i64.load offset=8
                      i64.store offset=176
                      local.get 4
                      local.get 3
                      i64.load
                      i64.store offset=168
                      local.get 4
                      i32.const 0
                      i32.store8 offset=312
                      local.get 4
                      i64.const 1
                      i64.store offset=416
                      local.get 4
                      i64.const 1
                      i64.store offset=408
                      local.get 4
                      local.get 4
                      i32.const 312
                      i32.add
                      i32.store offset=424
                      local.get 4
                      i32.const 16
                      i32.add
                      local.get 4
                      i32.const 408
                      i32.add
                      call $"<core::iter::adapters::GenericShunt<core::iter::adapters::map::Map<core::iter::sources::once::Once<u64>, core::result::Result<u64, ()>::Ok>, core::result::Result<core::convert::Infallible, ()>> as alloc::rc::ToRcSlice<u64>>::to_rc_slice"
                      local.get 4
                      local.get 4
                      i32.load offset=20
                      local.tee 7
                      i32.store offset=380
                      local.get 4
                      local.get 4
                      i32.load offset=16
                      local.tee 3
                      i32.store offset=376
                      block ;; label = @10
                        local.get 4
                        i32.load8_u offset=312
                        i32.const 1
                        i32.ne
                        br_if 0 (;@10;)
                        local.get 3
                        local.get 3
                        i32.load
                        i32.const -1
                        i32.add
                        local.tee 2
                        i32.store
                        local.get 2
                        br_if 6 (;@4;)
                        local.get 4
                        i32.const 376
                        i32.add
                        call $"<alloc::rc::Rc<[u64]>>::drop_slow"
                        br 6 (;@4;)
                      end
                      local.get 3
                      i32.eqz
                      br_if 5 (;@4;)
                      local.get 4
                      i32.const 224
                      i32.add
                      i32.const 8
                      i32.add
                      local.set 5
                      local.get 4
                      i32.const 1
                      i32.store8 offset=420
                      local.get 4
                      local.get 7
                      i32.store offset=416
                      local.get 4
                      local.get 3
                      i32.store offset=412
                      local.get 4
                      i32.const 4
                      i32.store8 offset=408
                      local.get 4
                      i32.const 224
                      i32.add
                      local.get 4
                      i32.const 408
                      i32.add
                      call $<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::number
                      block ;; label = @10
                        block ;; label = @11
                          local.get 4
                          i64.load offset=224
                          i64.const 1
                          i64.ne
                          br_if 0 (;@11;)
                          local.get 0
                          i64.const 1
                          i64.store
                          local.get 0
                          local.get 5
                          i64.load offset=8
                          i64.store offset=16
                          local.get 0
                          local.get 5
                          i64.load
                          i64.store offset=8
                          br 1 (;@10;)
                        end
                        local.get 4
                        local.get 5
                        i64.load offset=8
                        i64.store offset=216
                        local.get 4
                        local.get 5
                        i64.load
                        i64.store offset=208
                        local.get 4
                        i32.const 0
                        i32.store16 offset=320
                        local.get 4
                        i64.const 4294967297
                        i64.store offset=312 align=4
                        local.get 4
                        i32.const 408
                        i32.add
                        local.get 4
                        i32.const 312
                        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]>>"
                        local.get 4
                        i32.load8_u offset=408
                        local.tee 3
                        i32.const 255
                        i32.ne
                        br_if 5 (;@5;)
                        local.get 4
                        i32.const 288
                        i32.add
                        i32.const 8
                        i32.add
                        local.set 3
                        local.get 4
                        local.get 4
                        i64.load offset=412 align=4
                        i64.store offset=380 align=4
                        local.get 4
                        i32.const 3
                        i32.store8 offset=376
                        local.get 4
                        i32.const 288
                        i32.add
                        local.get 4
                        i32.const 376
                        i32.add
                        call $<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::number
                        block ;; label = @11
                          block ;; label = @12
                            local.get 4
                            i64.load offset=288
                            i64.const 1
                            i64.ne
                            br_if 0 (;@12;)
                            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
                            br 1 (;@11;)
                          end
                          local.get 4
                          local.get 3
                          i64.load offset=8
                          i64.store offset=280
                          local.get 4
                          local.get 3
                          i64.load
                          i64.store offset=272
                          local.get 4
                          i32.const 312
                          i32.add
                          local.get 4
                          i32.const 32
                          i32.add
                          call $"#func212 <nanvm_lib::naive::Naive as core::clone::Clone>::clone"
                          local.get 4
                          i64.const 0
                          i64.store offset=416
                          local.get 4
                          i32.const 2
                          i32.store8 offset=408
                          local.get 4
                          i32.const 376
                          i32.add
                          local.get 4
                          i32.const 312
                          i32.add
                          local.get 4
                          i32.const 408
                          i32.add
                          call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::new
                          block ;; label = @12
                            local.get 4
                            i32.load8_u offset=376
                            i32.const 255
                            i32.ne
                            br_if 0 (;@12;)
                            local.get 0
                            local.get 4
                            i64.load offset=392
                            i64.store offset=16
                            local.get 0
                            local.get 4
                            i64.load offset=384
                            i64.store offset=8
                            local.get 0
                            i64.const 1
                            i64.store
                            local.get 4
                            i32.const 272
                            i32.add
                            call $"#func195 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                            br 1 (;@11;)
                          end
                          local.get 4
                          i32.const 248
                          i32.add
                          i32.const 8
                          i32.add
                          local.set 3
                          local.get 4
                          local.get 4
                          i64.load offset=400
                          i64.store offset=432
                          local.get 4
                          local.get 4
                          i64.load offset=392
                          i64.store offset=424
                          local.get 4
                          local.get 4
                          i64.load offset=384
                          i64.store offset=416
                          local.get 4
                          local.get 4
                          i64.load offset=376
                          i64.store offset=408
                          local.get 4
                          i32.const 312
                          i32.add
                          local.get 4
                          i32.const 408
                          i32.add
                          call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::read
                          local.get 4
                          i32.const 248
                          i32.add
                          local.get 4
                          i32.const 272
                          i32.add
                          local.get 4
                          i32.const 312
                          i32.add
                          call $"<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive> as core::ops::arith::Add>::add"
                          local.get 4
                          i64.load offset=248
                          i64.const 1
                          i64.ne
                          br_if 3 (;@8;)
                          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 208
                        i32.add
                        call $"#func195 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                      end
                      local.get 4
                      i32.const 168
                      i32.add
                      call $"#func195 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                    end
                    local.get 4
                    i32.const 112
                    i32.add
                    call $"#func195 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                    br 5 (;@3;)
                  end
                  local.get 4
                  local.get 4
                  i64.load offset=112
                  i64.store offset=48
                  local.get 4
                  local.get 4
                  i64.load offset=120
                  i64.store offset=56
                  local.get 4
                  local.get 4
                  i64.load offset=168
                  i64.store offset=64
                  local.get 4
                  local.get 4
                  i64.load offset=176
                  i64.store offset=72
                  local.get 4
                  local.get 4
                  i64.load offset=208
                  i64.store offset=80
                  local.get 4
                  local.get 4
                  i64.load offset=216
                  i64.store offset=88
                  local.get 4
                  local.get 3
                  i64.load offset=8
                  i64.store offset=104
                  local.get 4
                  local.get 3
                  i64.load
                  i64.store offset=96
                  local.get 4
                  i32.const 8
                  i32.add
                  local.get 4
                  i32.const 48
                  i32.add
                  call $"<nanvm_lib::naive::container::Container<(), nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>> as nanvm_lib::vm::internal::icontainer::IContainer<nanvm_lib::naive::Naive>>::new_ok::<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>; 4]>"
                  local.get 0
                  local.get 4
                  i64.load offset=8
                  i64.store offset=12 align=4
                  local.get 0
                  i32.const 6
                  i32.store8 offset=8
                  local.get 0
                  i64.const 0
                  i64.store
                  local.get 4
                  i32.const 32
                  i32.add
                  call $"#func195 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                  local.get 2
                  local.get 2
                  i32.load
                  i32.const -1
                  i32.add
                  local.tee 0
                  i32.store
                  local.get 0
                  br_if 6 (;@1;)
                  br 5 (;@2;)
                end
                unreachable
              end
              local.get 4
              local.get 4
              i32.load8_u offset=411
              i32.store8 offset=379
              local.get 4
              local.get 4
              i32.load16_u offset=409 align=1
              i32.store16 offset=377 align=1
              local.get 4
              local.get 4
              i32.load offset=420
              i32.store offset=388
              local.get 4
              local.get 4
              i64.load offset=412 align=4
              i64.store offset=380 align=4
              local.get 4
              local.get 3
              i32.store8 offset=376
              i32.const 1057960
              i32.const 43
              local.get 4
              i32.const 376
              i32.add
              i32.const 1057944
              i32.const 1058004
              call $core::result::unwrap_failed
              unreachable
            end
            local.get 4
            local.get 4
            i32.load8_u offset=411
            i32.store8 offset=379
            local.get 4
            local.get 4
            i32.load16_u offset=409 align=1
            i32.store16 offset=377 align=1
            local.get 4
            local.get 4
            i32.load offset=420
            i32.store offset=388
            local.get 4
            local.get 4
            i64.load offset=412 align=4
            i64.store offset=380 align=4
            local.get 4
            local.get 3
            i32.store8 offset=376
            i32.const 1057960
            i32.const 43
            local.get 4
            i32.const 376
            i32.add
            i32.const 1057944
            i32.const 1058004
            call $core::result::unwrap_failed
            unreachable
          end
          i32.const 1064316
          i32.const 43
          local.get 4
          i32.const 447
          i32.add
          i32.const 1064300
          i32.const 1064360
          call $core::result::unwrap_failed
          unreachable
        end
        local.get 4
        i32.const 32
        i32.add
        call $"#func195 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
        local.get 2
        local.get 2
        i32.load
        i32.const -1
        i32.add
        local.tee 0
        i32.store
        local.get 0
        br_if 1 (;@1;)
      end
      local.get 4
      i32.const 24
      i32.add
      call $"<alloc::rc::Rc<[nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>]>>::drop_slow"
    end
    local.get 4
    i32.const 448
    i32.add
    global.set $__stack_pointer
  )

Emergent Testing

Idle. Press Run to start the suite.

  • ./proof.f.mjs