Skip to main content

GenState

Struct GenState 

Source
pub struct GenState {
Show 14 fields pub func: FunctionData, pub args: Vec<Value>, pub this: Value, pub param_vars: Vec<(Rc<str>, Value)>, pub sent: Vec<GenCompletion>, pub started: bool, pub done: bool, pub returned: Value, pub call_scope: Option<Rc<RefCell<Scope>>>, pub done_stmts: Vec<Option<DoneStmtEntry>>, pub saved_scopes: Vec<Rc<RefCell<Scope>>>, pub(crate) vm_mode: u8, pub(crate) vm: Option<Box<GenFrame>>, pub(crate) executing: bool,
}
Expand description

Generator の状態。

【2026-11-30】本体は原則として interp::gen_vm の VM で実行し、yield で実行状態(vm)を 保存して本当に中断・再開する(副作用は 1 回だけ、return()/throw() は中断位置から finally・ IteratorClose を通る、長い generator も線形時間)。VM で扱えない構文(with の中の yield など)を 含む本体だけ、従来どおり resume のたびに本体を先頭から再実行(replay)し、N 番目の yield で中断する (sent・done_stmts などの欄はその方式用)。

Fields§

§func: FunctionData

generator 関数本体(params/body/closure を保持)。

§args: Vec<Value>

呼び出し時の実引数。

§this: Value

呼び出し時の this。

§param_vars: Vec<(Rc<str>, Value)>

呼び出し時に束縛し終えた仮引数の値(再実行のたびに仮引数の分解・既定値を評価し直さないため)。

§sent: Vec<GenCompletion>

既に通過した各 yield に .next(v)/.throw(e)/.return(v) で渡された結果。

§started: bool

最初の .next() を消費済みか(最初の next の引数は捨てられる)。

§done: bool

完了済みか(以降の next は常に done:true)。

§returned: Value

完了時の return 値(done:true の value)。

§call_scope: Option<Rc<RefCell<Scope>>>

初回起動時に作成した実行用スコープ(リプレイ間でローカル変数を維持し、先頭文・巻き上げの二重実行を防ぐ)。

§done_stmts: Vec<Option<DoneStmtEntry>>

完了した文の範囲情報 (end_stmt_cursor, end_scope_cursor, end_ctx_cursor, end_yield_counter, val)。

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

リプレイ間で維持される子ブロックスコープ列。

§vm_mode: u8

実行方式(GEN_MODE_*。最初の resume で決める)。2026-11-30

§vm: Option<Box<GenFrame>>

VM 方式の中断中の実行状態(命令位置・値スタック・スコープ・try/反復子の表)。実行中は取り出して None。

§executing: bool

本体を実行中か(同期 generator の再入は TypeError、非同期は待ち行列へ)。

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