Yul: Adds parsing @src comment in AsmParser to customize the AST's sourcer locations.

This commit is contained in:
Christian Parpart
2021-07-09 11:48:00 +02:00
parent 43cde4e175
commit 132fa46faa
6 changed files with 513 additions and 17 deletions
+13 -1
View File
@@ -80,7 +80,6 @@
#include <utility>
#include <map>
#include <range/v3/view/concat.hpp>
#include <boost/algorithm/string/replace.hpp>
@@ -927,6 +926,19 @@ map<string, unsigned> CompilerStack::sourceIndices() const
return indices;
}
map<unsigned, shared_ptr<CharStream>> CompilerStack::indicesToCharStreams() const
{
map<unsigned, shared_ptr<CharStream>> result;
unsigned index = 0;
for (auto const& s: m_sources)
result[index++] = s.second.scanner->charStream();
// NB: CompilerContext::yulUtilityFileName() does not have a source,
result[index++] = shared_ptr<CharStream>{};
return result;
}
Json::Value const& CompilerStack::contractABI(string const& _contractName) const
{
if (m_stackState < AnalysisPerformed)
+4
View File
@@ -239,6 +239,10 @@ public:
/// by sourceNames().
std::map<std::string, unsigned> sourceIndices() const;
/// @returns the reverse mapping of source indices to their respective
/// CharStream instances.
std::map<unsigned, std::shared_ptr<langutil::CharStream>> indicesToCharStreams() const;
/// @returns the previously used scanner, useful for counting lines during error reporting.
langutil::Scanner const& scanner(std::string const& _sourceName) const;