Adding support for recursive functions in MultiUseYulFunctionCollector

This commit is contained in:
Djordje Mijovic 2020-09-18 13:46:02 +02:00
parent 93df3d43df
commit 3ede1f1bca

View File

@ -33,8 +33,11 @@ string MultiUseYulFunctionCollector::requestedFunctions()
{ {
string result; string result;
for (auto const& f: m_requestedFunctions) for (auto const& f: m_requestedFunctions)
{
solAssert(f.second != "<<STUB<<", "");
// std::map guarantees ascending order when iterating through its keys. // std::map guarantees ascending order when iterating through its keys.
result += f.second; result += f.second;
}
m_requestedFunctions.clear(); m_requestedFunctions.clear();
return result; return result;
} }
@ -43,9 +46,10 @@ string MultiUseYulFunctionCollector::createFunction(string const& _name, functio
{ {
if (!m_requestedFunctions.count(_name)) if (!m_requestedFunctions.count(_name))
{ {
m_requestedFunctions[_name] = "<<STUB<<";
string fun = _creator(); string fun = _creator();
solAssert(!fun.empty(), ""); solAssert(!fun.empty(), "");
solAssert(fun.find("function " + _name) != string::npos, "Function not properly named."); solAssert(fun.find("function " + _name + "(") != string::npos, "Function not properly named.");
m_requestedFunctions[_name] = std::move(fun); m_requestedFunctions[_name] = std::move(fun);
} }
return _name; return _name;