Internals: Move DPI export AstScopeName out of statement list (#6280) (#8139)

AstScopeName is an AstNodeExpr, but V3Task stashed the DPI export scoping
marker into the enclosing AstCFunc's statement list (addStmtsp), placing an
expression in a statement position.

Give AstCFunc a dedicated 'scopeNamep' operand to hold the marker instead.
Part of #6280
This commit is contained in:
Geza Lore 2026-08-18 11:25:12 +02:00 committed by GitHub
parent 8baff6ae33
commit d9fb606869
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -508,6 +508,7 @@ class AstCFunc final : public AstNode {
// @astgen op1 := argsp : List[AstVar] // Argument (and return value) variables
// @astgen op2 := varsp : List[AstVar] // Local variables
// @astgen op3 := stmtsp : List[AstNode]
// @astgen op4 := scopeNamep : Optional[AstScopeName] // Scoping context for DPI export
//
// @astgen ptr := m_scopep : Optional[AstScope] // Scope that function is under
string m_name;
@ -658,7 +659,7 @@ public:
void cost(int cost) { m_cost = cost; }
// Special methods
bool emptyBody() const {
return !keepIfEmpty() && !argsp() && !varsp() && !stmtsp() && !isVirtual()
return !keepIfEmpty() && !argsp() && !varsp() && !stmtsp() && !scopeNamep() && !isVirtual()
&& !dpiImportPrototype();
}
};

View File

@ -1388,10 +1388,9 @@ class TaskVisitor final : public VNVisitor {
if (nodep->dpiExport()) {
AstScopeName* const snp = nodep->scopeNamep();
UASSERT_OBJ(snp, nodep, "Missing scoping context");
// The AstScopeName is really a statement(ish) for tracking, not a function
snp->dpiExport(true);
snp->unlinkFrBack();
cfuncp->addStmtsp(snp);
cfuncp->scopeNamep(snp);
}
// Create list of arguments and move to function