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, 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.MAX_SAFE_INTEGER or Number.parseFloat(x), each an admission of its own (built-ins). 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> (;208;) (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 1056411
    i32.store offset=24
    local.get 2
    i32.const 1056404
    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 32
          i32.const 0
          local.get 3
          local.get 6
          i32.const 1056467
          i32.const 75
          call $<nanvm_lib::naive::function::Function>::new
          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 $"#func201 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 1065572
        i32.const 43
        local.get 2
        i32.const 32
        i32.add
        i32.const 1065556
        i32.const 1065616
        call $core::result::unwrap_failed
        unreachable
      end
      i32.const 1057428
      i32.const 43
      local.get 2
      i32.const 95
      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 95
    i32.add
    i32.const 1057412
    i32.const 1057472
    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" (;209;) (type 4) (param i32 i32 i32 i32)
    (local i32 i32 i64 f64)
    global.get $__stack_pointer
    i32.const 352
    i32.sub
    local.tee 4
    global.set $__stack_pointer
    local.get 4
    local.get 3
    i32.store offset=20
    local.get 4
    local.get 2
    i32.store offset=16
    block ;; label = @1
      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
                        local.get 2
                        i32.load
                        local.tee 5
                        i32.const -1
                        i32.eq
                        br_if 0 (;@10;)
                        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
                        local.get 2
                        local.get 5
                        i32.const 2
                        i32.add
                        local.tee 5
                        i32.store
                        local.get 5
                        i32.eqz
                        br_if 0 (;@10;)
                        local.get 4
                        local.get 2
                        i32.store offset=276
                        local.get 4
                        i32.const 6
                        i32.store8 offset=272
                        local.get 4
                        local.get 3
                        i64.extend_i32_u
                        i64.store offset=280
                        local.get 4
                        i64.const 0
                        i64.store offset=312
                        local.get 4
                        i32.const 2
                        i32.store8 offset=304
                        local.get 4
                        i32.const 224
                        i32.add
                        local.get 4
                        i32.const 272
                        i32.add
                        local.get 4
                        i32.const 304
                        i32.add
                        call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::new
                        block ;; label = @11
                          local.get 4
                          i32.load8_u offset=224
                          i32.const 255
                          i32.ne
                          br_if 0 (;@11;)
                          local.get 0
                          local.get 4
                          i64.load offset=240
                          i64.store offset=16
                          local.get 0
                          local.get 4
                          i64.load offset=232
                          i64.store offset=8
                          local.get 0
                          i64.const 1
                          i64.store
                          br 7 (;@4;)
                        end
                        local.get 4
                        local.get 4
                        i64.load offset=248
                        i64.store offset=328
                        local.get 4
                        local.get 4
                        i64.load offset=240
                        i64.store offset=320
                        local.get 4
                        local.get 4
                        i64.load offset=232
                        i64.store offset=312
                        local.get 4
                        local.get 4
                        i64.load offset=224
                        i64.store offset=304
                        local.get 4
                        i32.const 272
                        i32.add
                        local.get 4
                        i32.const 304
                        i32.add
                        call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::own
                        block ;; label = @11
                          block ;; label = @12
                            local.get 4
                            i32.load8_u offset=272
                            i32.const 255
                            i32.eq
                            br_if 0 (;@12;)
                            local.get 4
                            local.get 4
                            i64.load offset=280
                            i64.store offset=264
                            local.get 4
                            local.get 4
                            i64.load offset=272
                            i64.store offset=256
                            br 1 (;@11;)
                          end
                          local.get 4
                          i32.const 256
                          i32.store16 offset=256
                        end
                        local.get 4
                        i32.const 304
                        i32.add
                        call $"#func562 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                        local.get 4
                        i32.const 320
                        i32.add
                        call $"#func562 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                        local.get 4
                        i32.const 208
                        i32.add
                        local.get 4
                        i32.const 256
                        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 = @11
                          local.get 4
                          i32.load8_u offset=208
                          local.tee 3
                          i32.const 255
                          i32.eq
                          br_if 0 (;@11;)
                          local.get 0
                          local.get 4
                          i32.load8_u offset=211
                          i32.store8 offset=11
                          local.get 0
                          local.get 4
                          i32.load16_u offset=209 align=1
                          i32.store16 offset=9 align=1
                          local.get 4
                          i64.load offset=212 align=4
                          local.set 6
                          local.get 0
                          local.get 4
                          i32.load offset=220
                          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 7 (;@4;)
                        end
                        local.get 4
                        local.get 4
                        i64.load offset=212 align=4
                        i64.store offset=124 align=4
                        local.get 4
                        i32.const 3
                        i32.store8 offset=120
                        local.get 4
                        i32.const 304
                        i32.add
                        local.get 4
                        i32.const 120
                        i32.add
                        call $<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::to_numeric
                        local.get 4
                        f64.load offset=320
                        local.set 7
                        local.get 4
                        i32.load offset=316
                        local.set 3
                        local.get 4
                        i32.load offset=312
                        local.set 5
                        local.get 4
                        i32.load offset=304
                        br_if 1 (;@9;)
                        block ;; label = @11
                          local.get 5
                          i32.const 1
                          i32.ne
                          br_if 0 (;@11;)
                          local.get 4
                          local.get 7
                          f64.store offset=308 align=4
                          local.get 4
                          local.get 3
                          i32.store offset=304
                          local.get 4
                          i32.const 304
                          i32.add
                          call $<nanvm_lib::vm::bigint::BigInt<nanvm_lib::naive::Naive>>::to_number
                          local.set 7
                          local.get 3
                          local.get 3
                          i32.load
                          i32.const -1
                          i32.add
                          local.tee 5
                          i32.store
                          local.get 5
                          br_if 0 (;@11;)
                          local.get 4
                          i32.const 304
                          i32.add
                          call $"<alloc::rc::Rc<[u64]>>::drop_slow"
                        end
                        local.get 4
                        local.get 7
                        f64.store offset=112
                        local.get 4
                        i32.const 2
                        i32.store offset=104
                        local.get 4
                        i32.const 0
                        i32.store16 offset=200
                        local.get 4
                        i32.const 1056908
                        i32.store offset=196
                        local.get 4
                        i32.const 1056904
                        i32.store offset=192
                        local.get 4
                        i32.const 304
                        i32.add
                        local.get 4
                        i32.const 192
                        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=304
                        local.tee 3
                        i32.const 255
                        i32.ne
                        br_if 2 (;@8;)
                        local.get 4
                        local.get 4
                        i64.load offset=308 align=4
                        i64.store offset=212 align=4
                        local.get 4
                        i32.const 3
                        i32.store8 offset=208
                        local.get 4
                        i32.const 304
                        i32.add
                        local.get 4
                        i32.const 208
                        i32.add
                        call $<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::to_numeric
                        local.get 4
                        f64.load offset=320
                        local.set 7
                        local.get 4
                        i32.load offset=316
                        local.set 3
                        local.get 4
                        i32.load offset=312
                        local.set 5
                        local.get 4
                        i32.load offset=304
                        br_if 3 (;@7;)
                        block ;; label = @11
                          local.get 5
                          i32.const 1
                          i32.ne
                          br_if 0 (;@11;)
                          local.get 4
                          local.get 7
                          f64.store offset=308 align=4
                          local.get 4
                          local.get 3
                          i32.store offset=304
                          local.get 4
                          i32.const 304
                          i32.add
                          call $<nanvm_lib::vm::bigint::BigInt<nanvm_lib::naive::Naive>>::to_number
                          local.set 7
                          local.get 3
                          local.get 3
                          i32.load
                          i32.const -1
                          i32.add
                          local.tee 5
                          i32.store
                          local.get 5
                          br_if 0 (;@11;)
                          local.get 4
                          i32.const 304
                          i32.add
                          call $"<alloc::rc::Rc<[u64]>>::drop_slow"
                        end
                        local.get 4
                        local.get 7
                        f64.store offset=144
                        local.get 4
                        i32.const 2
                        i32.store offset=136
                        local.get 4
                        i32.const 0
                        i32.store8 offset=192
                        local.get 4
                        i64.const 1
                        i64.store offset=312
                        local.get 4
                        i64.const 1
                        i64.store offset=304
                        local.get 4
                        local.get 4
                        i32.const 192
                        i32.add
                        i32.store offset=320
                        local.get 4
                        i32.const 8
                        i32.add
                        local.get 4
                        i32.const 304
                        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=12
                        local.tee 5
                        i32.store offset=212
                        local.get 4
                        local.get 4
                        i32.load offset=8
                        local.tee 3
                        i32.store offset=208
                        block ;; label = @11
                          local.get 4
                          i32.load8_u offset=192
                          i32.const 1
                          i32.ne
                          br_if 0 (;@11;)
                          local.get 3
                          local.get 3
                          i32.load
                          i32.const -1
                          i32.add
                          local.tee 2
                          i32.store
                          local.get 2
                          br_if 10 (;@1;)
                          local.get 4
                          i32.const 208
                          i32.add
                          call $"<alloc::rc::Rc<[u64]>>::drop_slow"
                          br 10 (;@1;)
                        end
                        local.get 3
                        i32.eqz
                        br_if 9 (;@1;)
                        local.get 4
                        i32.const 1
                        i32.store8 offset=284
                        local.get 4
                        local.get 5
                        i32.store offset=280
                        local.get 4
                        local.get 3
                        i32.store offset=276
                        local.get 4
                        i32.const 4
                        i32.store8 offset=272
                        local.get 4
                        i32.const 304
                        i32.add
                        local.get 4
                        i32.const 272
                        i32.add
                        call $<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::to_numeric
                        local.get 4
                        f64.load offset=320
                        local.set 7
                        local.get 4
                        i32.load offset=316
                        local.set 3
                        local.get 4
                        i32.load offset=312
                        local.set 5
                        local.get 4
                        i32.load offset=304
                        br_if 4 (;@6;)
                        block ;; label = @11
                          local.get 5
                          i32.const 1
                          i32.ne
                          br_if 0 (;@11;)
                          local.get 4
                          local.get 7
                          f64.store offset=308 align=4
                          local.get 4
                          local.get 3
                          i32.store offset=304
                          local.get 4
                          i32.const 304
                          i32.add
                          call $<nanvm_lib::vm::bigint::BigInt<nanvm_lib::naive::Naive>>::to_number
                          local.set 7
                          local.get 3
                          local.get 3
                          i32.load
                          i32.const -1
                          i32.add
                          local.tee 5
                          i32.store
                          local.get 5
                          br_if 0 (;@11;)
                          local.get 4
                          i32.const 304
                          i32.add
                          call $"<alloc::rc::Rc<[u64]>>::drop_slow"
                        end
                        local.get 4
                        local.get 7
                        f64.store offset=160
                        local.get 4
                        i32.const 2
                        i32.store offset=152
                        local.get 4
                        i32.const 0
                        i32.store16 offset=344
                        local.get 4
                        i64.const 4294967297
                        i64.store offset=336 align=4
                        local.get 4
                        i32.const 304
                        i32.add
                        local.get 4
                        i32.const 336
                        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=304
                        local.tee 3
                        i32.const 255
                        i32.ne
                        br_if 5 (;@5;)
                        local.get 4
                        local.get 4
                        i64.load offset=308 align=4
                        i64.store offset=212 align=4
                        local.get 4
                        i32.const 3
                        i32.store8 offset=208
                        local.get 4
                        i32.const 304
                        i32.add
                        local.get 4
                        i32.const 208
                        i32.add
                        call $<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive>>::to_numeric
                        local.get 4
                        f64.load offset=320
                        local.set 7
                        local.get 4
                        i32.load offset=316
                        local.set 3
                        local.get 4
                        i32.load offset=312
                        local.set 5
                        block ;; label = @11
                          block ;; label = @12
                            local.get 4
                            i32.load offset=304
                            br_if 0 (;@12;)
                            block ;; label = @13
                              local.get 5
                              i32.const 1
                              i32.ne
                              br_if 0 (;@13;)
                              local.get 4
                              local.get 7
                              f64.store offset=308 align=4
                              local.get 4
                              local.get 3
                              i32.store offset=304
                              local.get 4
                              i32.const 304
                              i32.add
                              call $<nanvm_lib::vm::bigint::BigInt<nanvm_lib::naive::Naive>>::to_number
                              local.set 7
                              local.get 3
                              local.get 3
                              i32.load
                              i32.const -1
                              i32.add
                              local.tee 5
                              i32.store
                              local.get 5
                              br_if 0 (;@13;)
                              local.get 4
                              i32.const 304
                              i32.add
                              call $"<alloc::rc::Rc<[u64]>>::drop_slow"
                            end
                            local.get 4
                            local.get 7
                            f64.store offset=200
                            local.get 4
                            i32.const 2
                            i32.store offset=192
                            local.get 4
                            i32.const 208
                            i32.add
                            local.get 4
                            i32.const 24
                            i32.add
                            call $"#func217 <nanvm_lib::naive::Naive as core::clone::Clone>::clone"
                            local.get 4
                            i64.const 0
                            i64.store offset=312
                            local.get 4
                            i32.const 2
                            i32.store8 offset=304
                            local.get 4
                            i32.const 272
                            i32.add
                            local.get 4
                            i32.const 208
                            i32.add
                            local.get 4
                            i32.const 304
                            i32.add
                            call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::new
                            block ;; label = @13
                              local.get 4
                              i32.load8_u offset=272
                              i32.const 255
                              i32.ne
                              br_if 0 (;@13;)
                              local.get 0
                              local.get 4
                              i64.load offset=288
                              i64.store offset=16
                              local.get 0
                              local.get 4
                              i64.load offset=280
                              i64.store offset=8
                              local.get 0
                              i64.const 1
                              i64.store
                              local.get 4
                              i32.const 192
                              i32.add
                              call $"#func201 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                              br 2 (;@11;)
                            end
                            local.get 4
                            i32.const 176
                            i32.add
                            local.set 3
                            local.get 4
                            local.get 4
                            i64.load offset=296
                            i64.store offset=328
                            local.get 4
                            local.get 4
                            i64.load offset=288
                            i64.store offset=320
                            local.get 4
                            local.get 4
                            i64.load offset=280
                            i64.store offset=312
                            local.get 4
                            local.get 4
                            i64.load offset=272
                            i64.store offset=304
                            local.get 4
                            i32.const 208
                            i32.add
                            local.get 4
                            i32.const 304
                            i32.add
                            call $<nanvm_lib::vm::lambda::member::Member<nanvm_lib::naive::Naive>>::read
                            local.get 4
                            i32.const 168
                            i32.add
                            local.get 4
                            i32.const 192
                            i32.add
                            local.get 4
                            i32.const 208
                            i32.add
                            call $"<nanvm_lib::vm::any::Any<nanvm_lib::naive::Naive> as core::ops::arith::Add>::add"
                            block ;; label = @13
                              local.get 4
                              i64.load offset=168
                              i64.const 1
                              i64.ne
                              br_if 0 (;@13;)
                              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 2 (;@11;)
                            end
                            local.get 4
                            local.get 4
                            i64.load offset=104
                            i64.store offset=40
                            local.get 4
                            local.get 4
                            i64.load offset=112
                            i64.store offset=48
                            local.get 4
                            local.get 4
                            i64.load offset=136
                            i64.store offset=56
                            local.get 4
                            local.get 4
                            i64.load offset=144
                            i64.store offset=64
                            local.get 4
                            local.get 4
                            i64.load offset=152
                            i64.store offset=72
                            local.get 4
                            local.get 4
                            i64.load offset=160
                            i64.store offset=80
                            local.get 4
                            local.get 3
                            i64.load offset=8
                            i64.store offset=96
                            local.get 4
                            local.get 3
                            i64.load
                            i64.store offset=88
                            local.get 4
                            local.get 4
                            i32.const 40
                            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
                            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 24
                            i32.add
                            call $"#func201 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 10 (;@2;)
                            br 9 (;@3;)
                          end
                          local.get 0
                          local.get 7
                          f64.store offset=16
                          local.get 0
                          local.get 3
                          i32.store offset=12
                          local.get 0
                          local.get 5
                          i32.store offset=8
                          local.get 0
                          i64.const 1
                          i64.store
                        end
                        local.get 4
                        i32.const 152
                        i32.add
                        call $"#func201 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                        local.get 4
                        i32.const 136
                        i32.add
                        call $"#func201 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                        local.get 4
                        i32.const 104
                        i32.add
                        call $"#func201 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                        br 6 (;@4;)
                      end
                      unreachable
                    end
                    local.get 0
                    local.get 7
                    f64.store offset=16
                    local.get 0
                    local.get 3
                    i32.store offset=12
                    local.get 0
                    local.get 5
                    i32.store offset=8
                    local.get 0
                    i64.const 1
                    i64.store
                    br 4 (;@4;)
                  end
                  local.get 4
                  local.get 4
                  i32.load8_u offset=307
                  i32.store8 offset=275
                  local.get 4
                  local.get 4
                  i32.load16_u offset=305 align=1
                  i32.store16 offset=273 align=1
                  local.get 4
                  local.get 4
                  i32.load offset=316
                  i32.store offset=284
                  local.get 4
                  local.get 4
                  i64.load offset=308 align=4
                  i64.store offset=276 align=4
                  local.get 4
                  local.get 3
                  i32.store8 offset=272
                  i32.const 1065572
                  i32.const 43
                  local.get 4
                  i32.const 272
                  i32.add
                  i32.const 1065556
                  i32.const 1065616
                  call $core::result::unwrap_failed
                  unreachable
                end
                local.get 0
                local.get 7
                f64.store offset=16
                local.get 0
                local.get 3
                i32.store offset=12
                local.get 0
                local.get 5
                i32.store offset=8
                local.get 0
                i64.const 1
                i64.store
                local.get 4
                i32.const 104
                i32.add
                call $"#func201 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
                br 2 (;@4;)
              end
              local.get 0
              local.get 7
              f64.store offset=16
              local.get 0
              local.get 3
              i32.store offset=12
              local.get 0
              local.get 5
              i32.store offset=8
              local.get 0
              i64.const 1
              i64.store
              local.get 4
              i32.const 136
              i32.add
              call $"#func201 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
              local.get 4
              i32.const 104
              i32.add
              call $"#func201 core::ptr::drop_glue::<nanvm_lib::vm::unpacked::Unpacked<nanvm_lib::naive::Naive>>"
              br 1 (;@4;)
            end
            local.get 4
            local.get 4
            i32.load8_u offset=307
            i32.store8 offset=275
            local.get 4
            local.get 4
            i32.load16_u offset=305 align=1
            i32.store16 offset=273 align=1
            local.get 4
            local.get 4
            i32.load offset=316
            i32.store offset=284
            local.get 4
            local.get 4
            i64.load offset=308 align=4
            i64.store offset=276 align=4
            local.get 4
            local.get 3
            i32.store8 offset=272
            i32.const 1065572
            i32.const 43
            local.get 4
            i32.const 272
            i32.add
            i32.const 1065556
            i32.const 1065616
            call $core::result::unwrap_failed
            unreachable
          end
          local.get 4
          i32.const 24
          i32.add
          call $"#func201 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 (;@2;)
        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 352
      i32.add
      global.set $__stack_pointer
      return
    end
    i32.const 1057428
    i32.const 43
    local.get 4
    i32.const 351
    i32.add
    i32.const 1057412
    i32.const 1057472
    call $core::result::unwrap_failed
    unreachable
  )

Emergent Testing

Idle. Press Run to start the suite.

  • ./proof.f.mjs