|
| 1 | +use core::any::Any; |
| 2 | + |
1 | 3 | use cairo_lang_casm::hints::Hint; |
2 | 4 | use cairo_lang_executable::executable::{EntryPointKind, Executable, ExecutableEntryPoint}; |
3 | 5 |
|
@@ -145,8 +147,17 @@ impl CairoRunner2 { |
145 | 147 |
|
146 | 148 | pub fn run( |
147 | 149 | &mut self, |
148 | | - _hint_processor: &mut dyn HintProcessor, |
| 150 | + hint_processor: &mut dyn HintProcessor, |
149 | 151 | ) -> Result<(), VirtualMachineError> { |
| 152 | + #[allow(unused_mut)] |
| 153 | + let mut hint_data = get_hint_data( |
| 154 | + &self.hint_collection, |
| 155 | + &self.reference_manager, |
| 156 | + hint_processor, |
| 157 | + )?; |
| 158 | + |
| 159 | + let _ = hint_data; |
| 160 | + |
150 | 161 | Ok(()) |
151 | 162 | } |
152 | 163 | } |
@@ -325,6 +336,26 @@ fn extend_stack_with_builtins( |
325 | 336 | } |
326 | 337 | } |
327 | 338 |
|
| 339 | +fn get_hint_data( |
| 340 | + collection: &HintsCollection, |
| 341 | + references: &[HintReference], |
| 342 | + processor: &dyn HintProcessor, |
| 343 | +) -> Result<Vec<Box<dyn Any>>, VirtualMachineError> { |
| 344 | + collection |
| 345 | + .iter_hints() |
| 346 | + .map(|hint| { |
| 347 | + processor |
| 348 | + .compile_hint( |
| 349 | + &hint.code, |
| 350 | + &hint.flow_tracking_data.ap_tracking, |
| 351 | + &hint.flow_tracking_data.reference_ids, |
| 352 | + references, |
| 353 | + ) |
| 354 | + .map_err(|_| VirtualMachineError::CompileHintFail(hint.code.clone().into())) |
| 355 | + }) |
| 356 | + .collect() |
| 357 | +} |
| 358 | + |
328 | 359 | /// TODO: Remove this once cyclic dependency is fixed. |
329 | 360 | /// It should not be necessary, but cargo treats executable BuiltinName as a separate type |
330 | 361 | /// which is why I had to create this adapter function. |
|
0 commit comments