Skip to main content

Interp

Struct Interp 

Source
pub struct Interp {
Show 40 fields pub steps: u64, pub max_steps: u64, pub(crate) task_start: u64, pub(crate) task_depth: u32, pub(crate) microtask_step_cap: u64, pub(crate) vm_stack: Vec<Value>, pub(crate) window_pos: usize, pub(crate) strict: bool, pub(crate) implicit_globals: Vec<Rc<str>>, pub(crate) arg_pool: Vec<Vec<Value>>, pub(crate) scope_pool: Vec<Rc<RefCell<Scope>>>, pub depth: u32, pub max_depth: u32, pub stack_limit: (usize, usize), pub aborted: bool, pub out: String, pub(crate) host: &'static HostHooks, pub(crate) host_state: Rc<dyn Any>, pub microtasks: Rc<RefCell<VecDeque<Job>>>, gen_replay: Option<GenReplay>, pub macrotasks: Rc<RefCell<VecDeque<TimerTask>>>, pub clock_skew: Rc<Cell<u64>>, pub base_url: String, pub global: Rc<RefCell<Scope>>, pub modules: ModuleRegistry, pub builtin_fn_cache: Rc<RefCell<BTreeMap<usize, Value>>>, pub runtime_id: u64, pub units_cache: Rc<RefCell<UnitsCache>>, pub(crate) wm_index: Rc<RefCell<BTreeMap<usize, (Weak<RefCell<Obj>>, BTreeMap<usize, usize>)>>>, pub(crate) global_lexicals: Rc<RefCell<BTreeSet<Rc<str>>>>, pending_label: Option<Rc<str>>, pending_new_target: Option<Value>, pub(crate) forof_preset: Option<Value>, pub(crate) join_stack: Vec<usize>, new_target_stack: Vec<Value>, pub(crate) derived_this_stack: Vec<Option<Value>>, pub call_names: Vec<Value>, pub(crate) active_param_names: Vec<Vec<Rc<str>>>, pub(crate) eval_ctx_stack: Vec<EvalSyntaxCtx>, pub(crate) private_brand_seq: Rc<Cell<u64>>,
}
Expand description

1 回の評価セッションの実行器(ステップ予算等を保持)。

Fields§

§steps: u64§max_steps: u64

1 タスク(スクリプト・マイクロタスク・タイマー)あたりのステップ上限。無限ループ対策で、 超えたらそのタスクを打ち切る。

§task_start: u64

実行中のタスクが始まった時点の steps。

§task_depth: u32

別のタスクの内側か(同期 await がタスクを回している間は 1 以上)。

§microtask_step_cap: u64

1 回の run_microtasks で使うステップの目安。超えたら次のタスクの切れ目で描画へ戻る。

§vm_stack: Vec<Value>

バイトコードの値スタック(bytecode.rs)。

§window_pos: usize

グローバルの表の中の window の位置の覚え。

§strict: bool

いま実行している利用者のコードが strict モードか(関数の呼び出しごとに本体の strict へ切り替え、戻ると元に戻す)。 失敗した代入(PutValue)を TypeError にするかの判定に使う。

§implicit_globals: Vec<Rc<str>>

代入だけで作られたグローバル変数(delete で消せる)。

§arg_pool: Vec<Vec<Value>>

関数呼び出しの引数の Vec のプール(eval_arguments・recycle_args)。

§scope_pool: Vec<Rc<RefCell<Scope>>>

クロージャに捕捉されなかった関数呼び出しスコープの再利用プール。

§depth: u32§max_depth: u32§stack_limit: (usize, usize)

JS 呼び出しを打ち切る SP の下限と、そのスタックの上端(js_stack_window)。 別スレッドから使われて SP が範囲外になったら求め直す。

§aborted: bool§out: String§host: &'static HostHooks

ホスト物(ObjKind::HostRef)の操作の表(2026-11-19 手順 7。js/host.rs)。

§host_state: Rc<dyn Any>

ホスト側の評価状態(InterpHostState 等)。ECMAScript の核は中身を知らない。

§microtasks: Rc<RefCell<VecDeque<Job>>>

Promise マイクロタスクキュー(ランタイムと共有)。

§gen_replay: Option<GenReplay>

generator 本体を replay 実行中の一時状態(None なら通常実行)。

§macrotasks: Rc<RefCell<VecDeque<TimerTask>>>

タイマーのキュー(ランタイムと共有)。

§clock_skew: Rc<Cell<u64>>

タイマー用の仮想時刻のずれ(ランタイムと共有)。

§base_url: String

現在ページの絶対URL(fetch/XHR の相対URL解決の基準。未設定なら空)。

§global: Rc<RefCell<Scope>>

グローバルスコープ(location/history などネイティブ側からの参照用)。

§modules: ModuleRegistry

登録済み ES モジュール(ランタイムと共有)。

§builtin_fn_cache: Rc<RefCell<BTreeMap<usize, Value>>>

組込みネイティブ関数のシングルトン値を取得する(関数ポインタアドレスでキャッシュ)。

§runtime_id: u64

実行環境の番号(JsRuntime::runtime_id の写し。作った SourceBuffer に付ける。2026-11-17)。

§units_cache: Rc<RefCell<UnitsCache>>

長い文字列の UTF-16 の単位の写し(charCodeAt の繰り返しが毎回全文を変換しないように)。

§wm_index: Rc<RefCell<BTreeMap<usize, (Weak<RefCell<Obj>>, BTreeMap<usize, usize>)>>>

WeakMap の索引(ランタイムと共有)。

§global_lexicals: Rc<RefCell<BTreeSet<Rc<str>>>>

トップレベルのレキシカル宣言(let/const/class/using)の名前の集合(ランタイムと共有)。

§pending_label: Option<Rc<str>>

Statement::Labeled がループ文を実行する直前にセットする、そのループ自身の ラベル名(break label/continue label が「自分宛て」かどうかの判定に使う)。 ループの実行開始直後に take() で消費するため、ネストしたループ/ラベルには 影響しない(exec_stmt のシグネチャにラベル引数を追加する代わりの軽量な方式)。

§pending_new_target: Option<Value>

construct_object() が new 経由の呼び出し直前にセットする、その呼び出し先 コンストラクタ自身の値。call_value_inner の CallKind::User 実行開始時に take() して new_target_stack へ push する(pending_label と同じ軽量な方式)。

§forof_preset: Option<Value>

バイトコードが評価済みの for-of の反復対象を、木走査の exec_for_in へ渡すための一時置き場(Op::IterInitOrExec)。

§join_stack: Vec<usize>

Array.prototype.join で今つないでいる配列(循環する配列を “” にするため。仕様外だが V8 と同じ)。

§new_target_stack: Vec<Value>

new.target(MetaProperty)の現在値のスタック。関数呼び出しごとに (アロー関数を除き)push/pop する。空なら(モジュールトップレベル等)undefined。

§derived_this_stack: Vec<Option<Value>>

派生クラスコンストラクタ内の super() が返した置換後 this のスタック。

§call_names: Vec<Value>

呼び出し中の関数(外側から順)。例外の stack に at 名前 として積む (2026-09-26。従来は Error: メッセージ の 1 行だけで、どこで起きたか分からなかった)。 【2026-10-24】名前の文字列は必要になったときに作る(呼び出しのたびの確保をやめた)。

§active_param_names: Vec<Vec<Rc<str>>>

引数デフォルト式評価中に direct eval から var 再宣言を禁止する仮引数名群。

§eval_ctx_stack: Vec<EvalSyntaxCtx>

direct eval 用の現在実行中関数/フィールド初期化子/staticブロックの静的構文コンテキストスタック。

§private_brand_seq: Rc<Cell<u64>>

クラスプライベートブランド ID 採番器(JsRuntime と共有)。

Implementations§

Source§

impl Interp

Source

pub(crate) fn host_get( &mut self, o: &ObjRef, h: HostRef, key: &str, ) -> Option<Value>

ホスト物のプロパティを取得する。None なら核が普通の解決を続ける。

Source§

impl Interp

Source

pub(crate) fn host_proto_of(&self, kind: &ObjKind) -> Option<Option<ObjRef>>

実体に原型が無いホスト物の原型(HostHooks::proto の包み。ホスト物でなければ None)。

Source§

impl Interp

Source

pub(crate) fn host_keys_of(&self, kind: &ObjKind) -> HostKeys

自身の列挙可能なプロパティの所在(Object.keys など)。ホスト物と、ECMAScript の内部の物(Iter・GenReturn)を見分ける。

Source§

impl Interp

Source

fn load_slot( &mut self, name: &Rc<str>, slot: &Slot, scope: &Rc<RefCell<Scope>>, ) -> Result<Value, Value>

変数を読む。覚えた場所があれば名前の検索なしで読む。

Source

fn load_slot_miss( &mut self, name: &Rc<str>, slot: &Slot, scope: &Rc<RefCell<Scope>>, ) -> Result<Value, Value>

Source

