mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Only use yulAssert and not solAssert in libyul
This commit is contained in:
parent
3d96e2b11a
commit
4c7c7c0270
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
#include <libyul/AsmJsonConverter.h>
|
#include <libyul/AsmJsonConverter.h>
|
||||||
#include <libyul/AsmData.h>
|
#include <libyul/AsmData.h>
|
||||||
#include <liblangutil/Exceptions.h>
|
#include <libyul/Exceptions.h>
|
||||||
#include <libsolutil/CommonData.h>
|
#include <libsolutil/CommonData.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
@ -38,7 +38,7 @@ Json::Value AsmJsonConverter::operator()(Block const& _node) const
|
|||||||
|
|
||||||
Json::Value AsmJsonConverter::operator()(TypedName 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");
|
Json::Value ret = createAstNode(_node.location, "YulTypedName");
|
||||||
ret["name"] = _node.name.str();
|
ret["name"] = _node.name.str();
|
||||||
ret["type"] = _node.type.str();
|
ret["type"] = _node.type.str();
|
||||||
@ -51,7 +51,7 @@ Json::Value AsmJsonConverter::operator()(Literal const& _node) const
|
|||||||
switch (_node.kind)
|
switch (_node.kind)
|
||||||
{
|
{
|
||||||
case LiteralKind::Number:
|
case LiteralKind::Number:
|
||||||
solAssert(
|
yulAssert(
|
||||||
util::isValidDecimal(_node.value.str()) || util::isValidHex(_node.value.str()),
|
util::isValidDecimal(_node.value.str()) || util::isValidHex(_node.value.str()),
|
||||||
"Invalid number literal"
|
"Invalid number literal"
|
||||||
);
|
);
|
||||||
@ -71,7 +71,7 @@ Json::Value AsmJsonConverter::operator()(Literal const& _node) const
|
|||||||
|
|
||||||
Json::Value AsmJsonConverter::operator()(Identifier 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");
|
Json::Value ret = createAstNode(_node.location, "YulIdentifier");
|
||||||
ret["name"] = _node.name.str();
|
ret["name"] = _node.name.str();
|
||||||
return ret;
|
return ret;
|
||||||
@ -79,7 +79,7 @@ Json::Value AsmJsonConverter::operator()(Identifier const& _node) const
|
|||||||
|
|
||||||
Json::Value AsmJsonConverter::operator()(Assignment 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");
|
Json::Value ret = createAstNode(_node.location, "YulAssignment");
|
||||||
for (auto const& var: _node.variableNames)
|
for (auto const& var: _node.variableNames)
|
||||||
ret["variableNames"].append((*this)(var));
|
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
|
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");
|
Json::Value ret = createAstNode(_node.location, "YulFunctionDefinition");
|
||||||
ret["name"] = _node.name.str();
|
ret["name"] = _node.name.str();
|
||||||
for (auto const& var: _node.parameters)
|
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
|
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");
|
Json::Value ret = createAstNode(_node.location, "YulIf");
|
||||||
ret["condition"] = std::visit(*this, *_node.condition);
|
ret["condition"] = std::visit(*this, *_node.condition);
|
||||||
ret["body"] = (*this)(_node.body);
|
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
|
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");
|
Json::Value ret = createAstNode(_node.location, "YulSwitch");
|
||||||
ret["expression"] = std::visit(*this, *_node.expression);
|
ret["expression"] = std::visit(*this, *_node.expression);
|
||||||
for (auto const& var: _node.cases)
|
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
|
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");
|
Json::Value ret = createAstNode(_node.location, "YulForLoop");
|
||||||
ret["pre"] = (*this)(_node.pre);
|
ret["pre"] = (*this)(_node.pre);
|
||||||
ret["condition"] = std::visit(*this, *_node.condition);
|
ret["condition"] = std::visit(*this, *_node.condition);
|
||||||
ret["post"] = (*this)(_node.post);
|
ret["post"] = (*this)(_node.post);
|
||||||
ret["body"] = (*this)(_node.body);
|
ret["body"] = (*this)(_node.body);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Json::Value AsmJsonConverter::operator()(Break const& _node) const
|
Json::Value AsmJsonConverter::operator()(Break const& _node) const
|
||||||
{
|
{
|
||||||
@ -196,7 +196,6 @@ Json::Value AsmJsonConverter::vectorOfVariantsToJson(vector<T> const& _vec) cons
|
|||||||
Json::Value ret{Json::arrayValue};
|
Json::Value ret{Json::arrayValue};
|
||||||
for (auto const& var: _vec)
|
for (auto const& var: _vec)
|
||||||
ret.append(std::visit(*this, var));
|
ret.append(std::visit(*this, var));
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ void AssemblyStack::translate(AssemblyStack::Language _targetLanguage)
|
|||||||
if (m_language == _targetLanguage)
|
if (m_language == _targetLanguage)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
solAssert(
|
yulAssert(
|
||||||
m_language == Language::StrictAssembly && _targetLanguage == Language::Ewasm,
|
m_language == Language::StrictAssembly && _targetLanguage == Language::Ewasm,
|
||||||
"Invalid language combination"
|
"Invalid language combination"
|
||||||
);
|
);
|
||||||
@ -160,7 +160,7 @@ void AssemblyStack::compileEVM(AbstractAssembly& _assembly, bool _evm15, bool _o
|
|||||||
dialect = &EVMDialectTyped::instance(m_evmVersion);
|
dialect = &EVMDialectTyped::instance(m_evmVersion);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
solAssert(false, "Invalid language.");
|
yulAssert(false, "Invalid language.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ pair<YulString, BuiltinFunctionForEVM> createFunction(
|
|||||||
std::function<void(FunctionCall const&, AbstractAssembly&, BuiltinContext&, std::function<void(Expression const&)>)> _generateCode
|
std::function<void(FunctionCall const&, AbstractAssembly&, BuiltinContext&, std::function<void(Expression const&)>)> _generateCode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
solAssert(_literalArguments.size() == _params || _literalArguments.empty(), "");
|
yulAssert(_literalArguments.size() == _params || _literalArguments.empty(), "");
|
||||||
|
|
||||||
YulString name{std::move(_name)};
|
YulString name{std::move(_name)};
|
||||||
BuiltinFunctionForEVM f;
|
BuiltinFunctionForEVM f;
|
||||||
@ -207,7 +207,7 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
|
|||||||
BuiltinContext&,
|
BuiltinContext&,
|
||||||
std::function<void(Expression const&)> _visitExpression
|
std::function<void(Expression const&)> _visitExpression
|
||||||
) {
|
) {
|
||||||
solAssert(_call.arguments.size() == 2, "");
|
yulAssert(_call.arguments.size() == 2, "");
|
||||||
|
|
||||||
_visitExpression(_call.arguments[1]);
|
_visitExpression(_call.arguments[1]);
|
||||||
_assembly.setSourceLocation(_call.location);
|
_assembly.setSourceLocation(_call.location);
|
||||||
@ -227,7 +227,7 @@ map<YulString, BuiltinFunctionForEVM> createBuiltins(langutil::EVMVersion _evmVe
|
|||||||
BuiltinContext&,
|
BuiltinContext&,
|
||||||
std::function<void(Expression const&)>
|
std::function<void(Expression const&)>
|
||||||
) {
|
) {
|
||||||
solAssert(_call.arguments.size() == 1, "");
|
yulAssert(_call.arguments.size() == 1, "");
|
||||||
_assembly.appendImmutable(std::get<Literal>(_call.arguments.front()).value.str());
|
_assembly.appendImmutable(std::get<Literal>(_call.arguments.front()).value.str());
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user