use crate::expression::{Block, Expression};
use crate::types::{GenericParameter, Type};
#[derive(Clone, Debug)]
pub struct Parameter {
pub name: String,
pub parameter_type: 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 ImplBlock {
pub generic_parameters: Vec<GenericParameter>,
pub target_type: Type,
pub callable: Callable,
pub const_fn: bool,
}
#[derive(Clone, Debug)]
pub struct Callable {
pub return_type: Type,
pub body: Block,
pub parameters: Option<Vec<Parameter>>,
}
#[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 generic_parameters: Vec<GenericParameter>,
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),
Impl(ImplBlock),
Extern(ExternFunction),
Constant(Constant),
Import(String),
}
pub type Module = Vec<Declaration>;