pub struct Scopes { /* private fields */ }Expand description
The scopes of one translation unit.
Implementations§
Source§impl Scopes
impl Scopes
Sourcepub fn push(&mut self)
pub fn push(&mut self)
Opens a scope in every namespace.
Both are pushed together because C opens them together. A parameter list is a scope of
its own, which is why the tag in void f(struct S *p); is gone by the next declaration,
and getting that wrong in one namespace and not the other is how the two drift.
Sourcepub fn at_file_scope(&self) -> bool
pub fn at_file_scope(&self) -> bool
Whether the only open scope is the file scope.
Sourcepub fn declare(&mut self, name: Symbol, binding: Binding) -> Option<Binding>
pub fn declare(&mut self, name: Symbol, binding: Binding) -> Option<Binding>
Binds an ordinary identifier, and gives back what it was bound to in the same scope.
A returned value is a redeclaration, which is the caller’s to judge, since int x; int x; is one object at file scope and an error inside a function.
Sourcepub fn declare_at_file_scope(&mut self, name: Symbol, binding: Binding) -> bool
pub fn declare_at_file_scope(&mut self, name: Symbol, binding: Binding) -> bool
Binds an ordinary identifier in the file scope from wherever the checking is.
For a builtin, which C says the implementation declared and which therefore was not declared in whichever block first called it. Answers whether it took, which it does only when nothing else binds the name.
Sourcepub fn lookup_here(&self, name: Symbol) -> Option<Binding>
pub fn lookup_here(&self, name: Symbol) -> Option<Binding>
What an ordinary identifier names in the innermost scope alone.
Sourcepub fn declare_tag(&mut self, name: Symbol, tag: Tag) -> Option<Tag>
pub fn declare_tag(&mut self, name: Symbol, tag: Tag) -> Option<Tag>
Binds a tag, and gives back what it was bound to in the same scope.
Sourcepub fn tag_here(&self, name: Symbol) -> Option<Tag>
pub fn tag_here(&self, name: Symbol) -> Option<Tag>
What tag a name names in the innermost scope alone.
This is the question struct S; asks, since a bare declaration of a tag declares a new
type in this scope even where an outer one is visible, and struct S *p; asks the other
one, since it refers to whatever S already means.