Internal cleanup: no functional change.

Add cloneTree to each node type so cast not required after use.
Standardize declaring common AstNode functions via a macro.
This commit is contained in:
Wilson Snyder 2008-11-19 20:15:05 -05:00
parent a4bcb3de4a
commit ab668b066f
15 changed files with 209 additions and 665 deletions

View File

@ -129,7 +129,7 @@ public:
found: found:
// Not found, form a new one // Not found, form a new one
if (!activep) { if (!activep) {
AstSenTree* newsenp = sensesp->cloneTree(false)->castSenTree(); AstSenTree* newsenp = sensesp->cloneTree(false);
activep = new AstActive(fl, "sequent", newsenp); activep = new AstActive(fl, "sequent", newsenp);
activep->sensesStorep(activep->sensesp()); activep->sensesStorep(activep->sensesp());
UINFO(8," New ACTIVE "<<activep<<endl); UINFO(8," New ACTIVE "<<activep<<endl);

View File

@ -703,11 +703,15 @@ inline void AstNRelinker::relink(AstNode* newp) { newp->AstNode::relink(this); }
//###################################################################### //######################################################################
//=== AstNode* : Derived generic node types //=== AstNode* : Derived generic node types
#define ASTNODE_BASE_FUNCS(name) \
virtual ~Ast ##name() {} \
Ast ##name * cloneTree(bool cloneNext) { return AstNode::cloneTree(cloneNext)->cast ##name(); }
struct AstNodeMath : public AstNode { struct AstNodeMath : public AstNode {
// Math -- anything that's part of an expression tree // Math -- anything that's part of an expression tree
AstNodeMath(FileLine* fl) AstNodeMath(FileLine* fl)
: AstNode(fl) {} : AstNode(fl) {}
virtual ~AstNodeMath() {} ASTNODE_BASE_FUNCS(NodeMath)
// METHODS // METHODS
virtual string emitVerilog() = 0; /// Format string for verilog writing; see V3EmitV virtual string emitVerilog() = 0; /// Format string for verilog writing; see V3EmitV
virtual string emitC() = 0; virtual string emitC() = 0;
@ -719,7 +723,7 @@ struct AstNodeTermop : public AstNodeMath {
// Terminal operator -- a operator with no "inputs" // Terminal operator -- a operator with no "inputs"
AstNodeTermop(FileLine* fl) AstNodeTermop(FileLine* fl)
: AstNodeMath(fl) {} : AstNodeMath(fl) {}
virtual ~AstNodeTermop() {} ASTNODE_BASE_FUNCS(NodeTermop)
}; };
struct AstNodeUniop : public AstNodeMath { struct AstNodeUniop : public AstNodeMath {
@ -728,7 +732,7 @@ struct AstNodeUniop : public AstNodeMath {
: AstNodeMath(fl) { : AstNodeMath(fl) {
if (lhsp) widthSignedFrom(lhsp); if (lhsp) widthSignedFrom(lhsp);
setOp1p(lhsp); } setOp1p(lhsp); }
virtual ~AstNodeUniop() {} ASTNODE_BASE_FUNCS(NodeUniop)
AstNode* lhsp() const { return op1p()->castNode(); } AstNode* lhsp() const { return op1p()->castNode(); }
// METHODS // METHODS
virtual void numberOperate(V3Number& out, const V3Number& lhs) = 0; // Set out to evaluation of a AstConst'ed lhs virtual void numberOperate(V3Number& out, const V3Number& lhs) = 0; // Set out to evaluation of a AstConst'ed lhs
@ -744,7 +748,7 @@ struct AstNodeBiop : public AstNodeMath {
AstNodeBiop(FileLine* fl, AstNode* lhs, AstNode* rhs) AstNodeBiop(FileLine* fl, AstNode* lhs, AstNode* rhs)
: AstNodeMath(fl) { : AstNodeMath(fl) {
setOp1p(lhs); setOp2p(rhs); } setOp1p(lhs); setOp2p(rhs); }
virtual ~AstNodeBiop() {} ASTNODE_BASE_FUNCS(NodeBiop)
AstNode* lhsp() const { return op1p()->castNode(); } AstNode* lhsp() const { return op1p()->castNode(); }
AstNode* rhsp() const { return op2p()->castNode(); } AstNode* rhsp() const { return op2p()->castNode(); }
void lhsp(AstNode* nodep) { return setOp1p(nodep); } void lhsp(AstNode* nodep) { return setOp1p(nodep); }
@ -766,7 +770,7 @@ struct AstNodeTriop : public AstNodeMath {
AstNodeTriop(FileLine* fl, AstNode* lhs, AstNode* rhs, AstNode* ths) AstNodeTriop(FileLine* fl, AstNode* lhs, AstNode* rhs, AstNode* ths)
: AstNodeMath(fl) { : AstNodeMath(fl) {
setOp1p(lhs); setOp2p(rhs); setOp3p(ths); } setOp1p(lhs); setOp2p(rhs); setOp3p(ths); }
virtual ~AstNodeTriop() {} ASTNODE_BASE_FUNCS(NodeTriop)
AstNode* lhsp() const { return op1p()->castNode(); } AstNode* lhsp() const { return op1p()->castNode(); }
AstNode* rhsp() const { return op2p()->castNode(); } AstNode* rhsp() const { return op2p()->castNode(); }
AstNode* thsp() const { return op3p()->castNode(); } AstNode* thsp() const { return op3p()->castNode(); }
@ -790,14 +794,14 @@ struct AstNodeBiCom : public AstNodeBiop {
// Binary math with commutative properties // Binary math with commutative properties
AstNodeBiCom(FileLine* fl, AstNode* lhs, AstNode* rhs) AstNodeBiCom(FileLine* fl, AstNode* lhs, AstNode* rhs)
: AstNodeBiop(fl, lhs, rhs) {} : AstNodeBiop(fl, lhs, rhs) {}
virtual ~AstNodeBiCom() {} ASTNODE_BASE_FUNCS(NodeBiCom)
}; };
struct AstNodeBiComAsv : public AstNodeBiCom { struct AstNodeBiComAsv : public AstNodeBiCom {
// Binary math with commutative & associative properties // Binary math with commutative & associative properties
AstNodeBiComAsv(FileLine* fl, AstNode* lhs, AstNode* rhs) AstNodeBiComAsv(FileLine* fl, AstNode* lhs, AstNode* rhs)
: AstNodeBiCom(fl, lhs, rhs) {} : AstNodeBiCom(fl, lhs, rhs) {}
virtual ~AstNodeBiComAsv() {} ASTNODE_BASE_FUNCS(NodeBiComAsv)
}; };
struct AstNodeCond : public AstNodeTriop { struct AstNodeCond : public AstNodeTriop {
AstNodeCond(FileLine* fl, AstNode* condp, AstNode* expr1p, AstNode* expr2p) AstNodeCond(FileLine* fl, AstNode* condp, AstNode* expr1p, AstNode* expr2p)
@ -805,7 +809,7 @@ struct AstNodeCond : public AstNodeTriop {
if (expr1p) widthSignedFrom(expr1p); if (expr1p) widthSignedFrom(expr1p);
else if (expr2p) widthSignedFrom(expr2p); else if (expr2p) widthSignedFrom(expr2p);
} }
virtual ~AstNodeCond() {} ASTNODE_BASE_FUNCS(NodeCond)
virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, const V3Number& ths) { virtual void numberOperate(V3Number& out, const V3Number& lhs, const V3Number& rhs, const V3Number& ths) {
if (lhs.isNeqZero()) out.opAssign(rhs); else out.opAssign(ths); } if (lhs.isNeqZero()) out.opAssign(rhs); else out.opAssign(ths); }
AstNode* condp() const { return op1p()->castNode(); } // op1 = Condition AstNode* condp() const { return op1p()->castNode(); } // op1 = Condition
@ -826,7 +830,7 @@ struct AstNodePreSel : public AstNode {
AstNodePreSel(FileLine* fl, AstNode* lhs, AstNode* rhs, AstNode* ths) AstNodePreSel(FileLine* fl, AstNode* lhs, AstNode* rhs, AstNode* ths)
: AstNode(fl) { : AstNode(fl) {
setOp1p(lhs); setOp2p(rhs); setNOp3p(ths); } setOp1p(lhs); setOp2p(rhs); setNOp3p(ths); }
virtual ~AstNodePreSel() {} ASTNODE_BASE_FUNCS(NodePreSel)
AstNode* lhsp() const { return op1p()->castNode(); } AstNode* lhsp() const { return op1p()->castNode(); }
AstNode* rhsp() const { return op2p()->castNode(); } AstNode* rhsp() const { return op2p()->castNode(); }
AstNode* thsp() const { return op3p()->castNode(); } AstNode* thsp() const { return op3p()->castNode(); }
@ -842,7 +846,7 @@ struct AstNodeStmt : public AstNode {
// Statement -- anything that's directly under a function // Statement -- anything that's directly under a function
AstNodeStmt(FileLine* fl) AstNodeStmt(FileLine* fl)
: AstNode(fl) {} : AstNode(fl) {}
virtual ~AstNodeStmt() {} ASTNODE_BASE_FUNCS(NodeStmt)
// METHODS // METHODS
}; };
@ -852,7 +856,7 @@ struct AstNodeAssign : public AstNodeStmt {
setOp1p(rhsp); setOp2p(lhsp); setOp1p(rhsp); setOp2p(lhsp);
if (lhsp) widthSignedFrom(lhsp); if (lhsp) widthSignedFrom(lhsp);
} }
virtual ~AstNodeAssign() {} ASTNODE_BASE_FUNCS(NodeAssign)
virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp)=0; // Clone single node, just get same type back. virtual AstNode* cloneType(AstNode* lhsp, AstNode* rhsp)=0; // Clone single node, just get same type back.
// So iteration hits the RHS which is "earlier" in execution order, it's op1, not op2 // So iteration hits the RHS which is "earlier" in execution order, it's op1, not op2
AstNode* rhsp() const { return op1p()->castNode(); } // op1 = Assign from AstNode* rhsp() const { return op1p()->castNode(); } // op1 = Assign from
@ -871,7 +875,7 @@ struct AstNodeFor : public AstNodeStmt {
: AstNodeStmt(fileline) { : AstNodeStmt(fileline) {
addNOp1p(initsp); setOp2p(condp); addNOp3p(incsp); addNOp4p(bodysp); addNOp1p(initsp); setOp2p(condp); addNOp3p(incsp); addNOp4p(bodysp);
} }
virtual ~AstNodeFor() {} ASTNODE_BASE_FUNCS(NodeFor)
AstNode* initsp() const { return op1p()->castNode(); } // op1= initial statements AstNode* initsp() const { return op1p()->castNode(); } // op1= initial statements
AstNode* condp() const { return op2p()->castNode(); } // op2= condition to continue AstNode* condp() const { return op2p()->castNode(); } // op2= condition to continue
AstNode* incsp() const { return op3p()->castNode(); } // op3= increment statements AstNode* incsp() const { return op3p()->castNode(); } // op3= increment statements
@ -891,7 +895,7 @@ public:
: AstNodeStmt(fl) { : AstNodeStmt(fl) {
setOp1p(condp); addNOp2p(ifsp); addNOp3p(elsesp); setOp1p(condp); addNOp2p(ifsp); addNOp3p(elsesp);
} }
virtual ~AstNodeIf() {} ASTNODE_BASE_FUNCS(NodeIf)
AstNode* condp() const { return op1p(); } // op1 = condition AstNode* condp() const { return op1p(); } // op1 = condition
AstNode* ifsp() const { return op2p(); } // op2 = list of true statements AstNode* ifsp() const { return op2p(); } // op2 = list of true statements
AstNode* elsesp() const { return op3p(); } // op3 = list of false statements AstNode* elsesp() const { return op3p(); } // op3 = list of false statements
@ -911,7 +915,7 @@ struct AstNodeCase : public AstNodeStmt {
: AstNodeStmt(fl) { : AstNodeStmt(fl) {
setOp1p(exprp); addNOp2p(casesp); setOp1p(exprp); addNOp2p(casesp);
} }
virtual ~AstNodeCase() {} ASTNODE_BASE_FUNCS(NodeCase)
virtual int instrCount() const { return instrCountBranch(); } virtual int instrCount() const { return instrCountBranch(); }
AstNode* exprp() const { return op1p()->castNode(); } // op1 = case condition <expression> AstNode* exprp() const { return op1p()->castNode(); } // op1 = case condition <expression>
AstCaseItem* itemsp() const { return op2p()->castCaseItem(); } // op2 = list of case expressions AstCaseItem* itemsp() const { return op2p()->castCaseItem(); } // op2 = list of case expressions
@ -940,7 +944,7 @@ public:
// May have varp==NULL // May have varp==NULL
if (m_varp) widthSignedFrom((AstNode*)m_varp); if (m_varp) widthSignedFrom((AstNode*)m_varp);
} }
virtual ~AstNodeVarRef() {} ASTNODE_BASE_FUNCS(NodeVarRef)
virtual bool broken() const; virtual bool broken() const;
virtual int instrCount() const { return widthInstrs(); } virtual int instrCount() const { return widthInstrs(); }
virtual void cloneRelink(); virtual void cloneRelink();
@ -964,7 +968,7 @@ public:
AstNodePli(FileLine* fl, const string& text, AstNode* exprsp) AstNodePli(FileLine* fl, const string& text, AstNode* exprsp)
: AstNodeStmt(fl), m_text(text) { : AstNodeStmt(fl), m_text(text) {
addNOp1p(exprsp); } addNOp1p(exprsp); }
virtual ~AstNodePli() {} ASTNODE_BASE_FUNCS(NodePli)
virtual string name() const { return m_text; } virtual string name() const { return m_text; }
virtual int instrCount() const { return instrCountPli(); } virtual int instrCount() const { return instrCountPli(); }
void exprsp(AstNode* nodep) { addOp1p(nodep); } // op1 = Expressions to output void exprsp(AstNode* nodep) { addOp1p(nodep); } // op1 = Expressions to output
@ -983,7 +987,7 @@ public:
: AstNode(fileline) { : AstNode(fileline) {
m_text = textp; // Copy it m_text = textp; // Copy it
} }
virtual ~AstNodeText() {} ASTNODE_BASE_FUNCS(NodeText)
const string& text() const { return m_text; } const string& text() const { return m_text; }
virtual V3Hash sameHash() const { return V3Hash(text()); } virtual V3Hash sameHash() const { return V3Hash(text()); }
virtual bool same(AstNode* samep) const { virtual bool same(AstNode* samep) const {
@ -1013,7 +1017,7 @@ public:
, m_name(name), m_taskPublic(false) { , m_name(name), m_taskPublic(false) {
addNOp3p(stmtsp); addNOp3p(stmtsp);
} }
virtual ~AstNodeFTask() {} ASTNODE_BASE_FUNCS(NodeFTask)
virtual void dump(ostream& str=cout); virtual void dump(ostream& str=cout);
virtual string name() const { return m_name; } // * = Var name virtual string name() const { return m_name; } // * = Var name
virtual bool maybePointedTo() const { return true; } virtual bool maybePointedTo() const { return true; }
@ -1039,7 +1043,7 @@ public:
, m_taskp(NULL) { , m_taskp(NULL) {
setOp1p(namep); addNOp2p(pinsp); setOp1p(namep); addNOp2p(pinsp);
} }
virtual ~AstNodeFTaskRef() {} ASTNODE_BASE_FUNCS(NodeFTaskRef)
virtual bool broken() const { return m_taskp && !m_taskp->brokeExists(); } virtual bool broken() const { return m_taskp && !m_taskp->brokeExists(); }
virtual void cloneRelink() { if (m_taskp && m_taskp->clonep()) { virtual void cloneRelink() { if (m_taskp && m_taskp->clonep()) {
m_taskp = m_taskp->clonep()->castNodeFTask(); m_taskp = m_taskp->clonep()->castNodeFTask();

File diff suppressed because it is too large Load Diff

View File

@ -535,7 +535,7 @@ private:
AstNode* ap = lhsp->lhsp()->unlinkFrBack(); AstNode* ap = lhsp->lhsp()->unlinkFrBack();
AstNode* bp = lhsp->rhsp()->unlinkFrBack(); AstNode* bp = lhsp->rhsp()->unlinkFrBack();
AstNodeBiop* shift1p = nodep; AstNodeBiop* shift1p = nodep;
AstNodeBiop* shift2p = nodep->cloneTree(true)->castNodeBiop(); AstNodeBiop* shift2p = nodep->cloneTree(true);
shift1p->lhsp(ap); shift1p->rhsp(shiftp->cloneTree(true)); shift1p->lhsp(ap); shift1p->rhsp(shiftp->cloneTree(true));
shift2p->lhsp(bp); shift2p->rhsp(shiftp); shift2p->lhsp(bp); shift2p->rhsp(shiftp);
AstNodeBiop* newp = lhsp; AstNodeBiop* newp = lhsp;

View File

@ -370,8 +370,8 @@ private:
UINFO(4," Act: "<<m_activep<<endl); UINFO(4," Act: "<<m_activep<<endl);
UINFO(4," Act: "<<oldactivep<<endl); UINFO(4," Act: "<<oldactivep<<endl);
// Make a new sensitivity list, which is the combination of both blocks // Make a new sensitivity list, which is the combination of both blocks
AstSenItem* sena = m_activep->sensesp()->sensesp()->cloneTree(true)->castSenItem(); AstSenItem* sena = m_activep->sensesp()->sensesp()->cloneTree(true);
AstSenItem* senb = oldactivep->sensesp()->sensesp()->cloneTree(true)->castSenItem(); AstSenItem* senb = oldactivep->sensesp()->sensesp()->cloneTree(true);
AstSenTree* treep = new AstSenTree(m_activep->fileline(), sena); AstSenTree* treep = new AstSenTree(m_activep->fileline(), sena);
if (senb) treep->addSensesp(senb); if (senb) treep->addSensesp(senb);
if (AstSenTree* storep = oldactivep->sensesStorep()) { if (AstSenTree* storep = oldactivep->sensesStorep()) {

View File

@ -106,7 +106,7 @@ private:
if (moreOfSame1) { if (moreOfSame1) {
// Multiple functions under this name, need a wrapper function // Multiple functions under this name, need a wrapper function
UINFO(6," Wrapping "<<name<<" multifuncs\n"); UINFO(6," Wrapping "<<name<<" multifuncs\n");
AstCFunc* newfuncp = topFuncp->cloneTree(false)->castCFunc(); AstCFunc* newfuncp = topFuncp->cloneTree(false);
if (newfuncp->initsp()) newfuncp->initsp()->unlinkFrBackWithNext()->deleteTree(); if (newfuncp->initsp()) newfuncp->initsp()->unlinkFrBackWithNext()->deleteTree();
if (newfuncp->stmtsp()) newfuncp->stmtsp()->unlinkFrBackWithNext()->deleteTree(); if (newfuncp->stmtsp()) newfuncp->stmtsp()->unlinkFrBackWithNext()->deleteTree();
if (newfuncp->finalsp()) newfuncp->finalsp()->unlinkFrBackWithNext()->deleteTree(); if (newfuncp->finalsp()) newfuncp->finalsp()->unlinkFrBackWithNext()->deleteTree();

View File

@ -102,7 +102,7 @@ private:
m_statCells++; m_statCells++;
if (debug()>=9) { nodep->dumpTree(cout,"inlcell:"); } if (debug()>=9) { nodep->dumpTree(cout,"inlcell:"); }
//if (debug()>=9) { nodep->modp()->dumpTree(cout,"oldmod:"); } //if (debug()>=9) { nodep->modp()->dumpTree(cout,"oldmod:"); }
AstModule* newmodp = nodep->modp()->cloneTree(false)->castModule(); AstModule* newmodp = nodep->modp()->cloneTree(false);
if (debug()>=9) { newmodp->dumpTree(cout,"newmod:"); } if (debug()>=9) { newmodp->dumpTree(cout,"newmod:"); }
// Clear var markings // Clear var markings
AstNode::user2ClearTree(); AstNode::user2ClearTree();

View File

@ -156,7 +156,7 @@ private:
// Make all of the required clones // Make all of the required clones
m_instLsb = m_cellRangep->lsbConst(); m_instLsb = m_cellRangep->lsbConst();
for (m_instNum = m_instLsb; m_instNum<=m_cellRangep->msbConst(); m_instNum++) { for (m_instNum = m_instLsb; m_instNum<=m_cellRangep->msbConst(); m_instNum++) {
AstCell* newp = nodep->cloneTree(false)->castCell(); AstCell* newp = nodep->cloneTree(false);
nodep->addNextHere(newp); nodep->addNextHere(newp);
// Remove ranging and fix name // Remove ranging and fix name
newp->rangep()->unlinkFrBack()->deleteTree(); newp->rangep()->unlinkFrBack()->deleteTree();

View File

@ -156,7 +156,7 @@ void V3LinkLevel::wrapTop(AstNetlist* netlistp) {
if (AstVar* oldvarp=subnodep->castVar()) { if (AstVar* oldvarp=subnodep->castVar()) {
UINFO(8,"VARWRAP "<<oldvarp<<endl); UINFO(8,"VARWRAP "<<oldvarp<<endl);
if (oldvarp->isIO()) { if (oldvarp->isIO()) {
AstVar* varp = oldvarp->cloneTree(false)->castVar(); AstVar* varp = oldvarp->cloneTree(false);
newmodp->addStmtp(varp); newmodp->addStmtp(varp);
varp->sigPublic(true); // User needs to be able to get to it... varp->sigPublic(true); // User needs to be able to get to it...
if (oldvarp->isIO()) { if (oldvarp->isIO()) {

View File

@ -1085,8 +1085,8 @@ void OrderVisitor::processDomainsIterate(OrderEitherVertex* vertexp) {
UINFO(0," d2 ="<<fromVertexp->domainp()<<endl); UINFO(0," d2 ="<<fromVertexp->domainp()<<endl);
fromVertexp->domainp()->dumpTree(cout); fromVertexp->domainp()->dumpTree(cout);
} }
AstSenTree* newtreep = domainp->cloneTree(false)->castSenTree(); AstSenTree* newtreep = domainp->cloneTree(false);
AstSenItem* newtree2p = fromVertexp->domainp()->sensesp()->cloneTree(true)->castSenItem(); AstSenItem* newtree2p = fromVertexp->domainp()->sensesp()->cloneTree(true);
if (!newtree2p) fromVertexp->domainp()->v3fatalSrc("No senitem found under clocked domain"); if (!newtree2p) fromVertexp->domainp()->v3fatalSrc("No senitem found under clocked domain");
newtreep->addSensesp(newtree2p); newtreep->addSensesp(newtree2p);
newtreep->sortSenses(); // Remove duplicates newtreep->sortSenses(); // Remove duplicates

View File

@ -285,7 +285,7 @@ void ParamVisitor::visit(AstCell* nodep, AstNUser*) {
// Deep clone of new module // Deep clone of new module
// Note all module internal variables will be re-linked to the new modules by clone // Note all module internal variables will be re-linked to the new modules by clone
// However links outside the module (like on the upper cells) will not. // However links outside the module (like on the upper cells) will not.
modp = nodep->modp()->cloneTree(false)->castModule(); modp = nodep->modp()->cloneTree(false);
modp->name(newname); modp->name(newname);
nodep->modp()->addNextHere(modp); // Keep tree sorted by cell occurrences nodep->modp()->addNextHere(modp); // Keep tree sorted by cell occurrences

View File

@ -120,14 +120,14 @@ private:
virtual void visit(AstInitial* nodep, AstNUser*) { virtual void visit(AstInitial* nodep, AstNUser*) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
UINFO(4," Move "<<nodep<<endl); UINFO(4," Move "<<nodep<<endl);
AstInitial* clonep = nodep->cloneTree(false)->castInitial(); AstInitial* clonep = nodep->cloneTree(false);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* clonep->iterateChildren(*this); // We iterate under the *clone*
} }
virtual void visit(AstFinal* nodep, AstNUser*) { virtual void visit(AstFinal* nodep, AstNUser*) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
UINFO(4," Move "<<nodep<<endl); UINFO(4," Move "<<nodep<<endl);
AstFinal* clonep = nodep->cloneTree(false)->castFinal(); AstFinal* clonep = nodep->cloneTree(false);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* clonep->iterateChildren(*this); // We iterate under the *clone*
} }
@ -148,14 +148,14 @@ private:
virtual void visit(AstAlways* nodep, AstNUser*) { virtual void visit(AstAlways* nodep, AstNUser*) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
UINFO(4," Move "<<nodep<<endl); UINFO(4," Move "<<nodep<<endl);
AstAlways* clonep = nodep->cloneTree(false)->castAlways(); AstAlways* clonep = nodep->cloneTree(false);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
clonep->iterateChildren(*this); // We iterate under the *clone* clonep->iterateChildren(*this); // We iterate under the *clone*
} }
virtual void visit(AstCFunc* nodep, AstNUser*) { virtual void visit(AstCFunc* nodep, AstNUser*) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
UINFO(4," CFUNC "<<nodep<<endl); UINFO(4," CFUNC "<<nodep<<endl);
AstCFunc* clonep = nodep->cloneTree(false)->castCFunc(); AstCFunc* clonep = nodep->cloneTree(false);
clonep->scopep(m_scopep); clonep->scopep(m_scopep);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
// We iterate under the *clone* // We iterate under the *clone*
@ -164,7 +164,7 @@ private:
virtual void visit(AstNodeFTask* nodep, AstNUser*) { virtual void visit(AstNodeFTask* nodep, AstNUser*) {
// Add to list of blocks under this scope // Add to list of blocks under this scope
UINFO(4," FTASK "<<nodep<<endl); UINFO(4," FTASK "<<nodep<<endl);
AstNodeFTask* clonep = nodep->cloneTree(false)->castNodeFTask(); AstNodeFTask* clonep = nodep->cloneTree(false);
m_scopep->addActivep(clonep); m_scopep->addActivep(clonep);
// We iterate under the *clone* // We iterate under the *clone*
clonep->iterateChildren(*this); clonep->iterateChildren(*this);

View File

@ -109,7 +109,7 @@ public:
// Not found, form a new one // Not found, form a new one
if (!treep) { if (!treep) {
UASSERT(m_topscopep,"Never called main()"); UASSERT(m_topscopep,"Never called main()");
treep = sensesp->cloneTree(false)->castSenTree(); treep = sensesp->cloneTree(false);
m_topscopep->addStmtsp(treep); m_topscopep->addStmtsp(treep);
UINFO(8," New SENTREE "<<treep<<endl); UINFO(8," New SENTREE "<<treep<<endl);
m_treesp.push_back(treep); m_treesp.push_back(treep);

View File

@ -149,7 +149,7 @@ private:
UINFO(3," For "<<m_splitVscp<<endl); UINFO(3," For "<<m_splitVscp<<endl);
if (debug()>=9) nodep->dumpTree(cout,"-in : "); if (debug()>=9) nodep->dumpTree(cout,"-in : ");
// Duplicate it and link in // Duplicate it and link in
AstAlways* newp = nodep->cloneTree(false)->castAlways(); AstAlways* newp = nodep->cloneTree(false);
newp->user(true); // So we don't clone it again newp->user(true); // So we don't clone it again
nodep->addNextHere(newp); nodep->addNextHere(newp);
{ // Delete stuff we don't want in old { // Delete stuff we don't want in old

View File

@ -677,14 +677,14 @@ private:
if (nodep->taskPublic()) { if (nodep->taskPublic()) {
// Clone it first, because we may have later FTaskRef's that still need // Clone it first, because we may have later FTaskRef's that still need
// the original version. // the original version.
AstNodeFTask* clonedFuncp = nodep->cloneTree(false)->castNodeFTask(); AstNodeFTask* clonedFuncp = nodep->cloneTree(false);
AstCFunc* cfuncp = makeUserFunc(clonedFuncp, true); AstCFunc* cfuncp = makeUserFunc(clonedFuncp, true);
nodep->addNextHere(cfuncp); nodep->addNextHere(cfuncp);
iterateIntoFTask(clonedFuncp); // Do the clone too iterateIntoFTask(clonedFuncp); // Do the clone too
} }
if (m_statep->ftaskNoInline(nodep)) { if (m_statep->ftaskNoInline(nodep)) {
m_statep->checkPurity(nodep); m_statep->checkPurity(nodep);
AstNodeFTask* clonedFuncp = nodep->cloneTree(false)->castNodeFTask(); AstNodeFTask* clonedFuncp = nodep->cloneTree(false);
AstCFunc* cfuncp = makeUserFunc(clonedFuncp, false); AstCFunc* cfuncp = makeUserFunc(clonedFuncp, false);
nodep->user5p(cfuncp); nodep->user5p(cfuncp);
nodep->addNextHere(cfuncp); nodep->addNextHere(cfuncp);