[Sol->Yul] Adding util function to copy literal to storage.

Co-authored-by: Daniel Kirchner <daniel@ekpyron.org>

Co-authored-by: chriseth <chris@ethereum.org>
This commit is contained in:
Djordje Mijovic
2021-05-05 11:33:03 +02:00
co-authored by Daniel Kirchner chriseth
parent 9d156b52c4
commit f0c5cdca9f
8 changed files with 176 additions and 83 deletions
@@ -4,12 +4,17 @@ contract C {
function f() public {
a.push("abc");
a.push("def");
a.push("abcdefghabcdefghabcdefghabcdefgh");
a.push("abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh");
assert(a[0][0] == "a");
assert(a[1][0] == "d");
assert(a[1][31] == "h");
assert(a[2][32] == "a");
}
}
// ====
// compileViaYul: also
// ----
// f() ->
// gas irOptimized: 181480
// gas legacy: 180320
// gas legacyOptimized: 180103
@@ -0,0 +1,22 @@
contract C {
bytes public s = "abc";
bytes public s1 = "abcd";
function f() public {
s = "abcd";
s1 = "abc";
}
function g() public {
(s, s1) = ("abc", "abcd");
}
}
// ====
// compileViaYul: also
// ----
// s() -> 0x20, 3, "abc"
// s1() -> 0x20, 4, "abcd"
// f() ->
// s() -> 0x20, 4, "abcd"
// s1() -> 0x20, 3, "abc"
// g() ->
// s() -> 0x20, 3, "abc"
// s1() -> 0x20, 4, "abcd"