vhdlpp: Improved handling for subprogram-related errors.
This commit is contained in:
parent
8d3f559b38
commit
ad5b003488
|
|
@ -795,7 +795,9 @@ const VType*ExpFunc::probe_type(Entity*, ScopeBase*scope) const
|
||||||
prog = library_find_subprogram(name_);
|
prog = library_find_subprogram(name_);
|
||||||
|
|
||||||
if(!prog) {
|
if(!prog) {
|
||||||
cerr << get_fileline() << ": sorry: VHDL function " << name_ << " not yet implemented" << endl;
|
cerr << get_fileline() << ": sorry: could not find function ";
|
||||||
|
emit_subprogram_sig(cerr, name_, arg_types);
|
||||||
|
cerr << endl;
|
||||||
ivl_assert(*this, false);
|
ivl_assert(*this, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -812,8 +814,13 @@ int ExpFunc::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*)
|
||||||
if(!prog)
|
if(!prog)
|
||||||
prog = library_find_subprogram(name_);
|
prog = library_find_subprogram(name_);
|
||||||
|
|
||||||
ivl_assert(*this, def_==0);
|
|
||||||
def_ = prog;
|
def_ = prog;
|
||||||
|
if(!def_) {
|
||||||
|
cerr << get_fileline() << ": error: could not find function ";
|
||||||
|
emit_subprogram_sig(cerr, name_, arg_types);
|
||||||
|
cerr << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Elaborate arguments
|
// Elaborate arguments
|
||||||
for (size_t idx = 0; idx < argv_.size(); ++idx) {
|
for (size_t idx = 0; idx < argv_.size(); ++idx) {
|
||||||
|
|
@ -828,11 +835,6 @@ int ExpFunc::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*)
|
||||||
name_ = def_->name();
|
name_ = def_->name();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!def_) {
|
|
||||||
cerr << get_fileline() << ": error: could not find function " << name_ << endl;
|
|
||||||
++errors;
|
|
||||||
}
|
|
||||||
|
|
||||||
return errors;
|
return errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -183,7 +183,12 @@ int ProcedureCall::elaborate(Entity*ent, ScopeBase*scope)
|
||||||
if(!def_)
|
if(!def_)
|
||||||
def_ = library_find_subprogram(name_);
|
def_ = library_find_subprogram(name_);
|
||||||
|
|
||||||
assert(def_);
|
if(!def_) {
|
||||||
|
cerr << get_fileline() << ": error: could not find procedure ";
|
||||||
|
emit_subprogram_sig(cerr, name_, arg_types);
|
||||||
|
cerr << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
// Elaborate arguments
|
// Elaborate arguments
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
|
|
|
||||||
|
|
@ -169,4 +169,8 @@ class SubprogramBuiltin : public SubprogramStdHeader
|
||||||
perm_string sv_name_;
|
perm_string sv_name_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Helper function to print out a human-readable function signature.
|
||||||
|
void emit_subprogram_sig(std::ostream&out, perm_string name,
|
||||||
|
const std::list<const VType*>&arg_types);
|
||||||
|
|
||||||
#endif /* IVL_subprogram_H */
|
#endif /* IVL_subprogram_H */
|
||||||
|
|
|
||||||
|
|
@ -142,3 +142,23 @@ int SubprogramBuiltin::emit_name(const std::vector<Expression*>&,
|
||||||
out << sv_name_;
|
out << sv_name_;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void emit_subprogram_sig(ostream&out, perm_string name,
|
||||||
|
const list<const VType*>&arg_types)
|
||||||
|
{
|
||||||
|
out << name << "(";
|
||||||
|
bool first = true;
|
||||||
|
for(list<const VType*>::const_iterator it = arg_types.begin();
|
||||||
|
it != arg_types.end(); ++it) {
|
||||||
|
if(first)
|
||||||
|
first = false;
|
||||||
|
else
|
||||||
|
out << ", ";
|
||||||
|
|
||||||
|
if(*it)
|
||||||
|
(*it)->write_to_stream(out);
|
||||||
|
else
|
||||||
|
out << "<unresolved type>";
|
||||||
|
}
|
||||||
|
out << ")";
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue