// Using nested function to avoid exposing the level parameter
Using nested function to avoid exposing the level parameter
Using nested function to avoid exposing the level parameter
fn _get_declref_type(ast_context: &TypedAstContext, expr_id: CExprId, level: u32) -> Result<(Option<Qualifiers>, CTypeId), &str> {
            let expr : &CExpr = ast_context.index(expr_id);
            return match expr.kind {
                // level 0 arms
                CExprKind::Unary(_type_id, c_ast::UnOp::AddressOf, inner_expr_id) if level == 0  => {
                    _get_declref_type(ast_context, inner_expr_id, level + 1)
                }
                CExprKind::ImplicitCast(_type_id, inner_expr_id, CastKind::FunctionToPointerDecay, _field_id) if level == 0 => {
                    _get_declref_type(ast_context, inner_expr_id, level + 1)
                }
                // level 1 arms
                CExprKind::DeclRef(_type_id, decl_id) if level == 1 => {
                    let cdecl : &CDecl = ast_context.index(decl_id);
                    match cdecl.kind {
                        CDeclKind::Function { typ, .. } => Ok((None, typ)),
                        CDeclKind::Variable { typ, ..} => {
                            Ok((Some(typ.qualifiers), typ.ctype))
                        }
                        _ => Err("couldn't get leaf node type")
                    }
                }
                _ => Err("couldn't get leaf node type")
            }
        }
fn _get_declref_type ( ast_context : & TypedAstContext , expr_id : CExprId , level : u32 ) -> Result < ( Option < Qualifiers > , CTypeId ) , & str > { let expr : & CExpr = ast_context . index ( expr_id ) ; return match expr . kind { // level 0 arms CExprKind :: Unary ( _type_id , c_ast :: UnOp :: AddressOf , inner_expr_id ) if level == 0 => { _get_declref_type ( ast_context , inner_expr_id , level + 1 ) } CExprKind :: ImplicitCast ( _type_id , inner_expr_id , CastKind :: FunctionToPointerDecay , _field_id ) if level == 0 => { _get_declref_type ( ast_context , inner_expr_id , level + 1 ) } // level 1 arms CExprKind :: DeclRef ( _type_id , decl_id ) if level == 1 => { let cdecl : & CDecl = ast_context . index ( decl_id ) ; match cdecl . kind { CDeclKind :: Function { typ , .. } => Ok ( ( None , typ ) ) , CDeclKind :: Variable { typ , .. } => { Ok ( ( Some ( typ . qualifiers ) , typ . ctype ) ) } _ => Err ( " " ) } } _ => Err ( " " ) } }
Using nested function to avoid exposing the level parameter
Using nested function to avoid exposing the level parameter
ast_context
&TypedAstContext
expr_id
CExprId
level
u32