mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Tests for functional inliner.
This commit is contained in:
parent
e7ef227226
commit
a7ae7c6d04
@ -35,7 +35,7 @@ using namespace std;
|
|||||||
using namespace dev;
|
using namespace dev;
|
||||||
using namespace dev::julia;
|
using namespace dev::julia;
|
||||||
using namespace dev::julia::test;
|
using namespace dev::julia::test;
|
||||||
using namespace dev::solidity::assembly;
|
using namespace dev::solidity;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ string inlineFunctions(string const& _source, bool _julia = true)
|
|||||||
{
|
{
|
||||||
auto ast = disambiguate(_source, _julia);
|
auto ast = disambiguate(_source, _julia);
|
||||||
FunctionalInliner(ast).run();
|
FunctionalInliner(ast).run();
|
||||||
return AsmPrinter(_julia)(ast);
|
return assembly::AsmPrinter(_julia)(ast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +136,26 @@ BOOST_AUTO_TEST_CASE(no_inline_with_mload)
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE(no_move_with_side_effects)
|
||||||
|
{
|
||||||
|
// The calls to g and h cannot be moved because g and h are not movable. Therefore, the call
|
||||||
|
// to f is not inlined.
|
||||||
|
BOOST_CHECK_EQUAL(
|
||||||
|
inlineFunctions(R"({
|
||||||
|
function f(a, b) -> x { x := add(b, a) }
|
||||||
|
function g() -> y { y := mload(0) mstore(0, 4) }
|
||||||
|
function h() -> z { mstore(0, 4) z := mload(0) }
|
||||||
|
let r := f(g(), h())
|
||||||
|
})", false),
|
||||||
|
format(R"({
|
||||||
|
function f(a, b) -> x { x := add(b, a) }
|
||||||
|
function g() -> y { y := mload(0) mstore(0, 4) }
|
||||||
|
function h() -> z { mstore(0, 4) z := mload(0) }
|
||||||
|
let r := f(g(), h())
|
||||||
|
})", false)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(complex_with_evm)
|
BOOST_AUTO_TEST_CASE(complex_with_evm)
|
||||||
{
|
{
|
||||||
BOOST_CHECK_EQUAL(
|
BOOST_CHECK_EQUAL(
|
||||||
|
Loading…
Reference in New Issue
Block a user