Merge pull request #10641 from ethereum/yul-error

Simplify StackTooDeepError in Yul
This commit is contained in:
Alex Beregszaszi 2020-12-17 12:46:26 +00:00 committed by GitHub
commit 2fa0e3c88a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 7 deletions

View File

@ -483,8 +483,10 @@ void CodeTransform::operator()(FunctionDefinition const& _function)
if (stackLayout.size() > 17)
{
StackTooDeepError error(_function.name, YulString{}, static_cast<int>(stackLayout.size()) - 17);
error << errinfo_comment(
StackTooDeepError error(
_function.name,
YulString{},
static_cast<int>(stackLayout.size()) - 17,
"The function " +
_function.name.str() +
" has " +
@ -716,8 +718,9 @@ size_t CodeTransform::variableHeightDiff(Scope::Variable const& _var, YulString
size_t limit = _forSwap ? 17 : 16;
if (heightDiff > limit)
{
m_stackErrors.emplace_back(_varName, heightDiff - limit);
m_stackErrors.back() << errinfo_comment(
m_stackErrors.emplace_back(
_varName,
heightDiff - limit,
"Variable " +
_varName.str() +
" is " +

View File

@ -43,10 +43,16 @@ class EVMAssembly;
struct StackTooDeepError: virtual YulException
{
StackTooDeepError(YulString _variable, int _depth): variable(_variable), depth(_depth) {}
StackTooDeepError(YulString _functionName, YulString _variable, int _depth):
StackTooDeepError(YulString _variable, int _depth, std::string const& _message):
variable(_variable), depth(_depth)
{
*this << util::errinfo_comment(_message);
}
StackTooDeepError(YulString _functionName, YulString _variable, int _depth, std::string const& _message):
functionName(_functionName), variable(_variable), depth(_depth)
{}
{
*this << util::errinfo_comment(_message);
}
YulString functionName;
YulString variable;
int depth;