Skip to content

Commit 9a56148

Browse files
Build hint data
1 parent 3278f2f commit 9a56148

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

vm/src/vm/runners/cairo_runner_2.rs

+32-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use core::any::Any;
2+
13
use cairo_lang_casm::hints::Hint;
24
use cairo_lang_executable::executable::{EntryPointKind, Executable, ExecutableEntryPoint};
35

@@ -145,8 +147,17 @@ impl CairoRunner2 {
145147

146148
pub fn run(
147149
&mut self,
148-
_hint_processor: &mut dyn HintProcessor,
150+
hint_processor: &mut dyn HintProcessor,
149151
) -> 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+
150161
Ok(())
151162
}
152163
}
@@ -325,6 +336,26 @@ fn extend_stack_with_builtins(
325336
}
326337
}
327338

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+
328359
/// TODO: Remove this once cyclic dependency is fixed.
329360
/// It should not be necessary, but cargo treats executable BuiltinName as a separate type
330361
/// which is why I had to create this adapter function.

0 commit comments

Comments
 (0)