Internals: Rename MethodCall. No functional change.

This commit is contained in:
Wilson Snyder 2020-01-18 14:11:05 -05:00
parent 835f668aaa
commit 18e837336a
5 changed files with 29 additions and 29 deletions

View File

@ -1366,7 +1366,7 @@ public:
void addPinsp(AstNode* nodep) { addOp2p(nodep); } void addPinsp(AstNode* nodep) { addOp2p(nodep); }
}; };
class AstCMethodCall : public AstNodeStmt { class AstCMethodHard : public AstNodeStmt {
// A reference to a "C" hardocded member task (or function) // A reference to a "C" hardocded member task (or function)
// PARENTS: stmt/math // PARENTS: stmt/math
// Not all calls are statments vs math. AstNodeStmt needs isStatement() to deal. // Not all calls are statments vs math. AstNodeStmt needs isStatement() to deal.
@ -1374,7 +1374,7 @@ private:
string m_name; // Name of method string m_name; // Name of method
bool m_pure; // Pure optimizable bool m_pure; // Pure optimizable
public: public:
AstCMethodCall(FileLine* fl, AstNode* fromp, VFlagChildDType, const string& name, AstCMethodHard(FileLine* fl, AstNode* fromp, VFlagChildDType, const string& name,
AstNode* pinsp) AstNode* pinsp)
: AstNodeStmt(fl, false) : AstNodeStmt(fl, false)
, m_name(name) , m_name(name)
@ -1383,19 +1383,19 @@ public:
dtypep(NULL); // V3Width will resolve dtypep(NULL); // V3Width will resolve
addNOp2p(pinsp); addNOp2p(pinsp);
} }
AstCMethodCall(FileLine* fl, AstNode* fromp, const string& name, AstNode* pinsp) AstCMethodHard(FileLine* fl, AstNode* fromp, const string& name, AstNode* pinsp)
: AstNodeStmt(fl, false) : AstNodeStmt(fl, false)
, m_name(name) { , m_name(name) {
setOp1p(fromp); setOp1p(fromp);
addNOp2p(pinsp); addNOp2p(pinsp);
} }
ASTNODE_NODE_FUNCS(CMethodCall) ASTNODE_NODE_FUNCS(CMethodHard)
virtual string name() const { return m_name; } // * = Var name virtual string name() const { return m_name; } // * = Var name
virtual bool hasDType() const { return true; } virtual bool hasDType() const { return true; }
virtual void name(const string& name) { m_name = name; } virtual void name(const string& name) { m_name = name; }
virtual V3Hash sameHash() const { return V3Hash(m_name); } virtual V3Hash sameHash() const { return V3Hash(m_name); }
virtual bool same(const AstNode* samep) const { virtual bool same(const AstNode* samep) const {
const AstCMethodCall* asamep = static_cast<const AstCMethodCall*>(samep); const AstCMethodHard* asamep = static_cast<const AstCMethodHard*>(samep);
return (m_name == asamep->m_name); } return (m_name == asamep->m_name); }
virtual bool isPure() const { return m_pure; } virtual bool isPure() const { return m_pure; }
void pure(bool flag) { m_pure = flag; } void pure(bool flag) { m_pure = flag; }

View File

