Struct SignatureLocalVariables
pub struct SignatureLocalVariables {
pub locals: Vec<SignatureLocalVariable>,
}Expand description
Local variable signature collection for method bodies.
Represents the complete local variable signature according to ECMA-335 Section II.23.2.6. This contains all local variables declared within a method body, including their types, modifiers, and special attributes like pinning and reference semantics.
§Local Variable Characteristics
§Scope and Lifetime
Local variables are scoped to the method in which they are declared:
- Created when the method is entered
- Destroyed when the method exits
- Accessible only within the declaring method
- Zero-initialized by default unless explicitly assigned
§Memory Management
Local variables use stack-based allocation by default:
- Value types: Stored directly on the stack
- Reference types: References stored on stack, objects on heap
- Pinned variables: Prevent garbage collection movement
- Large objects: May be allocated on the large object heap
§Binary Format (ECMA-335)
Local variable signatures are encoded as:
LocalVarSig ::= LOCAL_SIG Count (TYPEDBYREF | ([CustomMod]* [Constraint])* [BYREF] Type)*§Examples
§Simple Local Variables
use dotscope::metadata::signatures::{SignatureLocalVariables, SignatureLocalVariable, TypeSignature};
let locals = SignatureLocalVariables {
locals: vec![
SignatureLocalVariable {
modifiers: vec![],
is_byref: false,
is_pinned: false,
base: TypeSignature::I4, // int local
},
SignatureLocalVariable {
modifiers: vec![],
is_byref: false,
is_pinned: false,
base: TypeSignature::String, // string local
},
],
};§Complex Local Variables
use dotscope::metadata::signatures::{SignatureLocalVariables, SignatureLocalVariable, TypeSignature};
let complex_locals = SignatureLocalVariables {
locals: vec![
SignatureLocalVariable {
modifiers: vec![],
is_byref: true, // ref variable
is_pinned: false,
base: TypeSignature::I4,
},
SignatureLocalVariable {
modifiers: vec![],
is_byref: false,
is_pinned: true, // pinned variable
base: TypeSignature::String,
},
],
};§Thread Safety
SignatureLocalVariables is immutable after construction and safe to share between
threads. The actual local variable storage is thread-local per method execution.
§ECMA-335 Compliance
This structure implements ECMA-335 Partition II, Section 23.2.6 (LocalVarSig)
and supports all standard local variable signature scenarios.
§See Also
SignatureLocalVariable: For individual local variable definitionscrate::metadata::signatures::TypeSignature: For supported local variable typescrate::metadata::method::MethodBody: For method body context
Fields§
§locals: Vec<SignatureLocalVariable>The collection of local variables declared in this method.
Each SignatureLocalVariable represents a single local variable
with its type, modifiers, and special attributes. The order matches
the declaration order in the method body.
§Variable Access
Local variables are accessed by index in IL instructions:
ldloc.0,ldloc.1, etc. for loading local variablesstloc.0,stloc.1, etc. for storing to local variables- Index corresponds to position in this vector
§Empty Collections
Methods without local variables have an empty vector. This is common for simple methods that only use parameters.
Trait Implementations§
§impl Clone for SignatureLocalVariables
impl Clone for SignatureLocalVariables
§fn clone(&self) -> SignatureLocalVariables
fn clone(&self) -> SignatureLocalVariables
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for SignatureLocalVariables
impl Debug for SignatureLocalVariables
§impl Default for SignatureLocalVariables
impl Default for SignatureLocalVariables
§fn default() -> SignatureLocalVariables
fn default() -> SignatureLocalVariables
§impl PartialEq for SignatureLocalVariables
impl PartialEq for SignatureLocalVariables
impl StructuralPartialEq for SignatureLocalVariables
Auto Trait Implementations§
impl Freeze for SignatureLocalVariables
impl RefUnwindSafe for SignatureLocalVariables
impl Send for SignatureLocalVariables
impl Sync for SignatureLocalVariables
impl Unpin for SignatureLocalVariables
impl UnwindSafe for SignatureLocalVariables
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,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more