mirror of
https://github.com/verilator/verilator.git
synced 2026-10-06 18:13:50 +02:00
Internals: Improve astgen type enums to be switch statement friendly (#6362)
- Remove _ENUM_END, so -Wswitch does not demand it's covered. Use the new NUM_TYPES constexpr member instead. - Remove 'at' prefix. This seems historical and is not particularly useful. - Fix some cppcheck warts while at it
This commit is contained in:
+6
-8
@@ -387,9 +387,9 @@ static AstNode* createForeachLoop(AstNodeForeach* nodep, AstNode* bodysp, AstVar
|
||||
AstNodeExpr* condp;
|
||||
bool inc = true;
|
||||
switch (nodeType) {
|
||||
case VNType::atLteS: condp = new AstLteS{fl, varRefp, rightp}; break;
|
||||
case VNType::atLt: condp = new AstLt{fl, varRefp, rightp}; break;
|
||||
case VNType::atGteS:
|
||||
case VNType::LteS: condp = new AstLteS{fl, varRefp, rightp}; break;
|
||||
case VNType::Lt: condp = new AstLt{fl, varRefp, rightp}; break;
|
||||
case VNType::GteS:
|
||||
condp = new AstGteS{fl, varRefp, rightp};
|
||||
inc = false;
|
||||
break;
|
||||
@@ -419,8 +419,7 @@ static AstNode* createForeachLoopRanged(AstNodeForeach* nodep, AstNode* bodysp,
|
||||
AstNodeExpr* const leftp = new AstConst{fl, left};
|
||||
AstNodeExpr* const rightp = new AstConst{fl, right};
|
||||
return createForeachLoop(nodep, bodysp, varp, leftp, rightp,
|
||||
declRange.left() <= declRange.right() ? VNType::atLteS
|
||||
: VNType::atGteS);
|
||||
declRange.left() <= declRange.right() ? VNType::LteS : VNType::GteS);
|
||||
}
|
||||
AstNode* V3Begin::convertToWhile(AstForeach* nodep) {
|
||||
// UINFOTREE(1, nodep, "", "foreach-old");
|
||||
@@ -459,8 +458,7 @@ AstNode* V3Begin::convertToWhile(AstForeach* nodep) {
|
||||
if (adtypep->isString()) {
|
||||
AstConst* const leftp = new AstConst{fl, 0};
|
||||
AstNodeExpr* const rightp = new AstLenN{fl, fromp->cloneTreePure(false)};
|
||||
loopp
|
||||
= createForeachLoop(nodep, bodyPointp, varp, leftp, rightp, VNType::atLt);
|
||||
loopp = createForeachLoop(nodep, bodyPointp, varp, leftp, rightp, VNType::Lt);
|
||||
} else {
|
||||
UASSERT_OBJ(adtypep->isRanged(), varp, "foreach on basic " << adtypep);
|
||||
loopp = createForeachLoopRanged(nodep, bodyPointp, varp, adtypep->declRange());
|
||||
@@ -479,7 +477,7 @@ AstNode* V3Begin::convertToWhile(AstForeach* nodep) {
|
||||
subfromp->dtypep(fromDtp);
|
||||
rightp->dtypeSetSigned32();
|
||||
rightp->protect(false);
|
||||
loopp = createForeachLoop(nodep, bodyPointp, varp, leftp, rightp, VNType::atLt);
|
||||
loopp = createForeachLoop(nodep, bodyPointp, varp, leftp, rightp, VNType::Lt);
|
||||
} else if (VN_IS(fromDtp, AssocArrayDType)) {
|
||||
// Make this: var KEY_TYPE index;
|
||||
// bit index__Vfirst;
|
||||
|
||||
Reference in New Issue
Block a user