pub fn compute_size_of_type(&self, type_id: CTypeId) -> Result<WithStmts<P<Expr>>, String> {
        if let CTypeKind::VariableArray(elts, len) =
            self.ast_context.resolve_type(type_id).kind {

            let len = len.expect("Sizeof a VLA type with count expression omitted");

            let mut elts = self.compute_size_of_type(elts)?;
            let mut len = self.convert_expr(ExprUse::RValue, len, false, DecayRef::Default)?;

            let mut stmts = elts.stmts;
            stmts.append(&mut len.stmts);

            let lhs = elts.val;
            let rhs = cast_int(len.val, "usize");

            let val = mk().binary_expr(BinOpKind::Mul, lhs, rhs);

            Ok(WithStmts { stmts, val })

        } else {
            let ty = self.convert_type(type_id)?;
            let name = "size_of";
            let params = mk().angle_bracketed_param_types(vec![ty]);
            let path = vec![mk().path_segment(""),
                            mk().path_segment("std"),
                            mk().path_segment("mem"),
                            mk().path_segment_with_params(name, params)];
            let call = mk().call_expr(mk().path_expr(path), vec![] as Vec<P<Expr>>);
            Ok(WithStmts::new(call))
        }
    }
// Compute the size of a type
// Rust type: usize
Compute the size of a type
Rust type: usize
Compute the size of a type Rust type : usize
pub fn compute_size_of_type(&self, type_id: CTypeId) -> Result<WithStmts<P<Expr>>, String> {
        if let CTypeKind::VariableArray(elts, len) =
            self.ast_context.resolve_type(type_id).kind {
            let len = len.expect("Sizeof a VLA type with count expression omitted");
            let mut elts = self.compute_size_of_type(elts)?;
            let mut len = self.convert_expr(ExprUse::RValue, len, false, DecayRef::Default)?;
            let mut stmts = elts.stmts;
            stmts.append(&mut len.stmts);
            let lhs = elts.val;
            let rhs = cast_int(len.val, "usize");
            let val = mk().binary_expr(BinOpKind::Mul, lhs, rhs);
            Ok(WithStmts { stmts, val })
        } else {
            let ty = self.convert_type(type_id)?;
            let name = "size_of";
            let params = mk().angle_bracketed_param_types(vec![ty]);
            let path = vec![mk().path_segment(""),
                            mk().path_segment("std"),
                            mk().path_segment("mem"),
                            mk().path_segment_with_params(name, params)];
            let call = mk().call_expr(mk().path_expr(path), vec![] as Vec<P<Expr>>);
            Ok(WithStmts::new(call))
        }
    }
pub fn compute_size_of_type ( & self , type_id : CTypeId ) -> Result < WithStmts < P < Expr > > , String > { if let CTypeKind :: VariableArray ( elts , len ) = self . ast_context . resolve_type ( type_id ) . kind { let len = len . expect ( " " ) ; let mut elts = self . compute_size_of_type ( elts ) ? ; let mut len = self . convert_expr ( ExprUse :: RValue , len , false , DecayRef :: Default ) ? ; let mut stmts = elts . stmts ; stmts . append ( & mut len . stmts ) ; let lhs = elts . val ; let rhs = cast_int ( len . val , " " ) ; let val = mk ( ) . binary_expr ( BinOpKind :: Mul , lhs , rhs ) ; Ok ( WithStmts { stmts , val } ) } else { let ty = self . convert_type ( type_id ) ? ; let name = " " ; let params = mk ( ) . angle_bracketed_param_types ( vec ! [ ty ] ) ; let path = vec ! [ mk ( ) path_segment ( " " ) mk ( ) path_segment ( " " ) mk ( ) path_segment ( " " ) mk ( ) path_segment_with_params ( name params ) ] ; let call = mk ( ) . call_expr ( mk ( ) . path_expr ( path ) , vec ! [ ] as Vec < P < Expr > > ) ; Ok ( WithStmts :: new ( call ) ) } }
Compute the size of a type
Rust type: usize
Compute the size of a type Rust type : usize
&self
type_id
CTypeId
&self
type_id
CTypeId