Skip to main content

emit_call

Function emit_call 

Source
fn emit_call(call: &LowerCall, env_expr: &TokenStream) -> TokenStream
Expand description

Emit a TokenStream that builds + evaluates the lowered call.

The emitted code is:

unsafe {
    let __r_scope = ::miniextendr_api::gc_protect::ProtectScope::new();
    let __r_arg_0 = __r_scope.protect_raw(<atom>);
    ...
    ::miniextendr_api::expression::RCall::new("ident")
        .arg(__r_arg_0)
        ...
        .eval(#env_expr)
}

For namespaced calls (pkg::fn(args…)), the emitted code first resolves the function via RCall::namespaced, propagating errors early:

unsafe {
    let __r_scope = ::miniextendr_api::gc_protect::ProtectScope::new();
    let __r_ns_call = ::miniextendr_api::expression::RCall::namespaced("pkg", "fn")?;
    ...
    __r_ns_call.arg(...).eval(#env_expr)
}