use crate::expression::{Block, Expression, Span};
use crate::types::Type;
#[derive(Clone, Debug)]
pub struct Parameter {
pub name: String,
pub parameter_type: Option<Type>,
}
#[derive(Clone, Debug)]
pub enum ParameterList {
Fixed(Vec<Parameter>),
Variadic(Vec<Parameter>),
}
impl ParameterList {
pub fn parameters(&self) -> &[Parameter] {
match self {
Self::Fixed(parameters) | Self::Variadic(parameters) => parameters,
}
}
}
#[derive(Clone, Debug)]
pub struct FunctionDefinition {
pub name: String,
pub parameters: Vec<Parameter>,
pub return_type: Type,
pub body: Block,
pub public: bool,
pub span: Span,
}
#[derive(Clone, Debug)]
pub struct ExternFunction {
pub name: String,
pub parameters: ParameterList,
pub return_type: Type,
}
#[derive(Clone, Debug)]
pub struct Newtype {
pub name: String,
pub inner_type: Type,
pub public: bool,
}
#[derive(Clone, Debug)]
pub struct Constant {
pub name: String,
pub constant_type: Type,
pub value: Expression,
pub public: bool,
}
#[derive(Clone, Debug)]
pub enum Declaration {
Type(Newtype),
Function(FunctionDefinition),
Extern(ExternFunction),
Constant(Constant),
Import(String),
}
pub type Module = Vec<Declaration>;