From 6a6114493710743f83349f9ce19beca43ba309f4 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Sun, 6 Feb 2022 19:14:47 +0100 Subject: [PATCH] Support scoped base class type A base class can be referenced by scope. E.g. if the base class is in a package. ``` package P; class B; endclass endpackage module test; class C extends P::B; endlcass endmodule ``` To support this let the parser accept a scope identifier for the base class. A small change is also necessary to how the base class lockup is done during elaboration. At the moment the code will search for the base class by name in the current scope. This doesn't work with scoped identifiers. But we already have a reference to the base class data type, so we don't have to search for it by name. Signed-off-by: Lars-Peter Clausen --- elab_scope.cc | 2 +- parse.y | 14 +++++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/elab_scope.cc b/elab_scope.cc index c1b8546dd..b01aa1700 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -514,7 +514,7 @@ static void elaborate_scope_class(Design*des, NetScope*scope, PClass*pclass) netclass_t*use_base_class = 0; if (base_class) { - use_base_class = scope->find_class(des, base_class->name); + use_base_class = base_class->save_elaborated_type; if (use_base_class == 0) { cerr << pclass->get_fileline() << ": error: " << "Base class " << base_class->name diff --git a/parse.y b/parse.y index f536e161d..b11f4aa56 100644 --- a/parse.y +++ b/parse.y @@ -851,17 +851,13 @@ class_declaration_endlabel_opt a data_type. */ class_declaration_extends_opt /* IEEE1800-2005: A.1.2 */ - : K_extends TYPE_IDENTIFIER - { pform_set_type_referenced(@2, $2.text); - $$.type = $2.type; - $$.exprs= 0; - delete[]$2.text; + : K_extends ps_type_identifier + { $$.type = $2; + $$.exprs = 0; } - | K_extends TYPE_IDENTIFIER '(' expression_list_with_nuls ')' - { pform_set_type_referenced(@2, $2.text); - $$.type = $2.type; + | K_extends ps_type_identifier '(' expression_list_with_nuls ')' + { $$.type = $2; $$.exprs = $4; - delete[]$2.text; } | { $$.type = 0; $$.exprs = 0; }