Skip to main content

ValueId

Enum ValueId 

Source
#[non_exhaustive]
pub enum ValueId { Literal(LiteralId), Bytes(BytesId), Instruction(InstructionId), BasicBlock(BlockId), BlockParam(BlockParamId), Varnode(VarnodeId), Temp(TempId), Function(FunctionId), Poison(PoisonId), }
Expand description

A type-erased handle to any IR value stored in a Context.

ValueId is the “universal pointer” used wherever code must refer to a value without knowing its concrete type at compile time — for example in instruction operand lists, use-def chains, and the address/name maps.

It is Copy, cheap to compare, and contains no borrow of the context. To inspect the value, call Context::get_value which returns a ValueRef tied to the context’s lifetime.

§Exhaustiveness

ValueId is #[non_exhaustive]; new variants may be added in future versions without a major semver bump.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Literal(LiteralId)

A compile-time integer constant, optionally carrying a symbolic label.

§

Bytes(BytesId)

A compile-time opaque byte blob wider than a Literal can hold.

§

Instruction(InstructionId)

An SSA value produced by an Instruction.

§

BasicBlock(BlockId)

A control-flow node (BasicBlock).

§

BlockParam(BlockParamId)

A typed parameter declared at the entry of a basic block.

§

Varnode(VarnodeId)

A named memory location (Varnode) such as a register or global.

§

Temp(TempId)

A function-local temporary memory value.

§

Function(FunctionId)

A lifted or external FunctionBody.

§

Poison(PoisonId)

A typed poison value: a placeholder with undefined bits (argpromote v2 clobber slots). Never folded by GVN; reading it in the emulator is a hard error. See poison.

Implementations§

Source§

impl ValueId

Source

pub fn ty(&self) -> &'static str

Source

pub fn owning_function(self) -> Option<FunctionId>

The function that owns this value’s definition, if it is an SSA def (an Instruction result or a BlockParam). Shared values (literals, bytes, varnodes) and functions/blocks return None — they have no single owning function and their per-function use-lists live in each using function’s reverse-use map (exposed through FunctionBody::users_of).

Source

pub fn name_scope_function(self) -> Option<FunctionId>

The function whose name table owns this value’s name, if any. Block, instruction, and block-param names are function-scoped, so those return their function; module-scoped values (functions, varnodes, spaces, literals, bytes) return None and use the global name map. Unlike owning_function this includes blocks (by their storage function).

Source

pub fn as_literal(self) -> Option<LiteralId>

Source

pub fn as_instruction(self) -> Option<InstructionId>

Source

pub fn as_block(self) -> Option<BlockId>

Source

pub fn as_block_param(self) -> Option<BlockParamId>

Source

pub fn as_bytes(self) -> Option<BytesId>

Source

pub fn is_varnode(self) -> bool

Source

pub fn as_varnode(self) -> Option<VarnodeId>

Source

pub fn as_temp(self) -> Option<TempId>

Source

pub fn as_function(self) -> Option<FunctionId>

Source

pub fn as_poison(self) -> Option<PoisonId>

Source

pub fn is_poison(self) -> bool

Source§

impl ValueId

Source

pub fn order_key(&self) -> (u8, u32, u32)

A total-order sort key that does not require Into<usize> (which the composite instruction/block/param IDs deliberately lack). The tuple is (variant_tag, function-or-0, local-or-global-index); global values put their index in the third slot with function 0.

Source§

impl ValueId

Source

pub fn localize(self, func: FunctionId) -> LocalValueId

Localize a qualified id for storage inside func’s body, dropping the owning FunctionId from the arena arms. In debug builds this asserts the id’s func equals func — the strict-locality tripwire (ruling 2): a foreign operand is a bug and fires loudly here rather than misrouting. Shared/module arms pass through unchanged.

Source

pub fn strip_func(self) -> LocalValueId

Drop the owning FunctionId from the arena arms without a locality check, using the id’s own embedded func. Unlike localize there is no ambient function to assert against: this is for keying a per-function body map (e.g. FunctionBody.users) by a value that already carries its own func. Within one body’s map every arena key has that body’s func, so stripping it is injective and lookup-stable; shared/module arms pass through unchanged.

Source

pub fn as_function_agnostic(self) -> Option<LocalValueId>

Localize this id only if it is function-agnostic — a shared/module arm (Literal/Bytes/Varnode/Function) that carries no owning function and so needs no ambient body to convert. Returns None for the function-scoped arena arms (Instruction/BasicBlock/BlockParam/Temp), which cannot be dropped into a different body’s local space without misrouting. This is the safe localizer for a value that may legitimately be a constant flowing into a minted body but must otherwise be remapped through a value map.

Trait Implementations§

Source§

impl Clone for ValueId

Source§

fn clone(&self) -> ValueId

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ValueId

Source§

impl Debug for ValueId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for ValueId

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for ValueId

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ValueId

Source§

impl From<AddressTarget> for ValueId

Source§

fn from(target: AddressTarget) -> Self

Converts to this type from the input type.
Source§

impl From<BlockId> for ValueId

Source§

fn from(id: BlockId) -> Self

Converts to this type from the input type.
Source§

impl From<BlockParamId> for ValueId

Source§

fn from(id: BlockParamId) -> Self

Converts to this type from the input type.
Source§

impl From<BytesId> for ValueId

Source§

fn from(id: BytesId) -> Self

Converts to this type from the input type.
Source§

impl From<FunctionId> for ValueId

Source§

fn from(id: FunctionId) -> Self

Converts to this type from the input type.
Source§

impl From<InstructionId> for ValueId

Source§

fn from(id: InstructionId) -> Self

Converts to this type from the input type.
Source§

impl From<LiteralId> for ValueId

Source§

fn from(id: LiteralId) -> Self

Converts to this type from the input type.
Source§

impl From<PoisonId> for ValueId

Source§

fn from(id: PoisonId) -> Self

Converts to this type from the input type.
Source§

impl From<TempId> for ValueId

Source§

fn from(id: TempId) -> Self

Converts to this type from the input type.
Source§

impl From<VarnodeId> for ValueId

Source§

fn from(id: VarnodeId) -> Self

Converts to this type from the input type.
Source§

impl Hash for ValueId

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ValueId

Source§

fn eq(&self, other: &ValueId) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for ValueId

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for ValueId

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.