pub enum ConstValue {
I64(i64),
F64(f64),
Bool(bool),
Byte(u8),
Str(String),
Void,
Function(u16),
}Expand description
a value the constant pool can store.
derives Debug, Clone, PartialEq. NOT Eq – ConstValue::F64 holds
f64, and f64 is not Eq (NaN != NaN). this mirrors how the AST and
QalaError skip Eq for the same reason.
Variants§
I64(i64)
a 64-bit signed integer, the result of any i64-typed expression.
F64(f64)
a 64-bit IEEE 754 float. follows IEEE 754 for non-finite results
(inf, -inf, NaN); the Display impl
renders these explicitly so the output stays stable across Rust
toolchains.
Bool(bool)
a boolean – the result of any bool-typed comparison, logic, or
literal.
Byte(u8)
an 8-bit unsigned byte literal – the result of a b'X' literal or a
byte-typed sub-expression. rendered in lowercase-hex form by
Display.
Str(String)
an owned string. the constant pool holds the source-literal form; string-interpolation results live on the VM’s heap and never reach the constant pool.
Void
the value-shaped result of a void-typed expression (a no-trailing-
value block, or the () of a void-returning function). renders as
().
Function(u16)
an index into the enclosing program’s chunks. resolved by codegen
during call-site emission; the VM dispatches by index. width u16
matches every other indexed operand in the opcode set (so up to
65536 functions per program).
Trait Implementations§
Source§impl Clone for ConstValue
impl Clone for ConstValue
Source§fn clone(&self) -> ConstValue
fn clone(&self) -> ConstValue
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ConstValue
impl Debug for ConstValue
Source§impl Display for ConstValue
render a ConstValue byte-deterministically.
impl Display for ConstValue
render a ConstValue byte-deterministically.
the disassembler and the playground’s bytecode panel both read this
output; identical input produces identical bytes on every machine and
every Rust toolchain. non-finite floats (NaN, inf, -inf) are
hand-spelled because f64’s Display of these values is platform-stable
in current Rust but a deliberate spelling avoids future drift.
string values render with no escape processing: a Str containing a
single quote will produce visually ambiguous output, but the rendering is
still deterministic – acceptable in v1, the constant pool is in-process
only this phase.
Source§impl PartialEq for ConstValue
impl PartialEq for ConstValue
Source§fn eq(&self, other: &ConstValue) -> bool
fn eq(&self, other: &ConstValue) -> bool
self and other values to be equal, and is used by ==.