Merge pull request #2375 from ethereum/macro_with_zero_args

LLL: macro with zero args
This commit is contained in:
Alex Beregszaszi 2017-06-13 14:44:29 +01:00 committed by GitHub
commit 0c8c209194
3 changed files with 20 additions and 2 deletions

View File

@ -109,7 +109,7 @@ void dev::eth::parseTreeLLL(string const& _s, sp::utree& o_out)
qi::rule<it, space_type, sp::utree::list_type()> mstore = '[' > element > ']' > -qi::lit(":") > element;
qi::rule<it, space_type, sp::utree::list_type()> sstore = qi::lit("[[") > element > qi::lit("]]") > -qi::lit(":") > element;
qi::rule<it, space_type, sp::utree::list_type()> calldataload = qi::lit("$") > element;
qi::rule<it, space_type, sp::utree::list_type()> list = '(' > +element > ')';
qi::rule<it, space_type, sp::utree::list_type()> list = '(' > *element > ')';
qi::rule<it, space_type, sp::utree()> extra = sload[tagNode<2>()] | mload[tagNode<1>()] | sstore[tagNode<4>()] | mstore[tagNode<3>()] | seq[tagNode<5>()] | calldataload[tagNode<6>()];
element = atom | list | extra;

View File

@ -279,6 +279,18 @@ BOOST_AUTO_TEST_CASE(assembly_codecopy)
BOOST_CHECK(callFallback() == encodeArgs(string("abcdef")));
}
BOOST_AUTO_TEST_CASE(zeroarg_macro)
{
char const* sourceCode = R"(
(returnlll
(seq
(def 'zeroarg () (seq (mstore 0 0x1234) (return 0 32)))
(zeroarg)))
)";
compileAndRun(sourceCode);
BOOST_CHECK(callFallback() == encodeArgs(u256(0x1234)));
}
BOOST_AUTO_TEST_SUITE_END()
}

View File

@ -171,7 +171,13 @@ BOOST_AUTO_TEST_CASE(list)
BOOST_CHECK_EQUAL(parse(text), R"(( 1234 ))");
BOOST_CHECK(successParse("( 1234 5467 )"));
BOOST_CHECK(!successParse("()"));
BOOST_CHECK(successParse("()"));
}
BOOST_AUTO_TEST_CASE(macro_with_zero_args)
{
char const* text = "(def 'zeroargs () (asm INVALID))";
BOOST_CHECK(successParse(text));
}
BOOST_AUTO_TEST_SUITE_END()