yul::reindent() to reindent with spaces instead of tabs (width: 4)

This commit is contained in:
Christian Parpart
2019-07-08 11:43:11 +02:00
parent 019ec63f63
commit 7ba9537ae1
2 changed files with 84 additions and 79 deletions
+9 -4
View File
@@ -42,6 +42,8 @@ using boost::is_any_of;
string yul::reindent(string const& _code)
{
int constexpr indentationWidth = 4;
auto const static countBraces = [](string const& _s) noexcept -> int
{
auto const i = _s.find("//");
@@ -65,10 +67,13 @@ string yul::reindent(string const& _code)
if (diff < 0)
depth += diff;
for (int i = 0; i < depth; ++i)
out << '\t';
out << line << '\n';
if (!line.empty())
{
for (int i = 0; i < depth * indentationWidth; ++i)
out << ' ';
out << line;
}
out << '\n';
if (diff > 0)
depth += diff;