use std::sync::Arc; use uplc::builtins::DefaultFunction; use crate::{ ast::{AssignmentKind, BinOp, TypedRecordUpdateArg}, tipo::{Type, ValueConstructor}, }; #[derive(Debug, Clone)] pub enum Air { Int { scope: Vec, value: String, }, String { scope: Vec, value: String, }, ByteArray { scope: Vec, bytes: Vec, }, Var { scope: Vec, constructor: ValueConstructor, name: String, variant_name: String, }, Fn { scope: Vec, params: Vec, }, List { scope: Vec, count: usize, tipo: Arc, tail: bool, }, ListAccessor { scope: Vec, tipo: Arc, names: Vec, tail: bool, }, ListExpose { scope: Vec, tipo: Arc, tail_head_names: Vec<(String, String)>, tail: Option<(String, String)>, }, Call { scope: Vec, count: usize, }, Builtin { scope: Vec, func: DefaultFunction, tipo: Arc, }, BinOp { scope: Vec, name: BinOp, count: usize, tipo: Arc, }, Assignment { scope: Vec, name: String, kind: AssignmentKind, }, DefineFunc { scope: Vec, func_name: String, module_name: String, params: Vec, recursive: bool, variant_name: String, }, DefineConst { scope: Vec, func_name: String, module_name: String, count: usize, }, DefineConstrFields { scope: Vec, func_name: String, module_name: String, count: usize, }, DefineConstrFieldAccess { scope: Vec, func_name: String, module_name: String, count: usize, }, Lam { scope: Vec, name: String, }, When { scope: Vec, tipo: Arc, subject_name: String, }, Clause { scope: Vec, tipo: Arc, subject_name: String, complex_clause: bool, }, ListClause { scope: Vec, tipo: Arc, tail_name: String, complex_clause: bool, next_tail_name: Option, }, ClauseGuard { scope: Vec, subject_name: String, tipo: Arc, }, Discard { scope: Vec, }, Finally { scope: Vec, }, If { scope: Vec, }, Constr { scope: Vec, count: usize, }, Fields { scope: Vec, count: usize, }, RecordAccess { scope: Vec, index: u64, tipo: Arc, }, FieldsExpose { scope: Vec, count: usize, indices: Vec<(usize, String, Arc)>, }, // ModuleSelect { // scope: Vec, // tipo: Arc, // label: String, // module_name: String, // module_alias: String, // constructor: ModuleValueConstructor, // }, Tuple { scope: Vec, tipo: Arc, count: usize, }, // TupleIndex { // scope: Vec, // // tipo: Arc, // index: u64, // tuple: Box, // }, Todo { scope: Vec, label: Option, tipo: Arc, }, Record { scope: Vec, }, RecordUpdate { scope: Vec, tipo: Arc, spread: Box, args: Vec, }, Negate { scope: Vec, }, TupleAccessor { scope: Vec, names: Vec, tipo: Arc, }, } impl Air { pub fn scope(&self) -> Vec { match self { Air::Int { scope, .. } | Air::String { scope, .. } | Air::ByteArray { scope, .. } | Air::Var { scope, .. } | Air::List { scope, .. } | Air::ListAccessor { scope, .. } | Air::ListExpose { scope, .. } | Air::Fn { scope, .. } | Air::Call { scope, .. } | Air::Builtin { scope, .. } | Air::BinOp { scope, .. } | Air::Assignment { scope, .. } | Air::DefineFunc { scope, .. } | Air::DefineConst { scope, .. } | Air::DefineConstrFields { scope, .. } | Air::DefineConstrFieldAccess { scope, .. } | Air::Lam { scope, .. } | Air::When { scope, .. } | Air::Clause { scope, .. } | Air::ListClause { scope, .. } | Air::ClauseGuard { scope, .. } | Air::Discard { scope } | Air::Finally { scope } | Air::If { scope, .. } | Air::Constr { scope, .. } | Air::Fields { scope, .. } | Air::RecordAccess { scope, .. } | Air::FieldsExpose { scope, .. } | Air::Tuple { scope, .. } | Air::Todo { scope, .. } | Air::Record { scope, .. } | Air::RecordUpdate { scope, .. } | Air::Negate { scope, .. } | Air::TupleAccessor { scope, .. } => scope.to_vec(), } } }