From 89bdd138aa5e0843d57fc847cb4026220c06209e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Sun, 28 Feb 2021 17:24:01 +0100 Subject: uncomment missed function --- src/lib.rs | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index 5542d17..629d39f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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> { -// 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> { + 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 -- cgit v1.2.1