Skip to main content

Module cache

Module cache 

Source
Expand description

Port of src/ast/cache.ts: structural memoization of values computed from token trees.

A token tree is serialized into i32 values (a header with the type, the color type and the fields that follow, the fields that are not empty, then the token list and the children list). The typescript open addressing table over a key pool is ported as is: the keys are appended to a pool, the slots are numbered in insertion order, a lookup reuses a scratch buffer and a miss keeps the key.

The keys do not reference arena ids, the interned string ids are part of the keys: a memo must not outlive the string table of the arena.

Structsยง

StructuralMemo
memoize values by token structure. lookups return a slot, the value of a slot is None until it is set