pub struct ScopeStack { /* private fields */ }Expand description
The scope stack.
IDL name lookup walks outwards from the innermost scope, which is what makes a type usable by its simple name inside its own module and by a scoped name outside. OMG IDL 4.2 §7.5.
Implementations§
Source§impl ScopeStack
impl ScopeStack
Sourcepub fn new_placeholder() -> Self
pub fn new_placeholder() -> Self
A stack that has not been given its root yet.
Only for construction order: the lowering needs a context before it can ask the model for its root module.
Sourcepub fn new(root: Id<ModuleNode>) -> Self
pub fn new(root: Id<ModuleNode>) -> Self
A stack holding only the global scope.
Sourcepub fn push(&mut self, name: &str, module: Option<Id<ModuleNode>>)
pub fn push(&mut self, name: &str, module: Option<Id<ModuleNode>>)
Enter a named scope.
Reopening a module resumes it: the scope starts with everything
the previous opening left in it, so an unqualified reference
reaches back across the }; and a name declared twice is still
a collision.
Sourcepub fn push_container(&mut self, name: &str)
pub fn push_container(&mut self, name: &str)
Enter the body of an interface or a value type.
A scope of its own for lookup like any other, and in addition one
that names what is declared in it: the scoped name and the
repository id of exception NotFound in interface NamingContext
in module CosNaming go through all three (OMG IDL 4.2 §7.5,
CORBA 3.3 part 1 §14.7.1.1). An annotation declaration’s body is a
scope that names nothing and is entered with Self::push.
Sourcepub fn enclosing_container(&self) -> Option<&str>
pub fn enclosing_container(&self) -> Option<&str>
The interface or value type a declaration made now sits in, when the innermost scope is one.
Sourcepub fn current_module(&self) -> Option<Id<ModuleNode>>
pub fn current_module(&self) -> Option<Id<ModuleNode>>
The module the innermost enclosing scope belongs to.
Sourcepub fn is_bound_here(&self, name: &str) -> bool
pub fn is_bound_here(&self, name: &str) -> bool
Whether name is already bound in the innermost scope.
Case-insensitively, because IDL treats two identifiers differing only by case as the same name for collision purposes. OMG IDL 4.2 §7.2.3.
Sourcepub fn lookup_here(&self, name: &str) -> Option<AnyId>
pub fn lookup_here(&self, name: &str) -> Option<AnyId>
Look name up in the innermost scope only, matching exactly.
Exact rather than case-insensitive: completing a forward declaration requires the same name, while two names differing only by case are a collision and have to be reported as one.
Sourcepub fn qualify(&self, name: &str) -> ScopedName
pub fn qualify(&self, name: &str) -> ScopedName
The scoped name a declaration in the innermost scope would have.
Sourcepub fn qualify_segments(&self, segments: &[String]) -> ScopedName
pub fn qualify_segments(&self, segments: &[String]) -> ScopedName
The scoped name a written name has from the current scope.
A directive inside a module names its target relatively, so the enclosing scope’s path comes first. IDL 4.2 §7.5.
Sourcepub fn lookup_candidates(&self, segments: &[String]) -> Vec<ScopedName>
pub fn lookup_candidates(&self, segments: &[String]) -> Vec<ScopedName>
Every scoped name a written name could denote, innermost first.
§7.5: a name is looked up in the scope that writes it and then in
each enclosing scope outwards, and the first declaration found is
the one it means. Self::qualify_segments gives only the first
of those, which is right for a declaration being made and wrong
for a name being used: module m { typeprefix m "…"; }; named
m::m, a scope that does not exist, and the directive was
reported as naming nothing while ::m sat one step out.
The list always ends at the root, so a name declared at top level is reachable from any depth.
Sourcepub fn innermost_name(&self) -> Option<&str>
pub fn innermost_name(&self) -> Option<&str>
The name of the innermost named scope, if there is one.
Empty for the root, whose scope carries no name. IDL 4.2 §7.5.2 forbids redefining that name inside it, and the rule needs to know what it is.