use ecow::EcoString; use num_bigint::BigInt; #[derive(Debug, PartialEq, Eq, Default)] pub struct Module { pub functions: Vec, } #[derive(Debug, PartialEq, Eq)] pub struct Function { pub name: EcoString, pub return_type: Type, pub parameters: Vec, pub body: Expression, } #[derive(Debug, PartialEq, Eq)] pub struct FunctionParameter { pub type_: Type, pub name: Option, } #[derive(Debug, Clone, PartialEq, Eq)] pub enum Type { Int, Float, Bool, String, Struct { elements: Vec }, List(Box), Generic, } #[derive(Debug, PartialEq, Eq, Clone)] pub struct Var { pub name: EcoString, } #[derive(Debug, PartialEq, Eq, Clone)] pub enum Expression { Block(Vec), FunctionRef { module: EcoString, name: EcoString, arity: usize, }, Var(Var), Int { value: BigInt, }, Float { value: EcoString, }, Bool { value: bool, }, String { value: EcoString, }, Equals { lhs: Box, rhs: Box, }, NotEquals { lhs: Box, rhs: Box, }, IntGt { lhs: Box, rhs: Box, }, IntGtEq { lhs: Box, rhs: Box, }, IntLt { lhs: Box, rhs: Box, }, IntLtEq { lhs: Box, rhs: Box, }, IntAdd { lhs: Box, rhs: Box, }, IntSub { lhs: Box, rhs: Box, }, IntMul { lhs: Box, rhs: Box, }, IntDiv { lhs: Box, rhs: Box, }, IntRem { lhs: Box, rhs: Box, }, FloatGt { lhs: Box, rhs: Box, }, FloatGtEq { lhs: Box, rhs: Box, }, FloatLt { lhs: Box, rhs: Box, }, FloatLtEq { lhs: Box, rhs: Box, }, FloatAdd { lhs: Box, rhs: Box, }, FloatSub { lhs: Box, rhs: Box, }, FloatMul { lhs: Box, rhs: Box, }, FloatDiv { lhs: Box, rhs: Box, }, StringConcat { lhs: Box, rhs: Box, }, List { items: Vec, tail: Option>, }, Struct { tag: Option, items: Vec, }, StructTag { value: Box, }, StructAccess { value: Box, index: u64, }, Set { name: Var, value: Box, }, If { cond: Box, then: Box, else_: Box, }, Call { target: Box, args: Vec, }, }