Class fields

This commit is contained in:
2026-05-10 16:38:13 +02:00
parent 476d984d4a
commit 2fb38b6974
4 changed files with 61 additions and 5 deletions
+14 -1
View File
@@ -94,7 +94,7 @@ pub enum TopLevelKind {
visibility: Visibility,
name: Identifier,
generics: Generics,
fields: Vec<VarDeclStmt>,
fields: Vec<FieldDeclStmt>,
constructor: ClassConstructor,
methods: Vec<FunctionDecl>,
},
@@ -208,6 +208,19 @@ pub struct VarDeclStmt {
pub init: Option<Expression>,
}
#[derive(Debug, Clone, Serialize)]
pub struct FieldDecl {
pub visibility: Visibility,
pub type_: TypeExpr,
pub name: Identifier,
}
#[derive(Debug, Clone, Serialize)]
pub struct FieldDeclStmt {
pub decl: FieldDecl,
pub init: Option<Expression>,
}
#[derive(Debug, Clone, Serialize)]
pub struct VarAssignStmt {
pub target: Expression,