Skip to main content

LocalVars

Struct LocalVars 

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

Variables a direct eval declared in one function call.

A sloppy eval declares its vars in the caller’s variable environment, not on the global object: function f() { eval("var x = 1") } f(); x is a ReferenceError, and two calls to f get two xs. Each entry therefore records the phase it was declared in, so a lookup from the parameter list cannot see a body declaration.

Implementations§

Source§

impl LocalVars

Source

pub fn new() -> LocalVars

An empty set.

Source

pub fn get(&self, name: &str, phase: u8) -> Option<Gc<Cell>>

The cell name resolves to, when it was declared in phase or earlier.

Source

pub fn declare(&self, name: &str, phase: u8, cell: Gc<Cell>) -> Gc<Cell>

The cell for name, declaring it if this is the first time.

Source

pub fn contains(&self, name: &str) -> bool

Whether name has been declared at all.

Trait Implementations§

Source§

impl Default for LocalVars

Source§

fn default() -> LocalVars

Returns the “default value” for a type. Read more
Source§

impl Trace for LocalVars

Source§

fn trace(&self, tracer: &mut Tracer<'_>)

Report every Gc owned by self to tracer.

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> 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, 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.