3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-27 19:05:52 +00:00

verilog: check entire user type stack for type definition

This commit is contained in:
Xiretza 2021-03-18 21:53:02 +01:00 committed by Zachary Snow
parent 4f4e70876f
commit 92d5550a90
2 changed files with 22 additions and 6 deletions

View file

@ -163,12 +163,18 @@ static bool isInLocalScope(const std::string *name)
static AstNode *getTypeDefinitionNode(std::string type_name)
{
// return the definition nodes from the typedef statement
auto user_types = user_type_stack.back();
log_assert(user_types->count(type_name) > 0);
auto typedef_node = (*user_types)[type_name];
log_assert(typedef_node->type == AST_TYPEDEF);
return typedef_node->children[0];
// check current scope then outer scopes for a name
for (auto it = user_type_stack.rbegin(); it != user_type_stack.rend(); ++it) {
if ((*it)->count(type_name) > 0) {
// return the definition nodes from the typedef statement
auto typedef_node = (**it)[type_name];
log_assert(typedef_node->type == AST_TYPEDEF);
return typedef_node->children[0];
}
}
// The lexer recognized the name as a TOK_USER_TYPE, but now we can't find it anymore?
log_error("typedef for user type `%s' not found", type_name.c_str());
}
static AstNode *copyTypeDefinition(std::string type_name)