Merge pull request #11655 from ethereum/ObjectCompiler-user-src-new-test

Print source locations in AsmPrinter
This commit is contained in:
chriseth 2021-08-03 16:09:40 +02:00 committed by GitHub
commit 3b1eacfcaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 1319 additions and 109 deletions

View File

@ -279,8 +279,8 @@ InternalDispatchMap IRGenerator::generateInternalDispatchFunctions(ContractDefin
string funName = IRNames::internalDispatch(arity); string funName = IRNames::internalDispatch(arity);
m_context.functionCollector().createFunction(funName, [&]() { m_context.functionCollector().createFunction(funName, [&]() {
Whiskers templ(R"( Whiskers templ(R"(
<sourceLocationComment>
function <functionName>(fun<?+in>, <in></+in>) <?+out>-> <out></+out> { function <functionName>(fun<?+in>, <in></+in>) <?+out>-> <out></+out> {
<sourceLocationComment>
switch fun switch fun
<#cases> <#cases>
case <funID> case <funID>
@ -290,6 +290,7 @@ InternalDispatchMap IRGenerator::generateInternalDispatchFunctions(ContractDefin
</cases> </cases>
default { <panic>() } default { <panic>() }
} }
<sourceLocationComment>
)"); )");
templ("sourceLocationComment", sourceLocationComment(_contract, m_context)); templ("sourceLocationComment", sourceLocationComment(_contract, m_context));
templ("functionName", funName); templ("functionName", funName);
@ -336,14 +337,19 @@ string IRGenerator::generateFunction(FunctionDefinition const& _function)
return m_context.functionCollector().createFunction(functionName, [&]() { return m_context.functionCollector().createFunction(functionName, [&]() {
m_context.resetLocalVariables(); m_context.resetLocalVariables();
Whiskers t(R"( Whiskers t(R"(
<sourceLocationComment>
function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> { function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> {
<sourceLocationComment>
<retInit> <retInit>
<body> <body>
} }
<contractSourceLocationComment>
)"); )");
t("sourceLocationComment", sourceLocationComment(_function, m_context)); t("sourceLocationComment", sourceLocationComment(_function, m_context));
t(
"contractSourceLocationComment",
sourceLocationComment(m_context.mostDerivedContract(), m_context)
);
t("functionName", functionName); t("functionName", functionName);
vector<string> params; vector<string> params;
@ -398,12 +404,13 @@ string IRGenerator::generateModifier(
return m_context.functionCollector().createFunction(functionName, [&]() { return m_context.functionCollector().createFunction(functionName, [&]() {
m_context.resetLocalVariables(); m_context.resetLocalVariables();
Whiskers t(R"( Whiskers t(R"(
<sourceLocationComment>
function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> { function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> {
<sourceLocationComment>
<assignRetParams> <assignRetParams>
<evalArgs> <evalArgs>
<body> <body>
} }
<contractSourceLocationComment>
)"); )");
t("functionName", functionName); t("functionName", functionName);
vector<string> retParamsIn; vector<string> retParamsIn;
@ -428,6 +435,11 @@ string IRGenerator::generateModifier(
); );
solAssert(modifier, ""); solAssert(modifier, "");
t("sourceLocationComment", sourceLocationComment(*modifier, m_context)); t("sourceLocationComment", sourceLocationComment(*modifier, m_context));
t(
"contractSourceLocationComment",
sourceLocationComment(m_context.mostDerivedContract(), m_context)
);
switch (*_modifierInvocation.name().annotation().requiredLookup) switch (*_modifierInvocation.name().annotation().requiredLookup)
{ {
case VirtualLookup::Virtual: case VirtualLookup::Virtual:
@ -478,13 +490,18 @@ string IRGenerator::generateFunctionWithModifierInner(FunctionDefinition const&
return m_context.functionCollector().createFunction(functionName, [&]() { return m_context.functionCollector().createFunction(functionName, [&]() {
m_context.resetLocalVariables(); m_context.resetLocalVariables();
Whiskers t(R"( Whiskers t(R"(
<sourceLocationComment>
function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> { function <functionName>(<params>)<?+retParams> -> <retParams></+retParams> {
<sourceLocationComment>
<assignRetParams> <assignRetParams>
<body> <body>
} }
<contractSourceLocationComment>
)"); )");
t("sourceLocationComment", sourceLocationComment(_function, m_context)); t("sourceLocationComment", sourceLocationComment(_function, m_context));
t(
"contractSourceLocationComment",
sourceLocationComment(m_context.mostDerivedContract(), m_context)
);
t("functionName", functionName); t("functionName", functionName);
vector<string> retParams; vector<string> retParams;
vector<string> retParamsIn; vector<string> retParamsIn;
@ -522,12 +539,17 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
solAssert(paramTypes.empty(), ""); solAssert(paramTypes.empty(), "");
solUnimplementedAssert(type->sizeOnStack() == 1, ""); solUnimplementedAssert(type->sizeOnStack() == 1, "");
return Whiskers(R"( return Whiskers(R"(
<sourceLocationComment>
function <functionName>() -> rval { function <functionName>() -> rval {
<sourceLocationComment>
rval := loadimmutable("<id>") rval := loadimmutable("<id>")
} }
<contractSourceLocationComment>
)") )")
("sourceLocationComment", sourceLocationComment(_varDecl, m_context)) ("sourceLocationComment", sourceLocationComment(_varDecl, m_context))
(
"contractSourceLocationComment",
sourceLocationComment(m_context.mostDerivedContract(), m_context)
)
("functionName", functionName) ("functionName", functionName)
("id", to_string(_varDecl.id())) ("id", to_string(_varDecl.id()))
.render(); .render();
@ -536,12 +558,17 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
{ {
solAssert(paramTypes.empty(), ""); solAssert(paramTypes.empty(), "");
return Whiskers(R"( return Whiskers(R"(
<sourceLocationComment>
function <functionName>() -> <ret> { function <functionName>() -> <ret> {
<sourceLocationComment>
<ret> := <constantValueFunction>() <ret> := <constantValueFunction>()
} }
<contractSourceLocationComment>
)") )")
("sourceLocationComment", sourceLocationComment(_varDecl, m_context)) ("sourceLocationComment", sourceLocationComment(_varDecl, m_context))
(
"contractSourceLocationComment",
sourceLocationComment(m_context.mostDerivedContract(), m_context)
)
("functionName", functionName) ("functionName", functionName)
("constantValueFunction", IRGeneratorForStatements(m_context, m_utils).constantValueFunction(_varDecl)) ("constantValueFunction", IRGeneratorForStatements(m_context, m_utils).constantValueFunction(_varDecl))
("ret", suffixedVariableNameList("ret_", 0, _varDecl.type()->sizeOnStack())) ("ret", suffixedVariableNameList("ret_", 0, _varDecl.type()->sizeOnStack()))
@ -653,16 +680,21 @@ string IRGenerator::generateGetter(VariableDeclaration const& _varDecl)
} }
return Whiskers(R"( return Whiskers(R"(
<sourceLocationComment>
function <functionName>(<params>) -> <retVariables> { function <functionName>(<params>) -> <retVariables> {
<sourceLocationComment>
<code> <code>
} }
<contractSourceLocationComment>
)") )")
("functionName", functionName) ("functionName", functionName)
("params", joinHumanReadable(parameters)) ("params", joinHumanReadable(parameters))
("retVariables", joinHumanReadable(returnVariables)) ("retVariables", joinHumanReadable(returnVariables))
("code", std::move(code)) ("code", std::move(code))
("sourceLocationComment", sourceLocationComment(_varDecl, m_context)) ("sourceLocationComment", sourceLocationComment(_varDecl, m_context))
(
"contractSourceLocationComment",
sourceLocationComment(m_context.mostDerivedContract(), m_context)
)
.render(); .render();
}); });
} }
@ -769,6 +801,7 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract)
m_context.resetLocalVariables(); m_context.resetLocalVariables();
m_context.functionCollector().createFunction(IRNames::constructor(*contract), [&]() { m_context.functionCollector().createFunction(IRNames::constructor(*contract), [&]() {
Whiskers t(R"( Whiskers t(R"(
<sourceLocationComment>
function <functionName>(<params><comma><baseParams>) { function <functionName>(<params><comma><baseParams>) {
<evalBaseArguments> <evalBaseArguments>
<sourceLocationComment> <sourceLocationComment>
@ -776,6 +809,7 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract)
<initStateVariables> <initStateVariables>
<userDefinedConstructorBody> <userDefinedConstructorBody>
} }
<contractSourceLocationComment>
)"); )");
vector<string> params; vector<string> params;
if (contract->constructor()) if (contract->constructor())
@ -788,6 +822,10 @@ void IRGenerator::generateConstructors(ContractDefinition const& _contract)
contract->location(), contract->location(),
m_context m_context
)); ));
t(
"contractSourceLocationComment",
sourceLocationComment(m_context.mostDerivedContract(), m_context)
);
t("params", joinHumanReadable(params)); t("params", joinHumanReadable(params));
vector<string> baseParams = listAllParams(baseConstructorParams); vector<string> baseParams = listAllParams(baseConstructorParams);

View File

@ -41,48 +41,55 @@ using namespace solidity;
using namespace solidity::util; using namespace solidity::util;
using namespace solidity::yul; using namespace solidity::yul;
//@TODO source locations string AsmPrinter::operator()(Literal const& _literal)
string AsmPrinter::operator()(Literal const& _literal) const
{ {
string const locationComment = formatSourceLocationComment(_literal);
switch (_literal.kind) switch (_literal.kind)
{ {
case LiteralKind::Number: case LiteralKind::Number:
yulAssert(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); return locationComment + _literal.value.str() + appendTypeName(_literal.type);
case LiteralKind::Boolean: case LiteralKind::Boolean:
yulAssert(_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, true); return locationComment + ((_literal.value == "true"_yulstring) ? "true" : "false") + appendTypeName(_literal.type, true);
case LiteralKind::String: case LiteralKind::String:
break; break;
} }
return escapeAndQuoteString(_literal.value.str()) + appendTypeName(_literal.type); return locationComment + escapeAndQuoteString(_literal.value.str()) + appendTypeName(_literal.type);
} }
string AsmPrinter::operator()(Identifier const& _identifier) const string AsmPrinter::operator()(Identifier const& _identifier)
{ {
yulAssert(!_identifier.name.empty(), "Invalid identifier."); yulAssert(!_identifier.name.empty(), "Invalid identifier.");
return _identifier.name.str(); return formatSourceLocationComment(_identifier) + _identifier.name.str();
} }
string AsmPrinter::operator()(ExpressionStatement const& _statement) const string AsmPrinter::operator()(ExpressionStatement const& _statement)
{ {
return std::visit(*this, _statement.expression); string const locationComment = formatSourceLocationComment(_statement);
return locationComment + std::visit(*this, _statement.expression);
} }
string AsmPrinter::operator()(Assignment const& _assignment) const string AsmPrinter::operator()(Assignment const& _assignment)
{ {
string const locationComment = formatSourceLocationComment(_assignment);
yulAssert(_assignment.variableNames.size() >= 1, ""); yulAssert(_assignment.variableNames.size() >= 1, "");
string variables = (*this)(_assignment.variableNames.front()); string variables = (*this)(_assignment.variableNames.front());
for (size_t i = 1; i < _assignment.variableNames.size(); ++i) for (size_t i = 1; i < _assignment.variableNames.size(); ++i)
variables += ", " + (*this)(_assignment.variableNames[i]); variables += ", " + (*this)(_assignment.variableNames[i]);
return variables + " := " + std::visit(*this, *_assignment.value);
return locationComment + variables + " := " + std::visit(*this, *_assignment.value);
} }
string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) const string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration)
{ {
string out = "let "; string out = formatSourceLocationComment(_variableDeclaration);
out += "let ";
out += boost::algorithm::join( out += boost::algorithm::join(
_variableDeclaration.variables | ranges::views::transform( _variableDeclaration.variables | ranges::views::transform(
[this](TypedName argument) { return formatTypedName(argument); } [this](TypedName argument) { return formatTypedName(argument); }
@ -97,10 +104,12 @@ string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) c
return out; return out;
} }
string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) const string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition)
{ {
yulAssert(!_functionDefinition.name.empty(), "Invalid function name."); yulAssert(!_functionDefinition.name.empty(), "Invalid function name.");
string out = "function " + _functionDefinition.name.str() + "(";
string out = formatSourceLocationComment(_functionDefinition);
out += "function " + _functionDefinition.name.str() + "(";
out += boost::algorithm::join( out += boost::algorithm::join(
_functionDefinition.parameters | ranges::views::transform( _functionDefinition.parameters | ranges::views::transform(
[this](TypedName argument) { return formatTypedName(argument); } [this](TypedName argument) { return formatTypedName(argument); }
@ -122,30 +131,41 @@ string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) con
return out + "\n" + (*this)(_functionDefinition.body); return out + "\n" + (*this)(_functionDefinition.body);
} }
string AsmPrinter::operator()(FunctionCall const& _functionCall) const string AsmPrinter::operator()(FunctionCall const& _functionCall)
{ {
string const locationComment = formatSourceLocationComment(_functionCall);
string const functionName = (*this)(_functionCall.functionName);
return return
(*this)(_functionCall.functionName) + "(" + locationComment +
functionName + "(" +
boost::algorithm::join( boost::algorithm::join(
_functionCall.arguments | ranges::views::transform([&](auto&& _node) { return std::visit(*this, _node); }), _functionCall.arguments | ranges::views::transform([&](auto&& _node) { return std::visit(*this, _node); }),
", " ) + ", " ) +
")"; ")";
} }
string AsmPrinter::operator()(If const& _if) const string AsmPrinter::operator()(If const& _if)
{ {
yulAssert(_if.condition, "Invalid if condition."); yulAssert(_if.condition, "Invalid if condition.");
string out = formatSourceLocationComment(_if);
out += "if " + std::visit(*this, *_if.condition);
string body = (*this)(_if.body); string body = (*this)(_if.body);
char delim = '\n'; char delim = '\n';
if (body.find('\n') == string::npos) if (body.find('\n') == string::npos)
delim = ' '; delim = ' ';
return "if " + std::visit(*this, *_if.condition) + delim + (*this)(_if.body);
return out + delim + body;
} }
string AsmPrinter::operator()(Switch const& _switch) const string AsmPrinter::operator()(Switch const& _switch)
{ {
yulAssert(_switch.expression, "Invalid expression pointer."); yulAssert(_switch.expression, "Invalid expression pointer.");
string out = "switch " + std::visit(*this, *_switch.expression);
string out = formatSourceLocationComment(_switch);
out += "switch " + std::visit(*this, *_switch.expression);
for (auto const& _case: _switch.cases) for (auto const& _case: _switch.cases)
{ {
if (!_case.value) if (!_case.value)
@ -157,12 +177,15 @@ string AsmPrinter::operator()(Switch const& _switch) const
return out; return out;
} }
string AsmPrinter::operator()(ForLoop const& _forLoop) const string AsmPrinter::operator()(ForLoop const& _forLoop)
{ {
yulAssert(_forLoop.condition, "Invalid for loop condition."); yulAssert(_forLoop.condition, "Invalid for loop condition.");
string const locationComment = formatSourceLocationComment(_forLoop);
string pre = (*this)(_forLoop.pre); string pre = (*this)(_forLoop.pre);
string condition = std::visit(*this, *_forLoop.condition); string condition = std::visit(*this, *_forLoop.condition);
string post = (*this)(_forLoop.post); string post = (*this)(_forLoop.post);
char delim = '\n'; char delim = '\n';
if ( if (
pre.size() + condition.size() + post.size() < 60 && pre.size() + condition.size() + post.size() < 60 &&
@ -171,46 +194,50 @@ string AsmPrinter::operator()(ForLoop const& _forLoop) const
) )
delim = ' '; delim = ' ';
return return
locationComment +
("for " + move(pre) + delim + move(condition) + delim + move(post) + "\n") + ("for " + move(pre) + delim + move(condition) + delim + move(post) + "\n") +
(*this)(_forLoop.body); (*this)(_forLoop.body);
} }
string AsmPrinter::operator()(Break const&) const string AsmPrinter::operator()(Break const& _break)
{ {
return "break"; return formatSourceLocationComment(_break) + "break";
} }
string AsmPrinter::operator()(Continue const&) const string AsmPrinter::operator()(Continue const& _continue)
{ {
return "continue"; return formatSourceLocationComment(_continue) + "continue";
} }
string AsmPrinter::operator()(Leave const&) const // '_leave' and '__leave' is reserved in VisualStudio
string AsmPrinter::operator()(Leave const& leave_)
{ {
return "leave"; return formatSourceLocationComment(leave_) + "leave";
} }
string AsmPrinter::operator()(Block const& _block) const string AsmPrinter::operator()(Block const& _block)
{ {
string const locationComment = formatSourceLocationComment(_block);
if (_block.statements.empty()) if (_block.statements.empty())
return "{ }"; return locationComment + "{ }";
string body = boost::algorithm::join( string body = boost::algorithm::join(
_block.statements | ranges::views::transform([&](auto&& _node) { return std::visit(*this, _node); }), _block.statements | ranges::views::transform([&](auto&& _node) { return std::visit(*this, _node); }),
"\n" "\n"
); );
if (body.size() < 30 && body.find('\n') == string::npos) if (body.size() < 30 && body.find('\n') == string::npos)
return "{ " + body + " }"; return locationComment + "{ " + body + " }";
else else
{ {
boost::replace_all(body, "\n", "\n "); boost::replace_all(body, "\n", "\n ");
return "{\n " + body + "\n}"; return locationComment + "{\n " + body + "\n}";
} }
} }
string AsmPrinter::formatTypedName(TypedName _variable) const string AsmPrinter::formatTypedName(TypedName _variable)
{ {
yulAssert(!_variable.name.empty(), "Invalid variable name."); yulAssert(!_variable.name.empty(), "Invalid variable name.");
return _variable.name.str() + appendTypeName(_variable.type); return formatSourceLocationComment(_variable) + _variable.name.str() + appendTypeName(_variable.type);
} }
string AsmPrinter::appendTypeName(YulString _type, bool _isBoolLiteral) const string AsmPrinter::appendTypeName(YulString _type, bool _isBoolLiteral) const
@ -228,3 +255,31 @@ string AsmPrinter::appendTypeName(YulString _type, bool _isBoolLiteral) const
else else
return ":" + _type.str(); return ":" + _type.str();
} }
string AsmPrinter::formatSourceLocationComment(shared_ptr<DebugData const> const& _debugData, bool _statement)
{
if (
!_debugData ||
m_lastLocation == _debugData->location ||
m_nameToSourceIndex.empty()
)
return "";
m_lastLocation = _debugData->location;
string sourceIndex = "-1";
if (_debugData->location.sourceName)
sourceIndex = to_string(m_nameToSourceIndex.at(*_debugData->location.sourceName));
string sourceLocation =
"@src " +
sourceIndex +
":" +
to_string(_debugData->location.start) +
":" +
to_string(_debugData->location.end);
return
_statement ?
"/// " + sourceLocation + "\n" :
"/** " + sourceLocation + " */ ";
}

View File

@ -24,9 +24,14 @@
#pragma once #pragma once
#include <libyul/ASTForward.h> #include <libyul/ASTForward.h>
#include <libyul/YulString.h> #include <libyul/YulString.h>
#include <libsolutil/CommonData.h>
#include <liblangutil/SourceLocation.h>
#include <map>
namespace solidity::yul namespace solidity::yul
{ {
struct Dialect; struct Dialect;
@ -39,29 +44,52 @@ struct Dialect;
class AsmPrinter class AsmPrinter
{ {
public: public:
AsmPrinter() {} explicit AsmPrinter(
explicit AsmPrinter(Dialect const& _dialect): m_dialect(&_dialect) {} Dialect const* _dialect = nullptr,
std::optional<std::map<unsigned, std::shared_ptr<std::string const>>> _sourceIndexToName = {}
):
m_dialect(_dialect)
{
if (_sourceIndexToName)
for (auto&& [index, name]: *_sourceIndexToName)
m_nameToSourceIndex[*name] = index;
}
std::string operator()(Literal const& _literal) const;
std::string operator()(Identifier const& _identifier) const; explicit AsmPrinter(
std::string operator()(ExpressionStatement const& _expr) const; Dialect const& _dialect,
std::string operator()(Assignment const& _assignment) const; std::optional<std::map<unsigned, std::shared_ptr<std::string const>>> _sourceIndexToName = {}
std::string operator()(VariableDeclaration const& _variableDeclaration) const; ): AsmPrinter(&_dialect, _sourceIndexToName) {}
std::string operator()(FunctionDefinition const& _functionDefinition) const;
std::string operator()(FunctionCall const& _functionCall) const; std::string operator()(Literal const& _literal);
std::string operator()(If const& _if) const; std::string operator()(Identifier const& _identifier);
std::string operator()(Switch const& _switch) const; std::string operator()(ExpressionStatement const& _expr);
std::string operator()(ForLoop const& _forLoop) const; std::string operator()(Assignment const& _assignment);
std::string operator()(Break const& _break) const; std::string operator()(VariableDeclaration const& _variableDeclaration);
std::string operator()(Continue const& _continue) const; std::string operator()(FunctionDefinition const& _functionDefinition);
std::string operator()(Leave const& _continue) const; std::string operator()(FunctionCall const& _functionCall);
std::string operator()(Block const& _block) const; std::string operator()(If const& _if);
std::string operator()(Switch const& _switch);
std::string operator()(ForLoop const& _forLoop);
std::string operator()(Break const& _break);
std::string operator()(Continue const& _continue);
std::string operator()(Leave const& _continue);
std::string operator()(Block const& _block);
private: private:
std::string formatTypedName(TypedName _variable) const; std::string formatTypedName(TypedName _variable);
std::string appendTypeName(YulString _type, bool _isBoolLiteral = false) const; std::string appendTypeName(YulString _type, bool _isBoolLiteral = false) const;
std::string formatSourceLocationComment(std::shared_ptr<DebugData const> const& _debugData, bool _statement);
template <class T>
std::string formatSourceLocationComment(T const& _node)
{
bool isExpression = std::is_constructible<Expression, T>::value;
return formatSourceLocationComment(_node.debugData, !isExpression);
}
Dialect const* m_dialect = nullptr; Dialect const* const m_dialect = nullptr;
std::map<std::string const, unsigned> m_nameToSourceIndex;
langutil::SourceLocation m_lastLocation = {};
}; };
} }

View File

@ -25,11 +25,14 @@
#include <libyul/Exceptions.h> #include <libyul/Exceptions.h>
#include <libsolutil/CommonData.h> #include <libsolutil/CommonData.h>
#include <libsolutil/StringUtils.h>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/split.hpp> #include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <range/v3/view/transform.hpp>
using namespace std; using namespace std;
using namespace solidity; using namespace solidity;
using namespace solidity::yul; using namespace solidity::yul;
@ -47,18 +50,36 @@ string indent(std::string const& _input)
} }
string Data::toString(Dialect const*) const string Data::toString(Dialect const*, optional<SourceNameMap>) const
{ {
return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\""; return "data \"" + name.str() + "\" hex\"" + util::toHex(data) + "\"";
} }
string Object::toString(Dialect const* _dialect) const string Object::toString(Dialect const* _dialect) const
{
string useSrcComment;
if (debugData && debugData->sourceNames)
useSrcComment =
"/// @use-src " +
joinHumanReadable(ranges::views::transform(*debugData->sourceNames, [](auto&& _pair) {
return to_string(_pair.first) + ":" + util::escapeAndQuoteString(*_pair.second);
})) +
"\n";
return useSrcComment + toString(_dialect, debugData ? debugData->sourceNames : optional<SourceNameMap>{});
}
string Object::toString(Dialect const* _dialect, std::optional<SourceNameMap> _sourceNames) const
{ {
yulAssert(code, "No code"); yulAssert(code, "No code");
string inner = "code " + (_dialect ? AsmPrinter{*_dialect} : AsmPrinter{})(*code); string inner = "code " + AsmPrinter{_dialect, _sourceNames}(*code);
for (auto const& obj: subObjects) for (auto const& obj: subObjects)
inner += "\n" + obj->toString(_dialect); {
if (auto const* o = dynamic_cast<Object const*>(obj.get()))
yulAssert(!o->debugData || !o->debugData->sourceNames, "");
inner += "\n" + obj->toString(_dialect, _sourceNames);
}
return "object \"" + name.str() + "\" {\n" + indent(inner) + "\n}"; return "object \"" + name.str() + "\" {\n" + indent(inner) + "\n}";
} }

View File

@ -35,39 +35,55 @@ struct Dialect;
struct AsmAnalysisInfo; struct AsmAnalysisInfo;
using SourceNameMap = std::map<unsigned, std::shared_ptr<std::string const>>;
struct Object;
/** /**
* Generic base class for both Yul objects and Yul data. * Generic base class for both Yul objects and Yul data.
*/ */
struct ObjectNode struct ObjectNode
{ {
virtual ~ObjectNode() = default; virtual ~ObjectNode() = default;
virtual std::string toString(Dialect const* _dialect) const = 0;
std::string toString() { return toString(nullptr); }
/// Name of the object. /// Name of the object.
/// Can be empty since .yul files can also just contain code, without explicitly placing it in an object. /// Can be empty since .yul files can also just contain code, without explicitly placing it in an object.
YulString name; YulString name;
protected:
virtual std::string toString(Dialect const* _dialect, std::optional<SourceNameMap> _sourceNames) const = 0;
/// Object should have access to toString
friend struct Object;
}; };
/** /**
* Named data in Yul objects. * Named data in Yul objects.
*/ */
struct Data: ObjectNode struct Data: public ObjectNode
{ {
Data(YulString _name, bytes _data): data(std::move(_data)) { name = _name; } Data(YulString _name, bytes _data): data(std::move(_data)) { name = _name; }
std::string toString(Dialect const* _dialect) const override;
bytes data; bytes data;
protected:
std::string toString(Dialect const* _dialect, std::optional<SourceNameMap> _sourceNames) const override;
}; };
struct ObjectDebugData
{
std::optional<SourceNameMap> sourceNames = {};
};
/** /**
* Yul code and data object container. * Yul code and data object container.
*/ */
struct Object: ObjectNode struct Object: public ObjectNode
{ {
public: public:
/// @returns a (parseable) string representation. Includes types if @a _yul is set. /// @returns a (parseable) string representation.
std::string toString(Dialect const* _dialect) const override; std::string toString(Dialect const* _dialect) const;
/// @returns the set of names of data objects accessible from within the code of /// @returns the set of names of data objects accessible from within the code of
/// this object, including the name of object itself /// this object, including the name of object itself
@ -94,8 +110,12 @@ public:
std::map<YulString, size_t> subIndexByName; std::map<YulString, size_t> subIndexByName;
std::shared_ptr<yul::AsmAnalysisInfo> analysisInfo; std::shared_ptr<yul::AsmAnalysisInfo> analysisInfo;
std::shared_ptr<ObjectDebugData const> debugData;
/// @returns the name of the special metadata data object. /// @returns the name of the special metadata data object.
static std::string metadataName() { return ".metadata"; } static std::string metadataName() { return ".metadata"; }
protected:
std::string toString(Dialect const* _dialect, std::optional<SourceNameMap> _sourceNames) const override;
}; };
} }

View File

@ -58,8 +58,9 @@ shared_ptr<Object> ObjectParser::parse(shared_ptr<Scanner> const& _scanner, bool
} }
else else
object = parseObject(); object = parseObject();
if (object && !_reuseScanner) if (!_reuseScanner)
expectToken(Token::EOS); expectToken(Token::EOS);
object->debugData = make_shared<ObjectDebugData>(ObjectDebugData{m_sourceNameMapping});
return object; return object;
} }
catch (FatalError const&) catch (FatalError const&)
@ -111,7 +112,7 @@ shared_ptr<Block> ObjectParser::parseCode()
return parseBlock(); return parseBlock();
} }
optional<ObjectParser::SourceNameMap> ObjectParser::tryParseSourceNameMapping() const optional<SourceNameMap> ObjectParser::tryParseSourceNameMapping() const
{ {
// @use-src 0:"abc.sol", 1:"foo.sol", 2:"bar.sol" // @use-src 0:"abc.sol", 1:"foo.sol", 2:"bar.sol"
// //

View File

@ -55,7 +55,6 @@ public:
/// @returns an empty shared pointer on error. /// @returns an empty shared pointer on error.
std::shared_ptr<Object> parse(std::shared_ptr<langutil::Scanner> const& _scanner, bool _reuseScanner); std::shared_ptr<Object> parse(std::shared_ptr<langutil::Scanner> const& _scanner, bool _reuseScanner);
using SourceNameMap = std::map<unsigned, std::shared_ptr<std::string const>>;
std::optional<SourceNameMap> const& sourceNameMapping() const noexcept { return m_sourceNameMapping; } std::optional<SourceNameMap> const& sourceNameMapping() const noexcept { return m_sourceNameMapping; }
private: private:

View File

@ -165,6 +165,7 @@ EOF
# Replace escaped newlines by actual newlines for readability # Replace escaped newlines by actual newlines for readability
# shellcheck disable=SC1003 # shellcheck disable=SC1003
sed -i.bak -E -e 's/\\n/\'$'\n/g' "$stdout_path" sed -i.bak -E -e 's/\\n/\'$'\n/g' "$stdout_path"
sed -i.bak -e 's/\(^[ ]*auxdata: \)0x[0-9a-f]*$/\1<AUXDATA REMOVED>/' "$stdout_path"
rm "$stdout_path.bak" rm "$stdout_path.bak"
else else
sed -i.bak -e '/^Warning: This is a pre-release compiler version, please do not use it in production./d' "$stderr_path" sed -i.bak -e '/^Warning: This is a pre-release compiler version, please do not use it in production./d' "$stderr_path"

View File

@ -6,12 +6,16 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"constant_optimizer_yul/input.sol", 1:"#utility.yul"
object "C_12" { object "C_12" {
code { code {
{ {
/// @src 0:61:418
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
/// @src 0:103:238
sstore(0, shl(180, 1)) sstore(0, shl(180, 1))
/// @src 0:61:418
let _1 := datasize("C_12_deployed") let _1 := datasize("C_12_deployed")
codecopy(128, dataoffset("C_12_deployed"), _1) codecopy(128, dataoffset("C_12_deployed"), _1)
return(128, _1) return(128, _1)
@ -20,9 +24,12 @@ object "C_12" {
object "C_12_deployed" { object "C_12_deployed" {
code { code {
{ {
/// @src 0:61:418
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
/// @src 0:279:410
sstore(0, 0x1000000000000000000000000000000000000000000000) sstore(0, 0x1000000000000000000000000000000000000000000000)
/// @src 0:61:418
stop() stop()
} }
} }

View File

@ -25,11 +25,13 @@ object "C_81" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:82:370
function constructor_C_81() { function constructor_C_81() {
/// @src 0:82:370 /// @src 0:82:370
} }
/// @src 0:82:370
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -212,8 +214,8 @@ object "C_81" {
converted := cleanup_t_int256(value) converted := cleanup_t_int256(value)
} }
/// @src 0:96:368
function fun_f_80(var_a_4, var_b_6, var_c_8, var_d_10) -> var__13, var__15, var__17, var__19 { function fun_f_80(var_a_4, var_b_6, var_c_8, var_d_10) -> var__13, var__15, var__17, var__19 {
/// @src 0:96:368
/// @src 0:160:164 /// @src 0:160:164
let zero_t_uint256_1 := zero_value_for_split_t_uint256() let zero_t_uint256_1 := zero_value_for_split_t_uint256()
var__13 := zero_t_uint256_1 var__13 := zero_t_uint256_1
@ -336,6 +338,7 @@ object "C_81" {
leave leave
} }
/// @src 0:82:370
function panic_error_0x11() { function panic_error_0x11() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856) mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)

View File

@ -6,9 +6,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"ir_compiler_inheritance_nosubobjects/input.sol", 1:"#utility.yul"
object "C_7" { object "C_7" {
code { code {
{ {
/// @src 0:82:117
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("C_7_deployed") let _1 := datasize("C_7_deployed")
@ -19,6 +21,7 @@ object "C_7" {
object "C_7_deployed" { object "C_7_deployed" {
code { code {
{ {
/// @src 0:82:117
mstore(64, 128) mstore(64, 128)
revert(0, 0) revert(0, 0)
} }
@ -35,9 +38,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"ir_compiler_inheritance_nosubobjects/input.sol", 1:"#utility.yul"
object "D_10" { object "D_10" {
code { code {
{ {
/// @src 0:118:137
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("D_10_deployed") let _1 := datasize("D_10_deployed")
@ -48,6 +53,7 @@ object "D_10" {
object "D_10_deployed" { object "D_10_deployed" {
code { code {
{ {
/// @src 0:118:137
mstore(64, 128) mstore(64, 128)
revert(0, 0) revert(0, 0)
} }

View File

@ -6,9 +6,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"ir_compiler_subobjects/input.sol", 1:"#utility.yul"
object "C_3" { object "C_3" {
code { code {
{ {
/// @src 0:82:95
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("C_3_deployed") let _1 := datasize("C_3_deployed")
@ -19,6 +21,7 @@ object "C_3" {
object "C_3_deployed" { object "C_3_deployed" {
code { code {
{ {
/// @src 0:82:95
mstore(64, 128) mstore(64, 128)
revert(0, 0) revert(0, 0)
} }
@ -35,9 +38,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"ir_compiler_subobjects/input.sol", 1:"#utility.yul"
object "D_16" { object "D_16" {
code { code {
{ {
/// @src 0:96:165
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("D_16_deployed") let _1 := datasize("D_16_deployed")
@ -48,6 +53,7 @@ object "D_16" {
object "D_16_deployed" { object "D_16_deployed" {
code { code {
{ {
/// @src 0:96:165
mstore(64, 128) mstore(64, 128)
if iszero(lt(calldatasize(), 4)) if iszero(lt(calldatasize(), 4))
{ {
@ -56,17 +62,22 @@ object "D_16" {
{ {
if callvalue() { revert(_1, _1) } if callvalue() { revert(_1, _1) }
if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) }
/// @src 0:149:156
let _2 := datasize("C_3") let _2 := datasize("C_3")
let _3 := add(128, _2) let _3 := add(/** @src 0:96:165 */ 128, /** @src 0:149:156 */ _2)
if or(gt(_3, 0xffffffffffffffff), lt(_3, 128)) if or(gt(_3, 0xffffffffffffffff), lt(_3, /** @src 0:96:165 */ 128))
/// @src 0:149:156
{ {
/// @src 0:96:165
mstore(_1, shl(224, 0x4e487b71)) mstore(_1, shl(224, 0x4e487b71))
mstore(4, 0x41) mstore(4, 0x41)
revert(_1, 0x24) revert(_1, 0x24)
} }
datacopy(128, dataoffset("C_3"), _2) /// @src 0:149:156
if iszero(create(_1, 128, _2)) datacopy(/** @src 0:96:165 */ 128, /** @src 0:149:156 */ dataoffset("C_3"), _2)
if iszero(create(/** @src 0:96:165 */ _1, 128, /** @src 0:149:156 */ _2))
{ {
/// @src 0:96:165
let pos := mload(64) let pos := mload(64)
returndatacopy(pos, _1, returndatasize()) returndatacopy(pos, _1, returndatasize())
revert(pos, returndatasize()) revert(pos, returndatasize())
@ -80,6 +91,7 @@ object "D_16" {
object "C_3" { object "C_3" {
code { code {
{ {
/// @src 0:82:95
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("C_3_deployed") let _1 := datasize("C_3_deployed")
@ -90,6 +102,7 @@ object "D_16" {
object "C_3_deployed" { object "C_3_deployed" {
code { code {
{ {
/// @src 0:82:95
mstore(64, 128) mstore(64, 128)
revert(0, 0) revert(0, 0)
} }

View File

@ -6,9 +6,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"ir_with_assembly_no_memoryguard_creation/input.sol", 1:"#utility.yul"
object "D_12" { object "D_12" {
code { code {
{ {
/// @src 0:82:161
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("D_12_deployed") let _1 := datasize("D_12_deployed")
@ -19,6 +21,7 @@ object "D_12" {
object "D_12_deployed" { object "D_12_deployed" {
code { code {
{ {
/// @src 0:82:161
mstore(64, 128) mstore(64, 128)
if iszero(lt(calldatasize(), 4)) if iszero(lt(calldatasize(), 4))
{ {

View File

@ -6,9 +6,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"ir_with_assembly_no_memoryguard_runtime/input.sol", 1:"#utility.yul"
object "D_8" { object "D_8" {
code { code {
{ {
/// @src 0:82:153
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("D_8_deployed") let _1 := datasize("D_8_deployed")
@ -19,6 +21,7 @@ object "D_8" {
object "D_8_deployed" { object "D_8_deployed" {
code { code {
{ {
/// @src 0:82:153
mstore(64, 128) mstore(64, 128)
if iszero(lt(calldatasize(), 4)) if iszero(lt(calldatasize(), 4))
{ {

View File

@ -6,13 +6,17 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"keccak_optimization_deploy_code/input.sol", 1:"#utility.yul"
object "C_12" { object "C_12" {
code { code {
{ {
/// @src 0:62:463
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
/// @src 0:103:275
mstore(0, 100) mstore(0, 100)
sstore(0, keccak256(0, 32)) sstore(0, keccak256(0, 32))
/// @src 0:62:463
let _1 := datasize("C_12_deployed") let _1 := datasize("C_12_deployed")
codecopy(128, dataoffset("C_12_deployed"), _1) codecopy(128, dataoffset("C_12_deployed"), _1)
return(128, _1) return(128, _1)
@ -21,10 +25,13 @@ object "C_12" {
object "C_12_deployed" { object "C_12_deployed" {
code { code {
{ {
/// @src 0:62:463
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
/// @src 0:317:454
mstore(0, 100) mstore(0, 100)
sstore(0, 17385872270140913825666367956517731270094621555228275961425792378517567244498) sstore(0, 17385872270140913825666367956517731270094621555228275961425792378517567244498)
/// @src 0:62:463
stop() stop()
} }
} }

View File

@ -6,9 +6,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"keccak_optimization_low_runs/input.sol", 1:"#utility.yul"
object "C_7" { object "C_7" {
code { code {
{ {
/// @src 0:62:285
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("C_7_deployed") let _1 := datasize("C_7_deployed")
@ -19,10 +21,13 @@ object "C_7" {
object "C_7_deployed" { object "C_7_deployed" {
code { code {
{ {
/// @src 0:62:285
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
/// @src 0:109:277
mstore(0, 100) mstore(0, 100)
sstore(0, keccak256(0, 32)) sstore(0, keccak256(0, 32))
/// @src 0:62:285
stop() stop()
} }
} }

View File

@ -6,9 +6,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"name_simplifier/input.sol", 1:"#utility.yul"
object "C_59" { object "C_59" {
code { code {
{ {
/// @src 0:346:625
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("C_59_deployed") let _1 := datasize("C_59_deployed")
@ -19,6 +21,7 @@ object "C_59" {
object "C_59_deployed" { object "C_59_deployed" {
code { code {
{ {
/// @src 0:346:625
mstore(64, 128) mstore(64, 128)
if iszero(lt(calldatasize(), 4)) if iszero(lt(calldatasize(), 4))
{ {
@ -90,14 +93,18 @@ object "C_59" {
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
mstore(64, newFreePtr) mstore(64, newFreePtr)
} }
/// @src 0:381:623
function fun_sumArray(var_s_mpos) -> var, var_mpos function fun_sumArray(var_s_mpos) -> var, var_mpos
{ {
/// @src 0:346:625
if iszero(mload(var_s_mpos)) { panic_error_0x32() } if iszero(mload(var_s_mpos)) { panic_error_0x32() }
sstore(0x00, mload(mload(add(var_s_mpos, 32)))) sstore(/** @src 0:472:473 */ 0x00, /** @src 0:346:625 */ mload(/** @src 0:469:474 */ mload(/** @src 0:346:625 */ add(var_s_mpos, 32))))
if iszero(lt(1, mload(var_s_mpos))) { panic_error_0x32() } if iszero(lt(1, mload(var_s_mpos))) { panic_error_0x32() }
let _1 := mload(mload(add(var_s_mpos, 64))) let _1 := mload(/** @src 0:489:494 */ mload(/** @src 0:346:625 */ add(var_s_mpos, 64)))
sstore(0x02, _1) sstore(0x02, _1)
/// @src 0:500:619
var := _1 var := _1
/// @src 0:346:625
let memPtr := mload(64) let memPtr := mload(64)
let newFreePtr := add(memPtr, 160) let newFreePtr := add(memPtr, 160)
if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() } if or(gt(newFreePtr, 0xffffffffffffffff), lt(newFreePtr, memPtr)) { panic_error_0x41() }
@ -107,8 +114,10 @@ object "C_59" {
mstore(add(memPtr, 64), "ngstringlongstringlongstringlong") mstore(add(memPtr, 64), "ngstringlongstringlongstringlong")
mstore(add(memPtr, 96), "stringlongstringlongstringlongst") mstore(add(memPtr, 96), "stringlongstringlongstringlongst")
mstore(add(memPtr, 128), "ring") mstore(add(memPtr, 128), "ring")
/// @src 0:500:619
var_mpos := memPtr var_mpos := memPtr
} }
/// @src 0:346:625
function panic_error_0x32() function panic_error_0x32()
{ {
mstore(0, shl(224, 0x4e487b71)) mstore(0, shl(224, 0x4e487b71))

View File

@ -6,9 +6,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"optimizer_array_sload/input.sol", 1:"#utility.yul"
object "Arraysum_34" { object "Arraysum_34" {
code { code {
{ {
/// @src 0:80:429
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("Arraysum_34_deployed") let _1 := datasize("Arraysum_34_deployed")
@ -19,6 +21,7 @@ object "Arraysum_34" {
object "Arraysum_34_deployed" { object "Arraysum_34_deployed" {
code { code {
{ {
/// @src 0:80:429
mstore(64, 128) mstore(64, 128)
if iszero(lt(calldatasize(), 4)) if iszero(lt(calldatasize(), 4))
{ {
@ -28,19 +31,27 @@ object "Arraysum_34" {
if callvalue() { revert(_1, _1) } if callvalue() { revert(_1, _1) }
if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) }
let var_sum := _1 let var_sum := _1
let var_i := _1 /// @src 0:368:378
let var_i := /** @src 0:80:429 */ _1
let _2 := sload(_1) let _2 := sload(_1)
/// @src 0:364:423
for { } for { }
lt(var_i, _2) /** @src 0:380:397 */ lt(var_i, _2)
/// @src 0:368:378
{ {
/// @src 0:80:429
if eq(var_i, not(0)) { panic_error_0x11() } if eq(var_i, not(0)) { panic_error_0x11() }
var_i := add(var_i, 1) /// @src 0:399:402
var_i := /** @src 0:80:429 */ add(var_i, 1)
} }
/// @src 0:399:402
{ {
/// @src 0:80:429
mstore(_1, _1) mstore(_1, _1)
let _3 := sload(add(18569430475105882587588266137607568536673111973893317399460219858819262702947, var_i)) let _3 := sload(add(18569430475105882587588266137607568536673111973893317399460219858819262702947, var_i))
if gt(var_sum, not(_3)) { panic_error_0x11() } if gt(var_sum, not(_3)) { panic_error_0x11() }
var_sum := add(var_sum, _3) /// @src 0:407:423
var_sum := /** @src 0:80:429 */ add(var_sum, _3)
} }
let memPos := mload(64) let memPos := mload(64)
return(memPos, sub(abi_encode_uint256(memPos, var_sum), memPos)) return(memPos, sub(abi_encode_uint256(memPos, var_sum), memPos))

View File

@ -25,11 +25,13 @@ object "C_15" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:59:147
function constructor_C_15() { function constructor_C_15() {
/// @src 0:59:147 /// @src 0:59:147
} }
/// @src 0:59:147
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
@ -217,10 +219,11 @@ object "C_15" {
mstore(64, newFreePtr) mstore(64, newFreePtr)
} }
/// @src 0:93:145
function fun_f_14(var__7_mpos, var_e_10) { function fun_f_14(var__7_mpos, var_e_10) {
/// @src 0:93:145
} }
/// @src 0:59:147
function panic_error_0x41() { function panic_error_0x41() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856) mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)

View File

@ -5,8 +5,10 @@
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"C_7\" { object \"C_7\" {
code { code {
/// @src 0:79:121
mstore(64, 128) mstore(64, 128)
if callvalue() if callvalue()
{ {
@ -25,6 +27,7 @@ object \"C_7\" {
} }
object \"C_7_deployed\" { object \"C_7_deployed\" {
code { code {
/// @src 0:79:121
mstore(64, 128) mstore(64, 128)
if iszero(lt(calldatasize(), 4)) if iszero(lt(calldatasize(), 4))
{ {
@ -56,8 +59,10 @@ object \"C_7\" {
{ tail := add(headStart, 0) } { tail := add(headStart, 0) }
function allocate_unbounded() -> memPtr function allocate_unbounded() -> memPtr
{ memPtr := mload(64) } { memPtr := mload(64) }
/// @src 0:92:119
function fun_f_6() function fun_f_6()
{ } { }
/// @src 0:79:121
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74()
{ revert(0, 0) } { revert(0, 0) }
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb()

View File

@ -24,11 +24,13 @@ object \"C_7\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:79:121
function constructor_C_7() { function constructor_C_7() {
/// @src 0:79:121 /// @src 0:79:121
} }
/// @src 0:79:121
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -76,10 +78,11 @@ object \"C_7\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:92:119
function fun_f_6() { function fun_f_6() {
/// @src 0:92:119
} }
/// @src 0:79:121
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() {
revert(0, 0) revert(0, 0)

View File

@ -24,11 +24,13 @@ object \"C_3\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:79:92
function constructor_C_3() { function constructor_C_3() {
/// @src 0:79:92 /// @src 0:79:92
} }
/// @src 0:79:92
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -98,11 +100,13 @@ object \"D_16\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:93:146
function constructor_D_16() { function constructor_D_16() {
/// @src 0:93:146 /// @src 0:93:146
} }
/// @src 0:93:146
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -150,8 +154,8 @@ object \"D_16\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:106:144
function fun_f_15() { function fun_f_15() {
/// @src 0:106:144
/// @src 0:134:141 /// @src 0:134:141
let _1 := allocate_unbounded() let _1 := allocate_unbounded()
@ -168,6 +172,7 @@ object \"D_16\" {
let var_c_8_address := expr_12_address let var_c_8_address := expr_12_address
} }
/// @src 0:93:146
function panic_error_0x41() { function panic_error_0x41() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856) mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
@ -226,11 +231,13 @@ object \"D_16\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:79:92
function constructor_C_3() { function constructor_C_3() {
/// @src 0:79:92 /// @src 0:79:92
} }
/// @src 0:79:92
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)

View File

@ -25,11 +25,13 @@ object "test_11" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:79:169
function constructor_test_11() { function constructor_test_11() {
/// @src 0:79:169 /// @src 0:79:169
} }
/// @src 0:79:169
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -87,8 +89,8 @@ object "test_11" {
cleaned := iszero(iszero(value)) cleaned := iszero(iszero(value))
} }
/// @src 0:99:167
function fun_f_10() -> var__5 { function fun_f_10() -> var__5 {
/// @src 0:99:167
/// @src 0:133:137 /// @src 0:133:137
let zero_t_bool_1 := zero_value_for_split_t_bool() let zero_t_bool_1 := zero_value_for_split_t_bool()
var__5 := zero_t_bool_1 var__5 := zero_t_bool_1
@ -100,6 +102,7 @@ object "test_11" {
leave leave
} }
/// @src 0:79:169
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() {
revert(0, 0) revert(0, 0)

View File

@ -12,9 +12,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"viair_subobjects/input.sol", 1:"#utility.yul"
object "C_3" { object "C_3" {
code { code {
{ {
/// @src 0:82:95
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("C_3_deployed") let _1 := datasize("C_3_deployed")
@ -25,6 +27,7 @@ object "C_3" {
object "C_3_deployed" { object "C_3_deployed" {
code { code {
{ {
/// @src 0:82:95
mstore(64, 128) mstore(64, 128)
revert(0, 0) revert(0, 0)
} }
@ -47,9 +50,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"viair_subobjects/input.sol", 1:"#utility.yul"
object "D_16" { object "D_16" {
code { code {
{ {
/// @src 0:96:165
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("D_16_deployed") let _1 := datasize("D_16_deployed")
@ -60,6 +65,7 @@ object "D_16" {
object "D_16_deployed" { object "D_16_deployed" {
code { code {
{ {
/// @src 0:96:165
mstore(64, 128) mstore(64, 128)
if iszero(lt(calldatasize(), 4)) if iszero(lt(calldatasize(), 4))
{ {
@ -68,17 +74,22 @@ object "D_16" {
{ {
if callvalue() { revert(_1, _1) } if callvalue() { revert(_1, _1) }
if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) } if slt(add(calldatasize(), not(3)), _1) { revert(_1, _1) }
/// @src 0:149:156
let _2 := datasize("C_3") let _2 := datasize("C_3")
let _3 := add(128, _2) let _3 := add(/** @src 0:96:165 */ 128, /** @src 0:149:156 */ _2)
if or(gt(_3, 0xffffffffffffffff), lt(_3, 128)) if or(gt(_3, 0xffffffffffffffff), lt(_3, /** @src 0:96:165 */ 128))
/// @src 0:149:156
{ {
/// @src 0:96:165
mstore(_1, shl(224, 0x4e487b71)) mstore(_1, shl(224, 0x4e487b71))
mstore(4, 0x41) mstore(4, 0x41)
revert(_1, 0x24) revert(_1, 0x24)
} }
datacopy(128, dataoffset("C_3"), _2) /// @src 0:149:156
if iszero(create(_1, 128, _2)) datacopy(/** @src 0:96:165 */ 128, /** @src 0:149:156 */ dataoffset("C_3"), _2)
if iszero(create(/** @src 0:96:165 */ _1, 128, /** @src 0:149:156 */ _2))
{ {
/// @src 0:96:165
let pos := mload(64) let pos := mload(64)
returndatacopy(pos, _1, returndatasize()) returndatacopy(pos, _1, returndatasize())
revert(pos, returndatasize()) revert(pos, returndatasize())
@ -92,6 +103,7 @@ object "D_16" {
object "C_3" { object "C_3" {
code { code {
{ {
/// @src 0:82:95
mstore(64, 128) mstore(64, 128)
if callvalue() { revert(0, 0) } if callvalue() { revert(0, 0) }
let _1 := datasize("C_3_deployed") let _1 := datasize("C_3_deployed")
@ -102,6 +114,7 @@ object "D_16" {
object "C_3_deployed" { object "C_3_deployed" {
code { code {
{ {
/// @src 0:82:95
mstore(64, 128) mstore(64, 128)
revert(0, 0) revert(0, 0)
} }

View File

@ -6,9 +6,11 @@ Optimized IR:
* !USE AT YOUR OWN RISK! * * !USE AT YOUR OWN RISK! *
*=====================================================*/ *=====================================================*/
/// @use-src 0:"yul_optimizer_steps/input.sol", 1:"#utility.yul"
object "C_7" { object "C_7" {
code { code {
{ {
/// @src 0:80:112
mstore(64, 128) mstore(64, 128)
if callvalue() if callvalue()
{ {
@ -26,6 +28,7 @@ object "C_7" {
object "C_7_deployed" { object "C_7_deployed" {
code { code {
{ {
/// @src 0:80:112
mstore(64, 128) mstore(64, 128)
if iszero(lt(calldatasize(), 4)) if iszero(lt(calldatasize(), 4))
{ {

View File

@ -53,6 +53,7 @@ object \"C_54\" {
cleaned := value cleaned := value
} }
/// @src 0:175:223
function constructor_C_54(var__init_12) { function constructor_C_54(var__init_12) {
/// @src 0:175:223 /// @src 0:175:223
@ -70,6 +71,7 @@ object \"C_54\" {
let expr_17 := expr_16 let expr_17 := expr_16
} }
/// @src 0:79:428
function convert_t_int256_to_t_int256(value) -> converted { function convert_t_int256_to_t_int256(value) -> converted {
converted := cleanup_t_int256(value) converted := cleanup_t_int256(value)
@ -303,17 +305,18 @@ object \"C_54\" {
mstore(64, newFreePtr) mstore(64, newFreePtr)
} }
/// @src 0:343:426
function fun_f2_53() -> var__42 { function fun_f2_53() -> var__42 {
/// @src 0:343:426
/// @src 0:375:378 /// @src 0:375:378
let zero_t_int256_4 := zero_value_for_split_t_int256() let zero_t_int256_4 := zero_value_for_split_t_int256()
var__42 := zero_t_int256_4 var__42 := zero_t_int256_4
var__42 := modifier_m_40(var__42) var__42 := modifier_m_40(var__42)
} }
/// @src 0:79:428
/// @src 0:343:426
function fun_f2_53_inner(_8) -> var__42 { function fun_f2_53_inner(_8) -> var__42 {
/// @src 0:343:426
var__42 := _8 var__42 := _8
/// @src 0:392:400 /// @src 0:392:400
@ -359,9 +362,10 @@ object \"C_54\" {
leave leave
} }
/// @src 0:79:428
/// @src 0:226:302
function fun_f_30() -> var__23 { function fun_f_30() -> var__23 {
/// @src 0:226:302
/// @src 0:262:265 /// @src 0:262:265
let zero_t_int256_1 := zero_value_for_split_t_int256() let zero_t_int256_1 := zero_value_for_split_t_int256()
var__23 := zero_t_int256_1 var__23 := zero_t_int256_1
@ -379,9 +383,10 @@ object \"C_54\" {
leave leave
} }
/// @src 0:79:428
/// @src 0:152:171
function getter_fun_stateVar_10() -> ret { function getter_fun_stateVar_10() -> ret {
/// @src 0:152:171
let slot := 0 let slot := 0
let offset := 0 let offset := 0
@ -389,6 +394,7 @@ object \"C_54\" {
ret := read_from_storage_split_dynamic_t_int256(slot, offset) ret := read_from_storage_split_dynamic_t_int256(slot, offset)
} }
/// @src 0:79:428
function increment_t_int256(value) -> ret { function increment_t_int256(value) -> ret {
value := cleanup_t_int256(value) value := cleanup_t_int256(value)
@ -396,8 +402,8 @@ object \"C_54\" {
ret := add(value, 1) ret := add(value, 1)
} }
/// @src 0:304:341
function modifier_m_40(var__42) -> _5 { function modifier_m_40(var__42) -> _5 {
/// @src 0:304:341
_5 := var__42 _5 := var__42
/// @src 0:322:332 /// @src 0:322:332
@ -409,6 +415,7 @@ object \"C_54\" {
_5 := fun_f2_53_inner(var__42) _5 := fun_f2_53_inner(var__42)
} }
/// @src 0:79:428
function panic_error_0x11() { function panic_error_0x11() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856) mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)
@ -599,6 +606,7 @@ object \"D_72\" {
cleaned := value cleaned := value
} }
/// @src 0:175:223
function constructor_C_54(var__init_12) { function constructor_C_54(var__init_12) {
/// @src 0:175:223 /// @src 0:175:223
@ -616,7 +624,9 @@ object \"D_72\" {
let expr_17 := expr_16 let expr_17 := expr_16
} }
/// @src 1:91:166
/// @src 1:113:164
function constructor_D_72(var__init2_63) { function constructor_D_72(var__init2_63) {
/// @src 1:107:108 /// @src 1:107:108
let expr_60 := 0x03 let expr_60 := 0x03
@ -635,6 +645,7 @@ object \"D_72\" {
update_storage_value_offset_0t_int256_to_t_int256(0x00, expr_68) update_storage_value_offset_0t_int256_to_t_int256(0x00, expr_68)
} }
/// @src 1:91:166
function convert_t_int256_to_t_int256(value) -> converted { function convert_t_int256_to_t_int256(value) -> converted {
converted := cleanup_t_int256(value) converted := cleanup_t_int256(value)
@ -894,17 +905,18 @@ object \"D_72\" {
mstore(64, newFreePtr) mstore(64, newFreePtr)
} }
/// @src 0:343:426
function fun_f2_53() -> var__42 { function fun_f2_53() -> var__42 {
/// @src 0:343:426
/// @src 0:375:378 /// @src 0:375:378
let zero_t_int256_4 := zero_value_for_split_t_int256() let zero_t_int256_4 := zero_value_for_split_t_int256()
var__42 := zero_t_int256_4 var__42 := zero_t_int256_4
var__42 := modifier_m_40(var__42) var__42 := modifier_m_40(var__42)
} }
/// @src 1:91:166
/// @src 0:343:426
function fun_f2_53_inner(_8) -> var__42 { function fun_f2_53_inner(_8) -> var__42 {
/// @src 0:343:426
var__42 := _8 var__42 := _8
/// @src 0:392:400 /// @src 0:392:400
@ -950,9 +962,10 @@ object \"D_72\" {
leave leave
} }
/// @src 1:91:166
/// @src 0:226:302
function fun_f_30() -> var__23 { function fun_f_30() -> var__23 {
/// @src 0:226:302
/// @src 0:262:265 /// @src 0:262:265
let zero_t_int256_1 := zero_value_for_split_t_int256() let zero_t_int256_1 := zero_value_for_split_t_int256()
var__23 := zero_t_int256_1 var__23 := zero_t_int256_1
@ -970,9 +983,10 @@ object \"D_72\" {
leave leave
} }
/// @src 1:91:166
/// @src 0:152:171
function getter_fun_stateVar_10() -> ret { function getter_fun_stateVar_10() -> ret {
/// @src 0:152:171
let slot := 0 let slot := 0
let offset := 0 let offset := 0
@ -980,6 +994,7 @@ object \"D_72\" {
ret := read_from_storage_split_dynamic_t_int256(slot, offset) ret := read_from_storage_split_dynamic_t_int256(slot, offset)
} }
/// @src 1:91:166
function increment_t_int256(value) -> ret { function increment_t_int256(value) -> ret {
value := cleanup_t_int256(value) value := cleanup_t_int256(value)
@ -987,8 +1002,8 @@ object \"D_72\" {
ret := add(value, 1) ret := add(value, 1)
} }
/// @src 0:304:341
function modifier_m_40(var__42) -> _5 { function modifier_m_40(var__42) -> _5 {
/// @src 0:304:341
_5 := var__42 _5 := var__42
/// @src 0:322:332 /// @src 0:322:332
@ -1000,6 +1015,7 @@ object \"D_72\" {
_5 := fun_f2_53_inner(var__42) _5 := fun_f2_53_inner(var__42)
} }
/// @src 1:91:166
function panic_error_0x11() { function panic_error_0x11() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856) mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)

View File

@ -0,0 +1,24 @@
{
"language": "Solidity",
"sources":
{
"C":
{
"content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\n\ncontract C\n{\n int constant constVar = 41;\n int immutable immutVar = 42;\n int public stateVar;\n\n constructor(int _init)\n {\n stateVar = _init;\n }\n\n function f() external pure returns (int)\n {\n return constVar + immutVar;\n }\n modifier m()\n {\n stateVar++;\n _;\n }\n function f2() m public returns (int)\n {\n return stateVar + this.f() + immutVar;\n }\n}\n"
},
"D":
{
"content": "//SPDX-License-Identifier: GPL-2.0\npragma solidity >=0.0;\npragma abicoder v2;\nimport \"C\";\n\ncontract D is C(3)\n{\n constructor(int _init2)\n {\n stateVar += _init2;\n }\n}\n"
}
},
"settings":
{
"viaIR": true,
"optimizer": { "enabled": true },
"outputSelection":
{
"*": { "*": ["evm.assembly"] }
}
}
}

View File

@ -0,0 +1,888 @@
{"contracts":{"C":{"C":{"evm":{"assembly":" /* \"C\":79:428 contract C... */
mstore(0x40, 0xa0)
jumpi(tag_1, iszero(callvalue))
0x00
dup1
revert
tag_1:
bytecodeSize
codesize
dup2
swap1
sub
0xa0
0x1f
dup3
add
not(0x1f)
and
dup2
add
swap1
sub(shl(0x40, 0x01), 0x01)
dup3
gt
swap1
dup3
lt
or
iszero
tag_2
jumpi
mstore(0x00, shl(0xe0, 0x4e487b71))
mstore(0x04, 0x41)
revert(0x00, 0x24)
tag_2:
0x40
mstore
dup1
dup3
0xa0
codecopy
0x20
dup2
slt
iszero
tag_3
jumpi
0x00
dup1
revert
tag_3:
pop
pop
tag_4
mload(0xa0)
/* \"C\":147:149 42 */
mstore(0x80, 0x2a)
0x00
/* \"C\":79:428 contract C... */
sstore
/* \"C\":175:223 constructor(int _init)... */
jump
/* \"C\":79:428 contract C... */
tag_4:
mload(0x40)
dataSize(sub_0)
dup1
dataOffset(sub_0)
dup4
codecopy
mload(0x80)
dup3
assignImmutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\")
dup1
dup3
return
stop
sub_0: assembly {
/* \"C\":79:428 contract C... */
mstore(0x40, 0x80)
jumpi(tag_1, lt(calldatasize, 0x04))
0x00
dup1
calldataload
0xe0
shr
0x26121ff0
dup2
eq
tag_3
jumpi
0x793816ec
dup2
eq
tag_4
jumpi
0x9942ec6f
dup2
eq
tag_5
jumpi
jump(tag_2)
tag_3:
jumpi(tag_6, iszero(callvalue))
dup2
dup3
revert
tag_6:
tag_7
calldatasize
tag_8
jump\t// in
tag_7:
/* \"C\":279:298 constVar + immutVar */
tag_9
/* \"C\":290:298 immutVar */
immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\")
/* \"C\":279:298 constVar + immutVar */
tag_10
jump\t// in
tag_9:
/* \"C\":79:428 contract C... */
mload(0x40)
dup2
dup2
mstore
0x20
dup2
return
tag_4:
jumpi(tag_13, iszero(callvalue))
dup2
dup3
revert
tag_13:
tag_14
calldatasize
tag_8
jump\t// in
tag_14:
dup2
sload
mload(0x40)
dup2
dup2
mstore
0x20
dup2
return
tag_5:
jumpi(tag_16, iszero(callvalue))
dup2
dup3
revert
tag_16:
tag_17
calldatasize
tag_8
jump\t// in
tag_17:
/* \"C\":375:378 int */
tag_9
tag_19
jump\t// in
/* \"C\":79:428 contract C... */
tag_2:
pop
pop
tag_1:
0x00
dup1
revert
tag_8:
0x00
not(0x03)
dup3
add
slt
iszero
tag_23
jumpi
0x00
dup1
revert
tag_23:
pop
jump\t// out
tag_24:
0x00
0x20
dup3
dup5
sub
slt
iszero
tag_26
jumpi
0x00
dup1
revert
tag_26:
pop
mload
swap2
swap1
pop
jump\t// out
tag_10:
0x00
sub(shl(0xff, 0x01), 0x2a)
dup3
sgt
0x01
and
iszero
tag_30
jumpi
tag_30
tag_31
jump\t// in
tag_30:
pop
/* \"C\":117:119 41 */
0x29
/* \"C\":79:428 contract C... */
add
swap1
jump\t// out
tag_32:
0x00
dup1
dup3
slt
dup1
iszero
sub(shl(0xff, 0x01), 0x01)
dup5
swap1
sub
dup6
sgt
and
iszero
tag_35
jumpi
tag_35
tag_31
jump\t// in
tag_35:
shl(0xff, 0x01)
dup4
swap1
sub
dup5
slt
dup2
and
iszero
tag_37
jumpi
tag_37
tag_31
jump\t// in
tag_37:
pop
pop
add
swap1
jump\t// out
/* \"C\":304:341 modifier m()... */
tag_19:
0x00
/* \"C\":79:428 contract C... */
dup1
sload
/* \"C\":304:341 modifier m()... */
dup2
swap1
sub(shl(0xff, 0x01), 0x01)
/* \"C\":79:428 contract C... */
dup2
eq
iszero
tag_40
jumpi
tag_40
tag_31
jump\t// in
tag_40:
0x01
add
dup1
dup3
sstore
/* \"C\":403:407 this */
address
/* \"C\":403:411 this.f() */
extcodesize
tag_41
jumpi
/* \"C\":79:428 contract C... */
dup2
dup3
revert
/* \"C\":403:411 this.f() */
tag_41:
/* \"C\":79:428 contract C... */
mload(0x40)
shl(0xe4, 0x026121ff)
/* \"C\":403:411 this.f() */
dup2
mstore
0x20
/* \"C\":79:428 contract C... */
dup2
/* \"C\":403:411 this.f() */
0x04
/* \"C\":79:428 contract C... */
dup2
/* \"C\":403:407 this */
address
/* \"C\":403:411 this.f() */
gas
staticcall
dup1
tag_42
jumpi
/* \"C\":79:428 contract C... */
mload(0x40)
returndatasize
dup6
dup3
returndatacopy
returndatasize
dup2
revert
/* \"C\":403:411 this.f() */
tag_42:
/* \"C\":79:428 contract C... */
dup4
/* \"C\":403:411 this.f() */
dup2
iszero
tag_43
jumpi
returndatasize
/* \"C\":79:428 contract C... */
0x1f
add
not(0x1f)
and
/* \"C\":117:119 41 */
dup4
add
0xffffffffffffffff
dup2
gt
dup5
dup3
lt
or
iszero
tag_44
jumpi
shl(0xe0, 0x4e487b71)
/* \"C\":79:428 contract C... */
dup7
mstore
0x41
/* \"C\":403:411 this.f() */
0x04
/* \"C\":79:428 contract C... */
mstore
0x24
dup7
revert
/* \"C\":117:119 41 */
tag_44:
/* \"C\":79:428 contract C... */
0x40
/* \"C\":117:119 41 */
mstore
/* \"C\":403:411 this.f() */
tag_45
returndatasize
dup5
add
dup5
tag_24
jump\t// in
tag_45:
swap1
pop
tag_43:
/* \"C\":392:411 stateVar + this.f() */
tag_46
dup2
dup6
tag_32
jump\t// in
tag_46:
swap5
pop
pop
pop
pop
pop
/* \"C\":392:422 stateVar + this.f() + immutVar */
tag_47
/* \"C\":414:422 immutVar */
immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\")
/* \"C\":392:422 stateVar + this.f() + immutVar */
dup3
tag_32
jump\t// in
tag_47:
/* \"C\":336:337 _ */
swap2
pop
pop
/* \"C\":304:341 modifier m()... */
swap1
jump\t// out
/* \"C\":79:428 contract C... */
tag_31:
mstore(0x00, shl(0xe0, 0x4e487b71))
mstore(0x04, 0x11)
revert(0x00, 0x24)
auxdata: <AUXDATA REMOVED>
}
"}}},"D":{"D":{"evm":{"assembly":" /* \"D\":91:166 contract D is C(3)... */
mstore(0x40, 0xa0)
jumpi(tag_1, iszero(callvalue))
0x00
dup1
revert
tag_1:
bytecodeSize
codesize
dup2
swap1
sub
0xa0
0x1f
dup3
add
not(0x1f)
and
dup2
add
swap1
sub(shl(0x40, 0x01), 0x01)
dup3
gt
swap1
dup3
lt
or
iszero
tag_2
jumpi
mstore(0x00, shl(0xe0, 0x4e487b71))
mstore(0x04, 0x41)
revert(0x00, 0x24)
tag_2:
0x40
mstore
dup1
dup3
0xa0
codecopy
0x20
dup2
slt
iszero
tag_3
jumpi
0x00
dup1
revert
tag_3:
pop
pop
tag_4
mload(0xa0)
tag_5
jump\t// in
tag_4:
mload(0x40)
dataSize(sub_0)
dup1
dataOffset(sub_0)
dup4
codecopy
mload(0x80)
dup3
assignImmutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\")
dup1
dup3
return
/* \"D\":113:164 constructor(int _init2)... */
tag_5:
/* \"C\":147:149 42 */
mstore(0x80, 0x2a)
/* \"D\":107:108 3 */
0x03
0x00
/* \"D\":91:166 contract D is C(3)... */
sstore
sub(shl(0xff, 0x01), 0x04)
dup2
sgt
0x01
and
iszero
tag_8
jumpi
mstore(0x00, shl(0xe0, 0x4e487b71))
mstore(0x04, 0x11)
revert(0x00, 0x24)
tag_8:
/* \"D\":107:108 3 */
0x03
/* \"D\":91:166 contract D is C(3)... */
add
0x00
sstore
/* \"D\":113:164 constructor(int _init2)... */
jump\t// out
stop
sub_0: assembly {
/* \"D\":91:166 contract D is C(3)... */
mstore(0x40, 0x80)
jumpi(tag_1, lt(calldatasize, 0x04))
0x00
dup1
calldataload
0xe0
shr
0x26121ff0
dup2
eq
tag_3
jumpi
0x793816ec
dup2
eq
tag_4
jumpi
0x9942ec6f
dup2
eq
tag_5
jumpi
jump(tag_2)
tag_3:
jumpi(tag_6, iszero(callvalue))
dup2
dup3
revert
tag_6:
tag_7
calldatasize
tag_8
jump\t// in
tag_7:
/* \"C\":279:298 constVar + immutVar */
tag_9
/* \"C\":290:298 immutVar */
immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\")
/* \"C\":279:298 constVar + immutVar */
tag_10
jump\t// in
tag_9:
/* \"D\":91:166 contract D is C(3)... */
mload(0x40)
dup2
dup2
mstore
0x20
dup2
return
tag_4:
jumpi(tag_13, iszero(callvalue))
dup2
dup3
revert
tag_13:
tag_14
calldatasize
tag_8
jump\t// in
tag_14:
dup2
sload
mload(0x40)
dup2
dup2
mstore
0x20
dup2
return
tag_5:
jumpi(tag_16, iszero(callvalue))
dup2
dup3
revert
tag_16:
tag_17
calldatasize
tag_8
jump\t// in
tag_17:
/* \"C\":375:378 int */
tag_9
tag_19
jump\t// in
/* \"D\":91:166 contract D is C(3)... */
tag_2:
pop
pop
tag_1:
0x00
dup1
revert
tag_8:
0x00
not(0x03)
dup3
add
slt
iszero
tag_23
jumpi
0x00
dup1
revert
tag_23:
pop
jump\t// out
tag_24:
0x00
0x20
dup3
dup5
sub
slt
iszero
tag_26
jumpi
0x00
dup1
revert
tag_26:
pop
mload
swap2
swap1
pop
jump\t// out
tag_10:
0x00
sub(shl(0xff, 0x01), 0x2a)
dup3
sgt
0x01
and
iszero
tag_30
jumpi
tag_30
tag_31
jump\t// in
tag_30:
pop
/* \"C\":117:119 41 */
0x29
/* \"D\":91:166 contract D is C(3)... */
add
swap1
jump\t// out
tag_32:
0x00
dup1
dup3
slt
dup1
iszero
sub(shl(0xff, 0x01), 0x01)
dup5
swap1
sub
dup6
sgt
and
iszero
tag_35
jumpi
tag_35
tag_31
jump\t// in
tag_35:
shl(0xff, 0x01)
dup4
swap1
sub
dup5
slt
dup2
and
iszero
tag_37
jumpi
tag_37
tag_31
jump\t// in
tag_37:
pop
pop
add
swap1
jump\t// out
/* \"C\":304:341 modifier m()... */
tag_19:
0x00
/* \"D\":91:166 contract D is C(3)... */
dup1
sload
/* \"C\":304:341 modifier m()... */
dup2
swap1
sub(shl(0xff, 0x01), 0x01)
/* \"D\":91:166 contract D is C(3)... */
dup2
eq
iszero
tag_40
jumpi
tag_40
tag_31
jump\t// in
tag_40:
0x01
add
dup1
dup3
sstore
/* \"C\":403:407 this */
address
/* \"C\":403:411 this.f() */
extcodesize
tag_41
jumpi
/* \"D\":91:166 contract D is C(3)... */
dup2
dup3
revert
/* \"C\":403:411 this.f() */
tag_41:
/* \"D\":91:166 contract D is C(3)... */
mload(0x40)
shl(0xe4, 0x026121ff)
/* \"C\":403:411 this.f() */
dup2
mstore
0x20
/* \"D\":91:166 contract D is C(3)... */
dup2
/* \"C\":403:411 this.f() */
0x04
/* \"D\":91:166 contract D is C(3)... */
dup2
/* \"C\":403:407 this */
address
/* \"C\":403:411 this.f() */
gas
staticcall
dup1
tag_42
jumpi
/* \"D\":91:166 contract D is C(3)... */
mload(0x40)
returndatasize
dup6
dup3
returndatacopy
returndatasize
dup2
revert
/* \"C\":403:411 this.f() */
tag_42:
/* \"D\":91:166 contract D is C(3)... */
dup4
/* \"C\":403:411 this.f() */
dup2
iszero
tag_43
jumpi
returndatasize
/* \"D\":91:166 contract D is C(3)... */
0x1f
add
not(0x1f)
and
/* \"C\":117:119 41 */
dup4
add
0xffffffffffffffff
dup2
gt
dup5
dup3
lt
or
iszero
tag_44
jumpi
shl(0xe0, 0x4e487b71)
/* \"D\":91:166 contract D is C(3)... */
dup7
mstore
0x41
/* \"C\":403:411 this.f() */
0x04
/* \"D\":91:166 contract D is C(3)... */
mstore
0x24
dup7
revert
/* \"C\":117:119 41 */
tag_44:
/* \"D\":91:166 contract D is C(3)... */
0x40
/* \"C\":117:119 41 */
mstore
/* \"C\":403:411 this.f() */
tag_45
returndatasize
dup5
add
dup5
tag_24
jump\t// in
tag_45:
swap1
pop
tag_43:
/* \"C\":392:411 stateVar + this.f() */
tag_46
dup2
dup6
tag_32
jump\t// in
tag_46:
swap5
pop
pop
pop
pop
pop
/* \"C\":392:422 stateVar + this.f() + immutVar */
tag_47
/* \"C\":414:422 immutVar */
immutable(\"0xe4b1702d9298fee62dfeccc57d322a463ad55ca201256d01f62b45b2e1c21c10\")
/* \"C\":392:422 stateVar + this.f() + immutVar */
dup3
tag_32
jump\t// in
tag_47:
/* \"C\":336:337 _ */
swap2
pop
pop
/* \"C\":304:341 modifier m()... */
swap1
jump\t// out
/* \"D\":91:166 contract D is C(3)... */
tag_31:
mstore(0x00, shl(0xe0, 0x4e487b71))
mstore(0x04, 0x11)
revert(0x00, 0x24)
auxdata: <AUXDATA REMOVED>
}
"}}}},"sources":{"C":{"id":0},"D":{"id":1}}}

View File

@ -24,11 +24,13 @@ object \"C_11\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:78:164
function constructor_C_11() { function constructor_C_11() {
/// @src 0:78:164 /// @src 0:78:164
} }
/// @src 0:78:164
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -150,8 +152,8 @@ object \"C_11\" {
mstore(64, newFreePtr) mstore(64, newFreePtr)
} }
/// @src 0:91:162
function fun_f_10() -> var__5_mpos { function fun_f_10() -> var__5_mpos {
/// @src 0:91:162
/// @src 0:127:140 /// @src 0:127:140
let zero_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr() let zero_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr()
var__5_mpos := zero_t_string_memory_ptr_1_mpos var__5_mpos := zero_t_string_memory_ptr_1_mpos
@ -161,6 +163,7 @@ object \"C_11\" {
leave leave
} }
/// @src 0:78:164
function panic_error_0x41() { function panic_error_0x41() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856) mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)

View File

@ -24,11 +24,13 @@ object \"C_11\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:78:158
function constructor_C_11() { function constructor_C_11() {
/// @src 0:78:158 /// @src 0:78:158
} }
/// @src 0:78:158
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -90,8 +92,8 @@ object \"C_11\" {
converted := 0x6162636162630000000000000000000000000000000000000000000000000000 converted := 0x6162636162630000000000000000000000000000000000000000000000000000
} }
/// @src 0:91:156
function fun_f_10() -> var__5 { function fun_f_10() -> var__5 {
/// @src 0:91:156
/// @src 0:127:134 /// @src 0:127:134
let zero_t_bytes32_1 := zero_value_for_split_t_bytes32() let zero_t_bytes32_1 := zero_value_for_split_t_bytes32()
var__5 := zero_t_bytes32_1 var__5 := zero_t_bytes32_1
@ -101,6 +103,7 @@ object \"C_11\" {
leave leave
} }
/// @src 0:78:158
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() {
revert(0, 0) revert(0, 0)

View File

@ -24,11 +24,13 @@ object \"C_11\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:78:159
function constructor_C_11() { function constructor_C_11() {
/// @src 0:78:159 /// @src 0:78:159
} }
/// @src 0:78:159
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -94,8 +96,8 @@ object \"C_11\" {
converted := shift_left_224(cleanup_t_rational_1633837924_by_1(value)) converted := shift_left_224(cleanup_t_rational_1633837924_by_1(value))
} }
/// @src 0:91:157
function fun_f_10() -> var__5 { function fun_f_10() -> var__5 {
/// @src 0:91:157
/// @src 0:127:133 /// @src 0:127:133
let zero_t_bytes4_1 := zero_value_for_split_t_bytes4() let zero_t_bytes4_1 := zero_value_for_split_t_bytes4()
var__5 := zero_t_bytes4_1 var__5 := zero_t_bytes4_1
@ -107,6 +109,7 @@ object \"C_11\" {
leave leave
} }
/// @src 0:78:159
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() {
revert(0, 0) revert(0, 0)

View File

@ -24,11 +24,13 @@ object \"C_11\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:78:243
function constructor_C_11() { function constructor_C_11() {
/// @src 0:78:243 /// @src 0:78:243
} }
/// @src 0:78:243
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -150,8 +152,8 @@ object \"C_11\" {
mstore(64, newFreePtr) mstore(64, newFreePtr)
} }
/// @src 0:91:241
function fun_f_10() -> var__5_mpos { function fun_f_10() -> var__5_mpos {
/// @src 0:91:241
/// @src 0:127:140 /// @src 0:127:140
let zero_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr() let zero_t_string_memory_ptr_1_mpos := zero_value_for_split_t_string_memory_ptr()
var__5_mpos := zero_t_string_memory_ptr_1_mpos var__5_mpos := zero_t_string_memory_ptr_1_mpos
@ -161,6 +163,7 @@ object \"C_11\" {
leave leave
} }
/// @src 0:78:243
function panic_error_0x41() { function panic_error_0x41() {
mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856) mstore(0, 35408467139433450592217433187231851964531694900788300625387963629091585785856)

View File

@ -24,11 +24,13 @@ object \"C_11\" {
memPtr := mload(64) memPtr := mload(64)
} }
/// @src 0:78:159
function constructor_C_11() { function constructor_C_11() {
/// @src 0:78:159 /// @src 0:78:159
} }
/// @src 0:78:159
function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() { function revert_error_ca66f745a3ce8ff40e2ccaf1ad45db7774001b90d25810abd9040049be7bf4bb() {
revert(0, 0) revert(0, 0)
@ -94,8 +96,8 @@ object \"C_11\" {
converted := shift_left_224(cleanup_t_rational_2864434397_by_1(value)) converted := shift_left_224(cleanup_t_rational_2864434397_by_1(value))
} }
/// @src 0:91:157
function fun_f_10() -> var__5 { function fun_f_10() -> var__5 {
/// @src 0:91:157
/// @src 0:127:133 /// @src 0:127:133
let zero_t_bytes4_1 := zero_value_for_split_t_bytes4() let zero_t_bytes4_1 := zero_value_for_split_t_bytes4()
var__5 := zero_t_bytes4_1 var__5 := zero_t_bytes4_1
@ -107,6 +109,7 @@ object \"C_11\" {
leave leave
} }
/// @src 0:78:159
function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() { function revert_error_42b3090547df1d2001c96683413b8cf91c1b902ef5e3cb8d9f6f304cf7446f74() {
revert(0, 0) revert(0, 0)

View File

@ -108,7 +108,7 @@ Error expectError(string const& _source, bool _allowWarnings = false)
return *error; return *error;
} }
tuple<optional<ObjectParser::SourceNameMap>, ErrorList> tryGetSourceLocationMapping(string _source) tuple<optional<SourceNameMap>, ErrorList> tryGetSourceLocationMapping(string _source)
{ {
vector<string> lines; vector<string> lines;
boost::split(lines, _source, boost::is_any_of("\n")); boost::split(lines, _source, boost::is_any_of("\n"));