/// Emit the code for a variable declaration statement, given its HIR.
Emit the code for a variable declaration statement, given its HIR.
Emit the code for a variable declaration statement given its HIR .
fn emit_stmt_var_decl(
        &mut self,
        decl_id: NodeId,
        hir: &hir::VarDecl,
        env: ParamEnv,
    ) -> Result<()> {
        let ty = self.type_of_var_decl(
            Ref(self
                .ast_for_id(decl_id)
                .as_all()
                .get_var_decl_name()
                .unwrap()),
            env,
        );
        let ty = self.emit_type_both(ty)?;
        let init = match hir.init {
            Some(expr) => self.emit_rvalue(expr, env)?,
            None => self.emit_zero_for_type_both(ty),
        };
        let value = self.mk_var(init);
        self.builder.set_name(value.0, hir.name.value.to_string());
        self.set_emitted_value(decl_id, value);
        Ok(())
    }
fn emit_stmt_var_decl ( & mut self , decl_id : NodeId , hir : & hir :: VarDecl , env : ParamEnv , ) -> Result < ( ) > { let ty = self . type_of_var_decl ( Ref ( self . ast_for_id ( decl_id ) . as_all ( ) . get_var_decl_name ( ) . unwrap ( ) ) , env , ) ; let ty = self . emit_type_both ( ty ) ? ; let init = match hir . init { Some ( expr ) => self . emit_rvalue ( expr , env ) ? , None => self . emit_zero_for_type_both ( ty ) , } ; let value = self . mk_var ( init ) ; self . builder . set_name ( value . 0 , hir . name . value . to_string ( ) ) ; self . set_emitted_value ( decl_id , value ) ; Ok ( ( ) ) }
Emit the code for a variable declaration statement, given its HIR.
Emit the code for a variable declaration statement given its HIR .
&mut self
decl_id
NodeId
hir
&hir::VarDecl
env
ParamEnv