forked from github/verilator
Minor cleanup in V3Number
This commit is contained in:
parent
a972230b3a
commit
439d30a953
@ -124,10 +124,8 @@ V3Number::V3Number(AstNode* nodep, const AstNodeDType* nodedtypep) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3Number::V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl) {
|
void V3Number::create(const char* sourcep) {
|
||||||
init(nodep, 0);
|
|
||||||
m_data.setLogic();
|
m_data.setLogic();
|
||||||
m_fileline = fl;
|
|
||||||
const char* value_startp = sourcep;
|
const char* value_startp = sourcep;
|
||||||
for (const char* cp = sourcep; *cp; cp++) {
|
for (const char* cp = sourcep; *cp; cp++) {
|
||||||
if (*cp == '\'') {
|
if (*cp == '\'') {
|
||||||
@ -369,7 +367,7 @@ void V3Number::V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl)
|
|||||||
// m_value[0]);
|
// m_value[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void V3Number::setNames(AstNode* nodep) {
|
void V3Number::nodep(AstNode* nodep) {
|
||||||
m_nodep = nodep;
|
m_nodep = nodep;
|
||||||
if (!nodep) return;
|
if (!nodep) return;
|
||||||
m_fileline = nodep->fileline();
|
m_fileline = nodep->fileline();
|
||||||
|
@ -338,8 +338,8 @@ class V3Number final {
|
|||||||
|
|
||||||
// MEMBERS
|
// MEMBERS
|
||||||
V3NumberData m_data;
|
V3NumberData m_data;
|
||||||
AstNode* m_nodep = nullptr; // Parent node
|
AstNode* m_nodep = nullptr; // Parent node - for error reporting only
|
||||||
FileLine* m_fileline = nullptr;
|
FileLine* m_fileline = nullptr; // Source location - if no parent node is reasonable
|
||||||
|
|
||||||
// METHODS
|
// METHODS
|
||||||
V3Number& setSingleBits(char value);
|
V3Number& setSingleBits(char value);
|
||||||
@ -350,7 +350,7 @@ class V3Number final {
|
|||||||
void opCleanThis(bool warnOnTruncation = false);
|
void opCleanThis(bool warnOnTruncation = false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void nodep(AstNode* nodep) { setNames(nodep); }
|
void nodep(AstNode* nodep);
|
||||||
FileLine* fileline() const { return m_fileline; }
|
FileLine* fileline() const { return m_fileline; }
|
||||||
V3Number& setZero();
|
V3Number& setZero();
|
||||||
V3Number& setQuad(uint64_t value);
|
V3Number& setQuad(uint64_t value);
|
||||||
@ -473,11 +473,8 @@ public:
|
|||||||
opCleanThis();
|
opCleanThis();
|
||||||
}
|
}
|
||||||
// Create from a verilog 32'hxxxx number.
|
// Create from a verilog 32'hxxxx number.
|
||||||
V3Number(AstNode* nodep, const char* sourcep) { V3NumberCreate(nodep, sourcep, nullptr); }
|
V3Number(AstNode* nodep, const char* sourcep) { create(nodep, sourcep); }
|
||||||
class FileLined {}; // Fileline based errors, for parsing only, otherwise pass nodep
|
V3Number(FileLine* flp, const char* sourcep) { create(flp, sourcep); }
|
||||||
V3Number(FileLined, FileLine* fl, const char* sourcep) {
|
|
||||||
V3NumberCreate(nullptr, sourcep, fl);
|
|
||||||
}
|
|
||||||
class VerilogStringLiteral {}; // For creator type-overload selection
|
class VerilogStringLiteral {}; // For creator type-overload selection
|
||||||
V3Number(VerilogStringLiteral, AstNode* nodep, const string& str);
|
V3Number(VerilogStringLiteral, AstNode* nodep, const string& str);
|
||||||
class String {};
|
class String {};
|
||||||
@ -518,9 +515,19 @@ public:
|
|||||||
~V3Number() {}
|
~V3Number() {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void V3NumberCreate(AstNode* nodep, const char* sourcep, FileLine* fl);
|
void create(AstNode* nodep, const char* sourcep) {
|
||||||
|
init(nodep, 0);
|
||||||
|
m_fileline = nullptr;
|
||||||
|
create(sourcep);
|
||||||
|
}
|
||||||
|
void create(FileLine* flp, const char* sourcep) {
|
||||||
|
init(nullptr, 0);
|
||||||
|
m_fileline = flp;
|
||||||
|
create(sourcep);
|
||||||
|
}
|
||||||
|
void create(const char* sourcep);
|
||||||
void init(AstNode* nodep, int swidth = -1, bool sized = true) {
|
void init(AstNode* nodep, int swidth = -1, bool sized = true) {
|
||||||
setNames(nodep);
|
this->nodep(nodep);
|
||||||
if (swidth >= 0) {
|
if (swidth >= 0) {
|
||||||
if (swidth == 0) {
|
if (swidth == 0) {
|
||||||
swidth = 1;
|
swidth = 1;
|
||||||
@ -535,7 +542,6 @@ private:
|
|||||||
m_data.m_sized = false;
|
m_data.m_sized = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void setNames(AstNode* nodep);
|
|
||||||
static string displayPad(size_t fmtsize, char pad, bool left, const string& in);
|
static string displayPad(size_t fmtsize, char pad, bool left, const string& in);
|
||||||
string displayed(FileLine* fl, const string& vformat) const;
|
string displayed(FileLine* fl, const string& vformat) const;
|
||||||
string displayed(const string& vformat) const { return displayed(m_fileline, vformat); }
|
string displayed(const string& vformat) const { return displayed(m_fileline, vformat); }
|
||||||
|
@ -232,8 +232,8 @@ public:
|
|||||||
m_stringps.push_back(strp);
|
m_stringps.push_back(strp);
|
||||||
return strp;
|
return strp;
|
||||||
}
|
}
|
||||||
V3Number* newNumber(FileLine* fl, const char* text) {
|
V3Number* newNumber(FileLine* flp, const char* text) {
|
||||||
V3Number* nump = new V3Number(V3Number::FileLined(), fl, text);
|
V3Number* nump = new V3Number(flp, text);
|
||||||
m_numberps.push_back(nump);
|
m_numberps.push_back(nump);
|
||||||
return nump;
|
return nump;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user