Skip to main content

nanvm_demos/gen.samples/
switch_statement.rs

1// @generated by `fjs compile`. Do not edit: recompile the source module instead.
2
3use nanvm_lib::vm::unstable::{f64_any, strict_eq, string_any, string_key};
4use nanvm_lib::vm::{Any, IStaticFunction, 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 _b0: Any<A> = [string_any("array"), string_any("object"), string_any("string")].to_array().to_any();
10    Ok([(string_key("default"), A::static_function(|_self, _args| {
11        let _b768: Any<A> = _args.rest(0).to_any();
12        let _b5: Any<A> = (Any::dot(A::frame(_self)[0].clone(), (Any::number((Any::dot(_b768.clone(), f64_any(0x0000000000000000)).end())?))?).end())?;
13        if Any::<A>::to_boolean({
14            let _b6: Any<A> = (strict_eq(_b5.clone(), string_any("array")))?;
15            if Any::<A>::to_boolean(_b6.clone()) { _b6.clone() } else { (strict_eq(_b5.clone(), string_any("object")))? }
16        }) { Ok(string_any("container")) } else { if Any::<A>::to_boolean((strict_eq(_b5.clone(), string_any("string")))?) { Ok(string_any("text")) } else { Err([string_any("unknown"), (Any::dot(_b768.clone(), f64_any(0x0000000000000000)).end())?].to_array().to_any()) } }
17    }, 0, [_b0.clone()].to_array(), Some("(...$1)=>{const $2=$0[Number($1[0])];return (()=>{const $3=$2===\"array\";return $3?$3:$2===\"object\";})()?\"container\":$2===\"string\"?\"text\":(()=>{throw [\"unknown\",$1[0]];})();}")).to_any())].to_object().to_any())
18}