Skip to content

[v2] Re-export AST/ABI types in slang_solidity_v2 and clean up public facing modules#1721

Merged
ggiraldez merged 4 commits into
mainfrom
ggiraldez/v2-public-facing-api
May 11, 2026
Merged

[v2] Re-export AST/ABI types in slang_solidity_v2 and clean up public facing modules#1721
ggiraldez merged 4 commits into
mainfrom
ggiraldez/v2-public-facing-api

Conversation

@ggiraldez

@ggiraldez ggiraldez commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

This prepares slang_solidity_v2 to 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.

@ggiraldez ggiraldez requested review from OmarTawfik and teofr April 22, 2026 21:34
@ggiraldez ggiraldez requested review from a team as code owners April 22, 2026 21:34
@changeset-bot

changeset-bot Bot commented Apr 22, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 98f3266

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@ggiraldez ggiraldez force-pushed the ggiraldez/v2-public-facing-api branch from 035276d to eabf88f Compare April 24, 2026 20:45

@hedgar2017 hedgar2017 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I don't know if it's everything we need but we'll follow up!

@teofr teofr left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It LGTM, I'll @OmarTawfik in case he wants to have a look since he mentioned he was thinking of doing this.

Comment thread crates/solidity-v2/outputs/cargo/ast/src/ast/nodes.generated.rs Outdated
Comment thread crates/solidity-v2/outputs/cargo/semantic/src/binder/mod.rs
@ggiraldez ggiraldez force-pushed the ggiraldez/v2-public-facing-api branch from eabf88f to 6bddc99 Compare May 5, 2026 21:29
ggiraldez added 4 commits May 5, 2026 18:09
`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.
@ggiraldez ggiraldez force-pushed the ggiraldez/v2-public-facing-api branch from 6bddc99 to 98f3266 Compare May 5, 2026 22:14
@ggiraldez

Copy link
Copy Markdown
Contributor Author

I introduced some changes in the CompilationUnit API that call for review:

  • File is no longer public (it was actually not exposing any attribute or method)
  • CompilationUnit::files() is changed to CompilationUnit::file_ids()
  • For the moment, the only other file-related method is get_file_ast_root() which needs to be called from the CompilationUnit anyway (as it needs the SemanticContext)
  • get_file_ir_root() is for the snapshots tests only, and may be removed in a future PR when change the snapshot tests to use the public AST API

@ggiraldez ggiraldez added this pull request to the merge queue May 11, 2026
Merged via the queue into main with commit 10d51b2 May 11, 2026
16 checks passed
@ggiraldez ggiraldez deleted the ggiraldez/v2-public-facing-api branch May 11, 2026 21:19
github-merge-queue Bot pushed a commit that referenced this pull request May 11, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants