use std::rc::Rc; use crate::ast::types::{Value, StaticType}; use crate::ast::nodes::Node; #[derive(Debug, Clone, Copy, PartialEq)] pub enum Address { Local(u32), // Stack-Slot index (relative to frame base) Upvalue(u32), // Index in the closure's upvalue array Global(u32), // Index in the global environment vector } #[derive(Debug, Clone)] pub enum BoundKind { Nop, Constant(Value), // Variable Access (Resolved) Get(Address), // Variable Update (Resolved) Set { addr: Address, value: Box>, }, If { cond: Box>, then_br: Box>, else_br: Option>>, }, // Global Definition (Locals are implicit by stack position) DefGlobal { global_index: u32, value: Box>, }, Lambda { param_count: u32, // The list of variables captured from enclosing scopes upvalues: Vec
, body: Rc>, }, Call { callee: Box>, args: Vec>, }, TailCall { callee: Box>, args: Vec>, }, Block { exprs: Vec>, }, // NEW Tuple { elements: Vec>, }, Map { entries: Vec<(Node, Node)>, }, // Extension points (need to be adapted for bound nodes if they use variables) // For now, we assume extensions are self-contained or handled dynamically. }