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.
Rules for name resolution in Yul functions
- Loading branch information
Showing
8 changed files
with
266 additions
and
0 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
55 changes: 55 additions & 0 deletions
55
...s/solidity/outputs/cargo/slang_solidity/src/generated/bindings/generated/binding_rules.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
crates/solidity/outputs/cargo/tests/src/bindings_assertions/generated/yul.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
crates/solidity/outputs/cargo/tests/src/bindings_output/generated/yul.rs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
crates/solidity/testing/snapshots/bindings_assertions/yul/fun_scopes.sol
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
contract AssemblyFunctions { | ||
function test(uint256 a) public returns (uint256 r) { | ||
// ^def:4 | ||
// ^def:3 | ||
assembly { | ||
{ | ||
function inner(x_i) -> x { | ||
// ^def:1 | ||
x := add(x_i, 1) | ||
} | ||
|
||
r := inner(a) | ||
// ^ref:3 | ||
// ^ref:1 | ||
//<ref:4 | ||
} | ||
|
||
let z := 1 | ||
// ^def:5 | ||
|
||
function outer() -> y { | ||
// ^def:2 | ||
y := inner() | ||
// ^ref:! -- function is not visible here | ||
r := add(a, 1) | ||
// ^ref:! -- assembly functions cannot access Solidity variables | ||
//<ref:! | ||
y := z | ||
// ^ref:! -- vars declared outside the function are not visible either | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
crates/solidity/testing/snapshots/bindings_assertions/yul/functions.sol
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
contract AssemblyFunctions { | ||
function test(uint256 x) public returns (uint256 r) { | ||
assembly { | ||
function outer1(a) -> b { | ||
// ^def:1 | ||
b := add(a, 1) | ||
} | ||
|
||
{ | ||
r := add(outer1(x), inner(x)) | ||
// ^ref:2 | ||
// ^ref:1 | ||
function inner(f) -> g { | ||
// ^def:2 | ||
g:= mul(f, outer2(f)) | ||
// ^ref:3 | ||
} | ||
} | ||
|
||
function outer2(c) -> d { | ||
// ^def:3 | ||
d := mul(c, outer2_inner(c)) | ||
// ^ref:4 | ||
|
||
function outer2_inner(e) -> f { | ||
// ^def:4 | ||
f := e | ||
} | ||
} | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
crates/solidity/testing/snapshots/bindings_output/yul/functions/generated/0.4.11-success.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# This file is generated automatically by infrastructure scripts. Please don't edit by hand. | ||
|
||
References and definitions: | ||
╭─[input.sol:1:1] | ||
│ | ||
1 │ contract AssemblyFunctions { | ||
│ ────────┬──────── | ||
│ ╰────────── def: 1 | ||
2 │ function test(uint256 x) public returns (uint256 r) { | ||
│ ──┬─ ┬ ┬ | ||
│ ╰──────────────────────────────────────── def: 2 | ||
│ │ │ | ||
│ ╰───────────────────────────── def: 3 | ||
│ │ | ||
│ ╰── def: 4 | ||
│ | ||
4 │ let y := add(x, 5) | ||
│ ┬ ┬ | ||
│ ╰─────────── def: 5 | ||
│ │ | ||
│ ╰── ref: 3 | ||
5 │ x, y := swap(x, y) | ||
│ ┬ ┬ ──┬─ ┬ ┬ | ||
│ ╰────────────────── ref: 3 | ||
│ │ │ │ │ | ||
│ ╰─────────────── ref: 5 | ||
│ │ │ │ | ||
│ ╰──────── ref: 6 | ||
│ │ │ | ||
│ ╰───── ref: 3 | ||
│ │ | ||
│ ╰── ref: 5 | ||
6 │ r := add(x, y) | ||
│ ┬ ┬ ┬ | ||
│ ╰────────────── ref: 4 | ||
│ │ │ | ||
│ ╰───── ref: 3 | ||
│ │ | ||
│ ╰── ref: 5 | ||
│ | ||
8 │ function swap(a, b) -> c, d { | ||
│ ──┬─ ┬ ┬ ┬ ┬ | ||
│ ╰───────────────── def: 6 | ||
│ │ │ │ │ | ||
│ ╰────────────── def: 7 | ||
│ │ │ │ | ||
│ ╰─────────── def: 8 | ||
│ │ │ | ||
│ ╰───── def: 9 | ||
│ │ | ||
│ ╰── def: 10 | ||
9 │ c := b | ||
│ ┬ ┬ | ||
│ ╰─────── ref: 9 | ||
│ │ | ||
│ ╰── ref: 8 | ||
10 │ d := a | ||
│ ┬ ┬ | ||
│ ╰─────── ref: 10 | ||
│ │ | ||
│ ╰── ref: 7 | ||
────╯ |
14 changes: 14 additions & 0 deletions
14
crates/solidity/testing/snapshots/bindings_output/yul/functions/input.sol
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
contract AssemblyFunctions { | ||
function test(uint256 x) public returns (uint256 r) { | ||
assembly { | ||
let y := add(x, 5) | ||
x, y := swap(x, y) | ||
r := add(x, y) | ||
|
||
function swap(a, b) -> c, d { | ||
c := b | ||
d := a | ||
} | ||
} | ||
} | ||
} |