diff options
| author | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-01-18 20:35:06 +0100 |
|---|---|---|
| committer | Edvard Thörnros <edvard.thornros@gmail.com> | 2021-01-18 20:35:06 +0100 |
| commit | e84d99376ba669c41b38a8750f0b4411ac5d57dc (patch) | |
| tree | 16f0bc0e2e32f1e16df9a7b4fab623a9439fd8b7 /src/lib.rs | |
| parent | c7fa3245f4b73e0699ccfc3d359d864247f62dcc (diff) | |
| download | sylt-e84d99376ba669c41b38a8750f0b4411ac5d57dc.tar.gz | |
Typecheck all blocks
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -21,10 +21,15 @@ pub fn run_string(s: &str, print: bool) -> Result<(), Vec<Error>> { pub fn run(tokens: TokenStream, path: &Path, print: bool) -> Result<(), Vec<Error>> { match compiler::compile("main", path, tokens) { - Ok(block) => - vm::VM::new().print_blocks(print) - .print_ops(print) - .run(Rc::new(block)).or_else(|e| Err(vec![e])), + Ok(blocks) => { + let mut vm = vm::VM::new().print_blocks(print).print_ops(print); + vm.typecheck(&blocks)?; + if let Err(e) = vm.run(Rc::clone(&blocks[0])) { + Err(vec![e]) + } else { + Ok(()) + } + } Err(errors) => Err(errors), } } |
