nanvm_demos/gen.samples/
call_statements.rs1use nanvm_lib::vm::unstable::{f64_any, string_any, string_key};
4use nanvm_lib::vm::{Any, IStaticFunction, Nullish, ToAny, ToArray, ToObject};
5
6#[rustfmt::skip]
7#[allow(clippy::if_same_then_else)]
8pub fn module<A: IStaticFunction>(runtime: Any<A>) -> Result<Any<A>, Any<A>> {
9 let _b6: Any<A> = A::static_function(|_self, _args| {
10 let _b369: Any<A> = _args.rest(0).to_any();
11 if Any::<A>::to_boolean((Any::dot(_b369.clone(), f64_any(0x0000000000000000)).end())?) { Ok(Nullish::Undefined.to_any()) } else { Err((Any::dot(_b369.clone(), f64_any(0x3ff0000000000000)).end())?) }
12 }, 0, [runtime.clone()].to_array(), Some("(...$0)=>$0[0]?undefined:(()=>{throw $0[1];})()")).to_any();
13 Ok([(string_key("default"), {
14 let _b15: Any<A> = A::static_function(|_self, _args| {
15 let _b1288: Any<A> = (Any::call(A::frame(_self)[0].clone(), [(Any::lt(_args.argument(1), (Any::dot(_args.argument(0), string_any("length")).end())?))?, string_any("out of range")].to_array().to_any()))?;
16 Any::dot(_args.argument(0), string_any("at")).end_call(&A::frame(_self)[1], || Ok([_args.argument(1)].to_array().to_any()))
17 }, 2, [_b6.clone(), runtime.clone()].to_array(), Some("($1,$2)=>{const $3=$0($2<$1.length,\"out of range\");return $1.at($2);}")).to_any();
18 A::static_function(|_self, _args| {
19 let _b1194: Any<A> = _args.rest(0).to_any();
20 Any::call(A::frame(_self)[0].clone(), [[f64_any(0x3ff0000000000000), f64_any(0x4000000000000000), f64_any(0x4008000000000000)].to_array().to_any(), (Any::dot(_b1194.clone(), f64_any(0x0000000000000000)).end())?].to_array().to_any())
21 }, 0, [_b15.clone(), runtime.clone()].to_array(), Some("(...$1)=>$0([1,2,3],$1[0])")).to_any()
22 })].to_object().to_any())
23}