Fix break under foreach loop (#3230).

Internals: Move Foreach handling into V3Width.
This commit is contained in:
Wilson Snyder
2021-12-11 15:06:33 -05:00
parent 00ef0519f5
commit 984ee624ed
14 changed files with 315 additions and 80 deletions
+15 -1
View File
@@ -46,7 +46,7 @@ private:
// STATE
AstNodeModule* m_modp = nullptr; // Current module
AstNodeFTask* m_ftaskp = nullptr; // Current function/task
AstWhile* m_loopp = nullptr; // Current loop
AstNode* m_loopp = nullptr; // Current loop
bool m_loopInc = false; // In loop increment
bool m_inFork = false; // Under fork
int m_modRepeatNum = 0; // Repeat counter
@@ -66,6 +66,13 @@ private:
underp = VN_AS(nodep, NodeBlock)->stmtsp();
} else if (VN_IS(nodep, NodeFTask)) {
underp = VN_AS(nodep, NodeFTask)->stmtsp();
} else if (VN_IS(nodep, Foreach)) {
if (endOfIter) {
underp = VN_AS(nodep, Foreach)->bodysp();
} else {
underp = nodep;
under_and_next = false; // IE we skip the entire foreach
}
} else if (VN_IS(nodep, While)) {
if (endOfIter) {
// Note we jump to end of bodysp; a FOR loop has its
@@ -192,6 +199,13 @@ private:
iterateAndNextNull(nodep->incsp());
}
}
virtual void visit(AstForeach* nodep) override {
VL_RESTORER(m_loopp);
{
m_loopp = nodep;
iterateAndNextNull(nodep->bodysp());
}
}
virtual void visit(AstReturn* nodep) override {
iterateChildren(nodep);
const AstFunc* const funcp = VN_CAST(m_ftaskp, Func);