vhdlpp: Elaboration of ExpFunc parameters fallbacks to the types given in the Subprogram header.

This commit is contained in:
Maciej Suminski 2014-09-30 14:46:02 +02:00
parent 9951521212
commit 194a950f8d
3 changed files with 17 additions and 2 deletions

View File

@ -23,6 +23,7 @@
# include "architec.h"
# include "entity.h"
# include "vsignal.h"
# include "subprogram.h"
# include <iostream>
# include <typeinfo>
# include "parse_types.h"
@ -715,6 +716,8 @@ int ExpFunc::elaborate_expr(Entity*ent, Architecture*arc, const VType*)
for (size_t idx = 0 ; idx < argv_.size() ; idx += 1) {
const VType*tmp = argv_[idx]->probe_type(ent, arc);
if(!tmp && prog)
tmp = prog->peek_param_type(idx);
errors += argv_[idx]->elaborate_expr(ent, arc, tmp);
}

View File

@ -80,7 +80,7 @@ bool Subprogram::compare_specification(Subprogram*that) const
return true;
}
InterfacePort*Subprogram::find_param(perm_string nam)
const InterfacePort*Subprogram::find_param(perm_string nam) const
{
if(!ports_)
return NULL;
@ -94,6 +94,17 @@ InterfacePort*Subprogram::find_param(perm_string nam)
return NULL;
}
const VType*Subprogram::peek_param_type(int idx) const
{
if(!ports_ || idx >= ports_->size())
return NULL;
std::list<InterfacePort*>::const_iterator p = ports_->begin();
std::advance(p, idx);
return (*p)->type;
}
void Subprogram::fix_return_type(void)
{
if(!statements_)

View File

@ -48,7 +48,8 @@ class Subprogram : public LineInfo, public ScopeBase {
// matches this subprogram and that subprogram.
bool compare_specification(Subprogram*that) const;
InterfacePort*find_param(perm_string nam);
const InterfacePort*find_param(perm_string nam) const;
const VType*peek_param_type(int idx) const;
int emit(ostream&out, Entity*ent, Architecture*arc);