mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Remove recursive call to simplify with reversed arguments.
(We now have explicit rules for that).
This commit is contained in:
parent
295f8c07ad
commit
65c31ecaeb
@ -181,7 +181,7 @@ string ExpressionClasses::fullDAGToString(ExpressionClasses::Id _id) const
|
|||||||
return str.str();
|
return str.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionClasses::Id ExpressionClasses::tryToSimplify(Expression const& _expr, bool _secondRun)
|
ExpressionClasses::Id ExpressionClasses::tryToSimplify(Expression const& _expr)
|
||||||
{
|
{
|
||||||
static Rules rules;
|
static Rules rules;
|
||||||
|
|
||||||
@ -205,13 +205,6 @@ ExpressionClasses::Id ExpressionClasses::tryToSimplify(Expression const& _expr,
|
|||||||
return rebuildExpression(ExpressionTemplate(std::get<1>(*match)(), _expr.item->location()));
|
return rebuildExpression(ExpressionTemplate(std::get<1>(*match)(), _expr.item->location()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_secondRun && _expr.arguments.size() == 2 && SemanticInformation::isCommutativeOperation(*_expr.item))
|
|
||||||
{
|
|
||||||
Expression expr = _expr;
|
|
||||||
swap(expr.arguments[0], expr.arguments[1]);
|
|
||||||
return tryToSimplify(expr, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,8 +108,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
/// Tries to simplify the given expression.
|
/// Tries to simplify the given expression.
|
||||||
/// @returns its class if it possible or Id(-1) otherwise.
|
/// @returns its class if it possible or Id(-1) otherwise.
|
||||||
/// @param _secondRun is set to true for the second run where arguments of commutative expressions are reversed
|
Id tryToSimplify(Expression const& _expr);
|
||||||
Id tryToSimplify(Expression const& _expr, bool _secondRun = false);
|
|
||||||
|
|
||||||
/// Rebuilds an expression from a (matched) pattern.
|
/// Rebuilds an expression from a (matched) pattern.
|
||||||
Id rebuildExpression(ExpressionTemplate const& _template);
|
Id rebuildExpression(ExpressionTemplate const& _template);
|
||||||
|
Loading…
Reference in New Issue
Block a user