Skip to main content

ExprPayload

Struct ExprPayload 

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

Trait Implementations§

Source§

impl Clone for ExprPayload

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExprPayload

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ExprPayload

Source§

fn default() -> Self

Returns the “default value” for a type. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.