pub enum AccessPath {
Param(u32),
Global(ValueId),
Deref(Box<AccessPath>),
Field(Box<AccessPath>, u32),
Return,
}Expand description
Describes a memory access location relative to function parameters or globals.
Access paths form a tree rooted at a base (Param, Global, or Return)
with Deref and Field steps descending into pointed-to memory.
§Examples
Param(0)– the first parameter itselfDeref(Param(0))– what the first parameter points toField(Deref(Param(0)), 2)– field 2 of the struct pointed to by param 0Return– the return value
Variants§
Param(u32)
A function parameter by zero-based index.
Global(ValueId)
A global variable identified by its ValueId.
Deref(Box<AccessPath>)
Dereference of an inner access path (one level of pointer indirection).
Field(Box<AccessPath>, u32)
Field access at a given byte offset within a struct.
Return
The function return value.
Implementations§
Source§impl AccessPath
impl AccessPath
Sourcepub fn parse(s: &str) -> Result<Self, AccessPathParseError>
pub fn parse(s: &str) -> Result<Self, AccessPathParseError>
Parse an access path from its string representation.
Supported formats:
"return"–AccessPath::Return"param.N"–AccessPath::Paramwith index N"global(0x...)"–AccessPath::Globalwith hex ID"param.0->deref"–AccessPath::DerefwrappingParam(0)"param.0->field(8)"–AccessPath::Fieldwith offset 8- Steps can be chained:
"param.0->deref->field(4)->deref"
§Errors
Returns AccessPathParseError if the string is empty, contains an
unrecognized base or step token, or has invalid numeric indices.
Sourcefn parse_base(s: &str) -> Result<Self, AccessPathParseError>
fn parse_base(s: &str) -> Result<Self, AccessPathParseError>
Parse the base token (before any -> steps).
Sourcefn parse_step(base: Self, step: &str) -> Result<Self, AccessPathParseError>
fn parse_step(base: Self, step: &str) -> Result<Self, AccessPathParseError>
Parse a single step token and wrap the current path.
Sourcepub fn depth(&self) -> usize
pub fn depth(&self) -> usize
Compute the depth of this access path (number of Deref/Field steps).
Base paths (Param, Global, Return) have depth 0.
Sourcepub fn truncate(&self, k: u32) -> Self
pub fn truncate(&self, k: u32) -> Self
Truncate this access path to at most k levels of Deref/Field.
If the path is already within the limit, returns a clone. Otherwise,
the deepest steps beyond k are dropped, and the path is terminated
at the k-th level.
Sourcefn truncate_inner(&self, remaining: usize) -> Self
fn truncate_inner(&self, remaining: usize) -> Self
Recursive truncation helper.
Trait Implementations§
Source§impl Clone for AccessPath
impl Clone for AccessPath
Source§fn clone(&self) -> AccessPath
fn clone(&self) -> AccessPath
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AccessPath
impl Debug for AccessPath
Source§impl<'de> Deserialize<'de> for AccessPath
impl<'de> Deserialize<'de> for AccessPath
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl Display for AccessPath
impl Display for AccessPath
Source§impl Hash for AccessPath
impl Hash for AccessPath
Source§impl Ord for AccessPath
impl Ord for AccessPath
Source§fn cmp(&self, other: &AccessPath) -> Ordering
fn cmp(&self, other: &AccessPath) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for AccessPath
impl PartialEq for AccessPath
Source§impl PartialOrd for AccessPath
impl PartialOrd for AccessPath
Source§impl Serialize for AccessPath
impl Serialize for AccessPath
impl Eq for AccessPath
impl StructuralPartialEq for AccessPath
Auto Trait Implementations§
impl Freeze for AccessPath
impl RefUnwindSafe for AccessPath
impl Send for AccessPath
impl Sync for AccessPath
impl Unpin for AccessPath
impl UnsafeUnpin for AccessPath
impl UnwindSafe for AccessPath
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.