From 95044d9ac72ee816e1659746709d5a7e48a1fcd6 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Mon, 22 Jun 2015 14:00:24 +0200 Subject: [PATCH] vhdlpp: VType::type_match() checks definitions provided by VTypeDef. --- vhdlpp/vtype.h | 2 ++ vhdlpp/vtype_match.cc | 18 +++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/vhdlpp/vtype.h b/vhdlpp/vtype.h index 6703a86f6..9ff448dd5 100644 --- a/vhdlpp/vtype.h +++ b/vhdlpp/vtype.h @@ -356,6 +356,8 @@ class VTypeDef : public VType { VType*clone() const { return new VTypeDef(*this); } + bool type_match(const VType*that) const; + inline perm_string peek_name() const { return name_; } // If the type is not given a definition in the constructor, diff --git a/vhdlpp/vtype_match.cc b/vhdlpp/vtype_match.cc index e0559d24d..86c8f90ff 100644 --- a/vhdlpp/vtype_match.cc +++ b/vhdlpp/vtype_match.cc @@ -22,5 +22,21 @@ bool VType::type_match(const VType*that) const { - return this == that; + if(this == that) + return true; + + if(const VTypeDef*tdef = dynamic_cast(that)) { + if(type_match(tdef->peek_definition())) + return true; + } + + return false; +} + +bool VTypeDef::type_match(const VType*that) const +{ + if(VType::type_match(that)) + return true; + + return VType::type_match(type_); }