vhdlpp: Implemented ReturnStmt::elaborate() method.

This commit is contained in:
Maciej Suminski 2016-01-22 11:26:14 +01:00
parent 00f5785f2c
commit f1c07b86a3
3 changed files with 19 additions and 0 deletions

View File

@ -135,6 +135,7 @@ class ReturnStmt : public SequentialStmt {
~ReturnStmt();
public:
int elaborate(Entity*ent, ScopeBase*scope);
int emit(ostream&out, Entity*entity, ScopeBase*scope);
void write_to_stream(std::ostream&fd);
void dump(ostream&out, int indent) const;

View File

@ -133,6 +133,22 @@ int IfSequential::Elsif::elaborate(Entity*ent, ScopeBase*scope)
return errors;
}
int ReturnStmt::elaborate(Entity*ent, ScopeBase*scope)
{
const VType*ltype = NULL;
// Try to determine the expression type by
// looking up the function return type.
const SubprogramBody*subp = dynamic_cast<const SubprogramBody*>(scope);
if(subp) {
if(const SubprogramHeader*header = subp->header()) {
ltype = header->peek_return_type();
}
}
return val_->elaborate_expr(ent, scope, ltype);
}
int SignalSeqAssignment::elaborate(Entity*ent, ScopeBase*scope)
{
int errors = 0;

View File

@ -54,6 +54,8 @@ class SubprogramBody : public LineInfo, public ScopeBase {
void write_to_stream(std::ostream&fd) const;
void dump(std::ostream&fd) const;
const SubprogramHeader*header() const { return header_; }
private:
std::list<SequentialStmt*>*statements_;
SubprogramHeader*header_;