From 06d5a7b2bf08935cba34f8b712973184f2f5ba93 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 6 Jul 2015 19:37:20 -0400 Subject: [PATCH] Internals: Allow hashing nulls; misc cleanup --- src/V3EmitC.cpp | 6 +++--- src/V3String.h | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 642444b11..c4f07bfc8 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -1563,12 +1563,12 @@ void EmitCImp::emitSavableImp(AstNodeModule* modp) { VHashFnv hash; for (AstNode* nodep=modp->stmtsp(); nodep; nodep = nodep->nextp()) { if (AstVar* varp = nodep->castVar()) { - hash.hash(varp->name()); - hash.hash(varp->dtypep()->width()); + hash.insert(varp->name()); + hash.insert(varp->dtypep()->width()); } } ofp()->printf( "vluint64_t __Vcheckval = VL_ULL(0x%" VL_PRI64 "x);\n", - hash.value()); + hash.digestUInt64()); if (de) { puts("os.readAssert(__Vcheckval);\n"); } else { diff --git a/src/V3String.h b/src/V3String.h index 17f8da758..704308627 100644 --- a/src/V3String.h +++ b/src/V3String.h @@ -55,35 +55,35 @@ public: VHashFnv() : m_hash(FNV1_64_INIT) {} ~VHashFnv() {} - vluint64_t value() const { return m_hash; } + vluint64_t digestUInt64() const { return m_hash; } - VHashFnv& hash(const void* bufp, size_t len) { // Memory + VHashFnv& insert(const void* bufp, size_t len) { // Memory const uint8_t* bp = (const uint8_t*)bufp; const uint8_t* be = bp + len; while (bp < be) hashC((vluint64_t)*bp++); return *this; } - VHashFnv& hash(const char* strp) { // String + VHashFnv& insert(const char* strp) { // String const uint8_t* sp = (const uint8_t*)strp; while (*sp) hashC((vluint64_t)*sp++); return *this; } - VHashFnv& hash(const string& str) { return hash(str.data(), str.length()); } - VHashFnv& hash(vluint64_t n) { + VHashFnv& insert(const string& str) { return insert(str.data(), str.length()); } + VHashFnv& insert(vluint64_t n) { hashC(n>>0); hashC(n>>8); hashC(n>>16); hashC(n>>24); hashC(n>>32); hashC(n>>40); hashC(n>>48); hashC(n>>56); return *this; } - VHashFnv& hash(uint32_t n) { + VHashFnv& insert(uint32_t n) { hashC(n>>0); hashC(n>>8); hashC(n>>16); hashC(n>>24); return *this; } - VHashFnv& hash(uint16_t n) { + VHashFnv& insert(uint16_t n) { hashC(n>>0); hashC(n>>8); return *this; } - VHashFnv& hash(uint8_t n) { hashC(n); return *this; } - VHashFnv& hash(int n) { hashC((vluint64_t)n); return *this; } + VHashFnv& insert(uint8_t n) { hashC(n); return *this; } + VHashFnv& insert(int n) { hashC((vluint64_t)n); return *this; } }; //######################################################################