Jump types for yul functions.

This commit is contained in:
chriseth
2020-07-06 18:12:54 +02:00
parent 9009335b3f
commit 4d2b9cd38f
14 changed files with 151 additions and 35 deletions
+24
View File
@@ -182,6 +182,30 @@ BOOST_AUTO_TEST_CASE(location_test)
checkAssemblyLocations(items, locations);
}
BOOST_AUTO_TEST_CASE(jump_type)
{
auto sourceCode = make_shared<CharStream>(R"(
contract C {
function f(uint a) public pure returns (uint t) {
assembly {
function g(x) -> y { if x { leave } y := 8 }
t := g(a)
}
}
}
)", "");
AssemblyItems items = compileContract(sourceCode);
string jumpTypes;
for (AssemblyItem const& item: items)
if (item.getJumpType() != AssemblyItem::JumpType::Ordinary)
jumpTypes += item.getJumpTypeAsString() + "\n";
BOOST_CHECK_EQUAL(jumpTypes, "[in]\n[out]\n[in]\n[out]\n");
}
BOOST_AUTO_TEST_SUITE_END()
} // end namespaces