@ -282,7 +282,7 @@ private:
insureCleanAndNext(nodep->argsp()); insureCleanAndNext(nodep->argsp());
setClean(nodep, true); setClean(nodep, true);
} }
virtual void visit(AstCMethodCall* nodep) { virtual void visit(AstCMethodHard* nodep) {
iterateChildren(nodep); iterateChildren(nodep);
insureCleanAndNext(nodep->pinsp()); insureCleanAndNext(nodep->pinsp());
setClean(nodep, true); setClean(nodep, true);

View File

@ -192,7 +192,7 @@ public:
} else if (nodep->isWide() } else if (nodep->isWide()
&& VN_IS(nodep->lhsp(), VarRef) && VN_IS(nodep->lhsp(), VarRef)
&& !VN_IS(nodep->rhsp(), CMath) && !VN_IS(nodep->rhsp(), CMath)
&& !VN_IS(nodep->rhsp(), CMethodCall) && !VN_IS(nodep->rhsp(), CMethodHard)
&& !VN_IS(nodep->rhsp(), VarRef) && !VN_IS(nodep->rhsp(), VarRef)
&& !VN_IS(nodep->rhsp(), AssocSel) && !VN_IS(nodep->rhsp(), AssocSel)
&& !VN_IS(nodep->rhsp(), ArraySel)) { && !VN_IS(nodep->rhsp(), ArraySel)) {
@ -257,7 +257,7 @@ public:
puts(");\n"); puts(");\n");
} }
} }
virtual void visit(AstCMethodCall* nodep) { virtual void visit(AstCMethodHard* nodep) {
iterate(nodep->fromp()); iterate(nodep->fromp());
puts("."); puts(".");
puts(nodep->nameProtect()); puts(nodep->nameProtect());

View File

@ -1081,7 +1081,7 @@ private:
if (VN_IS(nodep->fromp()->dtypep(), QueueDType)) { if (VN_IS(nodep->fromp()->dtypep(), QueueDType)) {
switch (nodep->attrType()) { switch (nodep->attrType()) {
case AstAttrType::DIM_SIZE: { case AstAttrType::DIM_SIZE: {
AstNode* newp = new AstCMethodCall( AstNode* newp = new AstCMethodHard(
nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", NULL); nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", NULL);
newp->dtypeSetSigned32(); newp->dtypeSetSigned32();
newp->didWidth(true); newp->didWidth(true);
@ -1097,7 +1097,7 @@ private:
} }
case AstAttrType::DIM_RIGHT: case AstAttrType::DIM_RIGHT:
case AstAttrType::DIM_HIGH: { case AstAttrType::DIM_HIGH: {
AstNode* sizep = new AstCMethodCall( AstNode* sizep = new AstCMethodHard(
nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", NULL); nodep->fileline(), nodep->fromp()->unlinkFrBack(), "size", NULL);
sizep->dtypeSetSigned32(); sizep->dtypeSetSigned32();
sizep->didWidth(true); sizep->didWidth(true);
@ -1788,7 +1788,7 @@ private:
return false; return false;
} }
virtual void visit(AstCMethodCall* nodep) { virtual void visit(AstCMethodHard* nodep) {
// Never created before V3Width, so no need to redo it // Never created before V3Width, so no need to redo it
UASSERT_OBJ(nodep->dtypep(), nodep, "CMETHODCALLs should have already been sized"); UASSERT_OBJ(nodep->dtypep(), nodep, "CMETHODCALLs should have already been sized");
} }
@ -1936,11 +1936,11 @@ private:
} }
} }
void methodCallAssoc(AstMethodCall* nodep, AstAssocArrayDType* adtypep) { void methodCallAssoc(AstMethodCall* nodep, AstAssocArrayDType* adtypep) {
AstCMethodCall* newp = NULL; AstCMethodHard* newp = NULL;
if (nodep->name() == "num" // function int num() if (nodep->name() == "num" // function int num()
|| nodep->name() == "size") { || nodep->name() == "size") {
methodOkArguments(nodep, 0, 0); methodOkArguments(nodep, 0, 0);
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"size", NULL); // So don't need num() "size", NULL); // So don't need num()
newp->dtypeSetSigned32(); newp->dtypeSetSigned32();
@ -1952,7 +1952,7 @@ private:
|| nodep->name() == "prev") { || nodep->name() == "prev") {
methodOkArguments(nodep, 1, 1); methodOkArguments(nodep, 1, 1);
AstNode* index_exprp = methodCallAssocIndexExpr(nodep, adtypep); AstNode* index_exprp = methodCallAssocIndexExpr(nodep, adtypep);
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
nodep->name(), // first/last/next/prev nodep->name(), // first/last/next/prev
index_exprp->unlinkFrBack()); index_exprp->unlinkFrBack());
@ -1963,7 +1963,7 @@ private:
// IEEE really should have made this a "bit" return // IEEE really should have made this a "bit" return
methodOkArguments(nodep, 1, 1); methodOkArguments(nodep, 1, 1);
AstNode* index_exprp = methodCallAssocIndexExpr(nodep, adtypep); AstNode* index_exprp = methodCallAssocIndexExpr(nodep, adtypep);
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"exists", index_exprp->unlinkFrBack()); "exists", index_exprp->unlinkFrBack());
newp->dtypeSetSigned32(); newp->dtypeSetSigned32();
@ -1974,14 +1974,14 @@ private:
methodOkArguments(nodep, 0, 1); methodOkArguments(nodep, 0, 1);
methodCallLValue(nodep, nodep->fromp(), true); methodCallLValue(nodep, nodep->fromp(), true);
if (!nodep->pinsp()) { if (!nodep->pinsp()) {
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"clear", NULL); "clear", NULL);
newp->protect(false); newp->protect(false);
newp->makeStatement(); newp->makeStatement();
} else { } else {
AstNode* index_exprp = methodCallAssocIndexExpr(nodep, adtypep); AstNode* index_exprp = methodCallAssocIndexExpr(nodep, adtypep);
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"erase", "erase",
index_exprp->unlinkFrBack()); index_exprp->unlinkFrBack());
@ -2013,11 +2013,11 @@ private:
} }
} }
void methodCallQueue(AstMethodCall* nodep, AstQueueDType* adtypep) { void methodCallQueue(AstMethodCall* nodep, AstQueueDType* adtypep) {
AstCMethodCall* newp = NULL; AstCMethodHard* newp = NULL;
if (nodep->name() == "at") { // Created internally for [] if (nodep->name() == "at") { // Created internally for []
methodOkArguments(nodep, 1, 1); methodOkArguments(nodep, 1, 1);
methodCallLValue(nodep, nodep->fromp(), true); methodCallLValue(nodep, nodep->fromp(), true);
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"at", NULL); "at", NULL);
newp->dtypeFrom(adtypep->subDTypep()); newp->dtypeFrom(adtypep->subDTypep());
@ -2026,7 +2026,7 @@ private:
} else if (nodep->name() == "num" // function int num() } else if (nodep->name() == "num" // function int num()
|| nodep->name() == "size") { || nodep->name() == "size") {
methodOkArguments(nodep, 0, 0); methodOkArguments(nodep, 0, 0);
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"size", NULL); "size", NULL);
newp->dtypeSetSigned32(); newp->dtypeSetSigned32();
@ -2036,7 +2036,7 @@ private:
methodOkArguments(nodep, 0, 1); methodOkArguments(nodep, 0, 1);
methodCallLValue(nodep, nodep->fromp(), true); methodCallLValue(nodep, nodep->fromp(), true);
if (!nodep->pinsp()) { if (!nodep->pinsp()) {
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"clear", NULL); "clear", NULL);
newp->protect(false); newp->protect(false);
@ -2044,7 +2044,7 @@ private:
} else { } else {
AstNode* index_exprp = methodCallQueueIndexExpr(nodep); AstNode* index_exprp = methodCallQueueIndexExpr(nodep);
if (index_exprp->isZero()) { // delete(0) is a pop_front if (index_exprp->isZero()) { // delete(0) is a pop_front
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"pop_front", NULL); "pop_front", NULL);
newp->dtypeFrom(adtypep->subDTypep()); newp->dtypeFrom(adtypep->subDTypep());
@ -2053,7 +2053,7 @@ private:
newp->makeStatement(); newp->makeStatement();
} else { } else {
nodep->v3error("Unsupported: Queue .delete(index) method, as is O(n) complexity and slow."); nodep->v3error("Unsupported: Queue .delete(index) method, as is O(n) complexity and slow.");
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"erase", index_exprp->unlinkFrBack()); "erase", index_exprp->unlinkFrBack());
newp->protect(false); newp->protect(false);
@ -2067,14 +2067,14 @@ private:
AstArg* argp = VN_CAST(nodep->pinsp()->nextp(), Arg); AstArg* argp = VN_CAST(nodep->pinsp()->nextp(), Arg);
iterateCheckTyped(nodep, "insert value", argp->exprp(), adtypep->subDTypep(), BOTH); iterateCheckTyped(nodep, "insert value", argp->exprp(), adtypep->subDTypep(), BOTH);
if (index_exprp->isZero()) { // insert(0, ...) is a push_front if (index_exprp->isZero()) { // insert(0, ...) is a push_front
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
"push_front", argp->exprp()->unlinkFrBack()); "push_front", argp->exprp()->unlinkFrBack());
newp->protect(false); newp->protect(false);
newp->makeStatement(); newp->makeStatement();
} else { } else {
nodep->v3error("Unsupported: Queue .insert method, as is O(n) complexity and slow."); nodep->v3error("Unsupported: Queue .insert method, as is O(n) complexity and slow.");
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
nodep->name(), nodep->name(),
index_exprp->unlinkFrBack()); index_exprp->unlinkFrBack());
@ -2086,7 +2086,7 @@ private:
|| nodep->name() == "pop_back") { || nodep->name() == "pop_back") {
methodOkArguments(nodep, 0, 0); methodOkArguments(nodep, 0, 0);
methodCallLValue(nodep, nodep->fromp(), true); methodCallLValue(nodep, nodep->fromp(), true);
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
nodep->name(), NULL); nodep->name(), NULL);
newp->dtypeFrom(adtypep->subDTypep()); newp->dtypeFrom(adtypep->subDTypep());
@ -2101,7 +2101,7 @@ private:
methodCallLValue(nodep, nodep->fromp(), true); methodCallLValue(nodep, nodep->fromp(), true);
AstArg* argp = VN_CAST(nodep->pinsp(), Arg); AstArg* argp = VN_CAST(nodep->pinsp(), Arg);
iterateCheckTyped(nodep, "push value", argp->exprp(), adtypep->subDTypep(), BOTH); iterateCheckTyped(nodep, "push value", argp->exprp(), adtypep->subDTypep(), BOTH);
newp = new AstCMethodCall(nodep->fileline(), newp = new AstCMethodHard(nodep->fileline(),
nodep->fromp()->unlinkFrBack(), nodep->fromp()->unlinkFrBack(),
nodep->name(), argp->exprp()->unlinkFrBack()); nodep->name(), argp->exprp()->unlinkFrBack());
newp->protect(false); newp->protect(false);
@ -2737,7 +2737,7 @@ private:
newFormat += "%@"; newFormat += "%@";
AstNRelinker handle; AstNRelinker handle;
argp->unlinkFrBack(&handle); argp->unlinkFrBack(&handle);
AstCMethodCall* newp = new AstCMethodCall( AstCMethodHard* newp = new AstCMethodHard(
nodep->fileline(), argp, "to_string", NULL); nodep->fileline(), argp, "to_string", NULL);
newp->dtypeSetString(); newp->dtypeSetString();
newp->pure(true); newp->pure(true);

View File

@ -262,7 +262,7 @@ private:
else if (AstQueueDType* adtypep = VN_CAST(ddtypep, QueueDType)) { else if (AstQueueDType* adtypep = VN_CAST(ddtypep, QueueDType)) {
// SELBIT(array, index) -> CMETHODCALL(queue, "at", index) // SELBIT(array, index) -> CMETHODCALL(queue, "at", index)
AstNode* subp = rhsp; AstNode* subp = rhsp;
AstCMethodCall* newp = new AstCMethodCall(nodep->fileline(), AstCMethodHard* newp = new AstCMethodHard(nodep->fileline(),
fromp, "at", subp); fromp, "at", subp);
newp->dtypeFrom(adtypep->subDTypep()); // Need to strip off queue reference newp->dtypeFrom(adtypep->subDTypep()); // Need to strip off queue reference
if (debug()>=9) newp->dumpTree(cout, "--SELBTq: "); if (debug()>=9) newp->dumpTree(cout, "--SELBTq: ");