This commit is contained in:
nora 2022-07-24 18:38:19 +02:00
parent 475a520de3
commit 683f11c997
6 changed files with 111 additions and 13 deletions

View file

@ -262,3 +262,25 @@ pub enum ExternalDecl {
}
pub type TranslationUnit = Vec<Spanned<ExternalDecl>>;
impl Decl {
pub fn uwnrap_normal(&self) -> &NormalDecl {
match self {
Decl::Normal(decl) => decl,
Decl::StaticAssert => {
panic!("Expected normal declaration, found static assert declaration")
}
}
}
}
impl DirectDeclarator {
pub fn unwrap_with_params(&self) -> (&Ident, &Vec<FunctionParamDecl>) {
match self {
DirectDeclarator::Ident(_) => {
panic!("Expected declarator with parameters, found single identifier declarator1")
}
DirectDeclarator::WithParams { ident, params } => (ident, params),
}
}
}