Add symbol name to bound kinds
The `Get`, `DefLocal`, and `DefGlobal` bound kinds now store the symbol name associated with the variable. This information is useful for debugging and provides more context in the compiled output.
This commit is contained in:
+6
-6
@@ -102,7 +102,7 @@ macro_rules! dispatch_eval {
|
||||
BoundKind::Nop => Ok(Value::Void),
|
||||
BoundKind::Constant(v) => Ok(v.clone()),
|
||||
|
||||
BoundKind::DefGlobal { global_index, value } => {
|
||||
BoundKind::DefGlobal { global_index, value, .. } => {
|
||||
let val = $self.$eval_method($($observer,)? value)?;
|
||||
let idx = *global_index as usize;
|
||||
let mut globals = $self.globals.borrow_mut();
|
||||
@@ -113,7 +113,7 @@ macro_rules! dispatch_eval {
|
||||
Ok(val)
|
||||
},
|
||||
|
||||
BoundKind::Get(addr) => $self.get_value(*addr),
|
||||
BoundKind::Get { addr, .. } => $self.get_value(*addr),
|
||||
|
||||
BoundKind::Set { addr, value } => {
|
||||
let val = $self.$eval_method($($observer,)? value)?;
|
||||
@@ -121,7 +121,7 @@ macro_rules! dispatch_eval {
|
||||
Ok(val)
|
||||
},
|
||||
|
||||
BoundKind::DefLocal { slot, value, captured_by } => {
|
||||
BoundKind::DefLocal { slot, value, captured_by, .. } => {
|
||||
let val = $self.$eval_method($($observer,)? value)?;
|
||||
let final_val = if !captured_by.is_empty() {
|
||||
Value::Cell(Rc::new(RefCell::new(val)))
|
||||
@@ -454,7 +454,7 @@ impl VM {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::ast::nodes::Node;
|
||||
use crate::ast::nodes::{Node, Symbol};
|
||||
use crate::ast::types::{SourceLocation, NodeIdentity, StaticType};
|
||||
|
||||
fn make_dummy_identity() -> Rc<NodeIdentity> {
|
||||
@@ -531,7 +531,7 @@ mod tests {
|
||||
callee: Box::new(Node {
|
||||
identity: id.clone(),
|
||||
ty: StaticType::Any,
|
||||
kind: BoundKind::Get(Address::Local(1)),
|
||||
kind: BoundKind::Get { addr: Address::Local(1), name: Symbol::from("f") },
|
||||
}),
|
||||
args: vec![],
|
||||
},
|
||||
@@ -540,7 +540,7 @@ mod tests {
|
||||
Node {
|
||||
identity: id.clone(),
|
||||
ty: StaticType::Int,
|
||||
kind: BoundKind::Get(Address::Local(0)),
|
||||
kind: BoundKind::Get { addr: Address::Local(0), name: Symbol::from("x") },
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user