Measures Module
Roles for the integers the decoder passes around. The blob is full of `int`s and `uint32`s that mean entirely different things - a node index, a string index, a byte offset into one section or another, a bitmap, a shift distance - and nothing but the parameter name distinguishes them. These measures make the wrong one a compile error, and erase completely, so the decoder pays nothing for them. The bitwise operators are not defined for measured integers: `mask &&& mask` does not compile, let alone `field &&& mask`. That is the point rather than an obstacle - it forces the operations to be spelled out here, with the roles in the signature, so a mask cannot be used where a shift belongs and masking cannot silently change what a value is.
Types and nested modules
| Type/Module | Description |
|
|
|
|
A bit position in a node's child mask, i.e. a declared child slot. |
|
|
A bit count, for shift distances. |
|
|
A byte offset into the extended-data section, or within one record in it. |
|
|
A bitmap over some other value's bits. Masks are consumed by masking, never produced by it. |
|
|
An index into the blob's node section. `Ast.Root` is one of these. |
|
|
An index into the string offsets table. Word-indexed, not byte-indexed. |
|
|
A byte offset into the structured-data (msgpack) section. |
|
|
A node's raw 32-bit `data` word, before its type bits have been read. |
Functions and values
| Function or value |
Description
|
Full Usage:
tag value
Parameters:
uint32
Returns: uint32<'role>
Modifiers: inline Type parameters: 'role |
Tags a raw `uint32` with the role it plays. Erased; this is a compile-time assertion that the caller knows which of the blob's many integers it is holding.
|
Full Usage:
tagInt value
Parameters:
int
Returns: int<'role>
Modifiers: inline Type parameters: 'role |