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(); let mut runner = compilation_unit.with_virtual_machine(&mut vm).execute();
while runner.next().unwrap().is_none() { while runner.next().unwrap().is_none() {
let inner = compile("print(b)", Some(&compilation_unit)).unwrap(); // let inner = compile("print(b)", Some(&compilation_unit)).unwrap();
// let mut inner_runner = runner.execute(&inner);
runner.execute(&inner); // while {
while { // match inner_runner.next() {
match runner.next() { // Ok(Some(_)) => false,
Ok(Some(_)) => false, // Ok(None) => true,
Ok(None) => true, // Err(e) => {
Err(e) => { // println!("Error: {}", e);
print!("Error: {}", e); // false
false // }
} // }
} // } {}
} {}
} }
dbg!(&vm.get_globals()); dbg!(&vm.get_globals());

View File

@ -560,7 +560,7 @@ enum StackValue {
} }
impl ClosureRunner { 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) { if let Some(stack_slot) = self.stack.get_mut(&idx) {
match value { match value {
StackValue::Value(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); let value = self.stack.get(&idx);
if let Some(value) = value { if let Some(value) = value {
match &*value.borrow() { match &*value.borrow() {