fn store_slot( &mut self, target: &Expression, v: Value, slot: &Slot, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

name = v。覚えた場所があれば名前の検索なしで書く。

Source

pub(crate) fn run_code( &mut self, code: &Code, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

code を実行して関数の戻り値を返す。

Source

fn run_code_inner( &mut self, code: &Code, call_scope: &Rc<RefCell<Scope>>, block_scopes: &mut Vec<Rc<RefCell<Scope>>>, this: &Value, ) -> Result<Value, Value>

Source

fn try_prop_entry( &self, b: &Obj, name: &str, entry: &PropSlotEntry, cur_proto: Option<ObjRef>, ) -> Option<Value>

Source

fn get_prop_fast( &self, obj: &Value, name: &str, slot: &PropSlot, ) -> Option<Value>

Source

fn builtin_proto_data(&self, ctor: &str, name: &str) -> Option<Value>

組込みの原型(Array.prototype 等)の自前のデータプロパティ。アクセサや無い名前は None(遅い経路へ)。

Source

fn learn_prop_slot(&self, obj: &Value, name: &str, slot: &PropSlot)

Source

fn op_typeof_ident( &mut self, code: &Code, name_idx: u32, slot_idx: u32, scope: &Rc<RefCell<Scope>>, ) -> Result<Value, Value>

Source

fn op_binary_slow( &mut self, op: &BinaryOp, l: Value, r: Value, ) -> Result<Value, Value>

Source

fn op_member( &mut self, code: &Code, name: u32, object: *const Expression, slot: u32, ) -> Result<(), Value>

Source

fn op_index(&mut self) -> Result<(), Value>

Source

fn op_method( &mut self, code: &Code, name: u32, object: *const Expression, slot: u32, ) -> Result<(), Value>

Source

fn op_method_index(&mut self) -> Result<(), Value>

Source

fn try_inline_native( &mut self, fn_ptr: NativeFn, at: usize, argc: usize, ) -> bool

ホットビルトインを vm_stack 上で直接実行する(成功時 true、フォールバック時 false)。

Source

fn op_call(&mut self, argc: u32, callee: *const Expression) -> Result<(), Value>

Source

fn op_call_with_args(&mut self, callee: *const Expression) -> Result<(), Value>

Source

fn op_decl_var( &mut self, code: &Code, pat: *const Pattern, slot: u32, scope: &Rc<RefCell<Scope>>, ) -> Result<(), Value>

変換の対象は単純な名前だけで、巻き上げ済みなので関数のスコープに必ずある。

Source

fn op_store( &mut self, code: &Code, target: *const Expression, slot: u32, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

Source

fn op_add_assign_ident( &mut self, code: &Code, target: *const Expression, slot: u32, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

name += value。スタックの [今の値, 右辺] を取り、結果を残す。

【2026-11-05】文字列を伸ばすループ(s += x)が毎回 s 全体を写して新しい文字列を作り、長さの 2 乗の 写しになっていた(QEMU の YouTube で memcpy の最大の呼び出し元が二項演算)。右辺を評価した後で、変数が持つ文字列を 参照しているのが変数と読み出した値の 2 つだけなら、読み出した方を手放して変数の文字列の末尾に足す。

Source

fn op_store_member(&mut self, code: &Code, name: u32) -> Result<(), Value>

Source

fn op_store_index(&mut self) -> Result<(), Value>

Source

fn op_update( &mut self, code: &Code, name: u32, target: *const Expression, delta: f64, prefix: bool, slot: u32, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

Source

fn op_update_member( &mut self, code: &Code, name: u32, object: *const Expression, delta: f64, prefix: bool, slot: u32, ) -> Result<(), Value>

Source

fn op_update_index(&mut self, delta: f64, prefix: bool) -> Result<(), Value>

Source

fn op_delete_member(&mut self, code: &Code, name: u32) -> Result<(), Value>

Source

fn op_delete_index(&mut self) -> Result<(), Value>

Source

fn op_array(&mut self, len: u32)

Source

fn op_init_prop(&mut self, code: &Code, name: u32)

Source

fn op_init_prop_computed(&mut self) -> Result<(), Value>

Source

fn op_spread_object(&mut self) -> Result<(), Value>

Source

fn op_array_spread(&mut self) -> Result<(), Value>

Source

fn op_new(&mut self, argc: u32) -> Result<(), Value>

Source

fn op_template( &mut self, quasis: *const Vec<String>, len: u32, ) -> Result<(), Value>

Source

fn op_iter_init(&mut self, of: bool) -> Result<(), Value>

Source

fn pop_next_iter_item( &mut self, is_lexical: bool, call_scope: &Rc<RefCell<Scope>>, block_scopes: &mut Vec<Rc<RefCell<Scope>>>, ) -> Option<Value>

Source

fn throw_deferred_iter_err(&mut self) -> Result<(), Value>

要素が尽きた反復の配列に、途中の例外(_iterr)が残っていれば投げる(for-of が最後まで回ったときだけ呼ぶ)。

Source

fn op_iter_next( &mut self, code: &Code, name_idx: u32, slot_idx: u32, is_lexical: bool, call_scope: &Rc<RefCell<Scope>>, block_scopes: &mut Vec<Rc<RefCell<Scope>>>, ) -> bool

Source§

impl Interp

Source

pub(crate) fn mark_task_start(&mut self)

新しいタスクの開始を記録する(JS の実行中や同期 await の内側では何もしない)。

【2026-11-01】ステップ上限は評価全体の累積で、重いページでは正常なタスクが実行の途中で 打ち切られていた。Polymer の _stampTemplate が途中で切られると host スタックが積まれたまま 残り、以後の部品がすべて壊れる(YouTube の視聴ページの len=112)。実ブラウザは実行中の タスクを殺さないので、上限は無限ループ対策としてタスクごとにかける。

Source

pub(crate) fn tick(&mut self) -> bool

ステップを 1 消費。予算切れなら true(中断)。

Source

fn tick_abort_tab_kill(&mut self) -> bool

【2026-11-18 TODO R2 (d)】このタブだけを止める合図が来た。ステップの上限と同じく aborted を立てて 今のスクリプトを打ち切る(try/catch では捕まらない)。タブはアプリのスレッドが描画から戻った所で閉じる。

Source

fn cooperative_slice(&self) -> bool

32,768 ステップごとに協調的タイムスライスを実行し、他スレッド(USB/NET/GPU提示)へ CPU を譲渡する(TODO A3)。 戻り値: このタブだけを止める合図が来ていれば true(TODO R2 (d)、2026-11-18)。

Source

fn prof_sample(&self)

【一時診断】65536 ステップごとに実行中の関数(いちばん内側)を数え、20 秒ごとに多い順に出す(TODO B0: BotGuard の初期化の重い所)。

Source

fn tick_abort(&mut self) -> bool

Source

fn log_progress(&self, what: &str)

Source§

impl Interp

Source

pub(crate) fn note_thrown_value(&self, v: &Value)

【2026-11-04 診断】JS の throw 文で投げた値を note_engine_error と同じ表へ記録する(TODO B0)。 利用者のコードを呼ばないよう、Error なら自身の name/message、それ以外は型だけを見る。

Source

pub fn error(&self, msg: impl Into<String>) -> Value

ビルトインから使う public な例外生成。

Source

pub fn type_error(&self, msg: impl Into<String>) -> Value

it.error()と同じだがError.prototypeではなくTypeError.prototypeへ proto を繋ぐ(name文字列を"TypeError"へ書き換えるだけでは instanceof TypeErrorが満たされない、new Node()等が投げる “Illegal constructor” 例外で発覚したバグの修正用に新設。 2026-07-18 発見・実装)。

Source

pub fn reference_error(&self, msg: impl Into<String>) -> Value

ReferenceError(未宣言の変数など)。

Source

pub fn syntax_error(&self, msg: impl Into<String>) -> Value

SyntaxError(eval/new Function に渡したソースの構文エラー)。

Source

pub fn range_error(&self, msg: impl Into<String>) -> Value

RangeError(呼び出しが深すぎる等)。

Source

pub(crate) fn error_of_kind(&self, kind: &str, msg: impl Into<String>) -> Value

kind(TypeError・RangeError 等)の例外オブジェクト(proto もその種類へ繋ぐ)。

Source

pub(crate) fn throw(&self, msg: impl Into<String>) -> Value

Source

pub(crate) fn eval_source(&mut self, source: &str) -> Result<Value, Value>

グローバル eval(source) / Function(...) の実体。仕様上 direct eval は呼び出し元の レキシカルスコープを見るが、この処理系は常にグローバルスコープで実行する簡略実装 (indirect eval (0,eval)(code) と同じセマンティクス)。

Source

pub fn eval_script_source(&mut self, source: &str) -> Result<Value, Value>

スクリプト評価($262.evalScript 等。is_eval = false として configurable: false のグローバル宣言を作る)。

Source

pub(crate) fn eval_source_in( &mut self, source: &str, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

直接 eval(eval(code) の形の呼び出し)の実体。呼び出し元のスコープ(scope)と this で実行する。

Source

fn exec_eval_statements( &mut self, stmts: &[Statement], eval_scope: &Rc<RefCell<Scope>>, this: &Value, eval_strict: bool, ) -> Result<Completion, Value>

eval(直接・間接)の本体の宣言インスタンス化(ECMA-262 §19.2.1.3 / Annex B.3.3.3)と実行。

Source

pub(crate) fn exec_top_statements( &mut self, stmts: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

スクリプトまたは eval の最上位文リストを実行する。 最上位の function 宣言のみ CreateGlobalFunctionBinding を適用し、 内側のブロック・switch・try 内の関数宣言(Annex B.3.3.3)と区別する。

Source

pub(crate) fn exec_top_statements_strict( &mut self, stmts: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, inherit_strict: bool, ) -> Result<Completion, Value>

inherit_strict は直接 eval 用(呼び出し元が strict なら eval のコードも strict)。

Source

pub(crate) fn exec_statements( &mut self, stmts: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

pub(crate) fn exec_statements_hoisted( &mut self, stmts: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, hoisted: Option<&[Rc<str>]>, ) -> Result<Completion, Value>

exec_statements の、var 巻き上げの名前を呼び出し側が渡せる版(関数本体で保存済みの名前)。

Source

pub(crate) fn exec_statements_prehoisted( &mut self, stmts: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

巻き上げ完了済みの文列を実行する。

Source

fn hoist_global_declarations_impl( &mut self, stmts: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, hoisted: Option<&[Rc<str>]>, is_eval: bool, ) -> Result<(), Value>

ECMA-262 §16.1.7 GlobalDeclarationInstantiation 相当: トップレベルの var と function 宣言を検証・巻き上げし、globalThis の自前プロパティと同期する。

Source

fn hoist_top_global_function_decls( &mut self, stmts: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, is_eval: bool, )

スクリプト・eval 最上位の関数宣言を CreateGlobalFunctionBinding で巻き上げる。

Source

pub(crate) fn hoist_declarations( &mut self, stmts: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, hoisted: Option<&[Rc<str>]>, )

【2026-10-28 スタックフレーム縮小】var と関数宣言の巻き上げを exec_statements_hoisted から分離。 exec_statements_hoisted は全関数呼び出し・ブロック実行のコールスタックに乗るため、 巻き上げ用の一時変数(collected: Vec<Rc<str>> 等)をこのフレームに残さない。

Source

pub(crate) fn hoist_function_decls( &mut self, stmts: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, )

ブロック/関数本体のトップレベルにある関数宣言を現在のスコープへ巻き上げる。

Source

fn sync_global_var_binding(&self, name: &Rc<str>)

exec_var_decl / exec_for_in で更新されたグローバル var を globalThis.props へ同期する。

Source

fn exec_using_decl( &mut self, decls: &[(Pattern, Option<Expression>)], is_await: bool, scope: &Rc<RefCell<Scope>>, this: &Value, disposables: &mut Vec<(Value, bool)>, ) -> Result<(), Value>

Source

fn finish_disposables( &mut self, disposables: Vec<(Value, bool)>, outcome: Result<Completion, Value>, last: Value, ) -> Result<Completion, Value>

Source

pub(crate) fn exec_stmt( &mut self, stmt: &Statement, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn eval_gen_cached( &mut self, expr: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

ジェネレータリプレイ中のみ、完了済み式(ループの test / update 等)を done_stmts に記録・再生して再評価による副作用の二重適用を防ぐ。

Source

fn exec_stmt_inner( &mut self, stmt: &Statement, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

pub(crate) fn define_public_field( &mut self, target: &Value, key: &str, val: Value, ) -> Result<(), Value>

パブリッククラスフィールドの定義(CreateDataPropertyOrThrow)。素のオブジェクトへは直接書く。

Source

fn exec_var_decl( &mut self, kind: &VarKind, decls: &[(Pattern, Option<Expression>)], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn exec_block( &mut self, body: &[Statement], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn exec_while( &mut self, test: &Expression, body: &Statement, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn exec_do_while( &mut self, body: &Statement, test: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn exec_labeled( &mut self, label: &Rc<str>, inner: &Statement, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn exec_for( &mut self, init: Option<&Statement>, test: Option<&Expression>, update: Option<&Expression>, body: &Statement, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn exec_for_in( &mut self, decl_kind: &Option<VarKind>, pattern: &Pattern, object: &Expression, body: &Statement, of: bool, is_await: bool, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn for_of_lazy( &mut self, iterator: &Value, next_fn: &Value, decl_kind: &Option<VarKind>, pattern: &Pattern, body: &Statement, is_let_like: bool, own_label: Option<Rc<str>>, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

for-of の遅延反復(利用者定義の反復子)。next() を 1 回ずつ呼び、抜けるときは IteratorClose。

Source

fn exec_switch( &mut self, discriminant: &Expression, cases: &[SwitchCase], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn exec_try( &mut self, t: &TryStmt, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

fn exec_module_stmt( &mut self, stmt: &Statement, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Completion, Value>

Source

pub(crate) fn record_export( &mut self, scope: &Rc<RefCell<Scope>>, name: &str, val: Value, )

現在評価中モジュールの export マップにエントリを記録する。 モジュール文脈でない(通常スクリプト)の場合は無視する。

Source

fn module_body(&self, specifier: &str) -> Option<Vec<Statement>>

登録済みモジュールの文の列(無ければ None。構文の誤りがあっても木は返す)。

Source

fn resolve_export( &self, specifier: &str, name: &str, visited: &mut Vec<(String, String)>, ) -> Result<Option<(String, String)>, ()>

ResolveExport(§16.2.1.6.3)の簡略版。見つかれば Ok(Some((最終のモジュール, 束縛名)))、 無ければ Ok(None)、曖昧なら Err(())。未登録のモジュールは「見つかった」とみなす(寛容)。

連結の誤り(§16.2.1.5.3 InnerModuleLinking): 再エクスポートが解決できない・曖昧、 取り込む名前が公開されていない、は SyntaxError。依存するモジュールも辿る。

Source

pub(crate) fn module_namespace( &mut self, specifier: &str, ) -> Result<Value, Value>

評価済みモジュールの名前空間オブジェクト(モジュールごとに 1 つ。以後は同じ物を返す)。

Source

pub(crate) fn load_module_checked( &mut self, specifier: &str, ) -> Result<Rc<RefCell<BTreeMap<String, Value>>>, Value>

動的 import 用: 構文の誤りは SyntaxError で、評価中の例外はそのまま返す(以後の import でも同じ失敗を返す)。

Source

pub(crate) fn load_module( &mut self, specifier: &str, ) -> Result<Rc<RefCell<BTreeMap<String, Value>>>, Value>

指定子のモジュールを(必要なら)評価し、export マップを返す。 循環 import に備え、評価開始前に空マップをレジストリへ入れておく。

Source§

impl Interp

Source§

impl Interp

Source

pub(crate) fn is_lazy_iter_candidate(&self, obj: &Value) -> bool

遅延反復(と IteratorClose)の対象か。利用者定義の Symbol.iterator を持つ素のオブジェクト、 および配列の反復子(Array.prototype[Symbol.iterator] か自前の Symbol.iterator)が差し替えられた配列。 素の配列は従来の一括の高速な経路のまま。

Source

pub(crate) fn open_lazy_iterator( &mut self, obj: &Value, ) -> Result<Option<(Value, Value)>, Value>

利用者定義の反復子や配列/TypedArray の Symbol.iterator を遅延反復する準備。 Generator は 1 要素ずつ next() で遅延駆動し、break/return/throw で return() により閉じる。 Set/Map/ホスト物などは従来の一括の経路(None)。

Source

pub(crate) fn iterator_close(&mut self, iterator: &Value) -> Result<(), Value>

IteratorClose(§7.4.11)。return が無ければ何もしない。結果がオブジェクトでなければ TypeError。 例外で抜ける途中の呼び出しは、呼び出し側が結果を捨てる(元の例外を優先)。

Source

pub(crate) fn iterate_values( &mut self, obj: &Value, of: bool, ) -> Result<Vec<Value>, Value>

for-in / for-of の列挙対象を Value のリストへ。 generator は遅延駆動するため &mut self が必要。

Source

pub(crate) fn iterate_values_deferred( &mut self, obj: &Value, of: bool, deferred: &mut Option<Value>, ) -> Result<Vec<Value>, Value>

iterate_values。ただし for-of 用に、反復の途中(next()・done・value・ジェネレータ本体)で投げた例外は すぐ返さず deferred に入れ、それまでに取れた要素を返す(仕様では、本体が先の要素を処理した後で例外になる)。 呼び出し側は要素を回し終えた(break・return でない)後で deferred を投げる。

Source

pub(crate) fn is_gen_executing(&self, state: &Rc<RefCell<GenState>>) -> bool

Source

fn gen_ctx_obj(scope: &Rc<RefCell<Scope>>) -> Option<ObjRef>

Source

pub(crate) fn gen_is_async(&self, scope: &Rc<RefCell<Scope>>) -> bool

Source

fn gen_cache_peek(&self, scope: &Rc<RefCell<Scope>>) -> Option<Value>

Source

fn gen_cache_push(&self, scope: &Rc<RefCell<Scope>>, entry: Value)

Source

pub(crate) fn gen_await_cached( &mut self, scope: &Rc<RefCell<Scope>>, v: Value, ) -> Result<Value, Value>

Source

pub(crate) fn is_suspending(&self) -> bool

現在 generator 本体の中断処理中か(suspend 番兵 Err を try/catch が 捕捉しないようにするためのガード)。

Source

pub(crate) fn is_gen_returning(&self) -> bool

現在 generator が強制Returnによる巻き戻し中か。

Source

pub(crate) fn do_yield(&mut self, value: Value) -> Result<Value, Value>

yield value の評価。replay 中でなければ無効(undefined)。 target 番目の yield に達したら中断(suspend 番兵 Err を返す)。 既に通過済みの yield には保存済み resume 値を返して続行する。

Source

fn do_yield_delegate(&mut self, value: Value) -> Result<GenCompletion, Value>

yield* 委譲用の yield: 通過済みの場合は GenCompletion(Normal/Throw/Return)をそのまま返す。

Source

fn do_gen_return(&mut self, val: Value) -> Result<Value, Value>

Source

pub(crate) fn async_iterator_close( &mut self, iterator: &Value, ) -> Result<(), Value>

Source

pub(crate) fn get_iter_method_for_val( &mut self, v: &Value, sym_key: &str, ) -> Result<Value, Value>

Source

pub(crate) fn yield_star_get_iterator( &mut self, v: &Value, is_async: bool, ) -> Result<(Value, Value, bool), Value>

Source

pub(crate) fn yield_star_step( &mut self, iterator: &Value, next_fn: &Value, is_async: bool, is_async_from_sync: bool, received: GenCompletion, ) -> (u8, Value)

Source

pub(crate) fn eval_yield_delegate( &mut self, argument: Option<&Expression>, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

pub fn generator_resume( &mut self, state: &Rc<RefCell<GenState>>, sent: Value, ) -> Result<(Value, bool), Value>

Generator を 1 ステップ進める(.next(sent) 相当)。 戻り値は (value, done)。replay 方式で本体を先頭から再実行し、 次の yield まで進めて中断するか、本体完了で done:true を返す。

Source

pub fn generator_throw( &mut self, state: &Rc<RefCell<GenState>>, err: Value, ) -> Result<(Value, bool), Value>

.throw(err) 相当: 現在中断中の yield 式の位置で err を投げて generator を 再開する(generator 本体の try/catch で捕捉されなければ、そのまま呼び出し元へ 伝播する)。

Source

pub fn generator_return( &mut self, state: &Rc<RefCell<GenState>>, val: Value, ) -> Result<(Value, bool), Value>

.return(val) 相当: 現在中断中の yield 式の位置で return を発生させ、 try…finally ブロック等を実行して generator を再開・完了させる。

Source

pub(crate) fn generator_resume_inner( &mut self, state: &Rc<RefCell<GenState>>, sent: GenCompletion, ) -> Result<(Value, bool), Value>

Source

fn clear_gen_ctx(state: &Rc<RefCell<GenState>>)

Source

fn generator_resume_body( &mut self, state: &Rc<RefCell<GenState>>, sent: GenCompletion, ) -> Result<(Value, bool), Value>

Source

pub(crate) fn iter_step_once( &mut self, next_fn: &Value, iterator: &Value, ) -> Result<Option<Value>, Value>

イテレータを 1 つ進める(IteratorStepValue)。None は完了。

Source

pub(crate) fn drain_generator_deferred( &mut self, gen: &ObjRef, deferred: &mut Option<Value>, ) -> Vec<Value>

drain_generator の for-of 版(途中の例外は deferred へ)。

Source

pub(crate) fn require_iterable(&self, v: &Value) -> Result<(), Value>

反復できない値(undefined・null・数値・真偽値・BigInt)なら TypeError([...1]・f(...null)・ var [a] = 1)。【2026-11-16】以前は空として扱い、例外にならなかった。

Source

pub(crate) fn spread_values(&mut self, v: &Value) -> Result<Vec<Value>, Value>

スプレッド([...x]・f(...x))の要素。反復できない値は TypeError。

Source

pub(crate) fn destructure_values( &mut self, v: &Value, need: Option<usize>, ) -> Result<Vec<Value>, Value>

配列の分割(宣言・代入)の要素。generator は要る個数(need)だけ進める (無限の generator から const [a] = g() で先頭だけ取るため)。【2026-11-16】以前は generator を 空として扱い、var [a] = g() が undefined だった。

Source

pub fn iter_to_vec(&mut self, v: &Value) -> Result<Vec<Value>, Value>

イテラブルを Value 列に展開する。generator は遅延駆動する。 iterable_values(純関数)の generator 対応版。

Source§

impl Interp

Source

pub(crate) fn gen_vm_resume( &mut self, state: &Rc<RefCell<GenState>>, sent: GenCompletion, ) -> Result<Result<(Value, bool), Value>, GenCompletion>

generator を VM で 1 段進める。VM で扱えない本体なら Err(sent) を返す(呼び出し側が replay で実行する)。

Source

fn gen_vm_run(&mut self, f: &mut GenFrame, start: Option<Compl>) -> RunEnd

Source

fn gen_truncate_scopes(&mut self, f: &mut GenFrame, n: usize)

Source

fn gen_unwind( &mut self, f: &mut GenFrame, code: &GenCode, c: Compl, ) -> Option<RunEnd>

通常でない完了でハンドラを外側へたどる。続けて実行するなら None(f.pc を設定済み)。

Source

fn gen_drop_iter(&mut self, f: &mut GenFrame) -> Option<IterRec>

反復の表を外す(next() の例外など、IteratorClose を呼ばずに抜けるとき)。

Source

fn gen_step(&mut self, f: &mut GenFrame, op: &GOp) -> Result<Flow, Value>

Source

fn gen_iter_open(&mut self, obj: &Value, kind: u8) -> Result<IterRec, Value>

Source

fn gen_iter_next(&mut self, f: &mut GenFrame, exit: u32) -> Result<Flow, Value>

for-in/of の次の要素(木の評価の exec_for_in/for_of_lazy と同じ。next() の例外では閉じない)。

Source

fn gen_yield_star(&mut self, f: &mut GenFrame) -> Result<Flow, Value>

yield*(委譲先の反復子を 1 段ずつ進め、値をそのまま外へ渡す。throw()/return() も委譲先へ)。

Source§

impl Interp

Source

pub fn eval( &mut self, expr: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

pub(crate) fn resolve_this( &self, scope: &Rc<RefCell<Scope>>, fallback: &Value, ) -> Result<Value, Value>

変数を読む。スコープに無ければ window のプロパティを見る。

【2026-09-05】ブラウザでは window.x = 1 の後に素の x で読める(グローバルオブジェクトの プロパティ=グローバル変数)。この処理系は window を普通のオブジェクトとして持ち、グローバル変数とは 別管理なので、window.$ = ... が素の $ から見えなかった(jQuery 1.8.2 が $ is not defined になっていた)。【2026-10-22 高速化】self.global から直接 O(1)。

Source

pub(crate) fn load_identifier( &mut self, name: &Rc<str>, scope: &Rc<RefCell<Scope>>, ) -> Result<Value, Value>

Source

pub(crate) fn load_identifier_no_with( &mut self, name: &Rc<str>, scope: &Rc<RefCell<Scope>>, ) -> Result<Value, Value>

Source

fn eval_binary_expr( &mut self, op: &BinaryOp, left: &Expression, right: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

fn eval_member( &mut self, object: &Expression, property: &Rc<str>, optional: bool, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

fn eval_index( &mut self, object: &Expression, index: &Expression, optional: bool, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

fn eval_template_lit( &mut self, quasis: &[String], exprs: &[Expression], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

fn eval_tagged_template( &mut self, tag: &Expression, quasis: &[String], raw: &[String], exprs: &[Expression], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

fn eval_array_lit( &mut self, items: &[Expression], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

fn eval_object_lit( &mut self, props: &[Property], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

pub(crate) fn object_spread_copy( &mut self, o: &ObjRef, src: &Value, ) -> Result<(), Value>

オブジェクトリテラルの ...src(CopyDataProperties)。generator の VM と共用(2026-11-30 に切り出した)。

Source

pub(crate) fn object_lit_func_prop( &mut self, o: &ObjRef, p: &Property, key: PropKey, scope: &Rc<RefCell<Scope>>, this: &Value, home_scope: &mut Option<Rc<RefCell<Scope>>>, ) -> Result<(), Value>

オブジェクトリテラルの、値が関数の定義(メソッド・アクセサ・関数式)のプロパティ。 [[HomeObject]] のスコープ(__home__)で評価する。generator の VM と共用。

Source

pub(crate) fn eval_regex_lit( &self, lit: &(String, String), ) -> Result<Value, Value>

Source

fn expr_contains_yield_or_await(expr: &Expression) -> bool

リプレイで既通過の yield 引数を再評価してよいか判定するため、内側の関数境界を越えずに yield / await の有無を調べる。

Source

fn eval_yield( &mut self, argument: Option<&Expression>, delegate: bool, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

pub(crate) fn eval_function_expr( &self, name: &Option<Rc<str>>, params: &Rc<Vec<Param>>, body: &Rc<FnBody>, is_arrow: bool, is_async: bool, is_generator: bool, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

pub(crate) fn make_function( &self, name: Option<String>, params: Rc<Vec<Param>>, body: Rc<FnBody>, is_arrow: bool, is_async: bool, is_generator: bool, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Value

Source

pub(crate) fn bind_pattern( &mut self, pat: &Pattern, value: Value, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

分割代入パターンへ値を束縛する(var 宣言・引数・for-of 共通)。

Source

fn bind_array_pattern( &mut self, elems: &[ArrPatElem], value: &Value, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

Source

fn bind_array_pattern_lazy( &mut self, elems: &[ArrPatElem], iterator: &Value, next_fn: &Value, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

配列の分割代入(利用者定義の反復子)。next() の例外は閉じずに、束縛・既定値の例外は IteratorClose してから伝える。

Source

fn lookup_private_desc( &self, scope: &Rc<RefCell<Scope>>, name: &str, ) -> Result<PrivateDescriptor, Value>

クラス内のプライベート要素記述子(__priv_#name)をスコープ連鎖から引く。

Source

pub(crate) fn private_get( &mut self, obj: &Value, name: &str, scope: &Rc<RefCell<Scope>>, ) -> Result<Value, Value>

obj.#name の読み出し(フィールド/メソッド/getter、ブランド検査付き)。

Source

pub(crate) fn private_set( &mut self, obj: &Value, name: &str, val: Value, scope: &Rc<RefCell<Scope>>, ) -> Result<(), Value>

obj.#name = val の書き込み(フィールド/メソッド書込禁止/setter、ブランド検査付き)。

Source

pub(crate) fn private_in( &mut self, obj: &Value, name: &str, scope: &Rc<RefCell<Scope>>, ) -> Result<Value, Value>

#name in obj のブランド/スロット存在検査。

Source

pub(crate) fn eval_class( &mut self, name: &Option<String>, superclass: &Option<Box<Expression>>, members: &[ClassMember], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

class を評価し、コンストラクタ関数(prototype・静的メンバ・super 連携付き)を返す。

Source

pub(crate) fn super_ctor( &mut self, scope: &Rc<RefCell<Scope>>, ) -> Result<Value, Value>

現在のスコープから基底クラスのコンストラクタを取得。

Source

pub(crate) fn super_proto( &mut self, scope: &Rc<RefCell<Scope>>, ) -> Result<Value, Value>

super.x の探索の起点(ECMA-262 §13.3.7.3 MakeSuperPropertyReference: baseValue = env.GetSuperBase() = HomeObject.[GetPrototypeOf])。 【2026-11-19】以前は「基底クラスの prototype」固定で、static メソッドや オブジェクトリテラルのメソッド({ __proto__: p, f() { super.x } })で使えなかった。

Source

pub(crate) fn super_get( &mut self, scope: &Rc<RefCell<Scope>>, key: &str, this: &Value, ) -> Result<Value, Value>

super[key] / super.key の読み出し(§6.2.5.5 GetValue: 参照の thisValue = 現在の this)。 起点から原型の連鎖をたどり、アクセサ(getter)が先に見つかれば this を受け手にして呼ぶ。 【2026-11-19】以前は起点オブジェクトを受け手にしていて、getter の this が起点になっていた。

Source

pub(crate) fn super_set( &mut self, scope: &Rc<RefCell<Scope>>, key: &str, val: Value, this: &Value, ) -> Result<(), Value>

super.key = v の書き込み(§10.1.9.2 OrdinarySetWithOwnDescriptor, Receiver = 現在の this)。 起点の連鎖で setter が先に見つかれば this を受け手にして呼ぶ。データ値なら受け手 this の自身のプロパティに書く。

Source§

impl Interp

Source

pub fn promise_resolve( &mut self, state: &Rc<RefCell<PromiseState>>, value: Value, )

Promise を解決する。値が Promise/thenable なら採用(チェーン)する。

Source

pub fn promise_reject( &mut self, state: &Rc<RefCell<PromiseState>>, reason: Value, )

Promise を拒否する。

Source

pub fn promise_then( &mut self, state: &Rc<RefCell<PromiseState>>, on_fulfilled: Option<Value>, on_rejected: Option<Value>, ) -> Value

then 反応を登録し、派生 Promise を返す。

Source

pub(crate) fn schedule_reaction( &self, reaction: &Reaction, value: Value, is_fulfill: bool, )

Source

pub(crate) fn run_one_microtask(&mut self) -> bool

マイクロタスクを 1 つ実行。実行したら true。

Source

pub fn run_microtasks(&mut self)

保留中のマイクロタスクを全て消化する。

microtask_step_cap を超えたら次のジョブの前で戻る。残りは has_due_timers が検知して 次のフレームの pump_timers で続く(実行中のジョブは打ち切らない)。

Source

pub(crate) fn timer_now(&self) -> u64

setTimeout コールバック(マクロタスク)を 1 つ実行。実行したら true。 タイマー用の現在時刻(ミリ秒。実時刻 + 試験用の早送り分)。

Source

pub(crate) fn run_timer(&mut self, force: bool) -> bool

タイマーを 1 つ実行する。force なら期限前でも最も早いものを実行する(同期 await の進行用)。 期限の早い順、同じなら登録順。setInterval は呼ぶ前に次の予定を積み直す(コールバック内の clearInterval で消せるように)。実行したら true。

Source

pub(crate) fn run_one_macrotask(&mut self) -> bool

互換: 期限の来たタイマーを 1 つ実行する。

Source

pub fn has_due_timer(&self) -> bool

期限の来たタイマーがあるか。

Source

fn await_network_step(&mut self, wait_start: &mut Option<u64>) -> bool

同期 await の中で、非同期の通信(XHR)が走っている間の 1 歩。進めたら true。

【2026-11-04】従来は通信の結果を受け取らないまま期限前のタイマーを早送りしていたので、 「応答」と「時間切れのタイマー」の Promise.race を await すると、応答が先に届いていても必ず 時間切れが勝った(YouTube の next/player が net.timeout で失敗した。race を直して表に出た)。 届いた結果を先に配り、次に期限の来たタイマーだけを実行し、どちらも無ければ実時間で少し待つ。 待つのは最大 AWAIT_NET_WAIT_MS まで(過ぎたら従来どおり早送りへ戻る)。

Source

pub fn run_event_loop_for(&mut self, budget_ms: u64)

イベントループ: マイクロタスクを消化 → 期限の来たタイマー 1 つ → 繰り返す。 budget_ms を使い切るか期限の来たタイマーが無くなれば戻る(残りは次の呼び出しで)。

Source

pub fn run_event_loop(&mut self)

スクリプト評価直後のイベントループ(期限の来たタイマーを最大 300ms 分)。

Source

pub(crate) fn chain_suppressed( &mut self, prev: Option<Value>, new_err: Value, ) -> Value

await: 値が Promise ならマイクロタスクを駆動して解決まで進め、値を返す(reject は throw)。 using の複数 dispose が例外を投げた場合に、新しい例外(new_err)と既存の 保留中の例外(prev)を SuppressedError へ集約する。prev が無ければ new_err を そのまま返す(グローバルに SuppressedError が無い異常系でも new_err へ安全にフォールバック)。

Source

pub(crate) fn await_value(&mut self, v: Value) -> Result<Value, Value>

Source§

impl Interp

Source

pub(crate) fn eval_unary( &mut self, op: &UnaryOp, expr: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

pub(crate) fn unary_on_value( &mut self, op: &UnaryOp, v: Value, ) -> Result<Value, Value>

評価済みの値に単項演算子(delete 以外)を適用する(generator の VM と共用。2026-11-30)。

Source

pub(crate) fn eval_delete( &mut self, expr: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

delete expr の実装。expr がプロパティアクセス(obj.x/obj[x])なら 実際にプロパティを取り除いて true を返す。それ以外(変数・リテラル等)は 仕様上ほぼ no-op のため副作用なく true を返す(configurable:false 相当の 「削除できず false」ケースはこの処理系にはプロパティ属性の概念が無いため非対応)。

Source

pub(crate) fn delete_checked(&self, r: Value, key: &str) -> Result<Value, Value>

strict のコードの delete は、削除できなかった([[Delete]] が false)ときに TypeError(§13.5.1.2)。

Source

pub(crate) fn delete_property( &mut self, obj: &Value, property: &str, ) -> Result<Value, Value>

delete obj.prop/delete obj[key] の共通実装(Member/Index 両方から使う)。 以前は Member 経由でしか dataset/style/storage Host プロキシの特別扱いが 効かず、delete element.style['color'] のような Index 経由の等価な書き方だと 何も削除されないバグがあった。

Source

pub(crate) fn eval_update( &mut self, op: &str, prefix: bool, target: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

pub(crate) fn eval_assign( &mut self, op: &str, target: &Expression, value: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

fn delete_identifier( &mut self, name: &Rc<str>, scope: &Rc<RefCell<Scope>>, ) -> bool

delete name。消せるのは代入だけで作られたグローバル変数と window のプロパティ。 宣言された変数は消えず false。

Source

fn assign_ident_no_with( &mut self, name: &Rc<str>, val: Value, scope: &Rc<RefCell<Scope>>, ) -> Result<(), Value>

事前に with 解決済みの識別子に対して宣言的環境またはグローバルへ代入する。

Source

pub(crate) fn assign_to( &mut self, target: &Expression, val: Value, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

代入先(識別子・メンバ・添字)へ値を書き込む。

Source

pub(crate) fn set_on_nullish_error(&self, obj: &Value, key: &str) -> Value

undefined.x = 1 などの TypeError(V8 と同じ文言)。

Source

fn assign_array_destructure( &mut self, items: &[Expression], val: Value, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

配列の分割代入。代入先の各要素は識別子・メンバー・入れ子のパターン(既定値 = v・残り ...r つき)。

Source

fn eval_target_ref( &mut self, target: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Option<(Value, Value)>, Value>

分割代入の要素の代入先がメンバー/添字なら、その参照(対象と添字)を先に評価する。 識別子・入れ子のパターン・super・プライベートは None(従来どおり代入時に処理)。

Source

fn assign_prepared( &mut self, target: &Expression, pre: Option<(Value, Value)>, val: Value, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

eval_target_ref で評価済みの参照へ書き込む。None なら通常の assign_to。

Source

fn assign_array_destructure_lazy( &mut self, items: &[Expression], iterator: &Value, next_fn: &Value, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

Source

fn assign_object_destructure( &mut self, props: &[Property], val: Value, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(), Value>

オブジェクトの分割代入(({a, b: c, [k]: d = 1, ...rest} = o))。

Source

pub(crate) fn eval_key( &mut self, e: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

プロパティキー式の評価 + ToPropertyKey の ToPrimitive(例外を伝える)。

Source

pub(crate) fn prim_key_for( &mut self, base: &Value, k: Value, ) -> Result<Value, Value>

prim_key。ただし基底が undefined/null のときは変換しない(eval_key_for と同じ理由)。

Source

pub(crate) fn eval_key_for( &mut self, base: &Value, e: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

eval_key。ただし基底が undefined/null のときは変換しない(仕様: 基底の検査が ToPropertyKey より先。 呼び出し側が TypeError にする)。

Source

pub(crate) fn prim_num(&mut self, v: Value) -> Result<Value, Value>

数値のヒントで ToPrimitive(オブジェクト以外は素通し。例外を伝える)。

Source

pub(crate) fn prim_key(&mut self, v: Value) -> Result<Value, Value>

プロパティキー用に ToPrimitive(string)(オブジェクト以外は素通し。例外を伝える)。

Source

pub(crate) fn numeric_step( &mut self, v: &Value, delta: f64, ) -> Result<(Value, Value), Value>

++/-- の ToNumeric と加減算(BigInt なら BigInt のまま 1 を足し引きする)。 戻り値は(古い値の数値化、新しい値)。

Source

pub(crate) fn num_of(&mut self, v: &Value) -> Result<f64, Value>

ToNumber(例外を伝える)。オブジェクト以外は Value::to_number と同じ。

Source

pub(crate) fn to_primitive( &mut self, v: Value, hint: &str, ) -> Result<Value, Value>

ToPrimitive(ECMA-262 7.1.1)。原型の連鎖に利用者定義の Symbol.toPrimitive・toString・ valueOf があるときだけ呼ぶ(無ければ値をそのまま返し、従来の組込みの変換に任せる)。 hint は “string”・“number”・“default”。 【2026-10-20】String(obj)・obj + ''・テンプレート文字列・XHR の URL が利用者定義の toString を呼ばず [object Object] になっていた(YouTube の TrustedResourceUrl 相当の URL オブジェクトで GET /[object Object] を送っていた)。

Source

pub(crate) fn to_string_value(&mut self, v: Value) -> Result<String, Value>

ToString(利用者定義の toString を考慮)。

Source

pub fn eval_binary( &mut self, op: &BinaryOp, l: Value, r: Value, ) -> Result<Value, Value>

Source

pub(crate) fn instance_of( &mut self, l: &Value, r: &Value, ) -> Result<Value, Value>

l instanceof r: r.prototype を起点に l のプロトタイプ連鎖を辿って一致を探す (OrdinaryHasInstance の簡略実装。Symbol.hasInstance によるカスタマイズは非対応)。

Source

pub(crate) fn eval_binary_bigint( &mut self, op: &BinaryOp, l: Value, r: Value, ) -> Result<Value, Value>

BigInt が絡む二項演算。BigInt 同士は任意精度演算、BigInt と Number の 混在は算術・ビット演算で TypeError。等価・大小比較は数値として許容する。

Source

pub(crate) fn bigint_loose_eq(&self, l: &Value, r: &Value) -> bool

BigInt を含む緩い等価比較(BigInt↔Number/String を数値として比較)。

Source

pub(crate) fn bigint_compare( &self, op: &BinaryOp, l: &Value, r: &Value, ) -> Value

BigInt を含む大小比較(BigInt↔Number は f64 経由)。

Source§

impl Interp

Source

pub(crate) fn recursion_cycle_detail(&self) -> Vec<String>

呼び出しが深すぎた時、内側 64 段に現れる関数を本体ごとに 1 回ずつ(最大 6 個)説明する。 無名関数どうしの無限再帰がどの関数かを見分けるため(2026-10-29。YouTube で自動再生の後に起きる)。

Source

pub(crate) fn call_stack_names(&self, n: usize) -> Vec<String>

呼び出し中の関数名(内側から最大 n 個)。

Source

pub(crate) fn eval_call( &mut self, callee: &Expression, arguments: &[Expression], optional: bool, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

pub(crate) fn not_callable( &mut self, func: &Value, callee: &Expression, call_this: &Value, ) -> Option<Value>

呼べない値なら TypeError を返す。

Source

pub(crate) fn resolve_callee( &mut self, callee: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(Value, Value, bool), Value>

Call の callee を this 束縛込みで解決する(super/super.method は呼出元 eval_call で先に処理済みのためここには来ない)。戻り値は (関数, call_this, 途中で ?. 短絡したか)。object/callee 側は eval_chain_object を再帰的に使うため、a?.b.c() のように途中で短絡した場合は 以降のプロパティアクセス/引数評価/呼出を一切行わずチェーン全体が undefined になる (ECMA-262 の OptionalChain セマンティクス。以前は最初の ?. の直近1段しか 短絡せず、後続のアクセスで TypeError になっていた)。

Source

pub(crate) fn eval_chain_object( &mut self, expr: &Expression, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<(Value, bool), Value>

Member/Index/Call の「object/callee」位置を短絡込みで評価する。戻り値の bool は「このサブチェーンのどこかで ?. が短絡したか」。短絡時、値は常に Value::Undefined。グローバルな可変フラグではなく戻り値だけで伝播するため、 無関係な式の評価に短絡状態が漏れることが無い。super/super.method を含む Call は短絡セマンティクス対象外のため既存の eval_call にそのまま委譲する。

Source

pub(crate) fn eval_arguments( &mut self, arguments: &[Expression], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Vec<Value>, Value>

呼出引数を評価し、スプレッド ...x を展開した Vec を返す。

Source

pub(crate) fn recycle_args(&mut self, args: Vec<Value>)

呼び終えた引数の Vec をプールへ戻す(呼ばれた側は必要な値を複製済み)。

Source

pub(crate) fn eval_new( &mut self, callee: &Expression, arguments: &[Expression], scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

Source

pub fn construct_value( &mut self, func: &Value, args: &[Value], ) -> Result<Value, Value>

new の本体: インスタンスを生成しコンストラクタを呼ぶ。

Source

pub(crate) fn construct_object( &mut self, func: &Value, args: &[Value], ) -> Result<Value, Value>

Source

pub(crate) fn construct_with_target( &mut self, func: &Value, args: &[Value], new_target: &Value, ) -> Result<Value, Value>

new / Reflect.construct(func, args, new_target)。インスタンスの原型は new_target.prototype(仕様の OrdinaryCreateFromConstructor)。

Source

pub(crate) fn call_enter(&mut self, func: &Value) -> Result<(), Value>

関数呼び出しの共通前処理(再帰深度/スタック検査・コールスタック記録・循環GC)。

Source

pub(crate) fn call_leave(&mut self)

関数呼び出しの共通後処理(CE反応処理・コールスタック/深度復元)。

Source

pub(crate) fn call_value_with_new_target( &mut self, func: &Value, this: Value, args: &[Value], new_target: Value, ) -> Result<Value, Value>

new.target を設定して関数値を呼び出す(ホスト要素の構築フック用)。

Source

fn make_arguments_obj( &self, args: &[Value], callee: Value, is_strict: bool, ) -> Rc<RefCell<Obj>>

arguments オブジェクトを生成する。strict 関数では callee をシングルトン %ThrowTypeError% アクセサにする。

Source

pub fn call_value( &mut self, func: &Value, this: Value, args: &[Value], ) -> Result<Value, Value>

関数値を呼び出す。

Source

pub fn call_listener( &mut self, func: &Value, this: Value, args: &[Value], context: &str, ) -> bool

イベントリスナ・タイマコールバック・オブザーバ通知など、 呼び出し元へ例外を返せない場所からの関数呼び出し。

【2026-07-28】これらは従来 let _ = self.call_value(...) と書かれており、 ハンドラ内で投げられた例外はコンソールにもログにも現れず完全に消えていた (「ボタンを押しても何も起きない」だけが症状として残る)。ブラウザ同様、 捕捉されなかった例外は必ず報告する。

Source

pub fn report_uncaught(&mut self, context: &str, thrown: &Value)

捕捉されなかった例外を、ページのコンソール出力とシリアルログの両方へ出す。

Source

pub(crate) fn dispatch_call_kind( &mut self, kind: CallKind, func: &Value, this: Value, args: &[Value], ) -> Result<Value, Value>

1 回の borrow で取得済み CallKind を実行する(call_value_inner と op_call の共通本体)。

Source

pub(crate) fn call_value_inner( &mut self, func: &Value, this: Value, args: &[Value], ) -> Result<Value, Value>

Source

pub(crate) fn alloc_call_scope( &mut self, parent: Rc<RefCell<Scope>>, n_vars: usize, ) -> Rc<RefCell<Scope>>

Source

pub(crate) fn alloc_block_scope( &mut self, parent: Rc<RefCell<Scope>>, ) -> Rc<RefCell<Scope>>

Source

pub(crate) fn recycle_call_scope(&mut self, scope: Rc<RefCell<Scope>>)

Source

pub(crate) fn recycle_block_scope(&mut self, scope: Rc<RefCell<Scope>>)

Source

pub(crate) fn global_window(&mut self) -> Value

グローバルオブジェクト(globalThis)。位置を覚えて毎回の名前の検索を省く(非 strict の関数の呼び出しごとに要る)。

Source

pub(crate) fn call_user_function( &mut self, fd: &FunctionData, this: Value, args: &[Value], callee: Value, ) -> Result<Value, Value>

Source

fn call_user_function_inner( &mut self, fd: &FunctionData, this: Value, args: &[Value], callee: Value, dt_cell: Option<Rc<RefCell<Option<Value>>>>, ) -> Result<Value, Value>

Source§

impl Interp

Source

pub(crate) fn string_get_prop(&self, sv: &Value, key: &str) -> Value

Source

pub(crate) fn number_get_prop(&self, key: &str) -> Value

Source

pub(crate) fn boolean_get_prop(&self, key: &str) -> Value

Source

pub(crate) fn bigint_get_prop(&self, key: &str) -> Value

Source

pub(crate) fn object_get_prop(&self, o: &ObjRef, key: &str) -> Value

Source

pub(crate) fn has_property_chain(&self, o: &ObjRef, key: &str) -> bool

key in obj 用: 自身 props → プロトタイプ連鎖を辿って存在判定。 配列の length / 数値インデックスも考慮する。

Source

pub(crate) fn is_global_obj(&self, o: &ObjRef) -> bool

o がグローバルオブジェクト(globalThis / ブラウザ時は window)か。

Source

pub(crate) fn is_window_obj(&self, o: &ObjRef) -> bool

is_global_obj の互換名。

Source

pub fn get_property_of_expr( &mut self, recv: &Value, key: &str, obj_expr: &Expression, ) -> Result<Value, Value>

recv.key を読む。recv が undefined/null のときの例外に、その値を生んだ式 (obj_expr)を stack の先頭行の直後へ添える(2026-09-26。どの式が undefined だったか分からず、ミニファイされたライブラリの不具合を追えなかった)。

Source

pub(crate) fn get_index_fast(&self, obj: &Value, key: &Value) -> Option<Value>

数値の添字 obj[n] の読み取りの近道(配列・型付き配列・文字列)。扱えなければ None (呼び出し側は文字列キーの get_property へ回す)。 【2026-10-24】従来は添字を毎回文字列に変換(確保と数値の書式化)して文字列キーで 引き直していた。YouTube が JS 版 zlib(pako)で送信データを圧縮する内側のループ (S.window[p+2] 等)が QEMU で 1 回 90µs かかり、再生開始が数分遅れていた。 【2026-11-10】Value::Str に対するインデックスアクセスも直接高速処理し、UTF-16 単位キャッシュ から O(1) ゼロアロケーションで文字を返却可能に拡張。

Source

pub(crate) fn set_index_fast( &mut self, obj: &Value, key: &Value, val: Value, ) -> Option<Value>

数値の添字 obj[n] = v の書き込みの近道。扱えたら None、扱えなければ値を返す (呼び出し側は文字列キーの set_property へ回す)。 【2026-11-10】範囲内要素の上書きに加え、末尾要素の追加(i == items.len())および 近傍拡張(i - items.len() <= 64)を直接 push/resize でゼロアロケーション実行可能にし、 かつ _ta_kind の走査をゼロコピー借用に刷新。

Source

pub fn get_property(&mut self, recv: &Value, key: &str) -> Result<Value, Value>

Source

pub(crate) fn get_property_proto_chain( &mut self, recv: &Value, o: &ObjRef, key: &str, start: Option<ObjRef>, ) -> Result<Value, Value>

自身のプロパティ / アクセサ / プロトタイプ連鎖を辿って解決する。 アクセサの getter は必ず元の recv(レシーバ)を this として呼ぶ。 以前はプロトタイプ連鎖を get_property の再帰で辿っていたため、 継承した getter(class の get x(){} 等)を呼ぶ際に this が プロトタイプ自身に化けてしまい、インスタンス側のフィールドを 正しく読めない(this.r 等が常に undefined になる)バグがあった。 ここでは recv を固定したまま cur だけをプロトタイプ連鎖に沿って 進めるループに書き換えている。

Source

pub(crate) fn proto_chain_lookup( &mut self, recv: &Value, o: &ObjRef, key: &str, start: Option<ObjRef>, ) -> Option<Result<Value, Value>>

原型連鎖(実体が原型を持たない組込みは、種類に応じた組込みの prototype と Object.prototype まで)を 辿って、自前・アクセサ・継承のプロパティを探す。見つからなければ None(組込みの名前表へは進まない)。 【2026-11-20】以前は proto が無い配列・素のオブジェクトで連鎖が途切れ、Array.prototype.foo = …; [].foo()・ Object.prototype.bar = …; ({}).bar() が「関数でない」になっていた(test262 の原型汚染の試験が大量に落ちる)。

Source

pub fn set_property(&mut self, recv: &Value, key: &str, val: Value)

[[Set]] の結果を捨てる版(組み込み関数の内部用。従来どおり、失敗は黙殺し、setter・Proxy の例外は報告だけする)。

Source

pub fn set_property_rc(&mut self, recv: &Value, key: &Rc<str>, val: Value)

Source

pub fn put_value( &mut self, recv: &Value, key: &str, val: Value, ) -> Result<(), Value>

利用者のコードの代入(PutValue。ECMA-262 §6.2.5.6)。[[Set]] が false を返したとき、strict のコードなら TypeError、 setter・Proxy の set トラップが投げた例外は常に呼び出し元へ伝える。

Source

pub fn put_value_rc( &mut self, recv: &Value, key: &Rc<str>, val: Value, ) -> Result<(), Value>

Source

fn put_failed(&mut self, recv: &Value, key: &str) -> Result<(), Value>

Source

pub(crate) fn set_property_inner( &mut self, recv: &Value, key: &str, key_rc: Option<&Rc<str>>, val: Value, ) -> Result<bool, Value>

[[Set]](OrdinarySet 相当)。成功なら Ok(true)、拒否(書込み不可・拡張不可・setter なし)は Ok(false)、 setter・Proxy トラップの例外は Err。

Source

fn set_on_primitive( &mut self, recv: &Value, key: &str, val: Value, ) -> Result<bool, Value>

プリミティブ値への代入(OrdinarySet で receiver がオブジェクトでない場合)。原型連鎖に setter があれば this に そのプリミティブを渡して呼ぶ。それ以外は常に拒否(Ok(false)。strict では TypeError)。

Source§

impl Interp

Source

pub(crate) fn next_private_brand_id(&self) -> u64

新しい一意なプライベートブランド ID を払い出す。

Source

pub(crate) fn effective_this(&self, fallback: &Value) -> Value

super() が返したオブジェクトで置換された現在の this を返す。

Source

pub(crate) fn global_object(&self) -> Option<ObjRef>

グローバルオブジェクト(globalThis / ブラウザ時は window)を取得する。

Source

pub(crate) fn sync_global_prop_if_present( &self, name: &str, val: &Value, ) -> Option<Value>

グローバル変数の値更新を globalThis.props へ同期する(既に自前プロパティとして存在する場合のみ)。 writable: false のため更新を拒否した場合は Some(元の値) を返す(globalThis 以外のレキシカル宣言等は None)。

Source

pub fn builtin_fn_val(&self, name: &'static str, func: NativeFn) -> Value

組込みネイティブ関数のシングルトン値を取得する(無ければキャッシュに登録して返す)。 プロパティ参照([].push や el.getAttribute 等)での無駄なアロケーションをゼロにする。 関数ポインタアドレス func as usize をキーにすることで、[].slice と "".slice 等の 同名・別実装メソッド間のキャッシュ衝突を防ぐ。

Source

pub fn char_unit_val(&self, u: Option<u16>) -> Value

UTF-16 の単位 1 個の文字列。ASCII は実行環境ごとに使い回す(builtin_fn_cache の鍵 1〜128。2026-11-05。 s.charAt(i)・s[i] が 1 文字ごとに確保を 2 回していた)。

Source

pub fn empty_str_val(&self) -> Value

空文字列 "" のシングルトン Value を取得する(毎回ヒープアロケーションしない)。

Source§

impl Interp

Source

pub(crate) fn take_pending_new_target(&mut self) -> Option<Value>

new で呼ばれたネイティブのコンストラクタが、new.target を受け取る(呼ばれたのが new でなければ None)。

Source

pub(crate) fn resolve_with_scope( &mut self, scope: &Rc<RefCell<Scope>>, name: &str, ) -> Result<Option<(ObjRef, bool)>, Value>

with (obj) スコープチェーン上で識別子 name を解決する(HasBinding + @@unscopables)。

Source

pub(crate) fn with_get_binding_value( &mut self, wobj: &ObjRef, name: &str, _had_unscopables: bool, ) -> Result<Value, Value>

with オブジェクト環境レコードの GetBindingValue(ECMA-262 §9.1.1.2.6)。

Source

pub(crate) fn with_set_mutable_binding( &mut self, wobj: &ObjRef, name: &str, val: Value, ) -> Result<(), Value>

with オブジェクト環境レコードの SetMutableBinding(ECMA-262 §9.1.1.2.5)。

Source§

impl Interp

Source

pub(crate) fn attrs_map_get(&mut self, elem: usize, key: &str) -> Option<Value>

element.attributes(HOST_ATTRS)のメンバー。見つからないときは None(原型連鎖へ)。

Source

pub(crate) fn attrs_map_values(&self, elem: usize) -> Vec<Value>

for…of・展開で並べる Attr のハンドル。

Source

pub(crate) fn attr_node_get(&mut self, idx: usize, key: &str) -> Option<Value>

#attr ノード idx のメンバー。#attr でなければ None。

Source

pub(crate) fn attr_node_set(&mut self, idx: usize, key: &str, s: &str) -> bool

#attr ノードへの代入。扱ったら true。

Source§

impl Interp

Source

pub(crate) fn doc_node_get(&mut self, idx: usize, key: &str) -> Option<Value>

#document ノード idx の Document のメンバー。#document でなければ None(呼び出し側は通常の経路へ進む)。

Source

pub(crate) fn doc_node_set(&mut self, idx: usize, key: &str, s: &str) -> bool

#document ノードへの代入。扱ったら true。

Source§

impl Interp

Source

pub(crate) fn dom_exception(&self, name: &str, message: &str) -> Value

組み込みの DOMException の原型(DOMException.prototype)を持つ例外オブジェクトを作る (2026-11-19。e instanceof DOMException・e.constructor === DOMException が成り立つ。WPT の assert_throws_dom が見る)。 グローバルに DOMException が無ければ原型なしの make_dom_exception と同じ。

Source§

impl Interp

Source

fn ce_registry(&self) -> Option<ObjRef>

customElements の登録表(名前 → コンストラクタ)。

Source

pub(crate) fn ce_ctor_for(&self, tag: &str) -> Option<Value>

要素名 tag に定義されたコンストラクタ。

Source

pub(crate) fn ce_constructs_element(&self, new_target: &Value) -> bool

new new_target をカスタム要素の構築として扱うか(昇格中・同じ new.target の入れ子の構築・ 登録済みのクラス)。それ以外は原型が HTMLElement に届いても普通のオブジェクトとして構築する。 【2026-10-24】Polymer の templatize は <template> を拡張する ES5 の関数 v(原型が HTMLTemplateElement 経由で HTMLElement に届く。本体は既存のテンプレートを返すだけ)を new v() しており、未登録のため「Illegal constructor」で落ちていた(ブラウザでは普通の オブジェクトが作られる)。

Source

fn ce_name_for_ctor(&self, func: &Value) -> Option<String>

コンストラクタ func を登録した要素名。

Source

pub(crate) fn element_class_proto(&self, func: &Value) -> Option<ObjRef>

func.prototype の連鎖が HTMLElement.prototype に届くか(カスタム要素のクラスか)。

Source

pub(crate) fn ce_construct_target( &mut self, new_target: &Value, proto: ObjRef, ) -> Result<(usize, bool), Value>

カスタム要素のクラスの new: this にする DOM 要素の添字を決め、原型を付ける。 戻り値の bool は新しく構築を始めたか(構築スタックに積むか)。

  • 構築中の要素と同じ new.target の入れ子の構築(ES5 版の Reflect.construct(HTMLElement, [], this.constructor))は、同じ要素を返す(仕様の構築スタック)。
  • 昇格中ならその要素、そうでなければ new.target の登録名で要素を作る(未登録なら TypeError)。
Source

pub(crate) fn ce_try_upgrade(&mut self, idx: usize, connected: bool) -> bool

要素 idx を(定義があり、未昇格なら)昇格する。connected なら connectedCallback も呼ぶ。 昇格したら true。

Source

fn ce_callback(&mut self, idx: usize, name: &str)

昇格済みのカスタム要素のライフサイクル関数を呼ぶ(無ければ何もしない)。

Source

pub(crate) fn ce_adopted_callback(&mut self, idx: usize)

カスタム要素の adoptedCallback(oldDocument, newDocument) を呼ぶ

Source

pub(crate) fn process_ce_reactions(&mut self)

溜まったカスタム要素の反応を処理する(DOM を変える呼び出しの後に呼ぶ)。

反応の中(connectedCallback 等)で DOM を変えた場合も、その呼び出しが戻る前に処理する (仕様の CEReactions は呼び出しごとに要素キューを積んで、戻る前に空にする)。 【2026-10-24】従来は処理中の再入を禁じて外側の処理の後へ回していたため、YouTube の <ytd-watch-flexy> が connectedCallback 内でテンプレートを複製した直後に呼ぶ getPlayer().preparePlayer() で、子の <ytd-player> がまだ昇格しておらず例外になっていた。

Source§

impl Interp

Source

pub fn dispatch_event_in_interp( &mut self, node_idx: usize, event_type: &str, extra: &[(String, Value)], ) -> (bool, bool)

element.dispatchEvent から呼ぶ Interp 内ディスパッチ。JsRuntime 版と同じ capture→target→bubble の3フェーズ・once・stopPropagation を再現するが、 リスナは self.call_value で同一 Interp 上で実行する。戻り値: (発火したか, defaultPrevented)。

Source

pub fn dispatch_event_object( &mut self, node_idx: usize, event_type: &str, extra: &[(String, Value)], user_ev: Option<ObjRef>, ) -> (bool, bool)

dispatch_event_in_interp の、呼び出し元のイベントオブジェクト user_ev をそのまま リスナーへ渡す版(element.dispatchEvent(ev))。仕様どおりリスナーと呼び出し元は同じ オブジェクトを見る。【2026-10-24】従来は複製した新しいオブジェクトを渡していたため、 ShadyDOM(YouTube)がイベントに付けた印や、リスナー側で付けた値が呼び出し元に見えなかった。

Source

fn set_dispatch_target( &self, ev: &ObjRef, adj: &[Option<usize>], related: &[Option<usize>], has_related: bool, pos: usize, )

パス位置 pos の呼び出しに向け、event.target(直前までで最後の非 null な shadow-adjusted target) と retarget 済み relatedTarget を設定する。

Source

fn fire_window_listeners_in_dispatch( &mut self, ev: &ObjRef, event_type: &str, want_capture: bool, ) -> (bool, bool)

Source

fn fire_document_listeners( &mut self, ev: &ObjRef, event_type: &str, want_capture: bool, ) -> (bool, bool)

documentの_listeners[event_type]のうちcaptureフラグがwant_capture と一致するリスナを発火する。

Source

pub(crate) fn dom_obj(&self, idx: usize) -> ObjRef

DOM ノード idx の JS のオブジェクト。ノードごとに 1 個にまとめる。

【2026-11-02】従来はアクセスのたびに新しいオブジェクトを作っていた。YouTube の視聴ページでは ノード約 1.5 万個に対して 9 万個が生きていて、同じ要素をキーにした Map・WeakMap も毎回 別のキーになっていた。弱参照で覚えるので、JS が手放せば今までどおり解放される。

Source

pub(crate) fn dom_val(&self, idx: usize) -> Value

Value::Object(self.dom_obj(idx))。

非 DOM の EventTarget(window/XMLHttpRequest 等)向け relatedTarget の retarget。

Source

fn is_mouse_event_obj(&self, ev: &ObjRef) -> bool

ev が MouseEvent(またはそのサブクラス)のインスタンスか。

Source

fn post_activation_step( &mut self, act_idx: usize, act_state: Option<ActivationState>, default_prevented: bool, click_target_idx: usize, )

activation behavior の事後処理(click イベント配送完了・window.event 復元後)。

Source§

impl Interp

Source

pub(crate) fn dom_get_property(&mut self, disp: DomDisp, key: &str) -> Value

Source

pub(crate) fn dom_builtin_get(&mut self, idx: usize, key: &str) -> Value

要素の組込みメンバだけを引く(expando・カスタム要素のクラスを見ない)。 Element.prototype.setAttribute 等の転送用ネイティブが使う。

Source

pub(crate) fn dom_builtin_set(&mut self, idx: usize, key: &str, val: Value)

要素の組込みプロパティに書く(クラスの setter を経由しない)。

Source

fn dom_proto_override(&mut self, idx: usize, key: &str) -> Option<Value>

要素の原型連鎖に JS が定義した上書き(ネイティブでない関数・getter)があれば返す。 【2026-10-20】YouTube は Node.prototype.appendChild 等を JS で包み、挿入時に monomer 部品の接続処理を呼ぶ(usePatchedLifecycles)。組込みが先だと包みが効かず、 ytd-page-manager が接続されないまま視聴ページが描かれなかった。

Source

fn ce_chain_get(&mut self, idx: usize, key: &str) -> Option<Value>

昇格したカスタム要素のクラスの原型連鎖から key を引く(無ければ None)。

Source

pub(crate) fn dom_element_get(&mut self, idx: usize, key: &str) -> Value

Source

fn dom_proto_chain_get(&mut self, idx: usize, key: &str) -> Value

DOM 要素の原型の連鎖から key を引く(無ければ undefined)。

Source

pub(crate) fn dom_set_property(&mut self, disp: DomDisp, key: &str, val: Value)

Source

fn elem_ns_local(&self, idx: usize) -> Option<(Option<String>, String)>

要素ノードなら (namespaceURI, localName) を返す(テキスト・コメント・PI 等は None)。

Source

fn is_rel_list_elem(&self, idx: usize) -> bool

relList を持つ要素か(HTML の a/area/link/form、または SVG/MathML の a)。

Source

fn token_list_val(&self, class: u8, idx: usize) -> Value

DOMTokenList プロキシオブジェクトを生成し、DOMTokenList.prototype を接続して返す。

Source

pub(crate) fn get_iframe_content_window(&mut self, idx: usize) -> Value

iframe 要素の contentWindow(子フレームの WindowProxy オブジェクト)を取得し、同一ノードでは同一インスタンスを返す。

Source§

impl Interp

Source

pub(crate) fn dom_state(&self) -> &InterpHostState

Source

pub fn dom(&self) -> &Rc<RefCell<DomBridge>>

DOM ブリッジへの参照。

Source

pub(crate) fn wasm(&self) -> &Rc<RefCell<WasmState>>

Source

pub(crate) fn pending_xhrs(&self) -> &Rc<RefCell<BTreeMap<u64, Value>>>

Source

pub fn clean_unreachable_dom_resources(&self) -> usize

文書ツリーに属しておらず、かつ JS の変数やキャッシュからも参照されていない孤立 DOM ノードの リソース(リスナ、expando、カスタム要素プロトタイプ等)を解放する。

Source

pub(crate) fn media_status(&self, idx: usize) -> Option<PlaybackStatus>

<video>/<audio> が再生スレッドの対象(src が一致)なら、その再生状態。

Source

pub(crate) fn media_source_duration(&self, src: &str) -> Option<f64>

MSE の要素の長さ(秒): JS が設定した mediaSource.duration、無ければ buffered の終わり。

Source

pub(crate) fn resolve_url_against_page(&self, raw: &str) -> String

href/src/action IDL プロパティ用: 現在のページURL基準で相対URLを 絶対URLへ解決する(JsRuntime::new_interp の base_url 解決と同じ真実源)。

Source§

impl Interp

Source

pub(crate) fn dom_document_get( &mut self, o: &ObjRef, key: &str, ) -> Option<Value>

document の取得(body・head・title・cookie など。HOST_DOCUMENT)。 None は「ホストとしては処理しない」(getElementById 等のメソッドは通常の props 解決へ)。

Source

pub(crate) fn dom_document_set( &mut self, o: &ObjRef, key: &str, val: &Value, ) -> bool

document への代入(title・cookie)。処理したら true。

Source

pub(crate) fn dom_form_collection_get( &mut self, o: &ObjRef, key: &str, ) -> Option<Value>

RadioNodeList.prototype.value(HTML Standard §4.10.21.1 getter)と select.selectedIndex の取得。 対象外なら None(核が普通の解決を続ける)。

Source

pub(crate) fn dom_form_collection_set( &mut self, o: &ObjRef, key: &str, val: &Value, ) -> bool

RadioNodeList.prototype.value = val(同 setter)と select.selectedIndex = n。処理したら true。

Source

pub(crate) fn get_dom_node_proto(&self, node_idx: usize) -> Option<ObjRef>

DOM ノードのタグ名または種別から、動的に対応する HTMLXxxElement.prototype (または HTMLElement.prototype / Element.prototype / Node.prototype)を解決する。

Source§

impl Interp

Source

pub(crate) fn run_post_connection_steps(&mut self)

積まれた post-connection steps を処理し、外れた子フレームを捨てて window.length・window[i] を直す。 何も無ければすぐ戻る(関数呼び出しのたびに呼ばれる)。

Source

fn prune_frames_if_needed(&mut self)

木から外れた(閲覧コンテキストのある文書に繋がらなくなった)枠の子文書を捨てる。

Source

fn post_connect_one(&mut self, idx: usize)

Source

fn prepare_inserted_script(&mut self, idx: usize)

<script> の準備(HTML「prepare the script element」の、この処理系で扱う部分)。

Source

fn run_inline_script( &mut self, idx: usize, code: &str, frame_elem: Option<usize>, )

インラインのクラシックスクリプトを同期で実行する(document.currentScript を設定・復元し、例外は報告する)。

Source

fn setup_inserted_frame(&mut self, idx: usize)

<iframe>/<frame> の post-connection steps: 子の閲覧コンテキスト(about:blank の文書)を作り、 src が無ければ load を同期で送る。

Source

pub(crate) fn frame_has_browsing_context(&mut self, idx: usize) -> bool

枠の要素が子の閲覧コンテキストを持つか(contentWindow・contentDocument 用)。 閲覧コンテキストのある文書に繋がっていて post-connection 待ちでなければ、ここで子文書を作る (パーサが作った <iframe> は挿入の経路を通らないため)。

Source

pub(crate) fn sync_child_frames(&mut self)

主文書の window と各子フレームの contentWindow の length・[i] を、接続中の子フレームに合わせる(ツリー順)。

Source

fn set_window_frames(&mut self, win: &ObjRef, frames: &[usize])

Source§

impl Interp

Source

fn reflect_entry(&self, idx: usize, key: &str) -> Option<&'static Entry>

表の中で、この要素・この名前に当たる行。

Source

pub(crate) fn reflect_get(&mut self, idx: usize, key: &str) -> Option<Value>

el.<key> の取得。表に無ければ None(従来の実装へ)。

Source

fn reflect_resolve_url(&self, raw: &str) -> String

反映する URL 属性の取得: 文書の URL を基準に解析し、できなければ属性値そのまま(空文字列も基準 URL になる)。

Source

fn reflect_local(&self, idx: usize) -> Option<String>

Source

pub(crate) fn reflect_set(&mut self, idx: usize, key: &str, val: &Value) -> bool

el.<key> = val。表で処理したら true。

Source

pub(crate) fn anchor_url(&self, idx: usize) -> Option<Url>

<a>/<area> の href を、文書の URL を基準に解析した URL(解析できなければ None)。

Source

pub(crate) fn anchor_get(&self, idx: usize, key: &str) -> String

a.protocol などの取得(URL 分解プロパティ)。

Source

pub(crate) fn anchor_set(&mut self, idx: usize, key: &str, v: &str)

a.protocol = v などの代入。新しい URL を href 属性へ書く。

Auto Trait Implementations§

§

impl !RefUnwindSafe for Interp

§

impl !Send for Interp

§

impl !Sync for Interp

§

impl !UnwindSafe for Interp

§

impl Freeze for Interp

§

impl Unpin for Interp

§

impl UnsafeUnpin for Interp

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.