ASTBinaryWriter class
Encodes a parsed ASTRoot into a binary AST image — .avma, for Apollo
Virtual Machine Archive.
The point of the format is to skip the parser: an application parses once — at build time, or on first run — and afterwards loads the same code unit by decoding bytes, with no grammar and no backtracking.
var bytes = ASTBinaryWriter().writeCodeUnit(codeUnit);
Output is deterministic: the same AST always produces the same bytes, so an image can be content-addressed or compared byte for byte. Nothing time-dependent is recorded.
Signing is optional and pluggable — see ASTBinarySigner. Without it the image still carries a CRC-32, which detects corruption but proves nothing against a deliberate edit.
Constructors
- ASTBinaryWriter({ASTBinarySigner? signer})
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- signer → ASTBinarySigner?
-
Signs the image, when tamper-evidence is wanted.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
writeCodeUnit(
CodeUnit codeUnit) → Uint8List -
Encodes the AST of
codeUnit, which must already be loaded. -
writeCodeUnitOutput(
CodeUnit codeUnit) → BytesOutput -
Encodes
codeUnitas an annotated BytesOutput. -
writeRoot(
ASTRoot root, {required String language, String? namespace, String id = ''}) → Uint8List -
Encodes
rootdirectly.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited