From 741b17245da9b9480aa6ec870584af22fc0380c0 Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 16 Jul 2000 04:56:07 +0000 Subject: [PATCH] Handle some edge cases during node scans. --- functor.cc | 25 +++++++++++++++++++++++-- functor.h | 12 +++++++++++- net_design.cc | 6 +++++- netlist.h | 6 +++++- 4 files changed, 44 insertions(+), 5 deletions(-) diff --git a/functor.cc b/functor.cc index 0492f2024..b881f4849 100644 --- a/functor.cc +++ b/functor.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: functor.cc,v 1.19 2000/07/15 05:13:43 steve Exp $" +#ident "$Id: functor.cc,v 1.20 2000/07/16 04:56:07 steve Exp $" #endif # include "functor.h" @@ -110,12 +110,30 @@ void Design::functor(functor_t*fun) // apply to nodes if (nodes_) { + /* Scan the circular list of nodes, starting with the + front of the list. (nodes_ points to the *end* of the + list.) The bar is the end point. At the end of the + do-while loop, I know that the bar has been + processed or (if bar == 0) no undeleted node has been + processed. */ NetNode*cur = nodes_->node_next_; + NetNode*bar = 0; do { NetNode*tmp = cur->node_next_; cur->functor_node(this, fun); + + /* Detect the case that cur has been deleted by + noticing if tmp->node_prev_ no longer points to + cur. If that's the case, clear the bar. */ + if (tmp->node_prev_ != cur) { + if (cur == bar) + bar = 0; + } else if (bar == 0) { + bar = cur; + } cur = tmp; - } while (nodes_ && cur != nodes_->node_next_); + + } while (nodes_ && (cur != bar)); } } @@ -227,6 +245,9 @@ int proc_match_t::event_wait(NetEvWait*) /* * $Log: functor.cc,v $ + * Revision 1.20 2000/07/16 04:56:07 steve + * Handle some edge cases during node scans. + * * Revision 1.19 2000/07/15 05:13:43 steve * Detect muxing Vz as a bufufN. * diff --git a/functor.h b/functor.h index bc3090acf..c08b5b3f9 100644 --- a/functor.h +++ b/functor.h @@ -19,13 +19,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: functor.h,v 1.14 2000/07/15 05:13:44 steve Exp $" +#ident "$Id: functor.h,v 1.15 2000/07/16 04:56:07 steve Exp $" #endif /* * The functor is an object that can be applied to a design to * transform it. This is different from the target_t, which can only * scan the design but not transform it in any way. + * + * When a functor it scanning a process, signal or node, the functor + * is free to manipulate the list by deleting items, including the + * node being scanned. The Design class scanner knows how to handle + * the situation. However, if objects are added to the netlist, there + * is no guarantee that object will be scanned unless the functor is + * rerun. */ class Design; @@ -82,6 +89,9 @@ struct proc_match_t { /* * $Log: functor.h,v $ + * Revision 1.15 2000/07/16 04:56:07 steve + * Handle some edge cases during node scans. + * * Revision 1.14 2000/07/15 05:13:44 steve * Detect muxing Vz as a bufufN. * diff --git a/net_design.cc b/net_design.cc index ae4415753..1f82b80ad 100644 --- a/net_design.cc +++ b/net_design.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: net_design.cc,v 1.9 2000/07/14 06:12:57 steve Exp $" +#ident "$Id: net_design.cc,v 1.10 2000/07/16 04:56:08 steve Exp $" #endif /* @@ -46,6 +46,7 @@ static string parse_last_name(string&path) Design:: Design() : errors(0), root_scope_(0), nodes_(0), procs_(0), lcounter_(0) { + procs_idx_ = 0; } Design::~Design() @@ -470,6 +471,9 @@ void Design::delete_process(NetProcTop*top) /* * $Log: net_design.cc,v $ + * Revision 1.10 2000/07/16 04:56:08 steve + * Handle some edge cases during node scans. + * * Revision 1.9 2000/07/14 06:12:57 steve * Move inital value handling from NetNet to Nexus * objects. This allows better propogation of inital diff --git a/netlist.h b/netlist.h index 58decd43f..375edc900 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: netlist.h,v 1.146 2000/07/15 05:13:44 steve Exp $" +#ident "$Id: netlist.h,v 1.147 2000/07/16 04:56:08 steve Exp $" #endif /* @@ -266,6 +266,7 @@ class NetNode : public NetObj { virtual void emit_node(ostream&, struct target_t*) const; virtual void dump_node(ostream&, unsigned) const; + // This is used to scan a modifiable netlist, one node at a time. virtual void functor_node(Design*, functor_t*); private: @@ -2659,6 +2660,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.147 2000/07/16 04:56:08 steve + * Handle some edge cases during node scans. + * * Revision 1.146 2000/07/15 05:13:44 steve * Detect muxing Vz as a bufufN. *