pub struct Gep {
pub base: LocalValueId,
pub offset: usize,
}Expand description
Computes the address of a struct field: gep(base, offset) ≡
base + offset, but the result is typed PtrTo<field.type> and prints by
field name instead of the raw offset.
Unlike Extract — which projects a field value out of an in-register
aggregate — Gep does no memory access: it is pure pointer arithmetic.
The field value is obtained by a separate load of the Gep result. The
field name is recovered from the pointee of base’s
StructPointer type, keyed by the
byte offset.
Fields§
§base: LocalValueId§offset: usizeImplementations§
Source§impl Gep
impl Gep
Sourcepub fn field_name<'a>(
&self,
ctx: &'a Context<'_>,
func: FunctionId,
) -> Option<&'a str>
pub fn field_name<'a>( &self, ctx: &'a Context<'_>, func: FunctionId, ) -> Option<&'a str>
The name of the field this Gep addresses, recovered from the nominal
struct that base points at. None if base is not a typed struct
pointer or the offset matches no field.
pub fn field_name_view<'ctx, 'str: 'ctx>( &self, view: impl QCodeView<'ctx, 'str>, func: FunctionId, ) -> Option<&'ctx str>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Gep
impl<'de> Deserialize<'de> for Gep
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Gep
impl StructuralPartialEq for Gep
Auto Trait Implementations§
impl Freeze for Gep
impl RefUnwindSafe for Gep
impl Send for Gep
impl Sync for Gep
impl Unpin for Gep
impl UnsafeUnpin for Gep
impl UnwindSafe for Gep
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
Mutably borrows from an owned value. Read more