use std::sync::Arc; use uplc::builtins::DefaultFunction; use crate::{ ast::{ Annotation, Arg, AssignmentKind, BinOp, CallArg, Clause, IfBranch, Pattern, Span, TypedRecordUpdateArg, }, tipo::{ModuleValueConstructor, PatternConstructor, Type, ValueConstructor}, }; // [] #[derive(Debug, Clone)] pub enum IR { Int { value: String, }, String { value: String, }, ByteArray { bytes: Vec, }, Var { constructor: ValueConstructor, name: String, }, // Fn { // tipo: Arc, // is_capture: bool, // args: Vec>>, // body: Box, // return_annotation: Option, // }, List { count: usize, tipo: Arc, tail: bool, }, Tail { count: usize, }, ListAccessor { names: Vec, tail: bool, }, // func(x, other(y)) //[ Define(3) x definition *lam_body* -> [ (x [ (func [ func x [ (y [ other y ]) *definition* ] ]) *definition* ]) *definition* ], Define func -> [ (func [ func x [ (y [ other y ]) *definition* ] ]) *definition* ] , Call func -> [ func x [ (y [ other y ]) *definition* ] ], Var x -> x, Define y -> [ (y [ other y ]) *definition* ], Call other -> [ other y ], Var y -> y] // [y_varCall other_var Call Call x_defCall func_var ] Call { count: usize, }, Builtin { func: DefaultFunction, }, BinOp { name: BinOp, count: usize, tipo: Arc, }, Assignment { name: String, kind: AssignmentKind, }, DefineFunc { func_name: String, module_name: String, count: usize, }, DefineConst { func_name: String, module_name: String, count: usize, }, DefineConstrFields { func_name: String, module_name: String, count: usize, }, DefineConstrFieldAccess { func_name: String, module_name: String, count: usize, }, // Try { // tipo: Arc, // value: Box, // then: Box, // pattern: Pattern>, // }, When { count: usize, }, Clause { count: usize, }, Finally { count: usize, }, If { count: usize, }, Constr { count: usize, }, Fields { count: usize, }, RecordAccess { label: String, index: u64, count: usize, }, FieldsExpose { count: usize, }, // ModuleSelect { // tipo: Arc, // label: String, // module_name: String, // module_alias: String, // constructor: ModuleValueConstructor, // }, // Tuple { // // tipo: Arc, // elems: Vec, // }, // TupleIndex { // // tipo: Arc, // index: u64, // tuple: Box, // }, Todo { label: Option, tipo: Arc, }, RecordUpdate { tipo: Arc, spread: Box, args: Vec, }, Negate { value: Box, }, } // pub fn get(r: Int) -> This{g: Int}{ // This{ g: r } // } //let x = get(rdmr) when datum is { Hold(h, thing: f) -> h > x.g, Sell{price} -> x.g == price } // [ When(3) datum_var Clause(2) FieldsExpose(3) datum_var h_field_var f_field_var Binop(Greater, 2) h_var FieldAccess(2) x_var g_field Finally(2) Binop(2, EqualsInteger) FieldAccess x_var g_field_var ] // [ Assignment(2) ] // [ Assignment(2) x_var ] // [ Assignment(2) x_var Call(2) ] // [ Assignment(2) x_var Call(2) func_get_var ] // ^Mark this index function insertion // [ Assignment(2) x_var Call(2) func_get_var rdmr_var When(4)] // [ Assignment(2) x_var Call(2) func_get_var ] // (var rdmr) // [ Assignment(2) x_var Call(2) ] // (var func_get) // arg stack [ (var rdmr)] // [ Assignment(2) x_var ] // [(var func_get) (var rdmr)] // [ Assignment(2)] // (var x) // arg stack [ [(var func_get) (var rdmr)] ]