mirror of
https://github.com/Noratrieb/uwucc.git
synced 2026-01-15 00:55:05 +01:00
some stuff works
This commit is contained in:
parent
4b646b9128
commit
79ab4bbb75
7 changed files with 239 additions and 100 deletions
|
|
@ -1,6 +1,8 @@
|
|||
use std::fmt::{Debug, Formatter};
|
||||
|
||||
use dbg_pls::DebugPls;
|
||||
|
||||
use crate::{Span, Spanned};
|
||||
use crate::Spanned;
|
||||
|
||||
#[derive(Debug, DebugPls)]
|
||||
pub enum TypeSpecifier {
|
||||
|
|
@ -24,13 +26,45 @@ pub enum TypeSpecifier {
|
|||
|
||||
pub type Ident = Spanned<String>;
|
||||
|
||||
#[derive(Debug, Default, DebugPls)]
|
||||
#[derive(Default)]
|
||||
pub struct DeclAttr {
|
||||
pub is_extern: bool,
|
||||
pub is_static: bool,
|
||||
pub is_thread_local: bool,
|
||||
}
|
||||
|
||||
impl Debug for DeclAttr {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
let mut d = f.debug_set();
|
||||
if self.is_extern {
|
||||
d.entry(&"extern");
|
||||
}
|
||||
if self.is_static {
|
||||
d.entry(&"static");
|
||||
}
|
||||
if self.is_thread_local {
|
||||
d.entry(&"thread_local");
|
||||
}
|
||||
d.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl DebugPls for DeclAttr {
|
||||
fn fmt(&self, f: dbg_pls::Formatter<'_>) {
|
||||
let mut d = f.debug_set();
|
||||
if self.is_extern {
|
||||
d = d.entry(&"extern");
|
||||
}
|
||||
if self.is_static {
|
||||
d = d.entry(&"static");
|
||||
}
|
||||
if self.is_thread_local {
|
||||
d = d.entry(&"thread_local");
|
||||
}
|
||||
d.finish();
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, DebugPls)]
|
||||
pub struct DeclSpec {
|
||||
pub ty: TypeSpecifier,
|
||||
|
|
@ -55,12 +89,18 @@ pub struct NormalDecl {
|
|||
pub init_declarators: Vec<Spanned<InitDecl>>,
|
||||
}
|
||||
|
||||
#[derive(Debug, DebugPls)]
|
||||
pub struct FunctionParamDecl {
|
||||
pub decl_spec: Spanned<DeclSpec>,
|
||||
pub declarator: Spanned<Declarator>,
|
||||
}
|
||||
|
||||
#[derive(Debug, DebugPls)]
|
||||
pub enum DirectDeclarator {
|
||||
Ident(Ident),
|
||||
WithParams {
|
||||
ident: Ident,
|
||||
params: Vec<NormalDecl>,
|
||||
params: Vec<FunctionParamDecl>,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
@ -70,18 +110,6 @@ pub struct Declarator {
|
|||
pub pointer: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, DebugPls)]
|
||||
pub struct FunctionParamDecl {
|
||||
pub decl_spec: DeclSpec,
|
||||
pub declarator: Declarator,
|
||||
}
|
||||
|
||||
#[derive(Debug, DebugPls)]
|
||||
pub enum FunctionParams {
|
||||
Void(Span),
|
||||
List(Vec<Spanned<NormalDecl>>),
|
||||
}
|
||||
|
||||
#[derive(Debug, DebugPls)]
|
||||
pub struct FunctionDef {
|
||||
pub declaration: Decl,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue