Document the vvp .scope record.

Also clean up some dead code in the vvp parser.
This commit is contained in:
Stephen Williams 2015-12-20 16:31:03 -08:00
parent 2aaa050b7c
commit 3e3f245d8c
3 changed files with 43 additions and 44 deletions

View File

@ -97,24 +97,33 @@ SCOPE STATEMENTS:
The syntax of a scope statement is:
<label> .scope <type>, <instance>, <declaration>, <parent> ;
<label> .scope <type>, <name> <type-name> <file> <lineno> ;
<label> .scope <type>, <name> <type-name> <file> <lineno>, \
<def-file> <def-lineno> <is-cell>, <parent> ;
The <type> is the general type of the scope: module, autofunction,
function, autotask, task, begin, fork or generate.
function, autotask, task, begin, fork, autobegin, autofork, or generate.
The <instance> is a string that is the base name of the instance. For
modules, this is the instance name. For tasks, this is the task name.
The <name> is a string that is the base name of the instance. For
modules, this is the instance name. For tasks and functions, this is
the task or function name.
The <declaration> is a string that represents the declaration. For
modules, this is the name of the module given in the module
declaration, and *not* the instantiation. For tasks and functions,
this is the hierarchical name of the path to the declaration. This is
because the declaration can be different within different module
instances.
The <type-name> is the name of the type. For most scope types, this is
the name as the <name>, but for module and class scopes, this is the
name of the definition, and not the instance.
Finally, the <parent> is the label for the parent scope for this
one. Root scopes leave this out. Otherwise, this label references
another .scope record.
The <file> and <lineno> are the location of the instantiation of this
scope. For a module, it is the location of the instance.
The <def-file> and <def-lineno> is the source file and line number for
the defintion of the scope. For modules, this is where the module is
defined instead of where it is instantiated.
The <is-cell> flag is only useful for module instances. It is true
(not zero) if the module is a celltype instead of a regular module.
The short form of the scope statement is only used for root scopes.
PARAMETER STATEMENTS:

View File

@ -696,20 +696,6 @@ statement
T_NUMBER T_NUMBER T_NUMBER ',' T_SYMBOL ';'
{ compile_scope_decl($1, $3, $5, $6, $14, $7, $8, $10, $11, $12); }
/* Legacy declaration that does not have `celldefine information. */
| T_LABEL K_SCOPE T_SYMBOL ',' T_STRING T_STRING T_NUMBER T_NUMBER ','
T_NUMBER T_NUMBER ',' T_SYMBOL ';'
{ compile_scope_decl($1, $3, $5, $6, $13, $7, $8, $10, $11, 0); }
/* XXXX Legacy declaration has no type name. */
| T_LABEL K_SCOPE T_SYMBOL ',' T_STRING ';'
{ compile_scope_decl($1, $3, $5, 0, 0, 0, 0, 0, 0, 0); }
| T_LABEL K_SCOPE T_SYMBOL ',' T_STRING ',' T_SYMBOL ';'
{ compile_scope_decl($1, $3, $5, 0, $7, 0, 0, 0, 0, 0); }
/* Scope recall has no label of its own, but refers by label to a
declared scope. */

View File

@ -449,32 +449,36 @@ compile_scope_decl(char*label, char*type, char*name, char*tname,
{
count_vpi_scopes += 1;
char*base_type;
bool is_automatic;
if (strncmp(type,"auto",4) == 0) {
is_automatic = true;
base_type = &type[4];
} else {
is_automatic = false;
base_type = &type[0];
}
bool is_automatic = false;
struct __vpiScope*scope;
if (strcmp(base_type,"module") == 0) {
if (strcmp(type,"module") == 0) {
scope = new vpiScopeModule;
} else if (strcmp(base_type,"function") == 0) {
} else if (strcmp(type,"function") == 0) {
scope = new vpiScopeFunction;
} else if (strcmp(base_type,"task") == 0) {
} else if (strcmp(type,"autofunction") == 0) {
scope = new vpiScopeFunction;
is_automatic = true;
} else if (strcmp(type,"task") == 0) {
scope = new vpiScopeTask;
} else if (strcmp(base_type,"fork") == 0) {
} else if (strcmp(type,"autotask") == 0) {
scope = new vpiScopeTask;
is_automatic = true;
} else if (strcmp(type,"fork") == 0) {
scope = new vpiScopeFork;
} else if (strcmp(base_type,"begin") == 0) {
} else if (strcmp(type,"autofork") == 0) {
scope = new vpiScopeFork;
is_automatic = true;
} else if (strcmp(type,"begin") == 0) {
scope = new vpiScopeBegin;
} else if (strcmp(base_type,"generate") == 0) {
} else if (strcmp(type,"autobegin") == 0) {
scope = new vpiScopeBegin;
is_automatic = true;
} else if (strcmp(type,"generate") == 0) {
scope = new vpiScopeGenerate;
} else if (strcmp(base_type,"package") == 0) {
} else if (strcmp(type,"package") == 0) {
scope = new vpiScopePackage;
} else if (strcmp(base_type,"class") == 0) {
} else if (strcmp(type,"class") == 0) {
scope = new vpiScopeClass;
} else {
scope = new vpiScopeModule;