Skip to content

Conversation

ggiraldez
Copy link
Contributor

@ggiraldez ggiraldez commented Dec 24, 2024

This PR introduces several changes to how built-ins are defined and processed. We define different built-in contexts to separate built-in symbols available in Solidity and Yul. Also, the part of the stack graph that contains all definitions of built-ins is now built directly into the stack graph, without generating a Solidity file and the processing it as a system file. This allows much faster initialization of the Bindings Graph and most symbol mangling is no longer needed since we're not required to parse the built-ins file anymore.

In addition, all Yul built-ins are no longer defined in the grammar as special keywords and instead are treated as normal identifiers and bound to built-in definitions using the regular binding rules.

The API add_system_file was removed from BindingGraphBuilder and the file descriptor renamed from system to built-ins. All code previously required to transform built-in identifiers (ie. from $ to %) to avoid clashing with user code is no longer necessary and hence removed.

Fix #1244: the changes for address payable are also included in this PR.

Copy link

changeset-bot bot commented Dec 24, 2024

🦋 Changeset detected

Latest commit: d83bf79

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@nomicfoundation/slang Minor

Not sure what this means? Click here to learn what changesets are.

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

@ggiraldez ggiraldez changed the title Allow defining built-ins types and functions only inside relevant contexts Define built-ins contexts (for Yul built-in functions) and synthetically build the stack graph for the built-ins Feb 5, 2025
@ggiraldez ggiraldez marked this pull request as ready for review February 5, 2025 06:50
@ggiraldez ggiraldez requested review from a team as code owners February 5, 2025 06:50
@mjoerussell mjoerussell removed their assignment Feb 6, 2025
Copy link
Contributor

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

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

Left a few qestions.

@ggiraldez ggiraldez requested a review from OmarTawfik February 18, 2025 14:43
Copy link
Contributor

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

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

Did another round, and resolved earlier comments.

@ggiraldez ggiraldez enabled auto-merge February 20, 2025 15:06
@ggiraldez ggiraldez added this pull request to the merge queue Feb 20, 2025
Merged via the queue into NomicFoundation:main with commit a5c3b1a Feb 20, 2025
2 checks passed
@ggiraldez ggiraldez deleted the built-in-contexts branch February 20, 2025 16:23
@github-actions github-actions bot mentioned this pull request Feb 20, 2025
@github-actions github-actions bot mentioned this pull request Mar 7, 2025
github-merge-queue bot pushed a commit that referenced this pull request Mar 10, 2025
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and publish to npm
yourself or [setup this action to publish
automatically](https://github.com/changesets/action#with-publishing). If
you're not ready to do a release yet, that's fine, whenever you add more
changesets to main, this PR will be updated.


# Releases
## @nomicfoundation/slang@0.20.0

### Minor Changes

- [#1203](#1203)
[`a5c3b1a`](a5c3b1a)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - add separate
contexts (ie. binding scopes) for Solidity and Yul built-ins

- [#1257](#1257)
[`9f5d8f0`](9f5d8f0)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - export
`assertUserFileLocation()` and `assertBuiltInLocation()` utilities from
the `bindings` module

- [#1243](#1243)
[`99d182f`](99d182f)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - add
`definition.references()` API to find all references that resolve to a
definition.

- [#1205](#1205)
[`103b331`](103b331)
Thanks [@mjoerussell](https://github.com/mjoerussell)! - Make
`Edge::label` a required field instead of being optional.

- [#1257](#1257)
[`9f5d8f0`](9f5d8f0)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - update user
guides with new binding graph and compilation APIs

- [#1257](#1257)
[`9f5d8f0`](9f5d8f0)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - export
`assertNonterminalNode()` and `assertTerminalNode()` utilities from the
`cst` module

### Patch Changes

- [#1246](#1246)
[`aea2dd0`](aea2dd0)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - unreserve `jump`
and `jumpi` yul keywords between `0.6.0` and `0.8.0`

- [#1203](#1203)
[`a5c3b1a`](a5c3b1a)
Thanks [@ggiraldez](https://github.com/ggiraldez)! - enable `address
payable` from 0.5.0 and remove `transfer` built-in from non-payable
`address`es

- [#1246](#1246)
[`aea2dd0`](aea2dd0)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - make sure
assembly flags are only enabled starting from `0.8.13`

- [#1246](#1246)
[`aea2dd0`](aea2dd0)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - enable yul's
`true` and `false` keywords starting from `0.6.2`

- [#1246](#1246)
[`aea2dd0`](aea2dd0)
Thanks [@OmarTawfik](https://github.com/OmarTawfik)! - make sure `super`
and `this` keywords are unreserved before `0.8.0`.

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
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.

address payable is enabled only from 0.5.0
3 participants