yul: adds reindent() function to reindent yul source code and makes use of it in IRGenerator.

This function does count curly and round braces and reindents
accordingly the beginning of each line.

It does consider line-comments (// and ///) but not multiline comments (/* ... */).
This commit is contained in:
Christian Parpart
2019-06-24 12:53:50 +02:00
committed by chriseth
parent 5329a84912
commit 0fd1db533e
4 changed files with 52 additions and 3 deletions
+2 -2
View File
@@ -30,6 +30,7 @@
#include <libsolidity/codegen/CompilerUtils.h>
#include <libyul/AssemblyStack.h>
#include <libyul/Utilities.h>
#include <libdevcore/CommonData.h>
#include <libdevcore/Whiskers.h>
@@ -45,8 +46,7 @@ using namespace dev::solidity;
pair<string, string> IRGenerator::run(ContractDefinition const& _contract)
{
// TODO Would be nice to pretty-print this while retaining comments.
string ir = generate(_contract);
string const ir = yul::reindent(generate(_contract));
yul::AssemblyStack asmStack(m_evmVersion, yul::AssemblyStack::Language::StrictAssembly, m_optimiserSettings);
if (!asmStack.parseAndAnalyze("", ir))