Fix some bugs

This commit is contained in:
Sofia 2026-03-17 22:26:02 +02:00
parent 80dfd74ee5
commit 0fda2c6d4b
2 changed files with 14 additions and 15 deletions

View File

@ -47,19 +47,18 @@ fn main() {
let mut runner = compilation_unit.with_virtual_machine(&mut vm).execute();
while runner.next().unwrap().is_none() {
let inner = compile("print(b)", Some(&compilation_unit)).unwrap();
runner.execute(&inner);
while {
match runner.next() {
Ok(Some(_)) => false,
Ok(None) => true,
Err(e) => {
print!("Error: {}", e);
false
}
}
} {}
// let inner = compile("print(b)", Some(&compilation_unit)).unwrap();
// let mut inner_runner = runner.execute(&inner);
// while {
// match inner_runner.next() {
// Ok(Some(_)) => false,
// Ok(None) => true,
// Err(e) => {
// println!("Error: {}", e);
// false
// }
// }
// } {}
}
dbg!(&vm.get_globals());

View File

@ -560,7 +560,7 @@ enum StackValue {
}
impl ClosureRunner {
pub fn set_stack(&mut self, idx: u16, value: StackValue) {
fn set_stack(&mut self, idx: u16, value: StackValue) {
if let Some(stack_slot) = self.stack.get_mut(&idx) {
match value {
StackValue::Value(value) => {
@ -580,7 +580,7 @@ impl ClosureRunner {
}
}
pub fn get_stack(&mut self, idx: u16) -> StackValue {
fn get_stack(&mut self, idx: u16) -> StackValue {
let value = self.stack.get(&idx);
if let Some(value) = value {
match &*value.borrow() {