From 5d26f0e28dc882ff7dda7bfbe57c501399069044 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Fri, 23 Jan 2015 17:24:00 +0100 Subject: [PATCH] vhdlpp: Added VTypeArray::is_variable_length() method. --- vhdlpp/vtype.cc | 16 ++++++++++++++++ vhdlpp/vtype.h | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/vhdlpp/vtype.cc b/vhdlpp/vtype.cc index 6e8ac00dd..795992649 100644 --- a/vhdlpp/vtype.cc +++ b/vhdlpp/vtype.cc @@ -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::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) { diff --git a/vhdlpp/vtype.h b/vhdlpp/vtype.h index a98c81a5d..e5b0fd378 100644 --- a/vhdlpp/vtype.h +++ b/vhdlpp/vtype.h @@ -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; }