You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 11, 2021. It is now read-only.
typeNode=distinctint32templatekind*(n: Node): JsonKind=JsonKind(n andKindMask)
templateoperand*(n: Node): int32= n shrKindShifttypeJsonTree=object
kids: seq[Node]
atoms: BiTable[string] # store numbers as strings too and parse them to numbers in the accessor procs
The crucial idea here is that atoms use 'operand' bits to index into the 'atoms' BiTable while compound nodes use it to store the total number of children. Via some clever arithmetic operations you can easily compute the ith-child anyway. See my PackedAST code in compiler/ic.
This should be close to the optimum design. The API on top should encourage efficient operations (don't use random access, iterate over the tree instead).
Have you tried this design:
The crucial idea here is that atoms use 'operand' bits to index into the 'atoms' BiTable while compound nodes use it to store the total number of children. Via some clever arithmetic operations you can easily compute the ith-child anyway. See my PackedAST code in compiler/ic.
This should be close to the optimum design. The API on top should encourage efficient operations (don't use random access, iterate over the tree instead).