[v2] Re-export AST/ABI types in slang_solidity_v2 and clean up public facing modules#1721
Conversation
|
035276d to
eabf88f
Compare
hedgar2017
left a comment
There was a problem hiding this comment.
Thanks! I don't know if it's everything we need but we'll follow up!
teofr
left a comment
There was a problem hiding this comment.
It LGTM, I'll @OmarTawfik in case he wants to have a look since he mentioned he was thinking of doing this.
eabf88f to
6bddc99
Compare
`SemanticFile` is not a public trait, so otherwise it's impossible to get the `id()` of a `File`.
Users still needed to call `compilation.get_file_ast_root()` anyway, and the `File` doesn't expose any useful information.
6bddc99 to
98f3266
Compare
|
I introduced some changes in the
|
Spawned from [this comment thread](#1721 (comment)). Extends the IR/AST node-type model so the codegen produces a richer, more useful tree. - Avoid re-exporting IR types in the AST. This will make it easier to evolve them independently (eg. the AST will need to be serializable to JSON). - Unique terminals now have a real IR struct (`Rc<XStruct>` with `id: NodeId` and `range`). Optional sequence fields go from `bool` to `Option<X>`, choice variants carry an `(X)` payload, and the AST wraps them. - Non-unique terminals are now wrapped in the AST as well. This will allow implementing some methods on them that require access to semantic information (eg. getting the type associated to a string expression). - Avoid re-using some IR types for typing/binding information. Eg. function visibility and mutability are now plain variant defined in `types`. We can no longer easily re-use the IR types (reason being the previous item). - `NodeType::Nonterminal` is gone and the IR-codegen model now distinguishes `Sequence`, `Choice`, `Collection`, `Terminal`, `UniqueTerminal`, and the new `External` kind. Templates dispatch on `kind`/`is_terminal`/`is_external` directly instead of looking up the kind on the side. Choice variants for unique terminals lose their `Eq`/`Hash` derives along the way (those types no longer make sense as set keys). - Shorten the auto-generated `expression_<X>_expression_operator` precedence-operator field names down to a uniform `operator` everywhere.
This prepares
slang_solidity_v2to be the only public facing crate users of Slang would have to depend on. Re-export AST and ABI types and adjust the public compilation modules.Finally, it narrows down the visibility of a lot of types and functions that we not being accessed from outside the crate, in particular in the semantic crate.