Skip to content

Commit c2d3dbb

Browse files
committed
Merge branch 'faster_witness_gen'
2 parents 5d48c2e + 88b3683 commit c2d3dbb

File tree

24 files changed

+626
-269
lines changed

24 files changed

+626
-269
lines changed

Cargo.lock

Lines changed: 20 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/lean_compiler/src/c_compile_final.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ struct Compiler {
3636

3737
pub fn compile_to_low_level_bytecode(
3838
mut intermediate_bytecode: IntermediateBytecode,
39+
program: String,
40+
function_locations: BTreeMap<usize, String>,
3941
) -> Result<Bytecode, String> {
4042
intermediate_bytecode.bytecode.insert(
4143
Label::EndProgram,
@@ -121,6 +123,8 @@ pub fn compile_to_low_level_bytecode(
121123
hints,
122124
starting_frame_memory,
123125
ending_pc,
126+
program,
127+
function_locations,
124128
})
125129
}
126130

crates/lean_compiler/src/lib.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
use std::collections::BTreeMap;
2-
31
use lean_vm::*;
42

53
use crate::{
@@ -16,38 +14,35 @@ mod parser;
1614
mod precompiles;
1715
pub 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

3533
pub 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

Comments
 (0)