Support array map() method (#7307) (#7316)

This commit is contained in:
Wei-Lun Chiu
2026-03-24 02:38:50 -07:00
committed by GitHub
parent 9a01a4054a
commit 6873dc2f63
8 changed files with 49 additions and 58 deletions
+12 -3
View File
@@ -4241,9 +4241,18 @@ class WidthVisitor final : public VNVisitor {
newp->dtypep(newp->findQueueIndexDType());
if (!nodep->firstAbovep()) newp->dtypeSetVoid();
} else if (nodep->name() == "map") {
nodep->v3warn(E_UNSUPPORTED,
"Unsupported: Array 'map' method (IEEE 1800-2023 7.12.5)");
nodep->dtypeFrom(adtypep->subDTypep()); // Best guess
// map() - IEEE 1800-2023 7.12.5
// Returns a queue with same element count, each element is the with expression result
AstWith* const withp
= methodWithClause(nodep, true, false, adtypep->subDTypep(),
nodep->findUInt32DType(), adtypep->subDTypep());
methodOkArguments(nodep, 0, 0);
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::READ);
newp = new AstCMethodHard{nodep->fileline(), nodep->fromp()->unlinkFrBack(),
VCMethod::ARRAY_MAP};
newp->withp(withp);
newp->dtypep(queueDTypeIndexedBy(withp ? withp->dtypep() : adtypep->subDTypep()));
if (!nodep->firstAbovep()) newp->dtypeSetVoid();
}
return newp;
}