Skip to main content

LexState

Struct LexState 

Source
pub struct LexState {
Show 17 fields pub current: i32, pub linenumber: i32, pub lastline: i32, pub t: LexToken, pub lookahead: LexToken, pub fs: Option<Box<FuncState>>, pub dyd: DynData, pub source: Option<GcRef<LuaString>>, pub envn: Option<GcRef<LuaString>>, pub lex: LexState, pub recursion_depth: u32, pub global_strict: bool, pub global_wildcard: bool, pub global_wildcard_const: bool, pub declared_globals: Vec<(GcRef<LuaString>, bool)>, pub scope_barriers: Vec<ScopeBarrier>, pub global_function_names: Vec<GcRef<LuaString>>,
}
Expand description

PORT NOTE: This is a Phase A stub. In Phase B, LexState lives in lua-lex and lua-parse imports it. FuncState will move here or be passed separately. The fs field creates a circular-crate dependency that Phase B must resolve (likely: both live in one crate).

Fields§

§current: i32§linenumber: i32§lastline: i32§t: LexToken§lookahead: LexToken§fs: Option<Box<FuncState>>§dyd: DynData§source: Option<GcRef<LuaString>>§envn: Option<GcRef<LuaString>>§lex: LexState

Underlying lexer state that owns the ZIO stream and lex buffer. The parser drives the lexer by calling lex_next / lex_lookahead, which forward to lua_lex::next / lua_lex::lookahead on this inner state and then mirror the resulting token into self.t / self.lookahead.

§recursion_depth: u32

Parser recursion depth for C-Lua’s enterlevel / leavelevel guard.

§global_strict: bool

Lua 5.5 global-declaration mode (manual §2.2). A chunk begins with an implicit global * (false here): every free name is a global, as in 5.4. The first explicit global name, … declaration flips this to true (“strict”), after which a free name must appear in Self::declared_globals or it is a compile-time error. global * flips it back to false. Only ever set on the 5.5 path (the lexer emits TK_GLOBAL only there), so pre-5.5 versions are unaffected.

§global_wildcard: bool

Lua 5.5: whether a global * (the wildcard declaration) is in effect for the current scope. When true, every free name is a global regardless of Self::global_strict — the wildcard suppresses the “not declared” error. Upstream represents * as a new_varkind(ls, NULL, ...) entry that coexists with named global declarations; a later global name does NOT void an active *. Block-scoped (saved/restored like Self::declared_globals).

§global_wildcard_const: bool

Whether the active explicit global * wildcard was declared <const>. Named global declarations still win for their own names; this applies only to otherwise free globals resolved through the wildcard.

§declared_globals: Vec<(GcRef<LuaString>, bool)>

Names declared via global, each paired with whether it was declared <const> (read-only). Consulted by name resolution under Self::global_strict.

§scope_barriers: Vec<ScopeBarrier>

Lua 5.5 global declarations participate in goto scope checks like locals, but they do not occupy VM registers. Keep that bookkeeping separate from FuncState::nactvar so codegen remains register-stable.

§global_function_names: Vec<GcRef<LuaString>>

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.