1
Fork 0

points the user away from the Allocation type and towards the Memory type

This commit is contained in:
Ralf Jung 2019-10-20 14:57:21 +02:00
parent 50ddcbb2f5
commit d4b365429d

View file

@ -245,6 +245,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
/// as a slice. /// as a slice.
/// ///
/// It is the caller's responsibility to check bounds and alignment beforehand. /// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to use the `PlaceTy` and `OperandTy`-based methods
/// on `InterpCx` instead.
#[inline] #[inline]
pub fn get_bytes( pub fn get_bytes(
&self, &self,
@ -275,6 +277,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
/// so be sure to actually put data there! /// so be sure to actually put data there!
/// ///
/// It is the caller's responsibility to check bounds and alignment beforehand. /// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to use the `PlaceTy` and `OperandTy`-based methods
/// on `InterpCx` instead.
pub fn get_bytes_mut( pub fn get_bytes_mut(
&mut self, &mut self,
cx: &impl HasDataLayout, cx: &impl HasDataLayout,
@ -297,6 +301,8 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> { impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
/// Reads bytes until a `0` is encountered. Will error if the end of the allocation is reached /// Reads bytes until a `0` is encountered. Will error if the end of the allocation is reached
/// before a `0` is found. /// before a `0` is found.
///
/// Most likely, you want to call `Memory::read_c_str` instead of this method.
pub fn read_c_str( pub fn read_c_str(
&self, &self,
cx: &impl HasDataLayout, cx: &impl HasDataLayout,
@ -342,6 +348,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
/// Writes `src` to the memory starting at `ptr.offset`. /// Writes `src` to the memory starting at `ptr.offset`.
/// ///
/// It is the caller's responsibility to check bounds and alignment beforehand. /// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to call `Memory::write_bytes` instead of this method.
pub fn write_bytes( pub fn write_bytes(
&mut self, &mut self,
cx: &impl HasDataLayout, cx: &impl HasDataLayout,
@ -363,6 +370,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
/// Sets `count` bytes starting at `ptr.offset` with `val`. Basically `memset`. /// Sets `count` bytes starting at `ptr.offset` with `val`. Basically `memset`.
/// ///
/// It is the caller's responsibility to check bounds and alignment beforehand. /// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to call `Memory::write_bytes` instead of this method.
pub fn write_repeat( pub fn write_repeat(
&mut self, &mut self,
cx: &impl HasDataLayout, cx: &impl HasDataLayout,
@ -386,6 +394,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
/// pointers being valid for ZSTs. /// pointers being valid for ZSTs.
/// ///
/// It is the caller's responsibility to check bounds and alignment beforehand. /// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to call `InterpCx::read_scalar` instead of this method.
pub fn read_scalar( pub fn read_scalar(
&self, &self,
cx: &impl HasDataLayout, cx: &impl HasDataLayout,
@ -424,6 +433,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
/// Reads a pointer-sized scalar. /// Reads a pointer-sized scalar.
/// ///
/// It is the caller's responsibility to check bounds and alignment beforehand. /// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to call `InterpCx::read_scalar` instead of this method.
pub fn read_ptr_sized( pub fn read_ptr_sized(
&self, &self,
cx: &impl HasDataLayout, cx: &impl HasDataLayout,
@ -441,6 +451,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
/// pointers being valid for ZSTs. /// pointers being valid for ZSTs.
/// ///
/// It is the caller's responsibility to check bounds and alignment beforehand. /// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to call `InterpCx::write_scalar` instead of this method.
pub fn write_scalar( pub fn write_scalar(
&mut self, &mut self,
cx: &impl HasDataLayout, cx: &impl HasDataLayout,
@ -483,6 +494,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra<Tag>> Allocation<Tag, Extra> {
/// Writes a pointer-sized scalar. /// Writes a pointer-sized scalar.
/// ///
/// It is the caller's responsibility to check bounds and alignment beforehand. /// It is the caller's responsibility to check bounds and alignment beforehand.
/// Most likely, you want to call `InterpCx::write_scalar` instead of this method.
pub fn write_ptr_sized( pub fn write_ptr_sized(
&mut self, &mut self,
cx: &impl HasDataLayout, cx: &impl HasDataLayout,