@@ -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,44 @@ 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+             // TODO: EXPLAIN THIS 
167+             #[ cfg( feature = "extensive_hints" ) ]  
168+             let  hint_data = & mut  hint_data; 
169+             #[ cfg( not( feature = "extensive_hints" ) ) ]  
170+             let  hint_data = self 
171+                 . hint_collection 
172+                 . get_hint_range_for_pc ( self . vm . get_pc ( ) . offset ) 
173+                 . and_then ( |range| { 
174+                     range. and_then ( |( start,  length) | hint_data. get ( start..start + length. get ( ) ) ) 
175+                 } ) 
176+                 . unwrap_or ( & [ ] ) ; 
177+ 
178+             self . vm . step ( 
179+                 hint_processor, 
180+                 & mut  self . execution_scopes , 
181+                 hint_data, 
182+                 #[ cfg( feature = "extensive_hints" ) ]  
183+                 & mut  hint_ranges, 
184+                 & self . constants , 
185+             ) ?; 
186+ 
187+             hint_processor. consume_step ( ) ; 
188+         } 
189+ 
190+         if  self . vm . get_pc ( )  != self . final_pc  { 
191+             return  Err ( VirtualMachineError :: UnfinishedExecution ) ; 
192+         } 
160193
161194        Ok ( ( ) ) 
162195    } 
0 commit comments