vhdlpp: Added VTypeArray::is_variable_length() method.

This commit is contained in:
Maciej Suminski 2015-01-23 17:24:00 +01:00
parent 774609fbbb
commit 5d26f0e28d
2 changed files with 22 additions and 0 deletions

View File

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

View File

@ -88,6 +88,10 @@ class VType {
// Returns true if the type has an undefined dimension.
virtual bool is_unbounded() const { return false; }
// 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; }
// Returns a perm_string that can be used in automatically created
// typedefs (i.e. not ones defined by the user).
perm_string get_generic_typename() const;
@ -227,6 +231,8 @@ class VTypeArray : public VType {
bool is_unbounded() const;
bool is_variable_length() const;
// To handle subtypes
inline void set_parent_type(const VTypeArray*parent) { parent_ = parent; }