mirror of
https://github.com/verilator/verilator.git
synced 2025-01-19 12:54:02 +00:00
Internals: make AstCFunc::m_isStatic a bool.
All functions are now known to be static or not static when they are created, so turn the isStatic flag into a bool (from VBoolOrUnknown).
This commit is contained in:
parent
6c332a2f8e
commit
729bd268de
@ -1818,11 +1818,7 @@ void AstCFunc::dump(std::ostream& str) const {
|
||||
this->AstNode::dump(str);
|
||||
if (slow()) str << " [SLOW]";
|
||||
if (pure()) str << " [PURE]";
|
||||
if (isStatic().unknown()) {
|
||||
str << " [STATICU]";
|
||||
} else if (isStatic().trueUnknown()) {
|
||||
str << " [STATIC]";
|
||||
}
|
||||
if (isStatic()) str << " [STATIC]";
|
||||
if (dpiExportDispatcher()) str << " [DPIED]";
|
||||
if (dpiExportImpl()) str << " [DPIEI]";
|
||||
if (dpiImportPrototype()) str << " [DPIIP]";
|
||||
|
@ -8734,7 +8734,7 @@ private:
|
||||
string m_ctorInits; // Constructor sub-class inits
|
||||
string m_ifdef; // #ifdef symbol around this function
|
||||
VBoolOrUnknown m_isConst; // Function is declared const (*this not changed)
|
||||
VBoolOrUnknown m_isStatic; // Function is declared static (no this)
|
||||
bool m_isStatic : 1; // Function is static (no need for a 'this' pointer)
|
||||
bool m_dontCombine : 1; // V3Combine shouldn't compare this func tree, it's special
|
||||
bool m_declPrivate : 1; // Declare it private
|
||||
bool m_formCallTree : 1; // Make a global function to call entire tree of functions
|
||||
@ -8758,10 +8758,10 @@ public:
|
||||
: ASTGEN_SUPER_CFunc(fl) {
|
||||
m_funcType = AstCFuncType::FT_NORMAL;
|
||||
m_isConst = VBoolOrUnknown::BU_UNKNOWN; // Unknown until analyzed
|
||||
m_isStatic = VBoolOrUnknown::BU_UNKNOWN; // Unknown until see where thisp needed
|
||||
m_scopep = scopep;
|
||||
m_name = name;
|
||||
m_rtnType = rtnType;
|
||||
m_isStatic = false;
|
||||
m_dontCombine = false;
|
||||
m_declPrivate = false;
|
||||
m_formCallTree = false;
|
||||
@ -8801,9 +8801,8 @@ public:
|
||||
VBoolOrUnknown isConst() const { return m_isConst; }
|
||||
void isConst(bool flag) { m_isConst.setTrueOrFalse(flag); }
|
||||
void isConst(VBoolOrUnknown flag) { m_isConst = flag; }
|
||||
VBoolOrUnknown isStatic() const { return m_isStatic; }
|
||||
void isStatic(bool flag) { m_isStatic.setTrueOrFalse(flag); }
|
||||
void isStatic(VBoolOrUnknown flag) { m_isStatic = flag; }
|
||||
bool isStatic() const { return m_isStatic; }
|
||||
void isStatic(bool flag) { m_isStatic = flag; }
|
||||
void cname(const string& name) { m_cname = name; }
|
||||
string cname() const { return m_cname; }
|
||||
AstScope* scopep() const { return m_scopep; }
|
||||
|
@ -128,7 +128,7 @@ private:
|
||||
// (Here instead of new visitor after V3Descope just to avoid another visitor)
|
||||
void needNonStaticFunc(AstNode* nodep) {
|
||||
UASSERT_OBJ(m_cfuncp, nodep, "Non-static accessor not under a function");
|
||||
if (m_cfuncp->isStatic().trueUnknown()) {
|
||||
if (m_cfuncp->isStatic()) {
|
||||
UINFO(5, "Mark non-public due to " << nodep << endl);
|
||||
m_cfuncp->isStatic(false);
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ private:
|
||||
if (VN_IS(m_modp, Class)) {
|
||||
funcp->argTypes(EmitCBaseVisitor::symClassVar());
|
||||
callp->argTypes("vlSymsp");
|
||||
} else if (funcp->isStatic().falseUnknown()) {
|
||||
} else if (!funcp->isStatic()) {
|
||||
callp->selfPointer("this");
|
||||
}
|
||||
UINFO(6, " New " << callp << endl);
|
||||
|
@ -49,7 +49,6 @@ private:
|
||||
AstScope* m_scopep = nullptr; // Current scope
|
||||
bool m_modSingleton = false; // m_modp is only instanced once
|
||||
bool m_allowThis = false; // Allow function non-static
|
||||
bool m_needThis = false; // Make function non-static
|
||||
FuncMmap m_modFuncs; // Name of public functions added
|
||||
|
||||
// METHODS
|
||||
@ -92,7 +91,6 @@ private:
|
||||
UINFO(8, " aboveScope " << scopep->aboveScopep() << endl);
|
||||
|
||||
if (relativeRefOk && scopep == m_scopep) {
|
||||
m_needThis = true;
|
||||
return "this";
|
||||
} else if (VN_IS(scopep->modp(), Class)) {
|
||||
return "";
|
||||
@ -105,7 +103,6 @@ private:
|
||||
string name = scopep->name();
|
||||
string::size_type pos;
|
||||
if ((pos = name.rfind('.')) != string::npos) name.erase(0, pos + 1);
|
||||
m_needThis = true;
|
||||
return "this->" + name;
|
||||
} else {
|
||||
// Reference to something elsewhere, or relative references are disabled. Use global
|
||||
@ -258,14 +255,11 @@ private:
|
||||
// nodep->funcp()->scopep(nullptr);
|
||||
}
|
||||
virtual void visit(AstCFunc* nodep) override {
|
||||
VL_RESTORER(m_needThis);
|
||||
VL_RESTORER(m_allowThis);
|
||||
if (!nodep->user1()) {
|
||||
m_needThis = false;
|
||||
m_allowThis = nodep->isStatic().falseUnknown(); // Non-static or unknown if static
|
||||
m_allowThis = !nodep->isStatic();
|
||||
iterateChildren(nodep);
|
||||
nodep->user1(true);
|
||||
if (m_needThis) nodep->isStatic(false);
|
||||
// If it's under a scope, move it up to the top
|
||||
if (m_scopep) {
|
||||
nodep->unlinkFrBack();
|
||||
|
@ -247,7 +247,7 @@ public:
|
||||
}
|
||||
void ccallIterateArgs(AstNodeCCall* nodep) {
|
||||
bool comma = false;
|
||||
if (nodep->funcp()->isLoose() && nodep->funcp()->isStatic().falseUnknown()) {
|
||||
if (nodep->funcp()->isLoose() && !nodep->funcp()->isStatic()) {
|
||||
UASSERT_OBJ(!nodep->selfPointer().empty(), nodep,
|
||||
"Call to loose method without self pointer");
|
||||
puts(nodep->selfPointerProtect(m_useSelfForThis));
|
||||
@ -384,7 +384,7 @@ public:
|
||||
} else if (funcp->dpiImportPrototype()) {
|
||||
// Calling DPI import
|
||||
puts(funcp->name());
|
||||
} else if (funcp->isProperMethod() && funcp->isStatic().trueUnknown()) {
|
||||
} else if (funcp->isProperMethod() && funcp->isStatic()) {
|
||||
// Call static method via the containing class
|
||||
AstNodeModule* modp = VN_CAST(funcp->user4p(), NodeModule);
|
||||
puts(prefixNameProtect(modp) + "::");
|
||||
@ -1588,7 +1588,7 @@ class EmitCImp final : EmitCStmts {
|
||||
|
||||
if (nodep->isLoose()) {
|
||||
m_lazyDecls.declared(nodep); // Defined here, so no longer needs declaration
|
||||
if (nodep->isStatic().falseUnknown()) { // Standard prologue
|
||||
if (!nodep->isStatic()) { // Standard prologue
|
||||
m_useSelfForThis = true;
|
||||
puts("if (false && vlSelf) {} // Prevent unused\n");
|
||||
if (!VN_IS(m_modp, Class)) puts(symClassAssign());
|
||||
@ -3864,7 +3864,7 @@ class EmitCTrace final : EmitCStmts {
|
||||
|
||||
if (nodep->isLoose()) {
|
||||
m_lazyDecls.declared(nodep); // Defined here, so no longer needs declaration
|
||||
if (nodep->isStatic().falseUnknown()) { // Standard prologue
|
||||
if (!nodep->isStatic()) { // Standard prologue
|
||||
puts("if (false && vlSelf) {} // Prevent unused\n");
|
||||
m_useSelfForThis = true;
|
||||
puts(symClassAssign());
|
||||
|
@ -105,7 +105,7 @@ public:
|
||||
string cFuncArgs(const AstCFunc* nodep) {
|
||||
// Return argument list for given C function
|
||||
string args;
|
||||
if (nodep->isLoose() && nodep->isStatic().falseUnknown()) {
|
||||
if (nodep->isLoose() && !nodep->isStatic()) {
|
||||
if (nodep->isConst().trueKnown()) args += "const ";
|
||||
AstNodeModule* modp = VN_CAST(nodep->user4p(), NodeModule);
|
||||
args += prefixNameProtect(modp);
|
||||
@ -148,7 +148,7 @@ public:
|
||||
ensureNewLine();
|
||||
if (!funcp->ifdef().empty()) puts("#ifdef " + funcp->ifdef() + "\n");
|
||||
if (cLinkage) puts("extern \"C\" ");
|
||||
if (funcp->isStatic().trueUnknown() && funcp->isProperMethod()) puts("static ");
|
||||
if (funcp->isStatic() && funcp->isProperMethod()) puts("static ");
|
||||
if (funcp->isVirtual()) {
|
||||
UASSERT_OBJ(funcp->isProperMethod(), funcp, "Virtual function is not a proper method");
|
||||
puts("virtual ");
|
||||
|
Loading…
Reference in New Issue
Block a user