Skip to main content

Scope

Struct Scope 

Source
pub struct Scope {
Show 13 fields pub vars: VarMap<Value>, pub parent: Option<Rc<RefCell<Scope>>>, pub is_block: bool, pub is_param: bool, pub is_catch: bool, pub(crate) annex_b_skip: Option<Box<[Rc<str>]>>, pub(crate) tdz: Option<Box<[Rc<str>]>>, pub(crate) this_barrier: bool, pub(crate) derived_this: Option<Rc<RefCell<Option<Value>>>>, pub(crate) with_obj: Option<ObjRef>, pub(crate) has_with: bool, pub(crate) is_eval: bool, pub gc_slot: u32,
}
Expand description

変数スコープ。

Fields§

§vars: VarMap<Value>

変数の表。【2026-10-24】BTreeMap から FNV ハッシュの PropMap へ(グローバルには数百の 変数があり、参照のたびに約 9 回の文字列比較が起きていた)。

§parent: Option<Rc<RefCell<Scope>>>§is_block: bool

ブロック({ let/const ... }・catch)のスコープか。var はここを素通りして 最も近い関数(またはプログラム)のスコープへ宣言する。

§is_param: bool

引数デフォルト式を評価中の一時的な仮引数環境か。

§is_catch: bool

Annex B.3.5 用の単純識別子 catch 仮引数スコープか。

§annex_b_skip: Option<Box<[Rc<str>]>>

Annex B.3.3 で外側への巻き上げを抑止する識別子名(仮引数・関数本体トップレベル let/const/class 等)。

§tdz: Option<Box<[Rc<str>]>>

仮引数デフォルト式評価中の TDZ 識別子名。

§this_barrier: bool

非アロー関数呼び出しの this 境界(アロー関数はここを越えて外の derived_this を参照する)。

§derived_this: Option<Rc<RefCell<Option<Value>>>>

派生クラスコンストラクタの this 束縛セル(None = super() 未呼出の TDZ)。

§with_obj: Option<ObjRef>

with (obj) のスコープ束縛オブジェクト。

§has_with: bool

このスコープまたは祖先スコープに with が含まれるか(通常時の高速スキップ用)。

§is_eval: bool

非 strict の直接 eval スコープか(トップレベル関数宣言とレキシカル宣言を区別するため)。

§gc_slot: u32

循環ゴミ回収(cycle_gc)の台帳の番号。

Implementations§

Source§

impl Scope

Source

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

Source

pub fn new_root() -> Rc<RefCell<Scope>>

Source

pub fn child(parent: Rc<RefCell<Scope>>) -> Rc<RefCell<Scope>>

Source

pub fn child_with_capacity( parent: Rc<RefCell<Scope>>, n: usize, ) -> Rc<RefCell<Scope>>

関数呼び出しのスコープ(変数の数 n が分かっていれば表を先に確保する)。 【2026-10-24】引数・巻き上げの var を 1 つずつ足すと表が 0→4→8… と伸び直し、 確保・複製・再ハッシュが呼び出しごとに起きていた。

Source

pub fn block(parent: Rc<RefCell<Scope>>) -> Rc<RefCell<Scope>>

ブロックスコープ(2026-10-03)。

Source

pub fn new_with(parent: Rc<RefCell<Scope>>, obj: ObjRef) -> Rc<RefCell<Scope>>

with (obj) のオブジェクト環境レコード。

Trait Implementations§

Source§

impl Drop for Scope

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Scope

§

impl !Send for Scope

§

impl !Sync for Scope

§

impl !UnwindSafe for Scope

§

impl Freeze for Scope

§

impl Unpin for Scope

§

impl UnsafeUnpin for Scope

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> Same for T

Source§

type Output = T

Should always be Self
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.