From 194a950f8dc39febc0f082213dfa003a186d1887 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 30 Sep 2014 14:46:02 +0200 Subject: [PATCH] vhdlpp: Elaboration of ExpFunc parameters fallbacks to the types given in the Subprogram header. --- vhdlpp/expression_elaborate.cc | 3 +++ vhdlpp/subprogram.cc | 13 ++++++++++++- vhdlpp/subprogram.h | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/vhdlpp/expression_elaborate.cc b/vhdlpp/expression_elaborate.cc index 1987be699..481a26597 100644 --- a/vhdlpp/expression_elaborate.cc +++ b/vhdlpp/expression_elaborate.cc @@ -23,6 +23,7 @@ # include "architec.h" # include "entity.h" # include "vsignal.h" +# include "subprogram.h" # include # include # include "parse_types.h" @@ -715,6 +716,8 @@ int ExpFunc::elaborate_expr(Entity*ent, Architecture*arc, const VType*) for (size_t idx = 0 ; idx < argv_.size() ; idx += 1) { const VType*tmp = argv_[idx]->probe_type(ent, arc); + if(!tmp && prog) + tmp = prog->peek_param_type(idx); errors += argv_[idx]->elaborate_expr(ent, arc, tmp); } diff --git a/vhdlpp/subprogram.cc b/vhdlpp/subprogram.cc index 0e3f22ab6..67b5c8cab 100644 --- a/vhdlpp/subprogram.cc +++ b/vhdlpp/subprogram.cc @@ -80,7 +80,7 @@ bool Subprogram::compare_specification(Subprogram*that) const return true; } -InterfacePort*Subprogram::find_param(perm_string nam) +const InterfacePort*Subprogram::find_param(perm_string nam) const { if(!ports_) return NULL; @@ -94,6 +94,17 @@ InterfacePort*Subprogram::find_param(perm_string nam) return NULL; } +const VType*Subprogram::peek_param_type(int idx) const +{ + if(!ports_ || idx >= ports_->size()) + return NULL; + + std::list::const_iterator p = ports_->begin(); + std::advance(p, idx); + + return (*p)->type; +} + void Subprogram::fix_return_type(void) { if(!statements_) diff --git a/vhdlpp/subprogram.h b/vhdlpp/subprogram.h index 68f62f8c3..5b38f1223 100644 --- a/vhdlpp/subprogram.h +++ b/vhdlpp/subprogram.h @@ -48,7 +48,8 @@ class Subprogram : public LineInfo, public ScopeBase { // matches this subprogram and that subprogram. bool compare_specification(Subprogram*that) const; - InterfacePort*find_param(perm_string nam); + const InterfacePort*find_param(perm_string nam) const; + const VType*peek_param_type(int idx) const; int emit(ostream&out, Entity*ent, Architecture*arc);