vhdlpp: Aggregate expression are elaborated if
they are used for Signal/Variable initalization.
This commit is contained in:
parent
c92dea77fc
commit
72ff9ac00b
|
|
@ -41,6 +41,24 @@ int Architecture::elaborate(Entity*entity)
|
||||||
cur->second->val->elaborate_expr(entity, this, cur->second->typ);
|
cur->second->val->elaborate_expr(entity, this, cur->second->typ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Elaborate initializer expressions for signals & variables
|
||||||
|
for (map<perm_string,Signal*>::iterator cur = old_signals_.begin()
|
||||||
|
; cur != old_signals_.end() ; ++cur) {
|
||||||
|
cur->second->elaborate_init_expr(entity, this);
|
||||||
|
}
|
||||||
|
for (map<perm_string,Signal*>::iterator cur = new_signals_.begin()
|
||||||
|
; cur != new_signals_.end() ; ++cur) {
|
||||||
|
cur->second->elaborate_init_expr(entity, this);
|
||||||
|
}
|
||||||
|
for (map<perm_string,Variable*>::iterator cur = old_variables_.begin()
|
||||||
|
; cur != old_variables_.end() ; ++cur) {
|
||||||
|
cur->second->elaborate_init_expr(entity, this);
|
||||||
|
}
|
||||||
|
for (map<perm_string,Variable*>::iterator cur = new_variables_.begin()
|
||||||
|
; cur != new_variables_.end() ; ++cur) {
|
||||||
|
cur->second->elaborate_init_expr(entity, this);
|
||||||
|
}
|
||||||
|
|
||||||
for (list<Architecture::Statement*>::iterator cur = statements_.begin()
|
for (list<Architecture::Statement*>::iterator cur = statements_.begin()
|
||||||
; cur != statements_.end() ; ++cur) {
|
; cur != statements_.end() ; ++cur) {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,27 +27,36 @@ using namespace std;
|
||||||
SigVarBase::SigVarBase(perm_string nam, const VType*typ, Expression*exp)
|
SigVarBase::SigVarBase(perm_string nam, const VType*typ, Expression*exp)
|
||||||
: name_(nam), type_(typ), init_expr_(exp), refcnt_sequ_(0)
|
: name_(nam), type_(typ), init_expr_(exp), refcnt_sequ_(0)
|
||||||
{
|
{
|
||||||
if(init_expr_)
|
}
|
||||||
{
|
|
||||||
|
SigVarBase::~SigVarBase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void SigVarBase::elaborate_init_expr(Entity*ent, Architecture*arc)
|
||||||
|
{
|
||||||
|
if(init_expr_) {
|
||||||
// convert the initializing string to bitstring if applicable
|
// convert the initializing string to bitstring if applicable
|
||||||
const ExpString *string = dynamic_cast<const ExpString*>(init_expr_);
|
const ExpString*string = dynamic_cast<const ExpString*>(init_expr_);
|
||||||
if(string) {
|
if(string) {
|
||||||
const std::vector<char>& val = string->get_value();
|
const std::vector<char>& val = string->get_value();
|
||||||
char buf[val.size() + 1];
|
char buf[val.size() + 1];
|
||||||
std::copy(val.begin(), val.end(), buf);
|
std::copy(val.begin(), val.end(), buf);
|
||||||
buf[val.size()] = 0;
|
buf[val.size()] = 0;
|
||||||
|
|
||||||
ExpBitstring *bitstring = new ExpBitstring(buf);
|
ExpBitstring*bitstring = new ExpBitstring(buf);
|
||||||
delete init_expr_;
|
delete init_expr_;
|
||||||
init_expr_ = bitstring;
|
init_expr_ = bitstring;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
ExpAggregate*aggr = dynamic_cast<ExpAggregate*>(init_expr_);
|
||||||
|
if(aggr) {
|
||||||
|
aggr->elaborate_expr(ent, arc, peek_type());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SigVarBase::~SigVarBase()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void SigVarBase::type_elaborate_(VType::decl_t&decl)
|
void SigVarBase::type_elaborate_(VType::decl_t&decl)
|
||||||
{
|
{
|
||||||
decl.type = type_;
|
decl.type = type_;
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,9 @@ class SigVarBase : public LineInfo {
|
||||||
|
|
||||||
void dump(ostream&out, int indent = 0) const;
|
void dump(ostream&out, int indent = 0) const;
|
||||||
|
|
||||||
|
// Elaborates initializer expressions if needed.
|
||||||
|
void elaborate_init_expr(Entity*ent, Architecture*arc);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
perm_string peek_name_() const { return name_; }
|
perm_string peek_name_() const { return name_; }
|
||||||
unsigned peek_refcnt_sequ_() const { return refcnt_sequ_; }
|
unsigned peek_refcnt_sequ_() const { return refcnt_sequ_; }
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue