@@ -11,6 +11,7 @@ use crate::{
1111 stdlib:: collections:: { BTreeMap , HashMap , HashSet } ,
1212 types:: {
1313 builtin_name:: BuiltinName ,
14+ exec_scope:: ExecutionScopes ,
1415 layout:: CairoLayout ,
1516 program:: HintsCollection ,
1617 relocatable:: { MaybeRelocatable , Relocatable } ,
@@ -36,6 +37,7 @@ pub struct CairoRunner2 {
3637 program_base : Relocatable ,
3738 execution_base : Relocatable ,
3839 final_pc : Relocatable ,
40+ execution_scopes : ExecutionScopes ,
3941
4042 // Configuration
4143 executable : Executable ,
@@ -133,6 +135,7 @@ impl CairoRunner2 {
133135 program_base,
134136 execution_base,
135137 final_pc,
138+ execution_scopes : ExecutionScopes :: new ( ) ,
136139 entrypoint_kind,
137140 layout,
138141 trace_enabled,
@@ -149,14 +152,43 @@ impl CairoRunner2 {
149152 & mut self ,
150153 hint_processor : & mut dyn HintProcessor ,
151154 ) -> Result < ( ) , VirtualMachineError > {
152- #[ allow( unused_mut) ]
155+ #[ cfg_attr ( not ( feature = "extensive_hints" ) , allow( unused_mut) ) ]
153156 let mut hint_data = get_hint_data (
154157 & self . hint_collection ,
155158 & self . reference_manager ,
156159 hint_processor,
157160 ) ?;
158161
159- let _ = hint_data;
162+ #[ cfg( feature = "extensive_hints" ) ]
163+ let mut hint_ranges = self . hint_collection . hints_ranges . clone ( ) ;
164+
165+ while self . vm . get_pc ( ) != self . final_pc && !hint_processor. consumed ( ) {
166+ #[ cfg( feature = "extensive_hints" ) ]
167+ let hint_data = & mut hint_data;
168+ #[ cfg( not( feature = "extensive_hints" ) ) ]
169+ let hint_data = self
170+ . hint_collection
171+ . get_hint_range_for_pc ( self . vm . get_pc ( ) . offset )
172+ . and_then ( |range| {
173+ range. and_then ( |( start, length) | hint_data. get ( start..start + length. get ( ) ) )
174+ } )
175+ . unwrap_or ( & [ ] ) ;
176+
177+ self . vm . step (
178+ hint_processor,
179+ & mut self . execution_scopes ,
180+ hint_data,
181+ #[ cfg( feature = "extensive_hints" ) ]
182+ & mut hint_ranges,
183+ & self . constants ,
184+ ) ?;
185+
186+ hint_processor. consume_step ( ) ;
187+ }
188+
189+ if self . vm . get_pc ( ) != self . final_pc {
190+ return Err ( VirtualMachineError :: UnfinishedExecution ) ;
191+ }
160192
161193 Ok ( ( ) )
162194 }
0 commit comments