Skip to main content

Interp

Struct Interp 

Source
pub struct Interp {
Show 18 fields pub steps: u64, pub max_steps: u64, pub depth: u32, pub max_depth: u32, pub aborted: bool, pub out: String, pub dom: Rc<RefCell<DomBridge>>, pub microtasks: Rc<RefCell<VecDeque<Job>>>, gen_replay: Option<GenReplay>, pub macrotasks: Rc<RefCell<VecDeque<(Value, Vec<Value>, u64)>>>, pub base_url: String, pub global: Rc<RefCell<Scope>>, pub io_callbacks: Vec<Value>, pub intervals: Vec<(u64, Value, Vec<Value>, u32)>, pub modules: ModuleRegistry, pending_label: Option<String>, pending_new_target: Option<Value>, new_target_stack: Vec<Value>,
}
Expand description

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

Fields§

§steps: u64§max_steps: u64§depth: u32§max_depth: u32§aborted: bool§out: String§dom: Rc<RefCell<DomBridge>>

DOM ブリッジ(ネイティブ DOM メソッドが借用して読み書きする)。

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

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

§gen_replay: Option<GenReplay>

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

§macrotasks: Rc<RefCell<VecDeque<(Value, Vec<Value>, u64)>>>

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

§base_url: String

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

§global: Rc<RefCell<Scope>>

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

§io_callbacks: Vec<Value>

IntersectionObserver コールバックキュー(ページ実行後に fire_intersection_observers で発火)。

§intervals: Vec<(u64, Value, Vec<Value>, u32)>

setInterval 登録テーブル: (id, callback, extra_args, remaining_fires)

§modules: ModuleRegistry

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

§pending_label: Option<String>

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

§pending_new_target: Option<Value>

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

§new_target_stack: Vec<Value>

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

Implementations§

Source§

impl Interp

Source

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

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

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

Source

pub(crate) fn exec_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

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

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

Source§

impl Interp

Source

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

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

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

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

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

Generator を最後まで駆動して yield 値を Vec に集める(for-of / spread 用)。 無限 generator はステップ予算超過(aborted)で打ち切られる。

Source

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

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

Source§

impl Interp

Source

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

Source

pub(crate) fn make_function( &self, name: Option<String>, params: Vec<Param>, body: Vec<Statement>, 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

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>

基底クラスの prototype を取得。

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)

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

Source

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

setTimeout コールバック(マクロタスク)を 1 つ実行。実行したら true。

Source

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

setInterval コールバックを発火し、残回数をデクリメント。全完了なら true。

Source

pub fn run_event_loop(&mut self)

イベントループ: マイクロタスクを消化 → マクロタスク 1 つ → インターバル → 繰り返す。

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 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_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

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

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

Source

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

Source

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

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

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 eval_call( &mut self, callee: &Expression, arguments: &[Expression], optional: bool, scope: &Rc<RefCell<Scope>>, this: &Value, ) -> Result<Value, Value>

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

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

document_listeners[event_type]のうちcaptureフラグがwant_capture と一致するリスナを発火する。documentself.dom.nodesの一員では なくDOMの祖先チェーンpathに含まれないため、キャプチャ方向では 最も外側、バブル方向では最後の仮想的な祖先としてdispatch_event_ in_interpの冒頭(キャプチャ)と末尾(バブル)から呼ばれる (2026-07-16新設。event_target_dispatch_eventの発火ループと同型の ロジックだが、document用にターゲット/フェーズ番号を差し替えている)。 戻り値は (1件でも発火したか, stopPropagation/stopImmediatePropagation で打ち切られたか)

Source

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

Source

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

Source§

impl Interp

Source

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

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

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

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

Source

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

Source§

impl Interp

Source

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

Source

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

Source

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

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.