From 7db01d8ded694e5bc3fc0bb82d14158ba187b873 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 7 May 2015 14:42:31 +0200 Subject: [PATCH] vhdlpp: ScopeBase::is_enum_name() returns VTypeEnum* instead of bool. --- vhdlpp/expression_elaborate.cc | 15 +++++++-------- vhdlpp/scope.cc | 6 +++--- vhdlpp/scope.h | 4 +++- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/vhdlpp/expression_elaborate.cc b/vhdlpp/expression_elaborate.cc index 4c64ff186..5f54fc66a 100644 --- a/vhdlpp/expression_elaborate.cc +++ b/vhdlpp/expression_elaborate.cc @@ -1027,19 +1027,18 @@ const VType* ExpName::probe_type(Entity*ent, ScopeBase*scope) const if (Variable*var = scope->find_variable(name_)) return var->peek_type(); - const VType*ctype = 0; + const VType*type = 0; Expression*cval = 0; - if (scope->find_constant(name_, ctype, cval)) - return ctype; + if (scope->find_constant(name_, type, cval)) + return type; - const VType*gtype = 0; Architecture*arc = dynamic_cast(scope); - if (arc && (gtype = arc->probe_genvar_type(name_))) { - return gtype; + if (arc && (type = arc->probe_genvar_type(name_))) { + return type; } - if (scope->is_enum_name(name_)) { - return &primitive_INTEGER; + if ((type = scope->is_enum_name(name_))) { + return type; } } diff --git a/vhdlpp/scope.cc b/vhdlpp/scope.cc index 0682a45d0..49b422e89 100644 --- a/vhdlpp/scope.cc +++ b/vhdlpp/scope.cc @@ -188,15 +188,15 @@ Subprogram* ScopeBase::find_subprogram(perm_string name) const return 0; } -bool ScopeBase::is_enum_name(perm_string name) const +const VTypeEnum* ScopeBase::is_enum_name(perm_string name) const { for(list::const_iterator it = use_enums_.begin(); it != use_enums_.end(); ++it) { if((*it)->has_name(name)) - return true; + return *it; } - return false; + return NULL; } /* diff --git a/vhdlpp/scope.h b/vhdlpp/scope.h index 69e859fb9..709e552ec 100644 --- a/vhdlpp/scope.h +++ b/vhdlpp/scope.h @@ -58,7 +58,9 @@ class ScopeBase { Variable* find_variable(perm_string by_name) const; virtual const InterfacePort* find_param(perm_string by_name) const; Subprogram* find_subprogram(perm_string by_name) const; - bool is_enum_name(perm_string name) const; + // Checks if a string is one of possible enum values. If so, the enum + // type is returned, otherwise NULL. + const VTypeEnum* is_enum_name(perm_string name) const; // Moves signals, variables and components from another scope to // this one. After the transfer new_* maps are cleared in the source scope.