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:
Stephen Williams 2012-01-15 17:29:18 -08:00
parent 42b3e6f268
commit 764b38bb3b
4 changed files with 12 additions and 9 deletions

View File

@ -303,6 +303,7 @@ TU [munpf]
perm_string tmp = lex_strings.make(yylval.text);
map<perm_string,ivl_discipline_t>::iterator cur = disciplines.find(tmp);
if (cur != disciplines.end()) {
delete[]yylval.text;
yylval.discipline = (*cur).second;
rc = DISCIPLINE_IDENTIFIER;
}
@ -311,8 +312,11 @@ TU [munpf]
/* If this identifer names a previously declared type, then
return this as a TYPE_IDENTIFIER instead. */
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;
}
}
return rc;

View File

@ -347,7 +347,8 @@ static void current_task_set_statement(vector<Statement*>*s)
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 <text> PATHPULSE_IDENTIFIER
%token <number> BASED_NUMBER DEC_NUMBER
@ -786,9 +787,7 @@ data_type
| enum_data_type
{ $$ = $1; }
| TYPE_IDENTIFIER
{ yyerror(@1, "sorry: Named types not supported here");
$$ = 0;
}
{ $$ = $1; }
;
type_declaration

View File

@ -83,7 +83,7 @@ extern bool have_timeprec_decl;
* parser detects typedefs and marks the typedef'ed identifiers as
* 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

View File

@ -408,7 +408,7 @@ void pform_set_typedef(perm_string name, data_type_t*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
// 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);
map<perm_string,data_type_t*>::iterator cur = lexical_scope->typedefs.find(name);
if (cur != lexical_scope->typedefs.end())
return true;
return cur->second;
else
return false;
return 0;
}
static void pform_put_behavior_in_scope(PProcess*pp)