Add "@use-src" header for generated yul code

This commit is contained in:
Mathias Baumann 2021-07-13 18:38:34 +02:00 committed by Marenz
parent 57db4c82ba
commit bf204403d8
12 changed files with 28 additions and 5 deletions

View File

@ -33,15 +33,13 @@
#include <libyul/AssemblyStack.h>
#include <libyul/Utilities.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/Whiskers.h>
#include <libsolutil/StringUtils.h>
#include <libsolutil/Algorithms.h>
#include <libsolutil/CommonData.h>
#include <libsolutil/StringUtils.h>
#include <libsolutil/Whiskers.h>
#include <liblangutil/SourceReferenceFormatter.h>
#include <range/v3/view/map.hpp>
#include <sstream>
#include <variant>
@ -135,6 +133,7 @@ string IRGenerator::generate(
};
Whiskers t(R"(
/// @use-src <useSrcMap>
object "<CreationObject>" {
code {
<sourceLocationComment>
@ -169,6 +168,16 @@ string IRGenerator::generate(
for (VariableDeclaration const* var: ContractType(_contract).immutableVariables())
m_context.registerImmutableVariable(*var);
auto invertedSourceIndicies = invertMap(m_context.sourceIndices());
string useSrcMap = joinHumanReadable(
ranges::views::transform(invertedSourceIndicies, [](auto&& _pair) {
return to_string(_pair.first) + ":" + escapeAndQuoteString(_pair.second);
}),
", "
);
t("useSrcMap", useSrcMap);
t("sourceLocationComment", sourceLocationComment(_contract, m_context));
t("CreationObject", IRNames::creationObject(_contract));

View File

@ -7,6 +7,7 @@ IR:
*=====================================================*/
/// @use-src 0:"exp_base_literal/input.sol", 1:"#utility.yul"
object "C_81" {
code {
/// @src 0:82:370

View File

@ -7,6 +7,7 @@ IR:
*=====================================================*/
/// @use-src 0:"revert_strings/input.sol", 1:"#utility.yul"
object "C_15" {
code {
/// @src 0:59:147

View File

@ -6,6 +6,7 @@
*=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"C_7\" {
code {
/// @src 0:79:121

View File

@ -6,6 +6,7 @@
*=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"C_3\" {
code {
/// @src 0:79:92
@ -79,6 +80,7 @@ object \"C_3\" {
*=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"D_16\" {
code {
/// @src 0:93:146
@ -206,6 +208,7 @@ object \"D_16\" {
* !USE AT YOUR OWN RISK! *
*=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"C_3\" {
code {
/// @src 0:79:92

View File

@ -7,6 +7,7 @@ IR:
*=====================================================*/
/// @use-src 0:"viair_abicoder_v1/input.sol", 1:"#utility.yul"
object "test_11" {
code {
/// @src 0:79:169

View File

@ -6,6 +6,7 @@
*=====================================================*/
/// @use-src 0:\"C\", 1:\"D\", 2:\"#utility.yul\"
object \"C_54\" {
code {
/// @src 0:79:428
@ -535,6 +536,7 @@ object \"C_54\" {
*=====================================================*/
/// @use-src 0:\"C\", 1:\"D\", 2:\"#utility.yul\"
object \"D_72\" {
code {
/// @src 1:91:166

View File

@ -6,6 +6,7 @@
*=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"C_11\" {
code {
/// @src 0:78:164

View File

@ -6,6 +6,7 @@
*=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"C_11\" {
code {
/// @src 0:78:158

View File

@ -6,6 +6,7 @@
*=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"C_11\" {
code {
/// @src 0:78:159

View File

@ -6,6 +6,7 @@
*=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"C_11\" {
code {
/// @src 0:78:243

View File

@ -6,6 +6,7 @@
*=====================================================*/
/// @use-src 0:\"A\", 1:\"#utility.yul\"
object \"C_11\" {
code {
/// @src 0:78:159