fn render_binding(x: &StarFun) -> TokenStream {
    match x.source {
        StarFunSource::Parameters => {
            let StarArg {
                attrs,
                mutable: _,
                by_ref: _,
                name,
                ty,
                default: _,
                source: _,
            } = &x.args[0];
            quote! { #( #attrs )* let #name : #ty = __args; }
        }
        StarFunSource::Argument(arg_count) => {
            let bind_args = x.args.map(render_binding_arg);
            quote! {
                let __this = __args.this;
                let __args: [_; #arg_count] = __signature.collect_into(__args, eval.heap())?;
                #( #bind_args )*
            }
        }
        StarFunSource::Positional(required, optional) => {
            let bind_args = x.args.map(render_binding_arg);
            if optional == 0 {
                quote! {
                    let __this = __args.this;
                    __args.no_named_args()?;
                    let __required: [_; #required] = __args.positional(eval.heap())?;
                    #( #bind_args )*
                }
            } else {
                quote! {
                    let __this = __args.this;
                    __args.no_named_args()?;
                    let (__required, __optional): ([_; #required], [_; #optional]) = __args.optional(eval.heap())?;
                    #( #bind_args )*
                }
            }
        }
        _ => unreachable!(),
    }
}
// Given __args and __signature (if render_signature was Some)
// create bindings for all the arguments
Given __args and __signature (if render_signature was Some)
create bindings for all the arguments
Given __args and __signature ( if render_signature was Some ) create bindings for all the arguments
fn render_binding(x: &StarFun) -> TokenStream {
    match x.source {
        StarFunSource::Parameters => {
            let StarArg {
                attrs,
                mutable: _,
                by_ref: _,
                name,
                ty,
                default: _,
                source: _,
            } = &x.args[0];
            quote! { #( #attrs )* let #name : #ty = __args; }
        }
        StarFunSource::Argument(arg_count) => {
            let bind_args = x.args.map(render_binding_arg);
            quote! {
                let __this = __args.this;
                let __args: [_; #arg_count] = __signature.collect_into(__args, eval.heap())?;
                #( #bind_args )*
            }
        }
        StarFunSource::Positional(required, optional) => {
            let bind_args = x.args.map(render_binding_arg);
            if optional == 0 {
                quote! {
                    let __this = __args.this;
                    __args.no_named_args()?;
                    let __required: [_; #required] = __args.positional(eval.heap())?;
                    #( #bind_args )*
                }
            } else {
                quote! {
                    let __this = __args.this;
                    __args.no_named_args()?;
                    let (__required, __optional): ([_; #required], [_; #optional]) = __args.optional(eval.heap())?;
                    #( #bind_args )*
                }
            }
        }
        _ => unreachable!(),
    }
}
fn render_binding ( x : & StarFun ) -> TokenStream { match x . source { StarFunSource :: Parameters => { let StarArg { attrs , mutable : _ , by_ref : _ , name , ty , default : _ , source : _ , } = & x . args [ 0 ] ; quote ! { ( attrs ) let name ty __args } } StarFunSource :: Argument ( arg_count ) => { let bind_args = x . args . map ( render_binding_arg ) ; quote ! { let __this __args this let __args [ arg_count ] __signature collect_into ( __args eval heap ( ) ) ( bind_args ) } } StarFunSource :: Positional ( required , optional ) => { let bind_args = x . args . map ( render_binding_arg ) ; if optional == 0 { quote ! { let __this __args this __args no_named_args ( ) let __required [ required ] __args positional ( eval heap ( ) ) ( bind_args ) } } else { quote ! { let __this __args this __args no_named_args ( ) let ( __required __optional ) ( [ required ] [ optional ] ) __args optional ( eval heap ( ) ) ( bind_args ) } } } _ => unreachable ! ( ) , } }
Given __args and __signature (if render_signature was Some)
create bindings for all the arguments
Given __args and __signature ( if render_signature was Some ) create bindings for all the arguments
x
&StarFun
x
&StarFun