Skip to main content

Scopes

Struct Scopes 

Source
pub struct Scopes { /* private fields */ }
Expand description

Every scope, binding and reference in a program. See the module docs.

Implementations§

Source§

impl Scopes

Source

pub fn analyze(ast: &Ast, src: &str) -> Scopes

Analyzes ast, parsed from src.

Source

pub fn root(&self) -> ScopeId

The global or module scope.

Source

pub fn scope(&self, id: ScopeId) -> &Scope

Source

pub fn scopes(&self) -> &[Scope]

Every scope, each after the scopes around it.

Source

pub fn binding(&self, id: BindingId) -> &Binding

Source

pub fn bindings(&self) -> &[Binding]

Source

pub fn references(&self) -> &[Reference]

Every reference, in source order.

Source

pub fn scope_of(&self, node: NodeId) -> Option<ScopeId>

The scope node makes, if it makes one.

Source

pub fn reference(&self, node: NodeId) -> Option<&Reference>

The reference node is, if it’s an IdentifierReference.

Source

pub fn declaration(&self, node: NodeId) -> Option<BindingId>

The binding node declares, if it’s a binding identifier.

Source

pub fn lookup(&self, scope: ScopeId, name: &str) -> Option<BindingId>

The binding a reference to name in scope would resolve to.

Source

pub fn free_names(&self) -> &[String]

The names references use that nothing in the program declares, each once, in the order they first appear.

Source

pub fn diagnostics(&self) -> &[Diagnostic]

Names declared twice, or both lexically and with var, where the spec makes that an early error.

Trait Implementations§

Source§

impl Clone for Scopes

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 Scopes

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Forget for Scopes

§

impl Freeze for Scopes

§

impl Move for Scopes

§

impl RefUnwindSafe for Scopes

§

impl Send for Scopes

§

impl Sync for Scopes

§

impl Unpin for Scopes

§

impl UnsafeUnpin for Scopes

§

impl UnwindSafe for Scopes

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.