Fixes to run the very first program: 5+7 -> 12

This commit is contained in:
Andrew Morris
2022-05-02 15:23:55 +10:00
parent 9af2274246
commit c798a36382
2 changed files with 2 additions and 9 deletions

View File

@@ -37,13 +37,6 @@ impl VirtualMachine {
while self.stack.len() > 0 {
self.step();
}
let a = VsNumber::from_f64(1_f64);
let b = VsString::from_str("2");
std::println!("a + b = {}", op_plus(&a, &b));
std::panic!("Not implemented");
}
pub fn new() -> VirtualMachine {

View File

@@ -35,8 +35,8 @@ impl VsValue for VsFunction {
fn push_frame(&self, vm: &mut VirtualMachine) -> bool {
let mut registers: Vec<Val> = Vec::with_capacity(self.register_count - 1);
for i in 0..(self.register_count - 1) {
registers[i] = VsUndefined::new();
for _ in 0..(self.register_count - 1) {
registers.push(VsUndefined::new());
}
vm.stack.push(StackFrame {