diff --git a/crates/cairo-lang-compiler/src/project.rs b/crates/cairo-lang-compiler/src/project.rs index e87f0eec2c3..d59fe28f514 100644 --- a/crates/cairo-lang-compiler/src/project.rs +++ b/crates/cairo-lang-compiler/src/project.rs @@ -22,7 +22,7 @@ pub enum ProjectError { /// Setup to 'db' to compile the file at the given path. /// Returns the id of the generated crate. -fn setup_single_file_project( +pub fn setup_single_file_project( db: &mut dyn SemanticGroup, path: &Path, ) -> Result { diff --git a/crates/cairo-lang-runner/src/casm_run/mod.rs b/crates/cairo-lang-runner/src/casm_run/mod.rs index 1a6d93aa0fe..41a613f0be7 100644 --- a/crates/cairo-lang-runner/src/casm_run/mod.rs +++ b/crates/cairo-lang-runner/src/casm_run/mod.rs @@ -224,7 +224,7 @@ fn get_double_deref_maybe( } /// Extracts a parameter assumed to be a buffer, and converts it into a relocatable. -fn extract_relocatable( +pub fn extract_relocatable( vm: &VirtualMachine, buffer: &ResOperand, ) -> Result { @@ -383,7 +383,7 @@ impl ResourceTracker for CairoHintProcessor<'_> { } /// Wrapper trait for a VM owner. -trait VMWrapper { +pub trait VMWrapper { fn vm(&mut self) -> &mut VirtualMachine; } impl VMWrapper for VirtualMachine { @@ -405,7 +405,7 @@ fn segment_with_data, Data: Iterator>( } /// A helper struct to continuously write and read from a buffer in the VM memory. -struct MemBuffer<'a> { +pub struct MemBuffer<'a> { /// The VM to write to. /// This is a trait so that we would borrow the actual VM only once. vm: &'a mut dyn VMWrapper, @@ -414,12 +414,12 @@ struct MemBuffer<'a> { } impl<'a> MemBuffer<'a> { /// Creates a new buffer. - fn new(vm: &'a mut dyn VMWrapper, ptr: Relocatable) -> Self { + pub fn new(vm: &'a mut dyn VMWrapper, ptr: Relocatable) -> Self { Self { vm, ptr } } /// Creates a new segment and returns a buffer wrapping it. - fn new_segment(vm: &'a mut dyn VMWrapper) -> Self { + pub fn new_segment(vm: &'a mut dyn VMWrapper) -> Self { let ptr = vm.vm().add_memory_segment(); Self::new(vm, ptr) } @@ -434,7 +434,7 @@ impl<'a> MemBuffer<'a> { /// Returns the felt252 value in the current position of the buffer and advances it by one. /// Fails if the value is not a felt252. /// Borrows the buffer since a reference is returned. - fn next_felt252(&mut self) -> Result, MemoryError> { + pub fn next_felt252(&mut self) -> Result, MemoryError> { let ptr = self.next(); self.vm.vm().get_integer(ptr) } @@ -442,21 +442,21 @@ impl<'a> MemBuffer<'a> { /// Returns the usize value in the current position of the buffer and advances it by one. /// Fails with `MemoryError` if the value is not a felt252. /// Panics if the value is not a usize. - fn next_usize(&mut self) -> Result { + pub fn next_usize(&mut self) -> Result { Ok(self.next_felt252()?.to_usize().unwrap()) } /// Returns the u128 value in the current position of the buffer and advances it by one. /// Fails with `MemoryError` if the value is not a felt252. /// Panics if the value is not a u128. - fn next_u128(&mut self) -> Result { + pub fn next_u128(&mut self) -> Result { Ok(self.next_felt252()?.to_u128().unwrap()) } /// Returns the u64 value in the current position of the buffer and advances it by one. /// Fails with `MemoryError` if the value is not a felt252. /// Panics if the value is not a u64. - fn next_u64(&mut self) -> Result { + pub fn next_u64(&mut self) -> Result { Ok(self.next_felt252()?.to_u64().unwrap()) } @@ -464,13 +464,13 @@ impl<'a> MemBuffer<'a> { /// it by two. /// Fails with `MemoryError` if any of the next two values are not felt252s. /// Panics if any of the next two values are not u128. - fn next_u256(&mut self) -> Result { + pub fn next_u256(&mut self) -> Result { Ok(self.next_u128()? + BigUint::from(self.next_u128()?).shl(128)) } /// Returns the address value in the current position of the buffer and advances it by one. /// Fails if the value is not an address. - fn next_addr(&mut self) -> Result { + pub fn next_addr(&mut self) -> Result { let ptr = self.next(); self.vm.vm().get_relocatable(ptr) } @@ -478,20 +478,20 @@ impl<'a> MemBuffer<'a> { /// Returns the array of integer values pointed to by the two next addresses in the buffer and /// advances it by two. Will fail if the two values are not addresses or if the addresses do /// not point to an array of integers. - fn next_arr(&mut self) -> Result, HintError> { + pub fn next_arr(&mut self) -> Result, HintError> { let start = self.next_addr()?; let end = self.next_addr()?; vm_get_range(self.vm.vm(), start, end) } /// Writes a value to the current position of the buffer and advances it by one. - fn write>(&mut self, value: T) -> Result<(), MemoryError> { + pub fn write>(&mut self, value: T) -> Result<(), MemoryError> { let ptr = self.next(); self.vm.vm().insert_value(ptr, value) } /// Writes an iterator of values starting from the current position of the buffer and advances /// it to after the end of the written value. - fn write_data, Data: Iterator>( + pub fn write_data, Data: Iterator>( &mut self, data: Data, ) -> Result<(), MemoryError> { @@ -503,7 +503,7 @@ impl<'a> MemBuffer<'a> { /// Writes an array into a new segment and writes the start and end pointers to the current /// position of the buffer. Advances the buffer by two. - fn write_arr, Data: Iterator>( + pub fn write_arr, Data: Iterator>( &mut self, data: Data, ) -> Result<(), MemoryError> { @@ -1831,7 +1831,7 @@ fn read_array_result_as_vec(memory: &[Option], value: &[Felt252]) -> Ve } /// Loads a range of values from the VM memory. -fn vm_get_range( +pub fn vm_get_range( vm: &mut VirtualMachine, mut calldata_start_ptr: Relocatable, calldata_end_ptr: Relocatable, @@ -1846,7 +1846,7 @@ fn vm_get_range( } /// Extracts a parameter assumed to be a buffer. -fn extract_buffer(buffer: &ResOperand) -> (&CellRef, Felt252) { +pub fn extract_buffer(buffer: &ResOperand) -> (&CellRef, Felt252) { let (cell, base_offset) = match buffer { ResOperand::Deref(cell) => (cell, 0.into()), ResOperand::BinOp(BinOpOperand { op: Operation::Add, a, b }) => {