Bootstrap Rust backend, generates types.rs file from JSON definitions.
Adds a Rust_backend
and its wiring on the main binary, including definitions for Rust representations of types on michelson_input.json
and the necessary code for parsing the extra rust_repr
field. This initial implementation is only focused on the types defined using macros, due to they being easier to represent, other types like OrItem
still need to be defined since it needs more design work on how to represent it on the JSON file.
I've tried to keep the file as close as possible to the one from the tezos-on-tezos
project, that's why it follows a list of predefined types so it can keep the same order of those on the project.
Also, a few extra definitions on the Rust_syntax
module were needed to be able to express some things that were needed, including:
-
T_Enum
in order to express theStackItem
type. -
E_Tup
for some definitions for parametric types, e.g.define_item_rec!(MapItem, Vec<(StackItem, StackItem)>, (Type, Type));
. -
MacCall
for the item type, so a macro call could be defined as a top level entity.
Added tests using Alcotest
, I've tried to focus on some specific properties. For instance it verifies if the generated output contains
the necessary definitions it should generate. Syntax should be validated using rustfmt
, type checking could be accomplished by cloning
and building the whole tezos-on-tezos
project.
While we don't do that, we need to process files with rustfmt
from stdin (echo $file | rustfmt
) instead of using the file directly otherwise it'll try to resolve
modules from the pub mod ...
definitions and fails since we only have this file for now.