Skip to content

Commit

Permalink
Add special case for handling byte and return Yul built-ins
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Jan 28, 2025
1 parent aadef74 commit d1059a4
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 3 deletions.
15 changes: 14 additions & 1 deletion crates/solidity/inputs/language/bindings/rules.msgb
Original file line number Diff line number Diff line change
Expand Up @@ -2931,7 +2931,20 @@ inherit .star_extension

@path [YulPath . @name [YulIdentifier]] {
node ref
attr (ref) node_reference = @name

; Handle `byte` and `return` as special cases, since we cannot define them
; directly as regular built-ins
var yul_symbol = (source-text @name)
scan (source-text @name) {
"byte" {
set yul_symbol = "%byte"
}
"return" {
set yul_symbol = "%return"
}
}
attr (ref) symbol_reference = yul_symbol
attr (ref) source_node = @name

edge ref -> @path.lexical_scope

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

References and definitions:
╭─[input.sol:1:1]
1 │ contract AssemblyBuiltIns {
│ ────────┬───────
│ ╰───────── name: 1
2 │ function test() public {
│ ──┬─
│ ╰─── name: 2
4 │ mstore(0x80, byte(10, 31))
│ ───┬── ──┬─
│ ╰─────────────── ref: built-in
│ │
│ ╰─── ref: built-in
5 │ return (0x80,1)
│ ───┬──
│ ╰──── ref: built-in
───╯
Definiens:
╭─[input.sol:1:1]
1 │ ╭─│ ▶ contract AssemblyBuiltIns {
2 │ │ ╭─▶ function test() public {
┆ ┆ ┆
7 │ │ ├─▶ }
│ │ │
│ │ ╰─────────── definiens: 2
8 │ ├───▶ }
│ │
│ ╰───────── definiens: 1
───╯
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
contract AssemblyBuiltIns {
function test() public {
assembly {
mstore(0x80, byte(10, 31))
return (0x80,1)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ References and definitions:
│ ╰── ref: 6
13 │ return(0, 0x20)
│ ───┬──
│ ╰──── unresolved
│ ╰──── ref: built-in
────╯
Definiens:
╭─[input.sol:1:1]
Expand Down

0 comments on commit d1059a4

Please sign in to comment.