pub struct ExprPayload {
pub ival: i64,
pub nval: f64,
pub strval: Option<GcRef<LuaString>>,
pub info: i32,
pub ind_idx: i16,
pub ind_t: u8,
pub var_ridx: u8,
pub var_vidx: u16,
pub const_snapshot: Option<LuaValue>,
pub global_const_name: Option<GcRef<LuaString>>,
}Expand description
The payload of an ExprDesc, discriminated by its sibling ExprKind
(ExprDesc::k). Only the field(s) named for the active kind are meaningful;
the rest are unused for that kind.
This is intentionally a flat struct rather than a tagged enum carrying
per-variant data. Folding it into one is a deliberate recorded
honest-negative (see the Sprint-1 recipe ledger): the kind and the payload
are set in separate statements throughout codegen (e.g. init_exp writes a
dummy info for every kind, then the caller overwrites the real field), and
several helpers take the kind and the payload as separate arguments — shapes
an enum’s “the variant is the data” model cannot express without an invalid
intermediate. The behavioral invariant (which field each kind uses) is held
by the bytecode-parity oracle, not by the type system here.
Fields§
§ival: i64§nval: f64§strval: Option<GcRef<LuaString>>§info: i32§ind_idx: i16§ind_t: u8§var_ridx: u8§var_vidx: u16§const_snapshot: Option<LuaValue>The materialized value of a ExprKind::Const (VCONST) expression: a
snapshot of the resolved <const> compile-time constant’s stored value,
copied out of the owning function’s VarDesc::const_val by [searchvar]
at resolution time. Some only for ExprKind::Const; None for every
other kind.
This snapshot exists so that constant discharge (cg_exp2const’s
const-of-const arm and cg_discharge_vars’s Const arm) can read the
value from the ExprDesc alone. Those run in FuncState-only codegen
contexts that hold no reference to LexState/DynData, so they cannot
re-read dyd.actvar[info].const_val the way C’s const2val does; the
absolute index in u.info is still kept for [check_readonly].
global_const_name: Option<GcRef<LuaString>>Lua 5.5: when this expression resolves a global that was declared
global x <const>, the declared name is recorded here so that an
assignment to it is rejected by [check_readonly]. None for every
other expression (and on all pre-5.5 versions).