vhdlpp: Subprogram parameters are taken into account when distinguishing between function calls and vector elements.
This commit is contained in:
parent
9e856810b9
commit
9951521212
|
|
@ -83,6 +83,7 @@ extern int yylex(union YYSTYPE*yylvalp,YYLTYPE*yyllocp,yyscan_t yyscanner);
|
||||||
*/
|
*/
|
||||||
static ActiveScope*active_scope = new ActiveScope;
|
static ActiveScope*active_scope = new ActiveScope;
|
||||||
static stack<ActiveScope*> scope_stack;
|
static stack<ActiveScope*> scope_stack;
|
||||||
|
static Subprogram*active_sub = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When a scope boundary starts, call the push_scope function to push
|
* When a scope boundary starts, call the push_scope function to push
|
||||||
|
|
@ -106,6 +107,13 @@ static void pop_scope(void)
|
||||||
scope_stack.pop();
|
scope_stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool is_subprogram_param(perm_string name)
|
||||||
|
{
|
||||||
|
if(!active_sub)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return (active_sub->find_param(name) != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void preload_global_types(void)
|
void preload_global_types(void)
|
||||||
{
|
{
|
||||||
|
|
@ -1543,7 +1551,7 @@ name /* IEEE 1076-2008 P8.1 */
|
||||||
| IDENTIFIER '(' expression_list ')'
|
| IDENTIFIER '(' expression_list ')'
|
||||||
{ perm_string name = lex_strings.make($1);
|
{ perm_string name = lex_strings.make($1);
|
||||||
delete[]$1;
|
delete[]$1;
|
||||||
if (active_scope->is_vector_name(name)) {
|
if (active_scope->is_vector_name(name) || is_subprogram_param(name)) {
|
||||||
ExpName*tmp = new ExpName(name, $3);
|
ExpName*tmp = new ExpName(name, $3);
|
||||||
$$ = tmp;
|
$$ = tmp;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2166,6 +2174,7 @@ signal_assignment_statement
|
||||||
|
|
||||||
subprogram_body /* IEEE 1076-2008 P4.3 */
|
subprogram_body /* IEEE 1076-2008 P4.3 */
|
||||||
: subprogram_specification K_is
|
: subprogram_specification K_is
|
||||||
|
{ active_sub = $1; }
|
||||||
subprogram_declarative_part
|
subprogram_declarative_part
|
||||||
K_begin subprogram_statement_part K_end
|
K_begin subprogram_statement_part K_end
|
||||||
subprogram_kind_opt identifier_opt ';'
|
subprogram_kind_opt identifier_opt ';'
|
||||||
|
|
@ -2178,8 +2187,9 @@ subprogram_body /* IEEE 1076-2008 P4.3 */
|
||||||
errormsg(@1, "Subprogram specification for %s doesn't match specification in package header.\n", prog->name().str());
|
errormsg(@1, "Subprogram specification for %s doesn't match specification in package header.\n", prog->name().str());
|
||||||
}
|
}
|
||||||
prog->transfer_from(*active_scope);
|
prog->transfer_from(*active_scope);
|
||||||
prog->set_program_body($5);
|
prog->set_program_body($6);
|
||||||
active_scope->bind_name(prog->name(), prog);
|
active_scope->bind_name(prog->name(), prog);
|
||||||
|
active_sub = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
| subprogram_specification K_is
|
| subprogram_specification K_is
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,20 @@ bool Subprogram::compare_specification(Subprogram*that) const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InterfacePort*Subprogram::find_param(perm_string nam)
|
||||||
|
{
|
||||||
|
if(!ports_)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (std::list<InterfacePort*>::const_iterator it = ports_->begin()
|
||||||
|
; it != ports_->end(); ++it) {
|
||||||
|
if((*it)->name == nam)
|
||||||
|
return *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
void Subprogram::fix_return_type(void)
|
void Subprogram::fix_return_type(void)
|
||||||
{
|
{
|
||||||
if(!statements_)
|
if(!statements_)
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,8 @@ class Subprogram : public LineInfo, public ScopeBase {
|
||||||
// matches this subprogram and that subprogram.
|
// matches this subprogram and that subprogram.
|
||||||
bool compare_specification(Subprogram*that) const;
|
bool compare_specification(Subprogram*that) const;
|
||||||
|
|
||||||
|
InterfacePort*find_param(perm_string nam);
|
||||||
|
|
||||||
int emit(ostream&out, Entity*ent, Architecture*arc);
|
int emit(ostream&out, Entity*ent, Architecture*arc);
|
||||||
|
|
||||||
// Emit a definition as it would show up in a package.
|
// Emit a definition as it would show up in a package.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue