From 4c7c7c02704468cac5d6264bf94a01e27ffec83e Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 20 May 2020 23:54:42 +0100 Subject: [PATCH] Only use yulAssert and not solAssert in libyul --- libyul/AsmJsonConverter.cpp | 21 ++++++++++----------- libyul/AssemblyStack.cpp | 4 ++-- libyul/backends/evm/EVMDialect.cpp | 6 +++--- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/libyul/AsmJsonConverter.cpp b/libyul/AsmJsonConverter.cpp index 4af0380cd..d2b905ece 100644 --- a/libyul/AsmJsonConverter.cpp +++ b/libyul/AsmJsonConverter.cpp @@ -21,7 +21,7 @@ #include #include -#include +#include #include using namespace std; @@ -38,7 +38,7 @@ Json::Value AsmJsonConverter::operator()(Block const& _node) const Json::Value AsmJsonConverter::operator()(TypedName const& _node) const { - solAssert(!_node.name.empty(), "Invalid variable name."); + yulAssert(!_node.name.empty(), "Invalid variable name."); Json::Value ret = createAstNode(_node.location, "YulTypedName"); ret["name"] = _node.name.str(); ret["type"] = _node.type.str(); @@ -51,7 +51,7 @@ Json::Value AsmJsonConverter::operator()(Literal const& _node) const switch (_node.kind) { case LiteralKind::Number: - solAssert( + yulAssert( util::isValidDecimal(_node.value.str()) || util::isValidHex(_node.value.str()), "Invalid number literal" ); @@ -71,7 +71,7 @@ Json::Value AsmJsonConverter::operator()(Literal const& _node) const Json::Value AsmJsonConverter::operator()(Identifier const& _node) const { - solAssert(!_node.name.empty(), "Invalid identifier"); + yulAssert(!_node.name.empty(), "Invalid identifier"); Json::Value ret = createAstNode(_node.location, "YulIdentifier"); ret["name"] = _node.name.str(); return ret; @@ -79,7 +79,7 @@ Json::Value AsmJsonConverter::operator()(Identifier const& _node) const Json::Value AsmJsonConverter::operator()(Assignment const& _node) const { - solAssert(_node.variableNames.size() >= 1, "Invalid assignment syntax"); + yulAssert(_node.variableNames.size() >= 1, "Invalid assignment syntax"); Json::Value ret = createAstNode(_node.location, "YulAssignment"); for (auto const& var: _node.variableNames) ret["variableNames"].append((*this)(var)); @@ -115,7 +115,7 @@ Json::Value AsmJsonConverter::operator()(VariableDeclaration const& _node) const Json::Value AsmJsonConverter::operator()(FunctionDefinition const& _node) const { - solAssert(!_node.name.empty(), "Invalid function name."); + yulAssert(!_node.name.empty(), "Invalid function name."); Json::Value ret = createAstNode(_node.location, "YulFunctionDefinition"); ret["name"] = _node.name.str(); for (auto const& var: _node.parameters) @@ -128,7 +128,7 @@ Json::Value AsmJsonConverter::operator()(FunctionDefinition const& _node) const Json::Value AsmJsonConverter::operator()(If const& _node) const { - solAssert(_node.condition, "Invalid if condition."); + yulAssert(_node.condition, "Invalid if condition."); Json::Value ret = createAstNode(_node.location, "YulIf"); ret["condition"] = std::visit(*this, *_node.condition); ret["body"] = (*this)(_node.body); @@ -137,7 +137,7 @@ Json::Value AsmJsonConverter::operator()(If const& _node) const Json::Value AsmJsonConverter::operator()(Switch const& _node) const { - solAssert(_node.expression, "Invalid expression pointer."); + yulAssert(_node.expression, "Invalid expression pointer."); Json::Value ret = createAstNode(_node.location, "YulSwitch"); ret["expression"] = std::visit(*this, *_node.expression); for (auto const& var: _node.cases) @@ -155,14 +155,14 @@ Json::Value AsmJsonConverter::operator()(Case const& _node) const Json::Value AsmJsonConverter::operator()(ForLoop const& _node) const { - solAssert(_node.condition, "Invalid for loop condition."); + yulAssert(_node.condition, "Invalid for loop condition."); Json::Value ret = createAstNode(_node.location, "YulForLoop"); ret["pre"] = (*this)(_node.pre); ret["condition"] = std::visit(*this, *_node.condition); ret["post"] = (*this)(_node.post); ret["body"] = (*this)(_node.body); return ret; - } +} Json::Value AsmJsonConverter::operator()(Break const& _node) const { @@ -196,7 +196,6 @@ Json::Value AsmJsonConverter::vectorOfVariantsToJson(vector const& _vec) cons Json::Value ret{Json::arrayValue}; for (auto const& var: _vec) ret.append(std::visit(*this, var)); - return ret; } diff --git a/libyul/AssemblyStack.cpp b/libyul/AssemblyStack.cpp index e0ff93939..4598d6d2b 100644 --- a/libyul/AssemblyStack.cpp +++ b/libyul/AssemblyStack.cpp @@ -108,7 +108,7 @@ void AssemblyStack::translate(AssemblyStack::Language _targetLanguage) if (m_language == _targetLanguage) return; - solAssert( + yulAssert( m_language == Language::StrictAssembly && _targetLanguage == Language::Ewasm, "Invalid language combination" ); @@ -160,7 +160,7 @@ void AssemblyStack::compileEVM(AbstractAssembly& _assembly, bool _evm15, bool _o dialect = &EVMDialectTyped::instance(m_evmVersion); break; default: - solAssert(false, "Invalid language."); + yulAssert(false, "Invalid language."); break; } diff --git a/libyul/backends/evm/EVMDialect.cpp b/libyul/backends/evm/EVMDialect.cpp index b6a46043e..99d52d080 100644 --- a/libyul/backends/evm/EVMDialect.cpp +++ b/libyul/backends/evm/EVMDialect.cpp @@ -93,7 +93,7 @@ pair createFunction( std::function)> _generateCode ) { - solAssert(_literalArguments.size() == _params || _literalArguments.empty(), ""); + yulAssert(_literalArguments.size() == _params || _literalArguments.empty(), ""); YulString name{std::move(_name)}; BuiltinFunctionForEVM f; @@ -207,7 +207,7 @@ map createBuiltins(langutil::EVMVersion _evmVe BuiltinContext&, std::function _visitExpression ) { - solAssert(_call.arguments.size() == 2, ""); + yulAssert(_call.arguments.size() == 2, ""); _visitExpression(_call.arguments[1]); _assembly.setSourceLocation(_call.location); @@ -227,7 +227,7 @@ map createBuiltins(langutil::EVMVersion _evmVe BuiltinContext&, std::function ) { - solAssert(_call.arguments.size() == 1, ""); + yulAssert(_call.arguments.size() == 1, ""); _assembly.appendImmutable(std::get(_call.arguments.front()).value.str()); } ));