vhdlpp: VTypeRange::write_to_stream uses to/downto depending on the range boundaries.

This commit is contained in:
Maciej Suminski 2015-04-24 17:00:21 +02:00
parent 61ace52f31
commit a33bbecc98
3 changed files with 9 additions and 9 deletions

View File

@ -273,11 +273,9 @@ void VTypeArray::evaluate_ranges(ScopeBase*scope) {
} }
} }
VTypeRange::VTypeRange(const VType*base, int64_t max_val, int64_t min_val) VTypeRange::VTypeRange(const VType*base, int64_t end_val, int64_t start_val)
: base_(base) : base_(base), end_(end_val), start_(start_val)
{ {
max_ = max_val;
min_ = min_val;
} }
VTypeRange::~VTypeRange() VTypeRange::~VTypeRange()

View File

@ -275,10 +275,10 @@ class VTypeArray : public VType {
class VTypeRange : public VType { class VTypeRange : public VType {
public: public:
VTypeRange(const VType*base, int64_t max_val, int64_t min_val); VTypeRange(const VType*base, int64_t end, int64_t start);
~VTypeRange(); ~VTypeRange();
VType*clone() const { return new VTypeRange(base_->clone(), max_, min_); } VType*clone() const { return new VTypeRange(base_->clone(), start_, end_); }
// Get the type that is limited by the range. // Get the type that is limited by the range.
inline const VType* base_type() const { return base_; } inline const VType* base_type() const { return base_; }
@ -289,7 +289,7 @@ class VTypeRange : public VType {
private: private:
const VType*base_; const VType*base_;
int64_t max_, min_; int64_t end_, start_;
}; };
class VTypeEnum : public VType { class VTypeEnum : public VType {

View File

@ -171,14 +171,16 @@ void VTypeRange::write_to_stream(ostream&fd) const
// Detect some special cases that can be written as ieee or // Detect some special cases that can be written as ieee or
// standard types. // standard types.
if (const VTypePrimitive*tmp = dynamic_cast<const VTypePrimitive*> (base_)) { if (const VTypePrimitive*tmp = dynamic_cast<const VTypePrimitive*> (base_)) {
if (min_==0 && max_==INT64_MAX && tmp->type()==VTypePrimitive::INTEGER) { if (start_==0 && end_==INT64_MAX && tmp->type()==VTypePrimitive::INTEGER) {
fd << "natural"; fd << "natural";
return; return;
} }
} }
base_->write_to_stream(fd); base_->write_to_stream(fd);
fd << " range " << min_ << " to " << max_; fd << " range " << start_;
fd << (start_ < end_ ? " to " : " downto ");
fd << end_;
} }
void VTypeRecord::write_to_stream(ostream&fd) const void VTypeRecord::write_to_stream(ostream&fd) const