diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-02-28 17:24:01 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-02-28 17:24:01 +0100 |
| commit | 89bdd138aa5e0843d57fc847cb4026220c06209e (patch) | |
| tree | 40a67ada0504d0e4066eb7c8f9829514053d54a9 /src | |
| parent | c3e1e3bcbb177a5cbdb972389626e8c7347cbfc2 (diff) | |
| download | sylt-89bdd138aa5e0843d57fc847cb4026220c06209e.tar.gz | |
uncomment missed function
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib.rs | 35 |
1 files changed, 18 insertions, 17 deletions
@@ -21,23 +21,24 @@ mod tokenizer; /// Compiles a file and links the supplied functions as callable external /// functions. Use this if you want your programs to be able to yield. -//pub fn compile_file( -// path: &Path, -// print: bool, -// functions: Vec<(String, RustFunction)> -//) -> Result<vm::VM, Vec<Error>> { -// match compiler::Compiler::new(path).compile("main", path, &functions) { -// Ok(prog) => { -// let mut vm = vm::VM::new(); -// vm.print_blocks = print; -// vm.print_ops = print; -// vm.typecheck(&prog)?; -// vm.init(&prog); -// Ok(vm) -// } -// Err(errors) => Err(errors), -// } -//} +pub fn compile_file( + path: &Path, + print: bool, + functions: Vec<(String, RustFunction)> +) -> Result<vm::VM, Vec<Error>> { + let sections = sectionizer::sectionize(path); + match compiler::Compiler::new(sections).compile("main", path, &functions) { + Ok(prog) => { + let mut vm = vm::VM::new(); + vm.print_blocks = print; + vm.print_ops = print; + vm.typecheck(&prog)?; + vm.init(&prog); + Ok(vm) + } + Err(errors) => Err(errors), + } +} /// Compiles, links and runs the given file. Supplied functions are callable /// external functions. If you want your program to be able to yield, use |
