Merge pull request #10174 from ethereum/storeInternalFunctions

Implement internal functions in storage.
This commit is contained in:
chriseth
2020-11-03 09:56:12 +01:00
committed by GitHub
24 changed files with 113 additions and 7 deletions
@@ -41,6 +41,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// EVMVersion: >homestead
// ----
// g() -> 32, 132, hex"15cfcc01", 32, 32, 1, 42, hex"00000000000000000000000000000000000000000000000000000000"
@@ -17,6 +17,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// one() -> 3
// two() -> FAILURE
@@ -5,6 +5,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// f(uint256): 0 -> 0x20, 0x4, "This"
// f(uint256): 1 -> 0x20, 0x2, "is"
@@ -13,5 +13,7 @@ contract C {
return this.h(a);
}
}
// ====
// compileViaYul: also
// ----
// g() -> 0x0700000000000000000000000000000000000000000000000000000000000000
@@ -16,6 +16,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// use(uint256): 3 -> 6
// result_in_constructor() -> 4
@@ -0,0 +1,25 @@
contract C {
uint16 public result_in_constructor;
function(uint16) returns (uint16) internal x;
uint16 public other = 0x1fff;
constructor() {
x = doubleInv;
result_in_constructor = use(2);
}
function doubleInv(uint16 _arg) public returns (uint16 _ret) {
_ret = ~(_arg * 2);
}
function use(uint16 _arg) public returns (uint16) {
return x(_arg);
}
}
// ====
// compileViaYul: also
// ----
// use(uint16): 3 -> 0xfff9
// result_in_constructor() -> 0xfffb
// other() -> 0x1fff
@@ -14,5 +14,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// t() -> 7
@@ -17,5 +17,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// t() -> 7
@@ -16,5 +16,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// t() -> FAILURE
@@ -20,6 +20,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// set() -> 7
// ca() -> 7
@@ -6,5 +6,7 @@ contract C {
return [this.f, this.g][0]{value: 1}();
}
}
// ====
// compileViaYul: also
// ----
// h(), 1 ether -> 1
@@ -25,6 +25,8 @@ contract Flow {
}
}
// ====
// compileViaYul: also
// ----
// success() -> false
// f() -> 7
@@ -11,5 +11,7 @@ contract C {
return x + 1;
}
}
// ====
// compileViaYul: also
// ----
// f(uint256): 7 -> 8
@@ -14,5 +14,7 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// test() -> true
@@ -0,0 +1,34 @@
struct S {
uint16 a;
function() returns (uint) x;
uint16 b;
}
contract Flow {
S[2] t;
function X() internal pure returns (uint) {
return 1;
}
function Y() internal pure returns (uint) {
return 2;
}
constructor() {
t[0].a = 0xff07;
t[0].b = 0xff07;
t[1].x = Y;
t[1].a = 0xff07;
t[1].b = 0xff07;
t[0].x = X;
}
function f() public returns (uint, uint) {
return (t[0].x(), t[1].x());
}
}
// ====
// compileViaYul: also
// ----
// f() -> 1, 2
@@ -7,5 +7,7 @@ contract Test {
}
}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE
@@ -14,6 +14,8 @@ contract C {
}
}
// ====
// compileViaYul: also
// ----
// g() -> 2
// h() -> FAILURE
@@ -32,6 +32,8 @@ contract C {
return (["any", "any"], ["any", "any", "any"]);
}
}
// ====
// compileViaYul: also
// ----
// r() -> true, false, true
// s() -> 123, 456, 789
@@ -41,4 +43,3 @@ contract C {
// w2() -> 0x20, 0x40, 0x80, 3, "any", 3, "any"
// w3() -> 0x20, 0x60, 0xa0, 0xe0, 3, "any", 3, "any", 3, "any"
// x() -> 0x40, 0x0100, 0x40, 0x80, 3, "any", 3, "any", 0x60, 0xa0, 0xe0, 3, "any", 3, "any", 3, "any"
@@ -8,5 +8,7 @@ contract Test {
assert(val[0].vals.length == 42);
}
}
// -----
// ====
// compileViaYul: also
// ----
// func() ->
@@ -35,5 +35,7 @@ contract InvalidTest {
x++;
}
}
// ====
// compileViaYul: also
// ----
// run() -> FAILURE
@@ -14,6 +14,8 @@ contract InvalidTest {
storedFn();
}
}
// ====
// compileViaYul: also
// ----
// f() -> FAILURE
// f() -> FAILURE
@@ -19,5 +19,7 @@ contract C {
return (a, b);
}
}
// ====
// compileViaYul: also
// ----
// g() -> 5, 6