Skip to main content

FuncState

Struct FuncState 

Source
pub struct FuncState {
Show 20 fields pub f: Box<LuaProto>, pub prev: Option<Box<FuncState>>, pub bl: Option<Box<BlockCnt>>, pub pc: i32, pub lasttarget: i32, pub previousline: i32, pub nk: i32, pub np: i32, pub nabslineinfo: i32, pub firstlocal: i32, pub firstlabel: i32, pub ndebugvars: i16, pub nactvar: u8, pub nactvar_reg: u8, pub first_scope_barrier: usize, pub nups: u8, pub freereg: u8, pub iwthabs: u8, pub needclose: bool, pub last_token_line: i32,
}
Expand description

Per-function compilation state. One per function being compiled; nested functions chain through prev (innermost first), heap-allocated as an Option<Box<FuncState>> owned by LexState.

Fields§

§f: Box<LuaProto>

The prototype under construction, owned outright (rather than behind the GC’s RefCell) for the duration of compilation; [close_func] hands it to the GC or the parent function at close time.

§prev: Option<Box<FuncState>>§bl: Option<Box<BlockCnt>>§pc: i32§lasttarget: i32§previousline: i32§nk: i32§np: i32§nabslineinfo: i32§firstlocal: i32§firstlabel: i32§ndebugvars: i16§nactvar: u8§nactvar_reg: u8

The number of active-variable registers actually occupied on the VM stack — C’s luaY_nvarstack(fs) / reglevel(fs, fs->nactvar). Equal to nactvar while every active variable is a real register-backed local, but strictly less once a <const> compile-time constant (RDKCTC) is in scope, since such a variable is counted by nactvar yet consumes no register. This is the watermark every register-bound codegen helper (cg_free_reg, cg_exp_to_any_reg, cg_free_reg_if_temp) must compare against instead of nactvar; it is maintained by adjust_local_vars and remove_vars (the only sites that grow/shrink the active set) so it is readable from FuncState-only contexts that cannot reach LexState’s dyd.actvar to recompute reglevel.

§first_scope_barrier: usize§nups: u8§freereg: u8§iwthabs: u8§needclose: bool§last_token_line: i32

Current ls.lastline, mirrored on every sync_from_lex. [emit_inst] attributes each instruction’s line to the just-consumed token via this field, instead of whatever line the caller threaded down. The threaded line parameter survives only for explicit line-fixup overrides.

Trait Implementations§

Source§

impl Debug for FuncState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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