use super::{Block, ConstExpr, Span, TypeExpr};
#[derive(Debug, Clone)]
pub enum Item {
Fn(FnDecl),
Struct(StructDecl),
Enum(EnumDecl),
Const(ConstDecl),
Opaque(OpaqueDecl),
Extern(ExternBlock),
Use(UseDecl),
Mod(ModDecl),
}
#[derive(Debug, Clone)]
pub struct FnDecl {
pub is_unsafe: bool,
pub name: String,
pub params: Vec<Param>,
pub return_type: TypeExpr,
pub body: Block,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct Param {
pub name: String,
pub ty: TypeExpr,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct StructDecl {
pub repr: Option<Repr>,
pub name: String,
pub fields: Vec<Field>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct Field {
pub name: String,
pub ty: TypeExpr,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct EnumDecl {
pub repr: Option<Repr>,
pub name: String,
pub variants: Vec<Variant>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct Variant {
pub name: String,
pub fields: Option<Vec<TypeExpr>>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct ConstDecl {
pub name: String,
pub ty: TypeExpr,
pub value: ConstExpr,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct OpaqueDecl {
pub name: String,
pub span: Span,
}
#[derive(Debug, Clone)]
pub struct ExternBlock {
pub abi: String,
pub items: Vec<ExternItem>,
pub span: Span,
}
#[derive(Debug, Clone)]
pub enum ExternItem {
Fn(FnProto),
Struct(StructDecl),
Enum(EnumDecl),
Opaque(OpaqueDecl),
}
#[derive(Debug, Clone)]
pub struct FnProto {
pub is_unsafe: bool,
pub name: String,
pub params: Vec<Param>,
pub return_type: TypeExpr,
pub span: Span,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Repr {
C,
I8,
U8,
I16,
U16,
I32,
U32,
I64,
U64,
}
#[derive(Debug, Clone)]
pub struct UseDecl {
pub path: Vec<String>,
pub items: UseItems,
pub span: Span,
}
#[derive(Debug, Clone)]
pub enum UseItems {
Single(String),
Multiple(Vec<String>),
Glob,
Module,
}
#[derive(Debug, Clone)]
pub struct ModDecl {
pub is_pub: bool,
pub name: String,
pub body: Option<Vec<Item>>,
pub span: Span,
}