mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11595 from ethereum/issue-11526
Fix yul codegen bug when using binary negation.
This commit is contained in:
@@ -658,12 +658,21 @@ void IRGeneratorForStatements::endVisit(Return const& _return)
|
||||
appendCode() << "leave\n";
|
||||
}
|
||||
|
||||
void IRGeneratorForStatements::endVisit(UnaryOperation const& _unaryOperation)
|
||||
bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
|
||||
{
|
||||
setLocation(_unaryOperation);
|
||||
Type const& resultType = type(_unaryOperation);
|
||||
Token const op = _unaryOperation.getOperator();
|
||||
|
||||
if (resultType.category() == Type::Category::RationalNumber)
|
||||
{
|
||||
define(_unaryOperation) << formatNumber(resultType.literalValue(nullptr)) << "\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
_unaryOperation.subExpression().accept(*this);
|
||||
setLocation(_unaryOperation);
|
||||
|
||||
if (op == Token::Delete)
|
||||
{
|
||||
solAssert(!!m_currentLValue, "LValue not retrieved.");
|
||||
@@ -689,8 +698,6 @@ void IRGeneratorForStatements::endVisit(UnaryOperation const& _unaryOperation)
|
||||
m_currentLValue->kind
|
||||
);
|
||||
}
|
||||
else if (resultType.category() == Type::Category::RationalNumber)
|
||||
define(_unaryOperation) << formatNumber(resultType.literalValue(nullptr)) << "\n";
|
||||
else if (resultType.category() == Type::Category::Integer)
|
||||
{
|
||||
solAssert(resultType == type(_unaryOperation.subExpression()), "Result type doesn't match!");
|
||||
@@ -749,6 +756,8 @@ void IRGeneratorForStatements::endVisit(UnaryOperation const& _unaryOperation)
|
||||
}
|
||||
else
|
||||
solUnimplementedAssert(false, "Unary operator not yet implemented");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
|
||||
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
bool visit(Continue const& _continueStatement) override;
|
||||
bool visit(Break const& _breakStatement) override;
|
||||
void endVisit(Return const& _return) override;
|
||||
void endVisit(UnaryOperation const& _unaryOperation) override;
|
||||
bool visit(UnaryOperation const& _unaryOperation) override;
|
||||
bool visit(BinaryOperation const& _binOp) override;
|
||||
void endVisit(FunctionCall const& _funCall) override;
|
||||
void endVisit(FunctionCallOptions const& _funCallOptions) override;
|
||||
|
||||
Reference in New Issue
Block a user