@@ -92,11 +92,10 @@ pub fn compile_to_low_level_bytecode(
9292 let mut hints = BTreeMap :: new ( ) ;
9393
9494 for ( label, pc) in label_to_pc. clone ( ) {
95- let pc_hints: & mut Vec < Hint > =
96- match hints. try_insert ( pc, vec ! [ ] ) {
97- Ok ( pc_hints) => pc_hints,
98- Err ( _) => hints. get_mut ( & pc) . unwrap ( ) ,
99- } ;
95+ let pc_hints: & mut Vec < Hint > = match hints. try_insert ( pc, vec ! [ ] ) {
96+ Ok ( pc_hints) => pc_hints,
97+ Err ( _) => hints. get_mut ( & pc) . unwrap ( ) ,
98+ } ;
10099 pc_hints. push ( Hint :: Label { label } ) ;
101100 }
102101
@@ -152,46 +151,43 @@ fn compile_block(
152151 _ => None ,
153152 } ;
154153
155- let codegen_jump =
156- |hints : & BTreeMap < CodeAddress , Vec < Hint > > ,
157- low_level_bytecode : & mut Vec < Instruction > ,
158- condition : IntermediateValue ,
159- dest : IntermediateValue ,
160- updated_fp : Option < IntermediateValue > | {
161- let dest = try_as_mem_or_constant ( & dest)
162- . expect ( "Fatal: Could not materialize jump destination" ) ;
163- let label =
164- match dest {
165- MemOrConstant :: Constant ( dest) => {
166- hints. get ( & usize:: try_from ( dest. as_canonical_u32 ( ) ) . unwrap ( ) )
167- . map ( |hints : & Vec < Hint > | hints. iter ( ) . find_map ( |x| {
168- match x {
169- Hint :: Label { label } => Some ( label) ,
170- _ => None ,
171- }
172- } ) )
173- . flatten ( )
174- . expect ( "Fatal: Unlabeled jump destination" )
175- . clone ( )
176- } ,
177- MemOrConstant :: MemoryAfterFp { offset } => {
178- if offset >= 0 {
179- format ! ( "fp+{offset}" )
180- } else {
181- format ! ( "fp-{offset}" )
182- }
183- } ,
184- } ;
185- let updated_fp = updated_fp
186- . map ( |fp| try_as_mem_or_fp ( & fp) . unwrap ( ) )
187- . unwrap_or ( MemOrFp :: Fp ) ;
188- low_level_bytecode. push ( Instruction :: Jump {
189- condition : try_as_mem_or_constant ( & condition) . unwrap ( ) ,
190- label,
191- dest,
192- updated_fp,
193- } ) ;
154+ let codegen_jump = |hints : & BTreeMap < CodeAddress , Vec < Hint > > ,
155+ low_level_bytecode : & mut Vec < Instruction > ,
156+ condition : IntermediateValue ,
157+ dest : IntermediateValue ,
158+ updated_fp : Option < IntermediateValue > | {
159+ let dest =
160+ try_as_mem_or_constant ( & dest) . expect ( "Fatal: Could not materialize jump destination" ) ;
161+ let label = match dest {
162+ MemOrConstant :: Constant ( dest) => hints
163+ . get ( & usize:: try_from ( dest. as_canonical_u32 ( ) ) . unwrap ( ) )
164+ . map ( |hints : & Vec < Hint > | {
165+ hints. iter ( ) . find_map ( |x| match x {
166+ Hint :: Label { label } => Some ( label) ,
167+ _ => None ,
168+ } )
169+ } )
170+ . flatten ( )
171+ . expect ( "Fatal: Unlabeled jump destination" )
172+ . clone ( ) ,
173+ MemOrConstant :: MemoryAfterFp { offset } => {
174+ if offset >= 0 {
175+ format ! ( "fp+{offset}" )
176+ } else {
177+ format ! ( "fp-{offset}" )
178+ }
179+ }
194180 } ;
181+ let updated_fp = updated_fp
182+ . map ( |fp| try_as_mem_or_fp ( & fp) . unwrap ( ) )
183+ . unwrap_or ( MemOrFp :: Fp ) ;
184+ low_level_bytecode. push ( Instruction :: Jump {
185+ condition : try_as_mem_or_constant ( & condition) . unwrap ( ) ,
186+ label,
187+ dest,
188+ updated_fp,
189+ } ) ;
190+ } ;
195191
196192 let mut pc = pc_start;
197193 for instruction in block {
@@ -266,11 +262,10 @@ fn compile_block(
266262 condition,
267263 dest,
268264 updated_fp,
269- } => {
270- codegen_jump ( hints, low_level_bytecode, condition, dest, updated_fp)
271- }
265+ } => codegen_jump ( hints, low_level_bytecode, condition, dest, updated_fp) ,
272266 IntermediateInstruction :: Jump { dest, updated_fp } => {
273- let one = IntermediateValue :: Constant ( ConstExpression :: Value ( ConstantValue :: Scalar ( 1 ) ) ) ;
267+ let one =
268+ IntermediateValue :: Constant ( ConstExpression :: Value ( ConstantValue :: Scalar ( 1 ) ) ) ;
274269 codegen_jump ( hints, low_level_bytecode, one, dest, updated_fp)
275270 }
276271 IntermediateInstruction :: Poseidon2_16 { arg_a, arg_b, res } => {
0 commit comments