Skip to content

Commit

Permalink
Ugly commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
vakaras committed Jan 27, 2023
1 parent 87152d6 commit b79f7db
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions prusti-contracts/prusti-contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ mod private {
/// not allow it. It should not be possible to construct from Rust code,
/// hence the private unit inside.
pub struct Lifetime(());

/// A methematical type representing a machine byte.
pub struct Byte(());

/// A methematical type representing a sequence of machine bytes.
pub struct Bytes(());
}

#[cfg(feature = "prusti")]
Expand Down Expand Up @@ -374,6 +380,14 @@ mod private {
panic!()
}
}

/// A methematical type representing a machine byte.
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Byte(());

/// A methematical type representing a sequence of machine bytes.
#[derive(Copy, Clone, PartialEq, Eq)]
pub struct Bytes(());
}

/// This function is used to evaluate an expression in the context just
Expand Down Expand Up @@ -576,6 +590,28 @@ macro_rules! own_range {
};
}

/// Obtain the bytes of the specified memory block.
#[doc(hidden)]
#[trusted]
pub fn prusti_bytes<T>(_address: T, _length: usize) -> Bytes {
unreachable!();
}

#[macro_export]
macro_rules! bytes {
($address:expr, $length:expr) => {
$crate::prusti_bytes(unsafe { core::ptr::addr_of!($address) }, $length)
};
}

/// Read the byte at the given index.
///
/// FIXME: This function does not check bounds. Instead, it returns garbage in
/// case of out-of-bounds
pub fn read_byte(bytes: Bytes, index: Int) -> Byte {
unreachable!();
}

/// Indicates that we have the `raw` capability to the specified address.
#[doc(hidden)]
#[trusted]
Expand Down

0 comments on commit b79f7db

Please sign in to comment.