Expand description
The Node CST as the other end of a rule. Spec §3.2.
Read crate::adapter::lua first: JavaScript’s situation is Lua’s —
“there is no type node” — with two consequences that follow from
JavaScript’s own grammar and not from a simplification made here.
§Why this materialiser declares almost nothing
crate::adapter::zig declares a struct type for every IDL
aggregate because Zig is statically typed and a codec function needs
a name to take. crate::adapter::lua still declares a descriptor
table for every aggregate, because lua-language-server’s ---@class
reads one and because a Lua table has no order of its own, so a
member list has to be written down somewhere to be read back in
order. Neither reason holds here: this column has no LuaCATS-shaped
consumer to serve, and a JavaScript object literal’s own property
order is insertion order (ECMA-262 §6.1.7.1) — the shared codec walk
already writes an aggregate’s members in the model’s declaration
order, so the order is carried by the generated code and needs no
separate table to state it again.
What is left to declare is exactly what needs a name at load time, because something outside the value it belongs to refers to it by that name:
- an enumeration, because
crate::emit::CodecTarget::enumerator_constantwritesColour.REDand something has to bindColour; - a bitmask’s bits, because a sample or a test names one by IDL
spelling and the value has to exist somewhere to be read; a
bitmask’s own “type” is nothing here — a member holding one is a
plain
numberorbigint, exactly ascrate::emit::node’s module documentation says; - a constant, an IDL
constdeclaration, because that is what it is for.
A struct, a union, a bitset, a valuetype, an exception, an interface,
a native declaration and a typedef all declare nothing. Every
one of them is a plain object literal wherever the codec walk or
crate::default_node builds one, and “the runtime carries the
shape” is not a slogan here — it is the reason there is no
node_member_type in this file for crate::adapter::zig::zig_member_type
to answer to.
§This column does not join the seesaw rule catalogue
crate::rule and crate::apply() exist to compare what different
backends declare for one construct, and every backend that has
nothing to compare has nothing to gain from joining. This column
declares nothing for six of the ten constructs the catalogue tracks
— struct, union, bitset, valuetype, exception, interface — because a
JavaScript object literal needs no declaration to exist. Registering
a Language::Node and a rule::node::catalogue() whose rules mostly
answer “nothing is created here” would be six rules whose only
purpose is to say so, in a system built to find the interesting cases
where two columns disagree about something. node_items is
called directly from the generator, the same as crate::adapter::c
is on the side that predates the catalogue.
§Where the IDL spelling of a name is kept
Nothing is renamed for style: JavaScript has no export-by-case rule
and this column changes no letter’s case. node::escape_member is
the identity always — zerodds_lang_cst::node’s module
documentation says why a property name is never renamed — so the
only escape in this file is node::escape_decl, applied to a
declaration’s flattened name: an enumeration’s own binding, a
bitmask bit’s, a constant’s. Every name it moves carries IDL: ….
in the comment above it, for the same reason crate::adapter::zig
keeps one: DDS-XTypes 1.3 §7.3.1.2.1.1 computes a member’s ID under
@autoid(HASH) from the first four octets of the MD5 of its IDL
name, and the escape does not invert.
Constants§
- MAP_
ENTRY - The marker
crate::emit::CodecTarget::map_entry_nameanswers with.
Functions§
- field_
name - The JavaScript spelling of a member, an enumerator, a bitfield or a
map-entry half. The identity, always:
zerodds_lang_cst::node’s module documentation says why a property name never collides with anything JavaScript reserves. - node_
file - The Node declarations, in a file with its own header.
- node_
items - Build the Node declarations a rule application produced.
- node_
type_ name - A declared type’s flattened JavaScript identifier.