1- use std:: collections:: BTreeMap ;
2-
31use lean_vm:: * ;
42
53use crate :: {
@@ -16,38 +14,35 @@ mod parser;
1614mod precompiles;
1715pub use precompiles:: PRECOMPILES ;
1816
19- pub fn compile_program ( program : & str ) -> ( Bytecode , BTreeMap < usize , String > ) {
20- let ( parsed_program, function_locations) = parse_program ( program) . unwrap ( ) ;
17+ pub fn compile_program ( program : String ) -> Bytecode {
18+ let ( parsed_program, function_locations) = parse_program ( & program) . unwrap ( ) ;
2119 // println!("Parsed program: {}", parsed_program.to_string());
2220 let simple_program = simplify_program ( parsed_program) ;
2321 // println!("Simplified program: {}", simple_program.to_string());
2422 let intermediate_bytecode = compile_to_intermediate_bytecode ( simple_program) . unwrap ( ) ;
2523 // println!("Intermediate Bytecode:\n\n{}", intermediate_bytecode.to_string());
26- let compiled = compile_to_low_level_bytecode ( intermediate_bytecode ) . unwrap ( ) ;
24+
2725 // println!("Function Locations: \n");
2826 // for (loc, name) in function_locations.iter() {
2927 // println!("{name}: {loc}");
3028 // }
3129 // println!("\n\nCompiled Program:\n\n{compiled}");
32- ( compiled , function_locations)
30+ compile_to_low_level_bytecode ( intermediate_bytecode , program , function_locations) . unwrap ( )
3331}
3432
3533pub fn compile_and_run (
36- program : & str ,
37- public_input : & [ F ] ,
38- private_input : & [ F ] ,
34+ program : String ,
35+ ( public_input, private_input) : ( & [ F ] , & [ F ] ) ,
3936 no_vec_runtime_memory : usize , // size of the "non-vectorized" runtime memory
4037 profiler : bool ,
4138) {
42- let ( bytecode, function_locations ) = compile_program ( program) ;
39+ let bytecode = compile_program ( program) ;
4340 execute_bytecode (
4441 & bytecode,
45- public_input,
46- private_input,
47- program,
48- & function_locations,
42+ ( public_input, private_input) ,
4943 no_vec_runtime_memory,
5044 ( profiler, true ) ,
45+ ( & vec ! [ ] , & vec ! [ ] ) ,
5146 ) ;
5247}
5348
0 commit comments