Use user defined types in the syntax.
Given that the syntax is already parsed and elaborated, it is a simple matter to bind that typedef'ed type to the instances that use it.
This commit is contained in:
parent
42b3e6f268
commit
764b38bb3b
|
|
@ -303,6 +303,7 @@ TU [munpf]
|
||||||
perm_string tmp = lex_strings.make(yylval.text);
|
perm_string tmp = lex_strings.make(yylval.text);
|
||||||
map<perm_string,ivl_discipline_t>::iterator cur = disciplines.find(tmp);
|
map<perm_string,ivl_discipline_t>::iterator cur = disciplines.find(tmp);
|
||||||
if (cur != disciplines.end()) {
|
if (cur != disciplines.end()) {
|
||||||
|
delete[]yylval.text;
|
||||||
yylval.discipline = (*cur).second;
|
yylval.discipline = (*cur).second;
|
||||||
rc = DISCIPLINE_IDENTIFIER;
|
rc = DISCIPLINE_IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|
@ -311,8 +312,11 @@ TU [munpf]
|
||||||
/* If this identifer names a previously declared type, then
|
/* If this identifer names a previously declared type, then
|
||||||
return this as a TYPE_IDENTIFIER instead. */
|
return this as a TYPE_IDENTIFIER instead. */
|
||||||
if (rc == IDENTIFIER && gn_system_verilog()) {
|
if (rc == IDENTIFIER && gn_system_verilog()) {
|
||||||
if (pform_test_type_identifier(yylval.text))
|
if (data_type_t*type = pform_test_type_identifier(yylval.text)) {
|
||||||
|
delete[]yylval.text;
|
||||||
|
yylval.data_type = type;
|
||||||
rc = TYPE_IDENTIFIER;
|
rc = TYPE_IDENTIFIER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
|
|
||||||
7
parse.y
7
parse.y
|
|
@ -347,7 +347,8 @@ static void current_task_set_statement(vector<Statement*>*s)
|
||||||
list<index_component_t> *dimensions;
|
list<index_component_t> *dimensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
%token <text> IDENTIFIER SYSTEM_IDENTIFIER TYPE_IDENTIFIER STRING TIME_LITERAL
|
%token <text> IDENTIFIER SYSTEM_IDENTIFIER STRING TIME_LITERAL
|
||||||
|
%token <data_type> TYPE_IDENTIFIER
|
||||||
%token <discipline> DISCIPLINE_IDENTIFIER
|
%token <discipline> DISCIPLINE_IDENTIFIER
|
||||||
%token <text> PATHPULSE_IDENTIFIER
|
%token <text> PATHPULSE_IDENTIFIER
|
||||||
%token <number> BASED_NUMBER DEC_NUMBER
|
%token <number> BASED_NUMBER DEC_NUMBER
|
||||||
|
|
@ -786,9 +787,7 @@ data_type
|
||||||
| enum_data_type
|
| enum_data_type
|
||||||
{ $$ = $1; }
|
{ $$ = $1; }
|
||||||
| TYPE_IDENTIFIER
|
| TYPE_IDENTIFIER
|
||||||
{ yyerror(@1, "sorry: Named types not supported here");
|
{ $$ = $1; }
|
||||||
$$ = 0;
|
|
||||||
}
|
|
||||||
;
|
;
|
||||||
|
|
||||||
type_declaration
|
type_declaration
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ extern bool have_timeprec_decl;
|
||||||
* parser detects typedefs and marks the typedef'ed identifiers as
|
* parser detects typedefs and marks the typedef'ed identifiers as
|
||||||
* type names.
|
* type names.
|
||||||
*/
|
*/
|
||||||
extern bool pform_test_type_identifier(const char*txt);
|
extern data_type_t* pform_test_type_identifier(const char*txt);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Export these functions because we have to generate PENumber class
|
* Export these functions because we have to generate PENumber class
|
||||||
|
|
|
||||||
6
pform.cc
6
pform.cc
|
|
@ -408,7 +408,7 @@ void pform_set_typedef(perm_string name, data_type_t*data_type)
|
||||||
ref = data_type;
|
ref = data_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pform_test_type_identifier(const char*txt)
|
data_type_t* pform_test_type_identifier(const char*txt)
|
||||||
{
|
{
|
||||||
// If there is no lexical_scope yet, then there is NO WAY the
|
// If there is no lexical_scope yet, then there is NO WAY the
|
||||||
// identifier can be a type_identifier.
|
// identifier can be a type_identifier.
|
||||||
|
|
@ -418,9 +418,9 @@ bool pform_test_type_identifier(const char*txt)
|
||||||
perm_string name = lex_strings.make(txt);
|
perm_string name = lex_strings.make(txt);
|
||||||
map<perm_string,data_type_t*>::iterator cur = lexical_scope->typedefs.find(name);
|
map<perm_string,data_type_t*>::iterator cur = lexical_scope->typedefs.find(name);
|
||||||
if (cur != lexical_scope->typedefs.end())
|
if (cur != lexical_scope->typedefs.end())
|
||||||
return true;
|
return cur->second;
|
||||||
else
|
else
|
||||||
return false;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void pform_put_behavior_in_scope(PProcess*pp)
|
static void pform_put_behavior_in_scope(PProcess*pp)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue