From e64b2d337297cebf319c21f321cb3d9d36ece4a3 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Fri, 6 May 2016 22:26:15 -0400 Subject: [PATCH] Internals: user#inc now has optional increment value. --- src/V3Ast.h | 10 +++++----- src/V3Dead.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/V3Ast.h b/src/V3Ast.h index 3971687ba..3a8278090 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1119,7 +1119,7 @@ public: void user1p(void* userp) { m_user1p=(AstNUser*)(userp); m_user1Cnt=AstUser1InUse::s_userCntGbl; } int user1() const { return user1p()->castInt(); } void user1(int val) { user1p(AstNUser::fromInt(val)); } - int user1Inc() { int v=user1(); user1(v+1); return v; } + int user1Inc(int val=1) { int v=user1(); user1(v+val); return v; } int user1SetOnce() { int v=user1(); if (!v) user1(1); return v; } // Better for cache than user1Inc() static void user1ClearTree() { AstUser1InUse::clear(); } // Clear userp()'s across the entire tree @@ -1129,7 +1129,7 @@ public: void user2p(void* userp) { m_user2p=(AstNUser*)(userp); m_user2Cnt=AstUser2InUse::s_userCntGbl; } int user2() const { return user2p()->castInt(); } void user2(int val) { user2p(AstNUser::fromInt(val)); } - int user2Inc() { int v=user2(); user2(v+1); return v; } + int user2Inc(int val=1) { int v=user2(); user2(v+val); return v; } int user2SetOnce() { int v=user2(); if (!v) user2(1); return v; } static void user2ClearTree() { AstUser2InUse::clear(); } @@ -1139,7 +1139,7 @@ public: void user3p(void* userp) { m_user3p=(AstNUser*)(userp); m_user3Cnt=AstUser3InUse::s_userCntGbl; } int user3() const { return user3p()->castInt(); } void user3(int val) { user3p(AstNUser::fromInt(val)); } - int user3Inc() { int v=user3(); user3(v+1); return v; } + int user3Inc(int val=1) { int v=user3(); user3(v+val); return v; } int user3SetOnce() { int v=user3(); if (!v) user3(1); return v; } static void user3ClearTree() { AstUser3InUse::clear(); } @@ -1149,7 +1149,7 @@ public: void user4p(void* userp) { m_user4p=(AstNUser*)(userp); m_user4Cnt=AstUser4InUse::s_userCntGbl; } int user4() const { return user4p()->castInt(); } void user4(int val) { user4p(AstNUser::fromInt(val)); } - int user4Inc() { int v=user4(); user4(v+1); return v; } + int user4Inc(int val=1) { int v=user4(); user4(v+val); return v; } int user4SetOnce() { int v=user4(); if (!v) user4(1); return v; } static void user4ClearTree() { AstUser4InUse::clear(); } @@ -1159,7 +1159,7 @@ public: void user5p(void* userp) { m_user5p=(AstNUser*)(userp); m_user5Cnt=AstUser5InUse::s_userCntGbl; } int user5() const { return user5p()->castInt(); } void user5(int val) { user5p(AstNUser::fromInt(val)); } - int user5Inc() { int v=user5(); user5(v+1); return v; } + int user5Inc(int val=1) { int v=user5(); user5(v+val); return v; } int user5SetOnce() { int v=user5(); if (!v) user5(1); return v; } static void user5ClearTree() { AstUser5InUse::clear(); } diff --git a/src/V3Dead.cpp b/src/V3Dead.cpp index 93b3fcf5f..cd75b5b69 100644 --- a/src/V3Dead.cpp +++ b/src/V3Dead.cpp @@ -49,7 +49,7 @@ private: // VISITORS virtual void visit(AstCell* nodep, AstNUser*) { nodep->iterateChildren(*this); - nodep->modp()->user1(nodep->modp()->user1() - 1); + nodep->modp()->user1Inc(-1); } //----- virtual void visit(AstNodeMath* nodep, AstNUser*) {} // Accelerate