Remove unused BoundKind enum
The `BoundKind` enum was declared but never used. This commit removes it to clean up the codebase.
This commit is contained in:
@@ -278,192 +278,6 @@ impl<P: CompilerPhase> Clone for Box<dyn BoundExtension<P>> {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum BoundKind<P: CompilerPhase = BoundPhase> {
|
||||
Nop,
|
||||
Constant(Value),
|
||||
Get {
|
||||
addr: Address<P::LocalAddress>,
|
||||
name: Symbol,
|
||||
},
|
||||
Set {
|
||||
addr: Address<P::LocalAddress>,
|
||||
value: Rc<Node<P>>,
|
||||
},
|
||||
Define {
|
||||
name: Symbol,
|
||||
addr: Address<P::LocalAddress>,
|
||||
kind: DeclarationKind,
|
||||
value: Rc<Node<P>>,
|
||||
captured_by: Vec<Identity>,
|
||||
},
|
||||
FieldAccessor(crate::ast::types::Keyword),
|
||||
GetField {
|
||||
rec: Rc<Node<P>>,
|
||||
field: crate::ast::types::Keyword,
|
||||
},
|
||||
If {
|
||||
cond: Rc<Node<P>>,
|
||||
then_br: Rc<Node<P>>,
|
||||
else_br: Option<Rc<Node<P>>>,
|
||||
},
|
||||
Destructure {
|
||||
pattern: Rc<Node<P>>,
|
||||
value: Rc<Node<P>>,
|
||||
},
|
||||
Lambda {
|
||||
params: Rc<Node<P>>,
|
||||
upvalues: Vec<Address<P::LocalAddress>>,
|
||||
body: Rc<Node<P>>,
|
||||
positional_count: Option<u32>,
|
||||
},
|
||||
Call {
|
||||
callee: Rc<Node<P>>,
|
||||
args: Rc<Node<P>>,
|
||||
},
|
||||
Again {
|
||||
args: Rc<Node<P>>,
|
||||
},
|
||||
Pipe {
|
||||
inputs: Vec<Rc<Node<P>>>,
|
||||
lambda: Rc<Node<P>>,
|
||||
out_type: crate::ast::types::StaticType,
|
||||
},
|
||||
Block {
|
||||
exprs: Vec<Rc<Node<P>>>,
|
||||
},
|
||||
Tuple {
|
||||
elements: Vec<Rc<Node<P>>>,
|
||||
},
|
||||
Record {
|
||||
layout: std::sync::Arc<crate::ast::types::RecordLayout>,
|
||||
values: Vec<Rc<Node<P>>>,
|
||||
},
|
||||
Expansion {
|
||||
original_call: Rc<crate::ast::nodes::SyntaxNode>,
|
||||
bound_expanded: Rc<Node<P>>,
|
||||
},
|
||||
Error,
|
||||
Extension(Box<dyn BoundExtension<P>>),
|
||||
}
|
||||
|
||||
impl<P: CompilerPhase> Clone for BoundKind<P> {
|
||||
fn clone(&self) -> Self {
|
||||
match self {
|
||||
BoundKind::Nop => BoundKind::Nop,
|
||||
BoundKind::Constant(v) => BoundKind::Constant(v.clone()),
|
||||
BoundKind::Get { addr, name } => BoundKind::Get { addr: *addr, name: name.clone() },
|
||||
BoundKind::Set { addr, value } => BoundKind::Set { addr: *addr, value: value.clone() },
|
||||
BoundKind::Define { name, addr, kind, value, captured_by } => BoundKind::Define { name: name.clone(), addr: *addr, kind: *kind, value: value.clone(), captured_by: captured_by.clone() },
|
||||
BoundKind::FieldAccessor(k) => BoundKind::FieldAccessor(*k),
|
||||
BoundKind::GetField { rec, field } => BoundKind::GetField { rec: rec.clone(), field: *field },
|
||||
BoundKind::If { cond, then_br, else_br } => BoundKind::If { cond: cond.clone(), then_br: then_br.clone(), else_br: else_br.clone() },
|
||||
BoundKind::Destructure { pattern, value } => BoundKind::Destructure { pattern: pattern.clone(), value: value.clone() },
|
||||
BoundKind::Lambda { params, upvalues, body, positional_count } => BoundKind::Lambda { params: params.clone(), upvalues: upvalues.clone(), body: body.clone(), positional_count: *positional_count },
|
||||
BoundKind::Call { callee, args } => BoundKind::Call { callee: callee.clone(), args: args.clone() },
|
||||
BoundKind::Again { args } => BoundKind::Again { args: args.clone() },
|
||||
BoundKind::Pipe { inputs, lambda, out_type } => BoundKind::Pipe { inputs: inputs.clone(), lambda: lambda.clone(), out_type: out_type.clone() },
|
||||
BoundKind::Block { exprs } => BoundKind::Block { exprs: exprs.clone() },
|
||||
BoundKind::Tuple { elements } => BoundKind::Tuple { elements: elements.clone() },
|
||||
BoundKind::Record { layout, values } => BoundKind::Record { layout: layout.clone(), values: values.clone() },
|
||||
BoundKind::Expansion { original_call, bound_expanded } => BoundKind::Expansion { original_call: original_call.clone(), bound_expanded: bound_expanded.clone() },
|
||||
BoundKind::Error => BoundKind::Error,
|
||||
BoundKind::Extension(ext) => BoundKind::Extension(ext.clone()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: CompilerPhase> PartialEq for BoundKind<P> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
match (self, other) {
|
||||
(BoundKind::Nop, BoundKind::Nop) => true,
|
||||
(BoundKind::Constant(a), BoundKind::Constant(b)) => a == b,
|
||||
(BoundKind::Get { addr: aa, name: na }, BoundKind::Get { addr: ab, name: nb }) => {
|
||||
aa == ab && na == nb
|
||||
}
|
||||
(BoundKind::Set { addr: aa, value: va }, BoundKind::Set { addr: ab, value: vb }) => {
|
||||
aa == ab && Rc::ptr_eq(va, vb)
|
||||
}
|
||||
(BoundKind::Define { name: na, addr: aa, kind: ka, value: va, captured_by: ca }, BoundKind::Define { name: nb, addr: ab, kind: kb, value: vb, captured_by: cb }) => {
|
||||
na == nb && aa == ab && ka == kb && Rc::ptr_eq(va, vb) && ca == cb
|
||||
}
|
||||
(BoundKind::FieldAccessor(a), BoundKind::FieldAccessor(b)) => a == b,
|
||||
(BoundKind::GetField { rec: ra, field: fa }, BoundKind::GetField { rec: rb, field: fb }) => {
|
||||
Rc::ptr_eq(ra, rb) && fa == fb
|
||||
}
|
||||
(BoundKind::If { cond: ca, then_br: ta, else_br: ea }, BoundKind::If { cond: cb, then_br: tb, else_br: eb }) => {
|
||||
Rc::ptr_eq(ca, cb) && Rc::ptr_eq(ta, tb) && match (ea, eb) {
|
||||
(Some(a), Some(b)) => Rc::ptr_eq(a, b),
|
||||
(None, None) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
(BoundKind::Destructure { pattern: pa, value: va }, BoundKind::Destructure { pattern: pb, value: vb }) => {
|
||||
Rc::ptr_eq(pa, pb) && Rc::ptr_eq(va, vb)
|
||||
}
|
||||
(BoundKind::Lambda { params: pa, upvalues: ua, body: ba, positional_count: pca }, BoundKind::Lambda { params: pb, upvalues: ub, body: bb, positional_count: pcb }) => {
|
||||
Rc::ptr_eq(pa, pb) && ua == ub && Rc::ptr_eq(ba, bb) && pca == pcb
|
||||
}
|
||||
(BoundKind::Call { callee: ca, args: aa }, BoundKind::Call { callee: cb, args: ab }) => {
|
||||
Rc::ptr_eq(ca, cb) && Rc::ptr_eq(aa, ab)
|
||||
}
|
||||
(BoundKind::Again { args: aa }, BoundKind::Again { args: ab }) => Rc::ptr_eq(aa, ab),
|
||||
(BoundKind::Block { exprs: ea }, BoundKind::Block { exprs: eb }) => {
|
||||
ea.len() == eb.len() && ea.iter().zip(eb.iter()).all(|(a, b)| Rc::ptr_eq(a, b))
|
||||
}
|
||||
(BoundKind::Tuple { elements: ea }, BoundKind::Tuple { elements: eb }) => {
|
||||
ea.len() == eb.len() && ea.iter().zip(eb.iter()).all(|(a, b)| Rc::ptr_eq(a, b))
|
||||
}
|
||||
(BoundKind::Record { layout: la, values: va }, BoundKind::Record { layout: lb, values: vb }) => {
|
||||
std::sync::Arc::ptr_eq(la, lb) && va.len() == vb.len() && va.iter().zip(vb.iter()).all(|(a, b)| Rc::ptr_eq(a, b))
|
||||
}
|
||||
(BoundKind::Expansion { original_call: ca, bound_expanded: ea }, BoundKind::Expansion { original_call: cb, bound_expanded: eb }) => {
|
||||
Rc::ptr_eq(ca, cb) && Rc::ptr_eq(ea, eb)
|
||||
}
|
||||
(BoundKind::Error, BoundKind::Error) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<P: CompilerPhase> BoundKind<P> {
|
||||
pub fn display_name(&self) -> String {
|
||||
match self {
|
||||
BoundKind::Nop => "NOP".to_string(),
|
||||
BoundKind::Constant(v) => format!("CONST({})", v),
|
||||
BoundKind::Get { addr, name } => format!("GET({}, {:?})", name.name, addr),
|
||||
BoundKind::Set { addr, .. } => format!("SET({:?})", addr),
|
||||
BoundKind::Define { name, addr, kind, .. } => {
|
||||
let k_str = match kind {
|
||||
DeclarationKind::Variable => "VAR",
|
||||
DeclarationKind::Parameter => "PARAM",
|
||||
};
|
||||
format!("DEF_{}({}, {:?})", k_str, name.name, addr)
|
||||
}
|
||||
BoundKind::FieldAccessor(k) => format!("FIELD_ACCESSOR(.{})", k.name()),
|
||||
BoundKind::GetField { field, .. } => format!("GET_FIELD(.{})", field.name()),
|
||||
BoundKind::If { .. } => "IF".to_string(),
|
||||
BoundKind::Destructure { .. } => "DESTRUCTURE".to_string(),
|
||||
BoundKind::Lambda { params, upvalues, .. } => {
|
||||
let p_str = match ¶ms.kind {
|
||||
NodeKind::Tuple { elements } => format!("p:{}", elements.len()),
|
||||
_ => "p:1".to_string(),
|
||||
};
|
||||
format!("LAMBDA({}, Captures:{})", p_str, upvalues.len())
|
||||
}
|
||||
BoundKind::Call { .. } => "CALL".to_string(),
|
||||
BoundKind::Again { .. } => "AGAIN".to_string(),
|
||||
BoundKind::Pipe { .. } => "PIPE".to_string(),
|
||||
BoundKind::Block { .. } => "BLOCK".to_string(),
|
||||
BoundKind::Tuple { elements } => format!("TUPLE({})", elements.len()),
|
||||
BoundKind::Record { values, .. } => format!("RECORD({})", values.len()),
|
||||
BoundKind::Expansion { .. } => "EXPANSION".to_string(),
|
||||
BoundKind::Extension(ext) => ext.display_name(),
|
||||
BoundKind::Error => "ERROR".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── NodeKind<P>: Unified AST node kind ─────────────────────────────────────────
|
||||
|
||||
/// A key-value pair in a record literal: `(key_node, value_node)`.
|
||||
|
||||
Reference in New Issue
Block a user