aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/lib.rs b/src/lib.rs
index fd9c094..8a139fc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -10,17 +10,20 @@ mod error;
use error::Error;
use tokenizer::TokenStream;
-pub fn run_file(path: &Path) -> Result<(), Vec<Error>> {
- run(tokenizer::file_to_tokens(path), path)
+pub fn run_file(path: &Path, print: bool) -> Result<(), Vec<Error>> {
+ run(tokenizer::file_to_tokens(path), path, print)
}
-pub fn run_string(s: &str) -> Result<(), Vec<Error>> {
- run(tokenizer::string_to_tokens(s), Path::new("builtin"))
+pub fn run_string(s: &str, print: bool) -> Result<(), Vec<Error>> {
+ run(tokenizer::string_to_tokens(s), Path::new("builtin"), print)
}
-pub fn run(tokens: TokenStream, path: &Path) -> Result<(), Vec<Error>> {
+pub fn run(tokens: TokenStream, path: &Path, print: bool) -> Result<(), Vec<Error>> {
match compiler::compile("main", path, tokens) {
- Ok(block) => vm::run_block(Rc::new(block)).or_else(|e| Err(vec![e])),
+ Ok(block) =>
+ vm::VM::new().print_blocks(print)
+ .print_ops(print)
+ .run(Rc::new(block)).or_else(|e| Err(vec![e])),
Err(errors) => Err(errors),
}
}
@@ -49,7 +52,7 @@ mod tests {
#[test]
fn unreachable_token() {
- assert_errs!(run_string("<!>\n"), [ErrorKind::Unreachable]);
+ assert_errs!(run_string("<!>\n", true), [ErrorKind::Unreachable]);
}
macro_rules! test_file {
@@ -57,7 +60,7 @@ mod tests {
#[test]
fn $fn() {
let file = Path::new($path);
- assert!(run_file(&file).is_ok());
+ assert!(run_file(&file, true).is_ok());
}
};
}