fn def_ana_fun(&mut self, name: &PA::FunctionName, body: &EA::FunctionBody, fun_idx: usize) {
        if let EA::FunctionBody_::Defined(seq) = &body.value {
            let full_name = self.qualified_by_module_from_name(&name.0);
            let entry = self
                .parent
                .fun_table
                .get(&full_name)
                .expect("function defined");
            let type_params = entry.type_params.clone();
            let params = entry.params.clone();
            let result_type = entry.result_type.clone();
            let mut et = ExpTranslator::new(self);
            et.translate_fun_as_spec_fun();
            let loc = et.to_loc(&body.loc);
            for (n, ty) in &type_params {
                et.define_type_param(&loc, *n, ty.clone());
            }
            et.enter_scope();
            for (n, ty) in &params {
                et.define_local(&loc, *n, ty.clone(), None);
            }
            let translated = et.translate_seq(&loc, &seq, &result_type);
            et.finalize_types();
            // If no errors were generated, then the function is considered pure.
            if !*et.errors_generated.borrow() {
                // Rewrite all type annotations in expressions to skip references.
                for node_id in translated.node_ids() {
                    et.parent
                        .type_map
                        .entry(node_id)
                        .and_modify(|ty| *ty = ty.skip_reference().clone());
                }
                et.called_spec_funs.iter().for_each(|(mid, fid)| {
                    self.parent.add_edge_to_move_fun_call_graph(
                        self.module_id,
                        SpecFunId::new(fun_idx),
                        *mid,
                        *fid,
                    );
                });
                self.spec_funs[self.spec_fun_index].body = Some(translated);
            }
        }
        self.spec_fun_index += 1;
    }
/// Definition analysis for Move functions.
/// If the function is pure, we translate its body.
Definition analysis for Move functions.
If the function is pure, we translate its body.
Definition analysis for Move functions . If the function is pure we translate its body .
fn def_ana_fun(&mut self, name: &PA::FunctionName, body: &EA::FunctionBody, fun_idx: usize) {
        if let EA::FunctionBody_::Defined(seq) = &body.value {
            let full_name = self.qualified_by_module_from_name(&name.0);
            let entry = self
                .parent
                .fun_table
                .get(&full_name)
                .expect("function defined");
            let type_params = entry.type_params.clone();
            let params = entry.params.clone();
            let result_type = entry.result_type.clone();
            let mut et = ExpTranslator::new(self);
            et.translate_fun_as_spec_fun();
            let loc = et.to_loc(&body.loc);
            for (n, ty) in &type_params {
                et.define_type_param(&loc, *n, ty.clone());
            }
            et.enter_scope();
            for (n, ty) in &params {
                et.define_local(&loc, *n, ty.clone(), None);
            }
            let translated = et.translate_seq(&loc, &seq, &result_type);
            et.finalize_types();
            // If no errors were generated, then the function is considered pure.
            if !*et.errors_generated.borrow() {
                // Rewrite all type annotations in expressions to skip references.
                for node_id in translated.node_ids() {
                    et.parent
                        .type_map
                        .entry(node_id)
                        .and_modify(|ty| *ty = ty.skip_reference().clone());
                }
                et.called_spec_funs.iter().for_each(|(mid, fid)| {
                    self.parent.add_edge_to_move_fun_call_graph(
                        self.module_id,
                        SpecFunId::new(fun_idx),
                        *mid,
                        *fid,
                    );
                });
                self.spec_funs[self.spec_fun_index].body = Some(translated);
            }
        }
        self.spec_fun_index += 1;
    }
fn def_ana_fun ( & mut self , name : & PA :: FunctionName , body : & EA :: FunctionBody , fun_idx : usize ) { if let EA :: FunctionBody_ :: Defined ( seq ) = & body . value { let full_name = self . qualified_by_module_from_name ( & name . 0 ) ; let entry = self . parent . fun_table . get ( & full_name ) . expect ( " " ) ; let type_params = entry . type_params . clone ( ) ; let params = entry . params . clone ( ) ; let result_type = entry . result_type . clone ( ) ; let mut et = ExpTranslator :: new ( self ) ; et . translate_fun_as_spec_fun ( ) ; let loc = et . to_loc ( & body . loc ) ; for ( n , ty ) in & type_params { et . define_type_param ( & loc , * n , ty . clone ( ) ) ; } et . enter_scope ( ) ; for ( n , ty ) in & params { et . define_local ( & loc , * n , ty . clone ( ) , None ) ; } let translated = et . translate_seq ( & loc , & seq , & result_type ) ; et . finalize_types ( ) ; // If no errors were generated, then the function is considered pure. if ! * et . errors_generated . borrow ( ) { // Rewrite all type annotations in expressions to skip references. for node_id in translated . node_ids ( ) { et . parent . type_map . entry ( node_id ) . and_modify ( | ty | * ty = ty . skip_reference ( ) . clone ( ) ) ; } et . called_spec_funs . iter ( ) . for_each ( | ( mid , fid ) | { self . parent . add_edge_to_move_fun_call_graph ( self . module_id , SpecFunId :: new ( fun_idx ) , * mid , * fid , ) ; } ) ; self . spec_funs [ self . spec_fun_index ] . body = Some ( translated ) ; } } self . spec_fun_index += 1 ; }
Definition analysis for Move functions.
Definition analysis for Move functions .
&mut self
name
&PA::FunctionName
body
&EA::FunctionBody
fun_idx
usize
&mut self
name
&PA::FunctionName
body
&EA::FunctionBody
fun_idx
usize