Elide empty begin-end in conditionals.

This commit is contained in:
steve 2003-07-02 04:19:16 +00:00
parent eb605694eb
commit 004ecd08dd
2 changed files with 30 additions and 4 deletions

View File

@ -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<NetBlock*>(i)) {
if (tmp->proc_first() == 0) {
delete i;
i = 0;
}
}
if (NetBlock*tmp = dynamic_cast<NetBlock*>(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(list<const char*>roots)
/*
* $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.
*

View File

@ -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.
*