vhdlpp: Improved type matching rules.

This commit is contained in:
Maciej Suminski 2016-02-12 15:17:03 +01:00
parent 69b7c000d0
commit 045d9e7117
3 changed files with 13 additions and 1 deletions

View File

@ -350,8 +350,10 @@ const VType* ExpBinary::probe_type(Entity*ent, ScopeBase*scope) const
if (t2 == 0)
return t1;
if (t1 == t2)
if (t1->type_match(t2))
return t1;
if (t2->type_match(t1))
return t2;
if (const VType*tb = resolve_operand_types_(t1, t2))
return tb;

View File

@ -295,6 +295,9 @@ class VTypeRangeConst : public VTypeRange {
return new VTypeRangeConst(base_type()->clone(), start_, end_);
}
int64_t start() const { return start_; }
int64_t end() const { return end_; }
void write_to_stream(std::ostream&fd) const;
private:

View File

@ -53,6 +53,13 @@ bool VTypePrimitive::type_match(const VType*that) const
(that_type == NATURAL || that_type == INTEGER));
}
if(const VTypeRangeConst*range = dynamic_cast<const VTypeRangeConst*>(that)) {
if (type_ == INTEGER)
return true;
if (type_ == NATURAL && range->start() >= 0 && range->end() >= 0)
return true;
}
return false;
}