From 004ecd08ddd08f3cd6da6438847a8c89827bfeb8 Mon Sep 17 00:00:00 2001 From: steve Date: Wed, 2 Jul 2003 04:19:16 +0000 Subject: [PATCH] Elide empty begin-end in conditionals. --- elaborate.cc | 22 +++++++++++++++++++++- netlist.h | 12 +++++++++--- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/elaborate.cc b/elaborate.cc index 59c244461..9d1aa1f2c 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elaborate.cc,v 1.283 2003/06/21 01:21:43 steve Exp $" +#ident "$Id: elaborate.cc,v 1.284 2003/07/02 04:19:16 steve Exp $" #endif # include "config.h" @@ -1387,6 +1387,23 @@ NetProc* PCondit::elaborate(Design*des, NetScope*scope) const NetProc*i = if_? if_->elaborate(des, scope) : 0; NetProc*e = else_? else_->elaborate(des, scope) : 0; + // Detect the special cases that the if or else statements are + // empty blocks. If this is the case, remove the blocks as + // null statements. + if (NetBlock*tmp = dynamic_cast(i)) { + if (tmp->proc_first() == 0) { + delete i; + i = 0; + } + } + + if (NetBlock*tmp = dynamic_cast(e)) { + if (tmp->proc_first() == 0) { + delete e; + e = 0; + } + } + NetCondit*res = new NetCondit(expr, i, e); res->set_line(*this); return res; @@ -2560,6 +2577,9 @@ Design* elaborate(listroots) /* * $Log: elaborate.cc,v $ + * Revision 1.284 2003/07/02 04:19:16 steve + * Elide empty begin-end in conditionals. + * * Revision 1.283 2003/06/21 01:21:43 steve * Harmless fixup of warnings. * diff --git a/netlist.h b/netlist.h index fbfeca4a2..c3249680e 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netlist.h,v 1.292 2003/06/21 01:21:43 steve Exp $" +#ident "$Id: netlist.h,v 1.293 2003/07/02 04:19:16 steve Exp $" #endif /* @@ -1628,8 +1628,11 @@ class NetCAssign : public NetProc, public NetNode { }; -/* A condit represents a conditional. It has an expression to test, - and a pair of statements to select from. */ +/* + * A condit represents a conditional. It has an expression to test, + * and a pair of statements to select from. If the original statement + * has empty clauses, then the NetProc for it will be a nul pointer. + */ class NetCondit : public NetProc { public: @@ -3306,6 +3309,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.293 2003/07/02 04:19:16 steve + * Elide empty begin-end in conditionals. + * * Revision 1.292 2003/06/21 01:21:43 steve * Harmless fixup of warnings. *