Updated type ast #65
This commit is contained in:
@@ -18,19 +18,13 @@ pub struct Identifier(pub String);
|
|||||||
pub struct ParamList(pub Vec<VarDecl>);
|
pub struct ParamList(pub Vec<VarDecl>);
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
#[derive(Debug, Clone, Serialize)]
|
||||||
pub struct TypeExpr(pub TypeExprKind, pub Vec<TypePostfix>);
|
pub enum TypeExpr {
|
||||||
|
Ref {
|
||||||
#[derive(Debug, Clone, Serialize)]
|
lifetime: Option<Identifier>,
|
||||||
pub enum TypePostfix {
|
mutable: bool,
|
||||||
Ref,
|
ty: Box<TypeExpr>,
|
||||||
RefMut,
|
},
|
||||||
RefLifetime(Identifier),
|
Dyn(Box<TypeExpr>),
|
||||||
RefMutLifetime(Identifier),
|
|
||||||
Dyn,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize)]
|
|
||||||
pub enum TypeExprKind {
|
|
||||||
Path(Path, Option<Generics>),
|
Path(Path, Option<Generics>),
|
||||||
Tuple(Vec<TypeExpr>),
|
Tuple(Vec<TypeExpr>),
|
||||||
Lifetime(Identifier),
|
Lifetime(Identifier),
|
||||||
@@ -43,20 +37,11 @@ pub struct Spanned<T> {
|
|||||||
pub item: T,
|
pub item: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TypeExpr {
|
|
||||||
pub fn no_px(kind: TypeExprKind) -> Self {
|
|
||||||
Self(kind, Vec::new())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl From<GenericDecl> for Generic {
|
impl From<GenericDecl> for Generic {
|
||||||
fn from(value: GenericDecl) -> Self {
|
fn from(value: GenericDecl) -> Self {
|
||||||
match value {
|
match value {
|
||||||
GenericDecl::Lifetime(life) => Generic::Lifetime(life),
|
GenericDecl::Lifetime(life) => Generic::Lifetime(life),
|
||||||
GenericDecl::Type(ty, _) => Generic::Type(TypeExpr(
|
GenericDecl::Type(ty, _) => Generic::Type(TypeExpr::Path(Path(vec![ty]), None)),
|
||||||
TypeExprKind::Path(Path(vec![ty]), None),
|
|
||||||
Vec::new(),
|
|
||||||
)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
void main() {}
|
*void main() {}
|
||||||
Reference in New Issue
Block a user