1use crate::language::{InternSymbol, Access};
2use crate::parser::expr::{ExprMeta, ExprBlock};
3
4
5#[derive(Debug, Clone)]
7pub struct FunctionDef {
8 pub signature: SignatureDef,
9 pub body: Box<ExprBlock>,
10}
11
12#[derive(Debug, Clone)]
13pub struct SignatureDef {
14 pub name: Option<InternSymbol>,
15 pub required: Box<[ParamDef]>,
16 pub default: Box<[DefaultDef]>,
17 pub variadic: Option<ParamDef>,
18}
19
20impl SignatureDef {
21 pub fn param_count(&self) -> usize {
22 self.required.len()
23 + self.default.len()
24 + usize::from(self.variadic.is_some())
25 }
26}
27
28#[derive(Debug, Clone)]
29pub struct ParamDef {
30 pub name: InternSymbol,
31 pub mode: Access,
32}
33
34#[derive(Debug, Clone)]
35pub struct DefaultDef {
36 pub name: InternSymbol,
37 pub mode: Access,
38 pub default: Box<ExprMeta>,
39}