diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 5b980d6d6..1fa1cb410 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -203,31 +203,6 @@ string AstNode::prettyTypeName() const { return string(typeName())+" '"+prettyName()+"'"; } -string AstNode::quoteName(const string& namein) { - // Encode control chars into C style escapes - // Reverse is V3Parse::deQuote - const char* start = namein.c_str(); - string out; - for (const char* pos = start; *pos; pos++) { - if (pos[0]=='\\' || pos[0]=='"') { - out += string("\\")+pos[0]; - } else if (pos[0]=='\n') { - out += "\\n"; - } else if (pos[0]=='\r') { - out += "\\r"; - } else if (pos[0]=='\t') { - out += "\\t"; - } else if (isprint(pos[0])) { - out += pos[0]; - } else { - // This will also cover \a etc - char octal[10]; sprintf(octal,"\\%03o",pos[0]); - out += octal; - } - } - return out; -} - //###################################################################### // Insertion diff --git a/src/V3Ast.h b/src/V3Ast.h index 4eecd7d2a..cc290d78f 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1017,7 +1017,6 @@ public: virtual string verilogKwd() const { return ""; } string shortName() const; // Name with __PVT__ removed for concatenating scopes static string dedotName(const string& namein); // Name with dots removed - static string quoteName(const string& namein); // Name with control chars quoted static string prettyName(const string& namein); // Name for printing out to the user static string encodeName(const string& namein); // Encode user name into internal C representation static string encodeNumber(vlsint64_t numin); // Encode number into internal C representation diff --git a/src/V3AstNodes.cpp b/src/V3AstNodes.cpp index afd2ce341..aa044b795 100644 --- a/src/V3AstNodes.cpp +++ b/src/V3AstNodes.cpp @@ -737,7 +737,7 @@ void AstNode::dump(ostream& str) { } else { // V3Broken will throw an error if (dtypep()) str<<" %Error-dtype-exp=null,got="<<(void*)dtypep(); } - if (name()!="") str<<" "< m_value; // The Value, with bit 0 being in bit 0 of this vector (unless X/Z) @@ -116,13 +116,13 @@ private: V3Number& opModDivGuts(const V3Number& lhs, const V3Number& rhs, bool is_modulus); public: - class VerilogString {}; // for creator type-overload selection + class VerilogStringLiteral {}; // for creator type-overload selection // CONSTRUCTORS V3Number(FileLine* fileline) { init(fileline, 1); } V3Number(FileLine* fileline, int width) { init(fileline, width); } // 0=unsized V3Number(FileLine* fileline, int width, uint32_t value) { init(fileline, width); m_value[0]=value; opCleanThis(); } V3Number(FileLine* fileline, const char* source); // Create from a verilog 32'hxxxx number. - V3Number(VerilogString, FileLine* fileline, const string& vvalue); + V3Number(VerilogStringLiteral, FileLine* fileline, const string& vvalue); private: void init(FileLine* fileline, int swidth) { @@ -155,6 +155,7 @@ public: // ACCESSORS string ascii(bool prefixed=true, bool cleanVerilog=false) const; + static string quoteNameControls(const string& namein); // Add backslash quotes to strings string displayed(const string& format) const; static bool displayedFmtLegal(char format); // Is this a valid format letter? int width() const { return m_width; } diff --git a/src/verilog.y b/src/verilog.y index ba02fe6de..61ada34a1 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -3484,7 +3484,7 @@ str: // yaSTRING but with \{escapes} need decoded ; strAsInt: - yaSTRING { $$ = new AstConst($1,V3Number(V3Number::VerilogString(),$1,GRAMMARP->deQuote($1,*$1)));} + yaSTRING { $$ = new AstConst($1,V3Number(V3Number::VerilogStringLiteral(),$1,GRAMMARP->deQuote($1,*$1)));} ; strAsIntIgnore: // strAsInt, but never matches for when expr shouldn't parse strings @@ -3735,7 +3735,7 @@ AstVar* V3ParseGrammar::createVariable(FileLine* fileline, string name, AstRange string V3ParseGrammar::deQuote(FileLine* fileline, string text) { // Fix up the quoted strings the user put in, for example "\"" becomes " - // Reverse is AstNode::quoteName(...) + // Reverse is V3Number::quoteNameControls(...) bool quoted = false; string newtext; unsigned char octal_val = 0;