pub enum Value {
Show 30 variants
Unit,
Bool(bool),
Int(i64),
Float(f64),
Length(Length),
Str(String),
List(Vec<Value>),
Tuple(Vec<Value>),
Ctor(String, Option<Box<Value>>),
Record(BTreeMap<String, Value>),
Context(Box<Context>),
InlineText {
elems: Rc<Vec<IText>>,
env: Env,
},
BlockText {
elems: Rc<Vec<BText>>,
env: Env,
},
MathText {
elems: Rc<Vec<MathElem>>,
env: Env,
},
Math(Rc<Vec<Math>>),
MathBoxes(Rc<Vec<Math>>),
Ref(Rc<RefCell<Value>>),
InlineBoxes(Vec<HorzBox>),
BlockBoxes(Vec<VertBox>),
Image(ImageId),
Document(Rc<DocumentValue>),
CompiledClosure {
opt_labels: Vec<String>,
body: CompiledExpr,
env: Env,
},
Code {
body: CompiledExpr,
env: Env,
},
Prim {
def: &'static PrimDef,
applied: Vec<Value>,
},
PrePath(PrePath),
Path(Path),
Graphics(GraphicsElem),
Font(FontKey),
TextInfo(TextInfo),
Hyphenation(HyphenLang),
}Variants§
Unit
Bool(bool)
Int(i64)
Float(f64)
Length(Length)
Str(String)
List(Vec<Value>)
Tuple(Vec<Value>)
Ctor(String, Option<Box<Value>>)
A variant constructor value, optionally carrying a payload
(None / Some 3).
Record(BTreeMap<String, Value>)
Context(Box<Context>)
InlineText
Quoted inline text with its captured environment
(InputHorzWithEnvironment). elems is the COMPILED element tree
(crate::quoted): command names and embedded expressions were
resolved at compile time, so nothing here is looked up by name at
layout time — the environment is still captured because a compiled
node resolves its locals against the environment it runs in.
BlockText
Quoted block text with its captured environment.
MathText
Quoted math text with its captured environment (mirrors
InlineText/BlockText); typesetting is deferred, so this
is carried opaquely for now.
Math(Rc<Vec<Math>>)
The faithful math value — what every math-* primitive
(math-char, math-concat, math-sup, …) builds and consumes, as
opposed to MathText’s elaborator-fused literal form. A math
value is always a sequence of atoms (mirroring upstream MathValue of math list, types.cppo.ml:888 — each Math here is one
already-classed atom, not a further list), so math-concat is a
plain Vec append and math-group/math-sup/… each wrap the whole
inner Vec as ONE new atom. Both this and MathText type as
"math" — a ${…} literal and a math-*-primitive-built value are
interchangeable wherever a math-typed argument is expected (see
primitives.rs’s as_math, which accepts either).
MathBoxes(Rc<Vec<Math>>)
math-boxes (V0_1 only) — the evaluated math tree read-math
produces, wrapping the SAME Math atom tree Value::Math uses so
every layout/primitive helper is shared unchanged. Distinct from
Value::Math: no V0_0 primitive ever produces or consumes this
variant, and no V0_1 primitive ever produces Value::Math — kept
apart so a V0_1 program can’t silently pass a math-text where
math-boxes is required (as_math_boxes is strict).
Ref(Rc<RefCell<Value>>)
A mutable cell (let-mutable’s binding; v0.0.6’s Location/store
entry). This port uses a directly-shared RefCell instead of an
indirection through a separate store table.
InlineBoxes(Vec<HorzBox>)
inline-boxes (the Horz base constant).
BlockBoxes(Vec<VertBox>)
block-boxes (the Vert base constant).
Image(ImageId)
image (load-image’s result): an index into the document-wide
image table (Interp::images), moved into DocumentValue::images
once page-break packages the final document. Carrying just the
index (not the decoded bytes) keeps this value cheap to clone, same
as Value::Ref’s Rc.
Document(Rc<DocumentValue>)
CompiledClosure
A closure. Its body is an already-compiled CompiledExpr, run
directly by crate::eval::Interp::apply — the only closure
representation.
Fields
opt_labels: Vec<String>SATySFi 0.1 labeled optional LABELS, in binder order; empty for
every 0.0.6-built closure. Each receives an option-typed value at
application (Some v when the call supplies ?(label = v), None
otherwise). Only the labels survive — a call site matches against
them by name — while the binders they bind to are slots 0..n of
the frame application pushes, so their names are gone.
body: CompiledExprThe positional parameter’s slot is opt_labels.len(), immediately
after the optional binders, so it needs no field of its own.
Code
&e — a quoted expression awaiting the next stage, with the
environment it was quoted in. Typed code ty (crate::types::MonoType::Code).
The same shape as Value::CompiledClosure minus a parameter, and
for the same reason: this evaluator compiles to slot-indexed
closures, so a fragment cannot be carried as a re-compilable syntax
tree the way upstream’s code_value is — its variable references
are already bound to the frames of the scope it was written in.
Carrying the compiled body with its environment keeps those
references meaning what they said, which is what ~ then forces.
Prim
A (possibly partially applied) native primitive.
PrePath(PrePath)
pre-path (start-path/line-to’s result).
Path(Path)
path (terminate-path/close-with-line’s result).
Graphics(GraphicsElem)
graphics — one resolved drawing element (fill/stroke’s result);
a graphics list is just Value::List of these, same as upstream.
Font(FontKey)
font (V0_1 only; upstream saphe-split’s BCFontKey of FontKey.t) — an OPAQUE handle on one loaded face, already resolved
through the metrics provider’s font store at the point the value was
minted. Upstream mints one per files[] entry of a FONT ENVELOPE
(envelopeChecker.ml’s check_font_envelope, evaluating the
internal LoadSingleFont{path}/LoadCollectionFont{path;index}
node to BCFontKey); this port’s bundled 0.1 font envelopes are
.satyh stand-ins that mint theirs through the LOCAL
load-single-font primitive instead.
Deliberately carries NO abbrev/name/path: it is a store INDEX, the
same thing upstream’s FontKey.t is, and nothing in the language can
map it back. That opacity is load-bearing for the cross-version
boundary: 0.0.6’s font-consuming primitives want an ABBREV naming a
row of dist/hash/fonts.satysfi-hash, and no such name is
recoverable from a key.
TextInfo(TextInfo)
text-info (the text-mode-context sliver).
Hyphenation(HyphenLang)
hyphenation (load-hyphenation-dictionary’s result) — the tag
set-hyphenation-dictionary writes into
Context::hyphen_dictionary, naming which dictionary was requested.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Value
impl !Send for Value
impl !Sync for Value
impl !UnwindSafe for Value
impl Freeze for Value
impl Unpin for Value
impl UnsafeUnpin for Value
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more