pub(crate) fn compile_pat_vec(
        &mut self,
        pat_vec: &ast::PatVec,
        false_label: Label,
        load: &dyn Fn(&mut Self, Needs) -> CompileResult<()>,
    ) -> CompileResult<()> {
        let span = pat_vec.span();
        log::trace!("PatVec => {:?}", self.source.source(span));

        // Assign the yet-to-be-verified tuple to an anonymous slot, so we can
        // interact with it multiple times.
        load(self, Needs::Value)?;
        let offset = self.scopes.decl_anon(span)?;

        // Copy the temporary and check that its length matches the pattern and
        // that it is indeed a vector.
        self.asm.push(Inst::Copy { offset }, span);

        let (is_open, count) = pat_items_count(&pat_vec.items)?;

        self.asm.push(
            Inst::MatchSequence {
                type_check: TypeCheck::Vec,
                len: count,
                exact: !is_open,
            },
            span,
        );

        self.asm
            .pop_and_jump_if_not(self.scopes.local_var_count(span)?, false_label, span);

        for (index, (pat, _)) in pat_vec.items.iter().take(count).enumerate() {
            let span = pat.span();

            let load = move |c: &mut Self, needs: Needs| {
                if needs.value() {
                    c.asm.push(Inst::TupleIndexGetAt { offset, index }, span);
                }

                Ok(())
            };

            self.compile_pat(&*pat, false_label, &load)?;
        }

        Ok(())
    }
/// Encode a vector pattern match.
Encode a vector pattern match.
Encode a vector pattern match .
pub(crate) fn compile_pat_vec(
        &mut self,
        pat_vec: &ast::PatVec,
        false_label: Label,
        load: &dyn Fn(&mut Self, Needs) -> CompileResult<()>,
    ) -> CompileResult<()> {
        let span = pat_vec.span();
        log::trace!("PatVec => {:?}", self.source.source(span));
        // Assign the yet-to-be-verified tuple to an anonymous slot, so we can
        // interact with it multiple times.
        load(self, Needs::Value)?;
        let offset = self.scopes.decl_anon(span)?;
        // Copy the temporary and check that its length matches the pattern and
        // that it is indeed a vector.
        self.asm.push(Inst::Copy { offset }, span);
        let (is_open, count) = pat_items_count(&pat_vec.items)?;
        self.asm.push(
            Inst::MatchSequence {
                type_check: TypeCheck::Vec,
                len: count,
                exact: !is_open,
            },
            span,
        );
        self.asm
            .pop_and_jump_if_not(self.scopes.local_var_count(span)?, false_label, span);
        for (index, (pat, _)) in pat_vec.items.iter().take(count).enumerate() {
            let span = pat.span();
            let load = move |c: &mut Self, needs: Needs| {
                if needs.value() {
                    c.asm.push(Inst::TupleIndexGetAt { offset, index }, span);
                }
                Ok(())
            };
            self.compile_pat(&*pat, false_label, &load)?;
        }
        Ok(())
    }
pub ( crate ) fn compile_pat_vec ( & mut self , pat_vec : & ast :: PatVec , false_label : Label , load : & dyn Fn ( & mut Self , Needs ) -> CompileResult < ( ) > , ) -> CompileResult < ( ) > { let span = pat_vec . span ( ) ; log :: trace ! ( " " self source source ( span ) ) ; // Assign the yet-to-be-verified tuple to an anonymous slot, so we can // interact with it multiple times. load ( self , Needs :: Value ) ? ; let offset = self . scopes . decl_anon ( span ) ? ; // Copy the temporary and check that its length matches the pattern and // that it is indeed a vector. self . asm . push ( Inst :: Copy { offset } , span ) ; let ( is_open , count ) = pat_items_count ( & pat_vec . items ) ? ; self . asm . push ( Inst :: MatchSequence { type_check : TypeCheck :: Vec , len : count , exact : ! is_open , } , span , ) ; self . asm . pop_and_jump_if_not ( self . scopes . local_var_count ( span ) ? , false_label , span ) ; for ( index , ( pat , _ ) ) in pat_vec . items . iter ( ) . take ( count ) . enumerate ( ) { let span = pat . span ( ) ; let load = move | c : & mut Self , needs : Needs | { if needs . value ( ) { c . asm . push ( Inst :: TupleIndexGetAt { offset , index } , span ) ; } Ok ( ( ) ) } ; self . compile_pat ( & * pat , false_label , & load ) ? ; } Ok ( ( ) ) }
Encode a vector pattern match.
Encode a vector pattern match .
&mut self
pat_vec
&ast::PatVec
false_label
Label
load
&dyn Fn(&mut Self, Needs) -> CompileResult<()>
&mut self
pat_vec
&ast::PatVec
false_label
Label
load
&dyn Fn(&mut Self, Needs) -> CompileResult<()>