Refactor: Use generic Define bound kind
This commit consolidates `DefLocal` and `DefGlobal` into a single `Define` bound kind. This simplifies the AST and makes it more consistent. It also introduces `DeclarationKind` to differentiate between variable and parameter definitions.
This commit is contained in:
+6
-17
@@ -98,26 +98,19 @@ impl TCO {
|
||||
addr: *addr,
|
||||
value: Box::new(Self::transform(Rc::new((**value).clone()), false)),
|
||||
},
|
||||
BoundKind::DefLocal {
|
||||
BoundKind::Define {
|
||||
name,
|
||||
slot,
|
||||
addr,
|
||||
kind,
|
||||
value,
|
||||
captured_by,
|
||||
} => BoundKind::DefLocal {
|
||||
} => BoundKind::Define {
|
||||
name: name.clone(),
|
||||
slot: *slot,
|
||||
addr: *addr,
|
||||
kind: *kind,
|
||||
value: Box::new(Self::transform(Rc::new((**value).clone()), false)),
|
||||
captured_by: captured_by.clone(),
|
||||
},
|
||||
BoundKind::DefGlobal {
|
||||
name,
|
||||
global_index,
|
||||
value,
|
||||
} => BoundKind::DefGlobal {
|
||||
name: name.clone(),
|
||||
global_index: *global_index,
|
||||
value: Box::new(Self::transform(Rc::new((**value).clone()), false)),
|
||||
},
|
||||
BoundKind::Destructure { pattern, value } => BoundKind::Destructure {
|
||||
pattern: Box::new(Self::transform(Rc::new((**pattern).clone()), false)),
|
||||
value: Box::new(Self::transform(Rc::new((**value).clone()), false)),
|
||||
@@ -143,10 +136,6 @@ impl TCO {
|
||||
elements: new_elements,
|
||||
}
|
||||
}
|
||||
BoundKind::Parameter { name, slot } => BoundKind::Parameter {
|
||||
name: name.clone(),
|
||||
slot: *slot,
|
||||
},
|
||||
BoundKind::Constant(v) => BoundKind::Constant(v.clone()),
|
||||
BoundKind::Get { addr, name } => BoundKind::Get {
|
||||
addr: *addr,
|
||||
|
||||
Reference in New Issue
Block a user