@@ -59,6 +59,11 @@ use super::{
5959} ;
6060use crate :: types:: instance_definitions:: mod_instance_def:: ModInstanceDef ;
6161
62+ type ProcessBuiltinSegmentClosure < ' a > = Box <
63+ dyn FnMut ( usize , Option < usize > , BuiltinName ) -> Result < Option < ( usize , usize ) > , RunnerError >
64+ + ' a ,
65+ > ;
66+
6267#[ derive( Clone , Debug , Eq , PartialEq ) ]
6368pub enum CairoArg {
6469 Single ( MaybeRelocatable ) ,
@@ -1012,15 +1017,28 @@ impl CairoRunner {
10121017 // Returns a map from builtin base's segment index to stop_ptr offset
10131018 // Aka the builtin's segment number and its maximum offset
10141019 pub fn get_builtin_segments_info ( & self ) -> Result < Vec < ( usize , usize ) > , RunnerError > {
1015- let mut builtin_segment_info = Vec :: new ( ) ;
1020+ let proof_mode = self . is_proof_mode ( ) ;
1021+
1022+ // Closure to process each builtin's segment info based on whether we are in proof mode or not.
1023+ let mut process: ProcessBuiltinSegmentClosure < ' _ > = if proof_mode {
1024+ Box :: new ( |index, stop_ptr, _name| {
1025+ // proof‐mode: silently skip when None
1026+ Ok ( stop_ptr. map ( |sp| ( index, sp) ) )
1027+ } )
1028+ } else {
1029+ Box :: new ( |index, stop_ptr, name| {
1030+ // non proof‐mode: return error when None
1031+ let sp = stop_ptr. ok_or_else ( || RunnerError :: NoStopPointer ( Box :: new ( name) ) ) ?;
1032+ Ok ( Some ( ( index, sp) ) )
1033+ } )
1034+ } ;
10161035
1036+ let mut builtin_segment_info = Vec :: new ( ) ;
10171037 for builtin in & self . vm . builtin_runners {
10181038 let ( index, stop_ptr) = builtin. get_memory_segment_addresses ( ) ;
1019-
1020- builtin_segment_info. push ( (
1021- index,
1022- stop_ptr. ok_or_else ( || RunnerError :: NoStopPointer ( Box :: new ( builtin. name ( ) ) ) ) ?,
1023- ) ) ;
1039+ if let Some ( pair) = process ( index, stop_ptr, builtin. name ( ) ) ? {
1040+ builtin_segment_info. push ( pair) ;
1041+ }
10241042 }
10251043
10261044 Ok ( builtin_segment_info)
0 commit comments