vhdlpp: VTypeArray::is_variable_length() uses ScopeBase to determine if variable has constant length.

This commit is contained in:
Maciej Suminski 2015-01-26 11:15:57 +01:00
parent 621cf37339
commit 90293d8e0a
3 changed files with 11 additions and 7 deletions

View File

@ -107,7 +107,7 @@ void Subprogram::fix_variables() {
// SystemVerilog does not handle variables that have length dependendent
// on other variables. We have to convert it to a dynamic array and
// construct it.
if(type->is_variable_length()) {
if(type->is_variable_length(this)) {
const VTypeArray*arr = dynamic_cast<const VTypeArray*>(type);
// Currently we handle only one dimensional variables

View File

@ -167,20 +167,23 @@ bool VTypeArray::is_unbounded() const {
return etype_->is_unbounded();
}
bool VTypeArray::is_variable_length() const {
bool VTypeArray::is_variable_length(ScopeBase*scope) const {
int64_t dummy;
if(is_unbounded())
return true;
for(std::vector<range_t>::const_iterator it = ranges_.begin();
it != ranges_.end(); ++it)
{
if(!it->lsb()->evaluate(NULL, dummy))
if(!it->lsb()->evaluate(scope, dummy))
return true;
if(!it->msb()->evaluate(NULL, dummy))
if(!it->msb()->evaluate(scope, dummy))
return true;
}
return etype_->is_variable_length();
return etype_->is_variable_length(scope);
}
VTypeRange::VTypeRange(const VType*base, int64_t max_val, int64_t min_val)

View File

@ -34,6 +34,7 @@ class Entity;
class Expression;
class prange_t;
class VTypeDef;
class ScopeBase;
typedef enum typedef_topo_e { NONE=0, PENDING, MARKED } typedef_topo_t;
typedef std::map<const VTypeDef*, typedef_topo_t> typedef_context_t;
@ -90,7 +91,7 @@ class VType {
// Checks if the variable length is dependent on other expressions, that
// cannot be evaluated (e.g. 'length, 'left, 'right).
virtual bool is_variable_length() const { return false; }
virtual bool is_variable_length(ScopeBase*) const { return false; }
// Returns a perm_string that can be used in automatically created
// typedefs (i.e. not ones defined by the user).
@ -231,7 +232,7 @@ class VTypeArray : public VType {
bool is_unbounded() const;
bool is_variable_length() const;
bool is_variable_length(ScopeBase*scope) const;
// To handle subtypes
inline void set_parent_type(const VTypeArray*parent) { parent_ = parent; }