@@ -241,6 +241,10 @@ impl CairoRunnerBuilder {
241241 || self . runner_mode == RunnerMode :: ProofModeCairo1
242242 }
243243
244+ pub fn get_program_base ( & self ) -> Option < Relocatable > {
245+ self . program_base
246+ }
247+
244248 pub fn add_memory_segment ( & mut self ) -> Relocatable {
245249 self . memory . add ( )
246250 }
@@ -378,6 +382,41 @@ impl CairoRunnerBuilder {
378382 Ok ( ( ) )
379383 }
380384
385+ /// *Initializes* and *includes* all the given builtins.
386+ ///
387+ /// Doesn't take the current layout into account.
388+ pub fn initialize_builtin_runners (
389+ & mut self ,
390+ builtins : & [ BuiltinName ] ,
391+ ) -> Result < ( ) , RunnerError > {
392+ for builtin_name in builtins {
393+ let builtin_runner = match builtin_name {
394+ BuiltinName :: pedersen => HashBuiltinRunner :: new ( Some ( 32 ) , true ) . into ( ) ,
395+ BuiltinName :: range_check => {
396+ RangeCheckBuiltinRunner :: < RC_N_PARTS_STANDARD > :: new ( Some ( 1 ) , true ) . into ( )
397+ }
398+ BuiltinName :: output => OutputBuiltinRunner :: new ( true ) . into ( ) ,
399+ BuiltinName :: ecdsa => SignatureBuiltinRunner :: new ( Some ( 1 ) , true ) . into ( ) ,
400+ BuiltinName :: bitwise => BitwiseBuiltinRunner :: new ( Some ( 1 ) , true ) . into ( ) ,
401+ BuiltinName :: ec_op => EcOpBuiltinRunner :: new ( Some ( 1 ) , true ) . into ( ) ,
402+ BuiltinName :: keccak => KeccakBuiltinRunner :: new ( Some ( 1 ) , true ) . into ( ) ,
403+ BuiltinName :: poseidon => PoseidonBuiltinRunner :: new ( Some ( 1 ) , true ) . into ( ) ,
404+ BuiltinName :: segment_arena => SegmentArenaBuiltinRunner :: new ( true ) . into ( ) ,
405+ BuiltinName :: range_check96 => {
406+ RangeCheckBuiltinRunner :: < RC_N_PARTS_96 > :: new ( Some ( 1 ) , true ) . into ( )
407+ }
408+ BuiltinName :: add_mod => {
409+ ModBuiltinRunner :: new_add_mod ( & ModInstanceDef :: new ( Some ( 1 ) , 1 , 96 ) , true ) . into ( )
410+ }
411+ BuiltinName :: mul_mod => {
412+ ModBuiltinRunner :: new_mul_mod ( & ModInstanceDef :: new ( Some ( 1 ) , 1 , 96 ) , true ) . into ( )
413+ }
414+ } ;
415+ self . builtin_runners . push ( builtin_runner) ;
416+ }
417+ Ok ( ( ) )
418+ }
419+
381420 pub fn initialize_base_segments ( & mut self ) {
382421 self . program_base = Some ( self . add_memory_segment ( ) ) ;
383422 self . execution_base = Some ( self . add_memory_segment ( ) ) ;
@@ -412,6 +451,16 @@ impl CairoRunnerBuilder {
412451 Ok ( ( ) )
413452 }
414453
454+ /// Preallocates memory for `n` more elements in the given segment.
455+ pub fn preallocate_segment (
456+ & mut self ,
457+ segment : Relocatable ,
458+ n : usize ,
459+ ) -> Result < ( ) , RunnerError > {
460+ self . memory . memory . preallocate_segment ( segment, n) ?;
461+ Ok ( ( ) )
462+ }
463+
415464 /// Loads decoded program instructions.
416465 ///
417466 /// # Safety
0 commit comments