cl-ast: Add syntax support for generics

This commit is contained in:
2025-04-22 07:22:44 -04:00
parent 681fbc88d3
commit 8ff17fd475
14 changed files with 124 additions and 36 deletions

View File

@@ -93,6 +93,12 @@ pub enum ItemKind {
Use(Use),
}
/// A list of type variables to introduce
#[derive(Clone, Debug, Default, PartialEq, Eq, Hash)]
pub struct Generics {
pub vars: Vec<Sym>,
}
/// An ordered collection of [Items](Item)
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Module {
@@ -128,6 +134,7 @@ pub struct Static {
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Function {
pub name: Sym,
pub gens: Generics,
pub sign: TyFn,
pub bind: Pattern,
pub body: Option<Expr>,
@@ -137,6 +144,7 @@ pub struct Function {
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Struct {
pub name: Sym,
pub gens: Generics,
pub kind: StructKind,
}
@@ -160,6 +168,7 @@ pub struct StructMember {
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Enum {
pub name: Sym,
pub gens: Generics,
pub variants: Option<Vec<Variant>>,
}