Internals: Move hasParameterList away from symbol table. No functional change intended.

This commit is contained in:
Wilson Snyder 2025-05-06 08:03:30 -04:00
parent da5eb620bf
commit d5f773f385
3 changed files with 13 additions and 12 deletions

View File

@ -111,6 +111,7 @@ struct V3ParseBisonYYSType final {
AstNode* scp; // Symbol table scope for future lookups
int token; // Read token, aka tok
VBaseOverride baseOverride;
bool flag = false; // Passed up some rules
union {
V3Number* nump;
string* strp;

View File

@ -130,13 +130,6 @@ public:
UASSERT_OBJ(!m_sympStack.empty(), nodep, "symbol stack underflow");
m_symCurrentp = m_sympStack.back();
}
AstNodeModule* findTopNodeModule(FileLine* fl, bool requireNoneNull = true) {
for (VSymEnt* const symp : vlstd::reverse_view(m_sympStack)) {
if (AstNodeModule* const modp = VN_CAST(symp->nodep(), NodeModule)) return modp;
}
if (requireNoneNull) fl->v3fatalSrc("fail to find current module");
return nullptr;
}
void showUpward() { // LCOV_EXCL_START
UINFO(1, "ParseSym Stack:\n");
for (VSymEnt* const symp : vlstd::reverse_view(m_sympStack)) {

View File

@ -1379,6 +1379,7 @@ module_declaration: // ==IEEE: module_declaration
modFront importsAndParametersE portsStarE ';'
/*cont*/ module_itemListE yENDMODULE endLabelE
{ $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc
$1->hasParameterList($<flag>2);
if ($2) $1->addStmtsp($2);
if ($3) $1->addStmtsp($3);
if ($5) $1->addStmtsp($5);
@ -1414,8 +1415,11 @@ modFront<nodeModulep>:
importsAndParametersE<nodep>: // IEEE: common part of module_declaration, interface_declaration, program_declaration
// // { package_import_declaration } [ parameter_port_list ]
parameter_port_listE { $$ = $1; }
| package_import_declarationList parameter_port_listE { $$ = addNextNull($1, $2); }
parameter_port_listE
{ $$ = $1; $<flag>$ = $<flag>1; } // hasParameterList
| package_import_declarationList parameter_port_listE
{ $$ = addNextNull($1, $2);
$<flag>$ = $<flag>2; } // hasParameterList
;
udpFront<nodeModulep>:
@ -1460,17 +1464,17 @@ parameter_value_assignmentClass<pinp>: // IEEE: parameter_value_assignment (for
;
parameter_port_listE<nodep>: // IEEE: parameter_port_list + empty == parameter_value_assignment
/* empty */ { $$ = nullptr; }
/* empty */ { $$ = nullptr; $<flag>$ = false; } // hasParameterList
| '#' '(' ')' { $$ = nullptr;
SYMP->findTopNodeModule($<fl>1)->hasParameterList(true); }
$<flag>$ = true; } // hasParameterList
// // IEEE: '#' '(' list_of_param_assignments { ',' parameter_port_declaration } ')'
// // IEEE: '#' '(' parameter_port_declaration { ',' parameter_port_declaration } ')'
// // Can't just do that as "," conflicts with between vars and between stmts, so
// // split into pre-comma and post-comma parts
| '#' '(' { VARRESET_LIST(GPARAM);
SYMP->findTopNodeModule($<fl>1)->hasParameterList(true);
GRAMMARP->m_pinAnsi = true; }
/*cont*/ paramPortDeclOrArgList ')' { $$ = $4;
$<flag>$ = true; // hasParameterList
VARRESET_NONLIST(UNKNOWN);
GRAMMARP->m_pinAnsi = false; }
// // Note legal to start with "a=b" with no parameter statement
@ -1685,6 +1689,7 @@ interface_declaration: // IEEE: interface_declaration + interface_nonan
{ if ($2) $1->addStmtsp($2);
if ($3) $1->addStmtsp($3);
if ($5) $1->addStmtsp($5);
$1->hasParameterList($<flag>2);
SYMP->popScope($1); }
| yEXTERN intFront parameter_port_listE portsStarE ';'
{ BBUNSUP($<fl>1, "Unsupported: extern interface"); }
@ -1769,6 +1774,7 @@ program_declaration: // IEEE: program_declaration + program_nonansi_h
pgmFront parameter_port_listE portsStarE ';'
/*cont*/ program_itemListE yENDPROGRAM endLabelE
{ $1->modTrace(GRAMMARP->allTracingOn($1->fileline())); // Stash for implicit wires, etc
$1->hasParameterList($<flag>2);
if ($2) $1->addStmtsp($2);
if ($3) $1->addStmtsp($3);
if ($5) $1->addStmtsp($5);
@ -7307,6 +7313,7 @@ class_declaration<nodep>: // ==IEEE: part of class_declaration
// // new class scope correct via classFront
classFront parameter_port_listE classExtendsE classImplementsE ';'
/*mid*/ { // Allow resolving types declared in base extends class
$1->hasParameterList($<flag>2);
if ($<scp>3) SYMP->importExtends($<scp>3);
}
/*cont*/ class_itemListEnd endLabelE