MIR: Use Micheline in parser and typechecker
Context
Rewire parser and typechecker to work with Micheline-like structure.
Using an owning Micheline-like construct a-la enum Micheline { ..., App(Prim, Vec<Micheline>, ...), ... } in Rust is rather inconvenient:
- Allocating many small (<8 elements) vectors is expensive both time- and space-wise, and Micheline basically consists of small vectors.
- Pattern-matching on
Vecis rather cumbersome (deref patterns aren't here yet), and we need to do a lot of pattern-matching in the typechecker.
Thus, instead, a non-owning Micheline struct is used. Allocations are done via the typed-arena crate. Using an arena slightly complicates things (something has to own the arena, and it needs to be passed around), but it's not that cumbersome, partially addresses (1) and completely resolves (2), so it's worth it.
One hiccup is that the parser still allocates small vectors. This can be alleviated to a large extent by handling common cases of 0-, 1- and 2-argument applications in the grammar explicitly, but that will complicate the grammar, and benchmarking is required to gauge the impact, so this is left for future work.
Based on: !10783 (merged)
Part of: #6539 (closed)
Resolves #6360 (closed)
Manually testing the MR
cargo test; this is mostly a refactoring MR; some tests had to be moved around, though, as syntax errors handled previously by the parser now have to be handled in the typechecker.
Checklist
-
Document the interface of any function added or modified (see the coding guidelines) -
Document any change to the user interface, including configuration parameters (see node configuration) -
Provide automatic testing (see the testing guide). -
For new features and bug fixes, add an item in the appropriate changelog ( docs/protocols/alpha.rstfor the protocol and the environment,CHANGES.rstat the root of the repository for everything else). -
Select suitable reviewers using the Reviewersfield below. -
Select as Assigneethe next person who should take action on that MR