Skip to main content

ScopeStack

Struct ScopeStack 

Source
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

Source

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.

Source

pub fn new(root: Id<ModuleNode>) -> Self

A stack holding only the global scope.

Source

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.

Source

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.

Source

pub fn enclosing_container(&self) -> Option<&str>

The interface or value type a declaration made now sits in, when the innermost scope is one.

Source

pub fn pop(&mut self)

Leave the innermost scope.

Source

pub fn current_module(&self) -> Option<Id<ModuleNode>>

The module the innermost enclosing scope belongs to.

Source

pub fn bind(&mut self, name: &str, node: AnyId)

Bind name in the innermost scope.

Source

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.

Source

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.

Source

pub fn lookup(&self, name: &str) -> Option<AnyId>

Look name up, innermost scope outwards.

Source

pub fn qualify(&self, name: &str) -> ScopedName

The scoped name a declaration in the innermost scope would have.

Source

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.

Source

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.

Source

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.

Source

pub fn depth(&self) -> usize

How deep the stack is, the global scope counting as one.

Trait Implementations§

Source§

impl Clone for ScopeStack

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ScopeStack

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.