pub struct Global {
pub name: String,
pub ty: Option<usize>,
pub decl: Option<Place>,
pub external: bool,
}Expand description
One variable the unit defines at file scope.
Not the same problem as a local, and that is the whole reason this is here and a local is not. A file-scope variable is at one address for the whole of the program, so its location is the address of its own symbol and the linker fills it in, the same way it fills in a function’s. A local’s location is wherever the code happens to be keeping it at the program counter the debugger stopped at, which is a list rather than an expression, and that is the rest of tamnd/rucc#9.
Fields§
§name: StringIts name, as the C program spelled it, which is what the relocation asks the linker for.
ty: Option<usize>Which of the unit’s types it is, and None when this compiler
cannot yet say.
A variable with nothing here still gets an entry, which is the one place the rule for a
function is turned around. A DW_TAG_variable with no DW_AT_type does not say void,
because nothing in C is a variable of type void, so a reader takes it as a variable whose
type was not recorded. The name and the address are worth having on their own: they are
what lets a debugger resolve the name at all, and a program that knows what it is looking
at can cast.
decl: Option<Place>Where it was declared, and nothing when that is not known.
external: boolWhether anything outside this unit can see it, which is the opposite of static.
Trait Implementations§
impl Eq for Global
impl StructuralPartialEq for Global
Auto Trait Implementations§
impl Freeze for Global
impl RefUnwindSafe for Global
impl Send for Global
impl Sync for Global
impl Unpin for Global
impl UnsafeUnpin for Global
impl UnwindSafe for Global
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.