Merge pull request #6787 from ethereum/sol2yul-ctor-code

Improve constructor-code codegen (wrt. state variable initialization)
This commit is contained in:
chriseth
2019-08-05 11:50:34 +02:00
committed by GitHub
6 changed files with 78 additions and 12 deletions
@@ -10,6 +10,9 @@ object \"C_6\" {
code {
mstore(64, 128)
// Begin state variable initialization for contract \"C\" (0 variables)
// End state variable initialization for contract \"C\".
codecopy(0, dataoffset(\"C_6_deployed\"), datasize(\"C_6_deployed\"))
return(0, datasize(\"C_6_deployed\"))
+4 -2
View File
@@ -7921,8 +7921,10 @@ BOOST_AUTO_TEST_CASE(accessor_for_state_variable)
}
)";
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("ticketPrice()"), encodeArgs(u256(500)));
ALSO_VIA_YUL(
compileAndRun(sourceCode);
ABI_CHECK(callContractFunction("ticketPrice()"), encodeArgs(u256(500)));
);
}
BOOST_AUTO_TEST_CASE(accessor_for_const_state_variable)
@@ -0,0 +1,14 @@
contract C {
uint public i = 1;
uint public k = 2;
constructor() public {
i = i + i;
k = k - i;
}
}
// ====
// compileViaYul: also
// ----
// i() -> 2
// k() -> 0