mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Replace all solAsserts with yulAsserts in libyul
This commit is contained in:
+18
-18
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <libyul/AsmPrinter.h>
|
||||
#include <libyul/AsmData.h>
|
||||
#include <liblangutil/Exceptions.h>
|
||||
#include <libyul/Exceptions.h>
|
||||
|
||||
#include <libdevcore/CommonData.h>
|
||||
|
||||
@@ -41,8 +41,8 @@ using namespace yul;
|
||||
|
||||
string AsmPrinter::operator()(yul::Instruction const& _instruction) const
|
||||
{
|
||||
solAssert(!m_yul, "");
|
||||
solAssert(isValidInstruction(_instruction.instruction), "Invalid instruction");
|
||||
yulAssert(!m_yul, "");
|
||||
yulAssert(isValidInstruction(_instruction.instruction), "Invalid instruction");
|
||||
return boost::to_lower_copy(instructionInfo(_instruction.instruction).name);
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ string AsmPrinter::operator()(Literal const& _literal) const
|
||||
switch (_literal.kind)
|
||||
{
|
||||
case LiteralKind::Number:
|
||||
solAssert(isValidDecimal(_literal.value.str()) || isValidHex(_literal.value.str()), "Invalid number literal");
|
||||
yulAssert(isValidDecimal(_literal.value.str()) || isValidHex(_literal.value.str()), "Invalid number literal");
|
||||
return _literal.value.str() + appendTypeName(_literal.type);
|
||||
case LiteralKind::Boolean:
|
||||
solAssert(_literal.value == "true"_yulstring || _literal.value == "false"_yulstring, "Invalid bool literal.");
|
||||
yulAssert(_literal.value == "true"_yulstring || _literal.value == "false"_yulstring, "Invalid bool literal.");
|
||||
return ((_literal.value == "true"_yulstring) ? "true" : "false") + appendTypeName(_literal.type);
|
||||
case LiteralKind::String:
|
||||
break;
|
||||
@@ -91,14 +91,14 @@ string AsmPrinter::operator()(Literal const& _literal) const
|
||||
|
||||
string AsmPrinter::operator()(Identifier const& _identifier) const
|
||||
{
|
||||
solAssert(!_identifier.name.empty(), "Invalid identifier.");
|
||||
yulAssert(!_identifier.name.empty(), "Invalid identifier.");
|
||||
return _identifier.name.str();
|
||||
}
|
||||
|
||||
string AsmPrinter::operator()(FunctionalInstruction const& _functionalInstruction) const
|
||||
{
|
||||
solAssert(!m_yul, "");
|
||||
solAssert(isValidInstruction(_functionalInstruction.instruction), "Invalid instruction");
|
||||
yulAssert(!m_yul, "");
|
||||
yulAssert(isValidInstruction(_functionalInstruction.instruction), "Invalid instruction");
|
||||
return
|
||||
boost::to_lower_copy(instructionInfo(_functionalInstruction.instruction).name) +
|
||||
"(" +
|
||||
@@ -116,21 +116,21 @@ string AsmPrinter::operator()(ExpressionStatement const& _statement) const
|
||||
|
||||
string AsmPrinter::operator()(Label const& _label) const
|
||||
{
|
||||
solAssert(!m_yul, "");
|
||||
solAssert(!_label.name.empty(), "Invalid label.");
|
||||
yulAssert(!m_yul, "");
|
||||
yulAssert(!_label.name.empty(), "Invalid label.");
|
||||
return _label.name.str() + ":";
|
||||
}
|
||||
|
||||
string AsmPrinter::operator()(StackAssignment const& _assignment) const
|
||||
{
|
||||
solAssert(!m_yul, "");
|
||||
solAssert(!_assignment.variableName.name.empty(), "Invalid variable name.");
|
||||
yulAssert(!m_yul, "");
|
||||
yulAssert(!_assignment.variableName.name.empty(), "Invalid variable name.");
|
||||
return "=: " + (*this)(_assignment.variableName);
|
||||
}
|
||||
|
||||
string AsmPrinter::operator()(Assignment const& _assignment) const
|
||||
{
|
||||
solAssert(_assignment.variableNames.size() >= 1, "");
|
||||
yulAssert(_assignment.variableNames.size() >= 1, "");
|
||||
string variables = (*this)(_assignment.variableNames.front());
|
||||
for (size_t i = 1; i < _assignment.variableNames.size(); ++i)
|
||||
variables += ", " + (*this)(_assignment.variableNames[i]);
|
||||
@@ -156,7 +156,7 @@ string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) c
|
||||
|
||||
string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) const
|
||||
{
|
||||
solAssert(!_functionDefinition.name.empty(), "Invalid function name.");
|
||||
yulAssert(!_functionDefinition.name.empty(), "Invalid function name.");
|
||||
string out = "function " + _functionDefinition.name.str() + "(";
|
||||
out += boost::algorithm::join(
|
||||
_functionDefinition.parameters | boost::adaptors::transformed(
|
||||
@@ -191,7 +191,7 @@ string AsmPrinter::operator()(FunctionCall const& _functionCall) const
|
||||
|
||||
string AsmPrinter::operator()(If const& _if) const
|
||||
{
|
||||
solAssert(_if.condition, "Invalid if condition.");
|
||||
yulAssert(_if.condition, "Invalid if condition.");
|
||||
string body = (*this)(_if.body);
|
||||
char delim = '\n';
|
||||
if (body.find('\n') == string::npos)
|
||||
@@ -201,7 +201,7 @@ string AsmPrinter::operator()(If const& _if) const
|
||||
|
||||
string AsmPrinter::operator()(Switch const& _switch) const
|
||||
{
|
||||
solAssert(_switch.expression, "Invalid expression pointer.");
|
||||
yulAssert(_switch.expression, "Invalid expression pointer.");
|
||||
string out = "switch " + std::visit(*this, *_switch.expression);
|
||||
for (auto const& _case: _switch.cases)
|
||||
{
|
||||
@@ -216,7 +216,7 @@ string AsmPrinter::operator()(Switch const& _switch) const
|
||||
|
||||
string AsmPrinter::operator()(ForLoop const& _forLoop) const
|
||||
{
|
||||
solAssert(_forLoop.condition, "Invalid for loop condition.");
|
||||
yulAssert(_forLoop.condition, "Invalid for loop condition.");
|
||||
string pre = (*this)(_forLoop.pre);
|
||||
string condition = std::visit(*this, *_forLoop.condition);
|
||||
string post = (*this)(_forLoop.post);
|
||||
@@ -261,7 +261,7 @@ string AsmPrinter::operator()(Block const& _block) const
|
||||
|
||||
string AsmPrinter::formatTypedName(TypedName _variable) const
|
||||
{
|
||||
solAssert(!_variable.name.empty(), "Invalid variable name.");
|
||||
yulAssert(!_variable.name.empty(), "Invalid variable name.");
|
||||
return _variable.name.str() + appendTypeName(_variable.type);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user