With --no-decoration, remove output whitespace (#3460)
Signed-off-by: Kamil Rakoczy <krakoczy@antmicro.com>
This commit is contained in:
parent
e7dc2de14b
commit
660d1059b0
|
|
@ -790,6 +790,10 @@ class EmitVPrefixedFormatter final : public V3OutFormatter {
|
|||
}
|
||||
}
|
||||
|
||||
virtual void putsOutput(const char* strg) override {
|
||||
for (const char* cp = strg; *cp; cp++) putcOutput(*cp);
|
||||
}
|
||||
|
||||
public:
|
||||
void prefixFl(FileLine* fl) { m_prefixFl = fl; }
|
||||
FileLine* prefixFl() const { return m_prefixFl; }
|
||||
|
|
|
|||
|
|
@ -700,6 +700,10 @@ int V3OutFormatter::endLevels(const char* strg) {
|
|||
}
|
||||
|
||||
void V3OutFormatter::puts(const char* strg) {
|
||||
if (!v3Global.opt.decoration()) {
|
||||
putsOutput(strg);
|
||||
return;
|
||||
}
|
||||
if (m_prependIndent && strg[0] != '\n') {
|
||||
putsNoTracking(indentSpaces(endLevels(strg)));
|
||||
m_prependIndent = false;
|
||||
|
|
@ -759,13 +763,8 @@ void V3OutFormatter::puts(const char* strg) {
|
|||
break;
|
||||
case '(':
|
||||
indentInc();
|
||||
if (v3Global.opt.decoration()) {
|
||||
// Line up continuation with open paren, plus one indent
|
||||
m_parenVec.push(m_column);
|
||||
} else {
|
||||
// Line up continuation with block+1
|
||||
m_parenVec.push(m_indentLevel * m_blockIndent);
|
||||
}
|
||||
break;
|
||||
case ')':
|
||||
if (!m_parenVec.empty()) m_parenVec.pop();
|
||||
|
|
@ -806,6 +805,7 @@ void V3OutFormatter::putBreakExpr() {
|
|||
|
||||
// Add a line break if too wide
|
||||
void V3OutFormatter::putBreak() {
|
||||
if (!v3Global.opt.decoration()) return;
|
||||
if (!m_nobreak) {
|
||||
// char s[1000]; sprintf(s, "{%d,%d}", m_column, m_parenVec.top()); putsNoTracking(s);
|
||||
if (exceededWidth()) {
|
||||
|
|
@ -824,11 +824,19 @@ void V3OutFormatter::putsQuoted(const string& strg) {
|
|||
putcNoTracking('"');
|
||||
}
|
||||
void V3OutFormatter::putsNoTracking(const string& strg) {
|
||||
if (!v3Global.opt.decoration()) {
|
||||
putsOutput(strg.c_str());
|
||||
return;
|
||||
}
|
||||
// Don't track {}'s, probably because it's a $display format string
|
||||
for (const char c : strg) putcNoTracking(c);
|
||||
}
|
||||
|
||||
void V3OutFormatter::putcNoTracking(char chr) {
|
||||
if (!v3Global.opt.decoration()) {
|
||||
putcOutput(chr);
|
||||
return;
|
||||
}
|
||||
switch (chr) {
|
||||
case '\n':
|
||||
m_lineno++;
|
||||
|
|
|
|||
|
|
@ -176,6 +176,7 @@ public:
|
|||
|
||||
// CALLBACKS - MUST OVERRIDE
|
||||
virtual void putcOutput(char chr) = 0;
|
||||
virtual void putsOutput(const char* str) = 0;
|
||||
};
|
||||
|
||||
//============================================================================
|
||||
|
|
@ -193,6 +194,7 @@ public:
|
|||
private:
|
||||
// CALLBACKS
|
||||
virtual void putcOutput(char chr) override { fputc(chr, m_fp); }
|
||||
virtual void putsOutput(const char* str) override { fputs(str, m_fp); }
|
||||
};
|
||||
|
||||
class V3OutCFile VL_NOT_FINAL : public V3OutFile {
|
||||
|
|
|
|||
Loading…
Reference in New Issue