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 <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-02-06 19:14:47 +01:00
parent 4bebcad6fd
commit 6a61144937
2 changed files with 6 additions and 10 deletions

View File

@ -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

14
parse.y
View File

@ -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; }