AST - Refactored class member data structures

This commit is contained in:
Emmanuel BENOîT 2023-01-14 11:14:53 +01:00
parent f2637fb319
commit c3bdc23081
2 changed files with 23 additions and 55 deletions

View file

@ -16,22 +16,20 @@ pub struct FunDecl {
pub body: Vec<StmtNode>,
}
/// A getter method for a property
/// The declaration of a class member.
#[derive(Debug, Clone)]
pub struct PropertyAccessor {
pub name: Token,
pub body: Vec<StmtNode>,
pub enum ClassMemberKind {
Method,
Getter,
Setter,
}
/// The declaration of a class member.
#[derive(Debug, Clone)]
pub enum ClassMemberDecl {
Method(FunDecl),
StaticMethod(FunDecl),
PropertyGetter(PropertyAccessor),
StaticPropertyGetter(PropertyAccessor),
PropertySetter(PropertyAccessor),
StaticPropertySetter(PropertyAccessor),
pub struct ClassMemberDecl {
pub kind: ClassMemberKind,
pub is_static: bool,
pub fun_decl: FunDecl,
}
/// A class declaration.