Add ExpName::elaborate_rval member function

This function is for the time being used in the
component instatiation. It is checked, whether
an expression is a correct r-value.
To be a correct r-value, it must be either
port name or signal name.
This commit is contained in:
Stephen Williams 2011-07-19 21:29:05 -07:00
parent 5821139e0f
commit e2932cb6b5
3 changed files with 23 additions and 0 deletions

View File

@ -66,6 +66,9 @@ int ComponentInstantiation::elaborate(Entity*ent, Architecture*arc)
continue;
}
ExpName* tmp;
if (cur->second && (tmp = dynamic_cast<ExpName*>(cur->second)))
errors += tmp->elaborate_rval(ent, arc);
/* It is possible for the port to be explicitly
unconnected. In that case, the Expression will be nil */
if (cur->second)

View File

@ -322,6 +322,7 @@ class ExpName : public Expression {
public: // Base methods
int elaborate_lval(Entity*ent, Architecture*arc, bool);
int elaborate_rval(Entity*ent, Architecture*arc);
const VType* probe_type(Entity*ent, Architecture*arc) const;
int elaborate_expr(Entity*ent, Architecture*arc, const VType*ltype);
int emit(ostream&out, Entity*ent, Architecture*arc);

View File

@ -71,6 +71,25 @@ int ExpName::elaborate_lval(Entity*ent, Architecture*arc, bool is_sequ)
return errors;
}
int ExpName::elaborate_rval(Entity*ent, Architecture*arc)
{
int errors = 0;
if (const InterfacePort*cur = ent->find_port(name_)) {
/* OK */
} else if (Signal* fs = arc->find_signal(name_)) {
/* OK */
} else {
cerr << get_fileline() << ": error: No port or signal " << name_
<< " to be used as r-value." << endl;
errors += 1;
}
return errors;
}
int ExpNameALL::elaborate_lval(Entity*ent, Architecture*arc, bool is_sequ)
{
return Expression::elaborate_lval(ent, arc, is_sequ);