From ea12c0fe23a55e6d4358b7d1f85443c7b41b45e7 Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Thu, 21 May 2015 14:25:46 +0200 Subject: [PATCH] vhdlp: Renamed ExpConditional::else_t to ExpConditional::option_t. --- vhdlpp/debug.cc | 4 +-- vhdlpp/expression.cc | 50 ++++++++++++++++++---------------- vhdlpp/expression.h | 13 +++++---- vhdlpp/expression_elaborate.cc | 4 +-- vhdlpp/expression_emit.cc | 8 +++--- vhdlpp/parse.y | 12 ++++---- 6 files changed, 47 insertions(+), 44 deletions(-) diff --git a/vhdlpp/debug.cc b/vhdlpp/debug.cc index 7c2295718..3d5d72a30 100644 --- a/vhdlpp/debug.cc +++ b/vhdlpp/debug.cc @@ -288,13 +288,13 @@ void ExpConditional::dump(ostream&out, int indent) const (*cur)->dump(out, indent+4); } - for (list::const_iterator cur = else_clause_.begin() + for (list::const_iterator cur = else_clause_.begin() ; cur != else_clause_.end() ; ++cur) { (*cur)->dump(out, indent); } } -void ExpConditional::else_t::dump(ostream&out, int indent) const +void ExpConditional::option_t::dump(ostream&out, int indent) const { out << setw(indent) << "" << "when:" << endl; if (cond_) cond_->dump(out, indent+4); diff --git a/vhdlpp/expression.cc b/vhdlpp/expression.cc index 0e3a0b493..6dc4c2125 100644 --- a/vhdlpp/expression.cc +++ b/vhdlpp/expression.cc @@ -301,7 +301,7 @@ void ExpConcat::visit(ExprVisitor& func) } ExpConditional::ExpConditional(Expression*co, list*tru, - list*fal) + list*fal) : cond_(co) { if (tru) true_clause_.splice(true_clause_.end(), *tru); @@ -317,7 +317,7 @@ ExpConditional::~ExpConditional() delete tmp; } while (! else_clause_.empty()) { - else_t*tmp = else_clause_.front(); + option_t*tmp = else_clause_.front(); else_clause_.pop_front(); delete tmp; } @@ -335,13 +335,13 @@ Expression*ExpConditional::clone() const } } - std::list*new_else_clause = NULL; + std::list*new_else_clause = NULL; if(!else_clause_.empty()) { - new_else_clause = new std::list(); + new_else_clause = new std::list(); - for(std::list::const_iterator it = else_clause_.begin(); + for(std::list::const_iterator it = else_clause_.begin(); it != else_clause_.end(); ++it) { - new_else_clause->push_back(new else_t(**it)); + new_else_clause->push_back(new option_t(**it)); } } @@ -350,35 +350,26 @@ Expression*ExpConditional::clone() const void ExpConditional::visit(ExprVisitor& func) { - if(!true_clause_.empty()) { - for(std::list::iterator it = true_clause_.begin(); - it != true_clause_.end(); ++it) { - (*it)->visit(func); - } + for(std::list::iterator it = true_clause_.begin(); + it != true_clause_.end(); ++it) { + (*it)->visit(func); } - if(!else_clause_.empty()) { - for(std::list::iterator it = else_clause_.begin(); - it != else_clause_.end(); ++it) { - std::list& else_clause = (*it)->extract_true_clause(); - - for(std::list::iterator jt = else_clause.begin(); - jt != else_clause.end(); ++jt) { - (*jt)->visit(func); - } - } + for(std::list::iterator it = else_clause_.begin(); + it != else_clause_.end(); ++it) { + (*it)->visit(func); } func(this); } -ExpConditional::else_t::else_t(Expression*cond, std::list*tru) +ExpConditional::option_t::option_t(Expression*cond, std::list*tru) : cond_(cond) { if (tru) true_clause_.splice(true_clause_.end(), *tru); } -ExpConditional::else_t::else_t(const else_t&other) +ExpConditional::option_t::option_t(const option_t&other) : LineInfo(other) { cond_ = other.cond_->clone(); @@ -388,7 +379,7 @@ ExpConditional::else_t::else_t(const else_t&other) } } -ExpConditional::else_t::~else_t() +ExpConditional::option_t::~option_t() { delete cond_; while (! true_clause_.empty()) { @@ -399,6 +390,17 @@ ExpConditional::else_t::~else_t() } +void ExpConditional::option_t::visit(ExprVisitor& func) +{ + if(cond_) + func(cond_); + + for(std::list::iterator it = true_clause_.begin(); + it != true_clause_.end(); ++it) { + func(*it); + } +} + ExpEdge::ExpEdge(ExpEdge::fun_t typ, Expression*op) : ExpUnary(op), fun_(typ) { diff --git a/vhdlpp/expression.h b/vhdlpp/expression.h index 479d207d5..d770507a0 100644 --- a/vhdlpp/expression.h +++ b/vhdlpp/expression.h @@ -460,17 +460,18 @@ class ExpConcat : public Expression { class ExpConditional : public Expression { public: - class else_t : public LineInfo { + class option_t : public LineInfo { public: - else_t(Expression*cond, std::list*tru); - else_t(const else_t&other); - ~else_t(); + option_t(Expression*cond, std::list*tru); + option_t(const option_t&other); + ~option_t(); int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*lt); int emit_when_else(ostream&out, Entity*ent, ScopeBase*scope); int emit_else(ostream&out, Entity*ent, ScopeBase*scope); void dump(ostream&out, int indent = 0) const; std::list& extract_true_clause() { return true_clause_; } + void visit(ExprVisitor& func); private: Expression*cond_; @@ -479,7 +480,7 @@ class ExpConditional : public Expression { public: ExpConditional(Expression*cond, std::list*tru, - std::list*fal); + std::list*fal); ~ExpConditional(); Expression*clone() const; @@ -494,7 +495,7 @@ class ExpConditional : public Expression { private: Expression*cond_; std::list true_clause_; - std::list else_clause_; + std::list else_clause_; }; /* diff --git a/vhdlpp/expression_elaborate.cc b/vhdlpp/expression_elaborate.cc index 71cda7c97..72fe1cf7f 100644 --- a/vhdlpp/expression_elaborate.cc +++ b/vhdlpp/expression_elaborate.cc @@ -721,7 +721,7 @@ int ExpConditional::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltyp errors += (*cur)->elaborate_expr(ent, scope, ltype); } - for (list::const_iterator cur = else_clause_.begin() + for (list::const_iterator cur = else_clause_.begin() ; cur != else_clause_.end() ; ++cur) { errors += (*cur)->elaborate_expr(ent, scope, ltype); } @@ -729,7 +729,7 @@ int ExpConditional::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltyp return errors; } -int ExpConditional::else_t::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) +int ExpConditional::option_t::elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) { int errors = 0; diff --git a/vhdlpp/expression_emit.cc b/vhdlpp/expression_emit.cc index e7263e406..ae5ad492e 100644 --- a/vhdlpp/expression_emit.cc +++ b/vhdlpp/expression_emit.cc @@ -497,10 +497,10 @@ int ExpConditional::emit(ostream&out, Entity*ent, ScopeBase*scope) // Draw out any when-else expressions. These are all the else_ // clauses besides the last. if (else_clause_.size() > 1) { - list::iterator last = else_clause_.end(); + list::iterator last = else_clause_.end(); -- last; - for (list::iterator cur = else_clause_.begin() + for (list::iterator cur = else_clause_.begin() ; cur != last ; ++cur) { errors += (*cur) ->emit_when_else(out, ent, scope); } @@ -519,7 +519,7 @@ int ExpConditional::emit(ostream&out, Entity*ent, ScopeBase*scope) return errors; } -int ExpConditional::else_t::emit_when_else(ostream&out, Entity*ent, ScopeBase*scope) +int ExpConditional::option_t::emit_when_else(ostream&out, Entity*ent, ScopeBase*scope) { int errors = 0; assert(cond_ != 0); @@ -541,7 +541,7 @@ int ExpConditional::else_t::emit_when_else(ostream&out, Entity*ent, ScopeBase*sc return errors; } -int ExpConditional::else_t::emit_else(ostream&out, Entity*ent, ScopeBase*scope) +int ExpConditional::option_t::emit_else(ostream&out, Entity*ent, ScopeBase*scope) { int errors = 0; // Trailing else must have no condition. diff --git a/vhdlpp/parse.y b/vhdlpp/parse.y index 8188052ba..1d481fe10 100644 --- a/vhdlpp/parse.y +++ b/vhdlpp/parse.y @@ -228,8 +228,8 @@ static void touchup_interface_for_functions(std::list*ports) IfSequential::Elsif*elsif; std::list*elsif_list; - ExpConditional::else_t*exp_else; - std::list*exp_else_list; + ExpConditional::option_t*exp_else; + std::list*exp_else_list; CaseSeqStmt::CaseStmtAlternative* case_alt; std::list* case_alt_list; @@ -800,12 +800,12 @@ concurrent_simple_signal_assignment else_when_waveforms : else_when_waveforms else_when_waveform - { list*tmp = $1; + { list*tmp = $1; tmp ->push_back($2); $$ = tmp; } | else_when_waveform - { list*tmp = new list; + { list*tmp = new list; tmp->push_back($1); $$ = tmp; } @@ -813,12 +813,12 @@ else_when_waveforms else_when_waveform : K_else waveform K_when expression - { ExpConditional::else_t*tmp = new ExpConditional::else_t($4, $2); + { ExpConditional::option_t*tmp = new ExpConditional::option_t($4, $2); FILE_NAME(tmp, @1); $$ = tmp; } | K_else waveform - { ExpConditional::else_t*tmp = new ExpConditional::else_t(0, $2); + { ExpConditional::option_t*tmp = new ExpConditional::option_t(0, $2); FILE_NAME(tmp, @1); $$ = tmp; }