pub struct Local {
pub name: Arc<str>,
pub slot: Slot,
pub layout: LayoutId,
pub from: Pc,
pub to: Pc,
}Expand description
One named binding, and the range of the function’s code over which that name denotes that slot.
A side table, and read for the same reason Function::spans is: a name
is wanted when a human asks what a frame holds — a debugger stopped at a
breakpoint, issue #241 — and never in the dispatch loop, so it belongs
beside the code rather than in it.
It exists because neither half of that question is answerable from the
frame. Function::reprs says what a slot’s word holds, for the whole
function, and that is all it says: until this table the only name anywhere
in a lowered program was Capture::name, parameters were positional and
locals were anonymous. So a debugger could say s7:int = 3, which is true
of the machine and can be a lie about the program.
§Two locals may share a slot, and that is the point
Function::reprs’ own note says a slot may be reused by a later value
of the same Repr, because the lowering hands a dead run to the next
value that asks for that shape. One slot is therefore several source
variables over a function’s life, and nothing but this table can tell them
apart. Two locals of one slot have disjoint ranges and, usually,
different names.
§Two locals may share a name
Shadowing is recorded, not resolved. let x = 1; let x = "two" is two
bindings and both are kept, because the first is still what the frame
holds at every pc before the second — and because resolving here would
make the table disagree with the lowering, whose scope is searched
backwards so that the latest declaration wins. Their ranges may overlap
and their slots differ. A reader keeps the locals whose range contains the
pc and takes the last match; Function::local_at is that rule
written down.
A break or a continue is not an end of a range. [from, to) is an
interval of program counters, every pc inside a scope’s body is one the
binding is live at, and the pc a break jumps to is outside the interval
already.
Fields§
§name: Arc<str>§slot: Slot§layout: LayoutId§from: PcThe first pc at which the name is bound.
to: PcOne past the last. [from, to) is a half-open interval, like a
Span.
Trait Implementations§
impl Eq for Local
impl StructuralPartialEq for Local
Auto Trait Implementations§
impl Freeze for Local
impl RefUnwindSafe for Local
impl Send for Local
impl Sync for Local
impl Unpin for Local
impl UnsafeUnpin for Local
impl UnwindSafe for Local
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> 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.