mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6787 from ethereum/sol2yul-ctor-code
Improve constructor-code codegen (wrt. state variable initialization)
This commit is contained in:
@@ -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\"))
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user