use crate::statement;
use crate::Span;
use crate::SpannedString;
#[derive(Clone, Debug)]
pub struct ParameterList {
pub names: Vec<SpannedString>,
pub variadic: bool,
pub span: Span,
}
impl ParameterList {
pub fn new(names: Vec<SpannedString>, variadic: bool, span: Span) -> Self {
Self {
names,
variadic,
span,
}
}
pub fn span(&self) -> Span {
self.span
}
}
#[derive(Clone, Debug)]
pub struct ExprFunction {
pub parameters: ParameterList,
pub block: statement::Block,
pub span: Span,
}
impl ExprFunction {
pub fn new(parameters: Option<ParameterList>, block: statement::Block, span: Span) -> Self {
if let Some(p) = parameters {
Self {
parameters: p,
block,
span,
}
} else {
Self {
parameters: ParameterList::new(Vec::new(), false, Span::new_none()),
block,
span,
}
}
}
pub fn span(&self) -> Span {
self.span
}
}