C++11: Use delegating constructors. No functional change.

This commit is contained in:
Wilson Snyder 2020-08-15 10:26:38 -04:00
parent c0127599df
commit ea4031cbd3
2 changed files with 22 additions and 35 deletions

View File

@ -7669,24 +7669,17 @@ public:
class AstReplicate : public AstNodeBiop { class AstReplicate : public AstNodeBiop {
// Also used as a "Uniop" flavor of Concat, e.g. "{a}" // Also used as a "Uniop" flavor of Concat, e.g. "{a}"
// Verilog {rhs{lhs}} - Note rhsp() is the replicate value, not the lhsp() // Verilog {rhs{lhs}} - Note rhsp() is the replicate value, not the lhsp()
private:
void init() {
if (lhsp()) {
if (const AstConst* constp = VN_CAST(rhsp(), Const)) {
dtypeSetLogicSized(lhsp()->width() * constp->toUInt(), VSigning::UNSIGNED);
}
}
}
public: public:
AstReplicate(FileLine* fl, AstNode* lhsp, AstNode* rhsp) AstReplicate(FileLine* fl, AstNode* lhsp, AstNode* rhsp)
: ASTGEN_SUPER(fl, lhsp, rhsp) { : ASTGEN_SUPER(fl, lhsp, rhsp) {
init(); if (lhsp) {
if (const AstConst* constp = VN_CAST(rhsp, Const)) {
dtypeSetLogicSized(lhsp->width() * constp->toUInt(), VSigning::UNSIGNED);
}
}
} }
AstReplicate(FileLine* fl, AstNode* lhsp, uint32_t repCount) AstReplicate(FileLine* fl, AstNode* lhsp, uint32_t repCount)
: ASTGEN_SUPER(fl, lhsp, new AstConst(fl, repCount)) { : AstReplicate(fl, lhsp, new AstConst(fl, repCount)) {}
init();
}
ASTNODE_NODE_FUNCS(Replicate) ASTNODE_NODE_FUNCS(Replicate)
virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) {
return new AstReplicate(this->fileline(), lhsp, rhsp); return new AstReplicate(this->fileline(), lhsp, rhsp);
@ -7705,18 +7698,13 @@ public:
}; };
class AstReplicateN : public AstNodeBiop { class AstReplicateN : public AstNodeBiop {
// String replicate // String replicate
private:
void init() { dtypeSetString(); }
public: public:
AstReplicateN(FileLine* fl, AstNode* lhsp, AstNode* rhsp) AstReplicateN(FileLine* fl, AstNode* lhsp, AstNode* rhsp)
: ASTGEN_SUPER(fl, lhsp, rhsp) { : ASTGEN_SUPER(fl, lhsp, rhsp) {
init(); dtypeSetString();
} }
AstReplicateN(FileLine* fl, AstNode* lhsp, uint32_t repCount) AstReplicateN(FileLine* fl, AstNode* lhsp, uint32_t repCount)
: ASTGEN_SUPER(fl, lhsp, new AstConst(fl, repCount)) { : AstReplicateN(fl, lhsp, new AstConst(fl, repCount)) {}
init();
}
ASTNODE_NODE_FUNCS(ReplicateN) ASTNODE_NODE_FUNCS(ReplicateN)
virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) { virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp) {
return new AstReplicateN(this->fileline(), lhsp, rhsp); return new AstReplicateN(this->fileline(), lhsp, rhsp);

View File

@ -116,9 +116,20 @@ class VHashSha256 {
size_t m_totLength; // Total all-chunk length as needed by output digest size_t m_totLength; // Total all-chunk length as needed by output digest
public: public:
// CONSTRUCTORS // CONSTRUCTORS
VHashSha256() { init(); } VHashSha256() {
explicit VHashSha256(const string& data) { m_inthash[0] = 0x6a09e667;
init(); m_inthash[1] = 0xbb67ae85;
m_inthash[2] = 0x3c6ef372;
m_inthash[3] = 0xa54ff53a;
m_inthash[4] = 0x510e527f;
m_inthash[5] = 0x9b05688c;
m_inthash[6] = 0x1f83d9ab;
m_inthash[7] = 0x5be0cd19;
m_final = false;
m_totLength = 0;
}
explicit VHashSha256(const string& data)
: VHashSha256() {
insert(data); insert(data);
} }
~VHashSha256() {} ~VHashSha256() {}
@ -138,18 +149,6 @@ public:
void insert(uint64_t value) { insert(cvtToStr(value)); } void insert(uint64_t value) { insert(cvtToStr(value)); }
private: private:
void init() {
m_inthash[0] = 0x6a09e667;
m_inthash[1] = 0xbb67ae85;
m_inthash[2] = 0x3c6ef372;
m_inthash[3] = 0xa54ff53a;
m_inthash[4] = 0x510e527f;
m_inthash[5] = 0x9b05688c;
m_inthash[6] = 0x1f83d9ab;
m_inthash[7] = 0x5be0cd19;
m_final = false;
m_totLength = 0;
}
static void selfTestOne(const string& data, const string& data2, const string& exp, static void selfTestOne(const string& data, const string& data2, const string& exp,
const string& exp64); const string& exp64);
void finalize(); // Process remaining data void finalize(); // Process remaining data