(
&mut self,
addr: Address,
v: DataValue,
mem_flags: MemFlagsData,
)
| 355 | } |
| 356 | |
| 357 | fn checked_store( |
| 358 | &mut self, |
| 359 | addr: Address, |
| 360 | v: DataValue, |
| 361 | mem_flags: MemFlagsData, |
| 362 | ) -> Result<(), MemoryError> { |
| 363 | let store_size = v.ty().bytes() as usize; |
| 364 | let addr_start = addr.offset as usize; |
| 365 | let addr_end = addr_start + store_size; |
| 366 | |
| 367 | let dst = match addr.region { |
| 368 | AddressRegion::Stack => { |
| 369 | if addr_end > self.stack.len() { |
| 370 | return Err(MemoryError::OutOfBoundsStore { |
| 371 | addr, |
| 372 | store_size, |
| 373 | mem_flags, |
| 374 | }); |
| 375 | } |
| 376 | |
| 377 | &mut self.stack[addr_start..addr_end] |
| 378 | } |
| 379 | _ => unimplemented!(), |
| 380 | }; |
| 381 | |
| 382 | // Aligned flag is set and address is not aligned for the given type |
| 383 | if mem_flags.aligned() && addr_start % store_size != 0 { |
| 384 | return Err(MemoryError::MisalignedStore { addr, store_size }); |
| 385 | } |
| 386 | |
| 387 | Ok(match mem_flags.endianness(self.native_endianness) { |
| 388 | Endianness::Big => v.write_to_slice_be(dst), |
| 389 | Endianness::Little => v.write_to_slice_le(dst), |
| 390 | }) |
| 391 | } |
| 392 | |
| 393 | fn function_address( |
| 394 | &self, |
no test coverage detected