From 92075e6bc23d63d62e2d0caf83acbf81ad0ccd99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edvard=20Th=C3=B6rnros?= Date: Thu, 28 Jan 2021 20:16:08 +0100 Subject: Pass blobs all the way --- src/vm.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/vm.rs') diff --git a/src/vm.rs b/src/vm.rs index 5f7e0e3..cb30704 100644 --- a/src/vm.rs +++ b/src/vm.rs @@ -8,6 +8,7 @@ use std::cell::RefCell; use crate::compiler::Type; use crate::error::{Error, ErrorKind}; +use crate::compiler::{Prog, Blob}; macro_rules! error { ( $thing:expr, $kind:expr) => { @@ -276,6 +277,9 @@ pub struct VM { stack: Vec, frames: Vec, + + blobs: Vec>, + print_blocks: bool, print_ops: bool, } @@ -291,6 +295,7 @@ impl VM { upvalues: HashMap::new(), stack: Vec::new(), frames: Vec::new(), + blobs: Vec::new(), print_blocks: false, print_ops: false, } @@ -620,7 +625,9 @@ impl VM { self.frame().block.borrow().ops[self.frame().ip]); } - pub fn run(&mut self, block: Rc>) -> Result<(), Error>{ + pub fn run(&mut self, prog: &Prog) -> Result<(), Error>{ + let block = Rc::clone(&prog.blocks[0]); + self.blobs = prog.blobs.clone(); self.stack.clear(); self.frames.clear(); @@ -834,10 +841,10 @@ impl VM { errors } - pub fn typecheck(&mut self, blocks: &Vec>>) -> Result<(), Vec> { + pub fn typecheck(&mut self, prog: &Prog) -> Result<(), Vec> { let mut errors = Vec::new(); - for block in blocks.iter() { + for block in prog.blocks.iter() { errors.append(&mut self.typecheck_block(Rc::clone(block))); } -- cgit v1.2.1