forked from NomicFoundation/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete built-ins support for Solidity (NomicFoundation#1125)
This PR adds support for the remaining built-ins in Solidity plus other bug fixes and missing binding cases: * Built-in types (both visible to the user and those used to create namespace like definitions such as `tx.origin`) are declared by prefixing them with `$` and renamed by transforming the CST tree and replacing `$` by `%` before adding them to the stack graph. Because `%` is not a valid identifier character, this ensures user code cannot accidentally clash. **This transformation process is explicit and must be done manually by the user of the bindings API.** This has a potential drawback: if the user is given the transformed CST tree, they cannot `unparse()` it and obtain a valid Solidity file; if the user is given the untransformed CST tree, the cursors they obtain from the bindings API will not apply directly to their tree. An alternative is to perform the transformation inside the rules and only for system (aka built-in) files. That would restrict the visibility to the stack graph only, at the expense of performance. * `type()` expressions bind to an internal `%typeIntType`/`%typeContractType`/`%typeInterfaceType` which allows binding members such as `name`, `min`/`max` and `creationCode`. * Added all global variables, built-in type members and functions and enable them on the Solidity versions they were introduced (or disable them if they were removed). * Make external and public functions in contracts and interfaces accessible through the enclosing type to be able to retrieve their `.selector`. * Arrays push a special scoped symbol `<>` that allows delay-resolving the element type. We use this to correctly bind `push()` and the `[]` operator to bind correctly. * Bind field names when constructing structs using named arguments. * Call options parameter names are bound to a special `%callOptions` built-in type. * The placeholder `_` modifier operator only binds inside a modifier body. * Minor optimization and clean up of the graph rules by making the `lexical_scope` scoped variable inheritable and removing unnecessarily created intermediate scopes. * All built-in variables and functions can be shadowed by user defined variables and functions of the same name. * Support binding constructor parameters with the old syntax in Solidity < 0.5.0. * Support `using X for *` directive.
- Loading branch information
Showing
124 changed files
with
6,888 additions
and
520 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.