use crate::{ ast::{BinOp, Curve, UnOp}, tipo::{Type, ValueConstructor}, }; use indexmap::IndexSet; use std::rc::Rc; use uplc::builtins::DefaultFunction; #[derive(Debug, Clone, PartialEq, Copy)] pub enum ExpectLevel { Full, Items, None, } impl From for ExpectLevel { fn from(value: bool) -> Self { if value { ExpectLevel::Full } else { ExpectLevel::None } } } #[derive(Debug, Clone, PartialEq)] pub enum FunctionVariants { Standard(Vec), Recursive { params: Vec, recursive_nonstatic_params: Vec, }, Cyclic(Vec>), Constant, } #[derive(Debug, Clone, PartialEq)] pub enum Air { // Primitives Int { value: String, }, String { value: String, }, ByteArray { bytes: Vec, }, CurvePoint { point: Curve, }, Bool { value: bool, }, List { count: usize, tipo: Rc, tail: bool, }, Tuple { tipo: Rc, count: usize, }, Pair { tipo: Rc, }, Void, Var { constructor: ValueConstructor, name: String, variant_name: String, }, // Functions Call { count: usize, tipo: Rc, }, DefineFunc { func_name: String, module_name: String, variant_name: String, variant: FunctionVariants, }, Fn { params: Vec, allow_inline: bool, }, Builtin { count: usize, func: DefaultFunction, tipo: Rc, }, // Operators BinOp { name: BinOp, tipo: Rc, argument_tipo: Rc, }, UnOp { op: UnOp, }, // Assignment Let { name: String, }, SoftCastLet { name: String, tipo: Rc, }, CastFromData { tipo: Rc, full_cast: bool, }, CastToData { tipo: Rc, }, AssertConstr { constr_index: usize, }, AssertBool { is_true: bool, }, // When When { tipo: Rc, subject_name: String, subject_tipo: Rc, }, Clause { subject_tipo: Rc, subject_name: String, complex_clause: bool, }, ListClause { subject_tipo: Rc, tail_name: String, next_tail_name: Option<(String, String)>, complex_clause: bool, }, WrapClause, TupleClause { subject_tipo: Rc, indices: IndexSet<(usize, String)>, predefined_indices: IndexSet<(usize, String)>, subject_name: String, complex_clause: bool, }, PairClause { subject_tipo: Rc, subject_name: String, fst_name: Option, snd_name: Option, complex_clause: bool, }, ClauseGuard { subject_name: String, subject_tipo: Rc, }, ListClauseGuard { subject_tipo: Rc, tail_name: String, next_tail_name: Option, inverse: bool, }, TupleGuard { subject_tipo: Rc, indices: IndexSet<(usize, String)>, subject_name: String, }, PairGuard { subject_tipo: Rc, subject_name: String, fst_name: Option, snd_name: Option, }, Finally, // If If { tipo: Rc, }, // Record Creation Constr { tag: usize, tipo: Rc, count: usize, }, RecordUpdate { highest_index: usize, indices: Vec<(usize, Rc)>, tipo: Rc, }, // Field Access FieldsExpose { indices: Vec<(usize, String, Rc)>, is_expect: bool, }, // ListAccess ListAccessor { tipo: Rc, names: Vec, tail: bool, expect_level: ExpectLevel, }, ListExpose { tipo: Rc, tail_head_names: Vec<(String, String)>, tail: Option<(String, String)>, }, // Tuple Access TupleAccessor { names: Vec, tipo: Rc, is_expect: bool, }, // Tuple Access PairAccessor { fst: Option, snd: Option, tipo: Rc, is_expect: bool, }, // Misc. ErrorTerm { tipo: Rc, validator: bool, }, Trace { tipo: Rc, }, NoOp, FieldsEmpty, ListEmpty, MultiValidator { two_arg_name: String, three_arg_name: String, }, }