Demo
Compiles a FunctionalScript module without imports into Rust calls that build its value in NaNVM. Compare the output with the .rs module written by fjs compile.
Rust module:
// @generated by `fjs compile`. Do not edit: recompile the source module instead. use nanvm_lib::vm::unstable::{f64_any, string_any, string_key}; use nanvm_lib::vm::{Any, Array, IStaticFunction, Nullish, ToAny, ToArray, ToObject}; #[rustfmt::skip] #[allow(clippy::if_same_then_else)] pub fn module<A: IStaticFunction>(_runtime: Any<A>) -> Result<Any<A>, Any<A>> { let _b0: Any<A> = (f64_any(0x3ff0000000000000) + f64_any(0x4000000000000000))?; let _b484: Any<A> = (Any::dot(_b0.clone(), string_any("x")).end())?; let _b2: Any<A> = (_b0.clone() * f64_any(0x4008000000000000))?; let _b3: Any<A> = (Any::lt(_b0.clone(), f64_any(0x4010000000000000)))?; Ok([(string_key("default"), [_b0.clone(), _b0.clone(), _b2.clone(), if Any::<A>::to_boolean(_b3.clone()) { _b0.clone() } else { _b3.clone() }, A::static_function(|_self, _args| { let _b285: Any<A> = _args.rest(0).to_any(); Ok(_b285.clone()) }, 0, Array::default(), Some("(...$0)=>$0")).to_any(), Nullish::Undefined.to_any()].to_array().to_any())].to_object().to_any()) }