From b981c81d37638b319ddac1be5ec30fbd0fa0c82b Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 26 Apr 2007 03:06:21 +0000 Subject: [PATCH] Rework hname_t to use perm_strings. --- HName.cc | 85 ++++++++++++++++++++++++------------------------ HName.h | 25 +++++++++----- PWire.cc | 7 ++-- PWire.h | 45 ++++--------------------- elab_pexpr.cc | 14 ++++---- elab_sig.cc | 25 ++++++++++++-- net_design.cc | 17 +++++----- net_scope.cc | 26 +++------------ netlist.h | 8 ++--- parse.y | 35 +++++++++++--------- pform.cc | 23 +++++++------ symbol_search.cc | 20 +++++------- 12 files changed, 157 insertions(+), 173 deletions(-) diff --git a/HName.cc b/HName.cc index 7342b7aa4..47a89cc9e 100644 --- a/HName.cc +++ b/HName.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: HName.cc,v 1.5 2002/11/02 03:27:52 steve Exp $" +#ident "$Id: HName.cc,v 1.6 2007/04/26 03:06:21 steve Exp $" #endif # include "config.h" @@ -31,13 +31,12 @@ hname_t::hname_t() { - item_ = 0; count_ = 0; } -hname_t::hname_t(const char*text) +hname_t::hname_t(perm_string text) { - item_ = strdup(text); + new (item_) perm_string(text); count_ = 1; } @@ -46,15 +45,14 @@ hname_t::hname_t(const hname_t&that) count_ = that.count_; switch (count_) { case 0: - item_ = 0; break; case 1: - item_ = strdup(that.item_); + new(item_) perm_string (that.item_ref1_()); break; default: - array_ = new char*[count_]; + array_ = new perm_string[count_]; for (unsigned idx = 0 ; idx < count_ ; idx += 1) - array_[idx] = strdup(that.array_[idx]); + array_[idx] = that.array_[idx]; break; } } @@ -65,11 +63,9 @@ hname_t::~hname_t() case 0: break; case 1: - free(item_); + item_ref1_().~perm_string(); break; default: - for (unsigned idx = 0 ; idx < count_ ; idx += 1) - free(array_[idx]); delete[]array_; break; } @@ -80,52 +76,54 @@ unsigned hname_t::component_count() const return count_; } -void hname_t::append(const char*text) +void hname_t::append(perm_string text) { - char**tmp; + perm_string*tmp; switch (count_) { case 0: count_ = 1; - item_ = strdup(text); + new (item_) perm_string(text); break; case 1: count_ = 2; - tmp = new char*[2]; - tmp[0] = item_; - tmp[1] = strdup(text); + tmp = new perm_string[2]; + tmp[0] = item_ref1_(); + tmp[1] = text; + item_ref1_().~perm_string(); array_ = tmp; break; default: - tmp = new char*[count_+1]; + tmp = new perm_string[count_+1]; for (unsigned idx = 0 ; idx < count_ ; idx += 1) tmp[idx] = array_[idx]; delete[]array_; array_ = tmp; - array_[count_] = strdup(text); + array_[count_] = text; count_ += 1; } } -void hname_t::prepend(const char*text) +void hname_t::prepend(perm_string text) { - char**tmp; + perm_string*tmp; switch (count_) { case 0: count_ = 1; - item_ = strdup(text); + new (item_) perm_string(text); break; case 1: count_ = 2; - tmp = new char*[2]; - tmp[0] = strdup(text); - tmp[1] = item_; + tmp = new perm_string[2]; + tmp[0] = text; + tmp[1] = item_ref1_(); + item_ref1_().~perm_string(); array_ = tmp; break; default: - tmp = new char*[count_+1]; - tmp[0] = strdup(text); + tmp = new perm_string[count_+1]; + tmp[0] = text; for (unsigned idx = 0 ; idx < count_ ; idx += 1) tmp[idx+1] = array_[idx]; delete[]array_; @@ -134,29 +132,29 @@ void hname_t::prepend(const char*text) } } -char* hname_t::remove_tail_name() +perm_string hname_t::remove_tail_name() { if (count_ == 0) - return 0; + return perm_string(); if (count_ == 1) { - char*tmp = item_; + perm_string tmp = item_ref1_(); count_ = 0; - item_ = 0; + item_ref1_().~perm_string(); return tmp; } if (count_ == 2) { - char*tmp1 = array_[0]; - char*tmp2 = array_[1]; + perm_string tmp1 = array_[0]; + perm_string tmp2 = array_[1]; delete[]array_; count_ = 1; - item_ = tmp1; + new (item_) perm_string(tmp1); return tmp2; } - char*tmpo = array_[count_-1]; - char**tmpa = new char*[count_-1]; + perm_string tmpo = array_[count_-1]; + perm_string*tmpa = new perm_string[count_-1]; for (unsigned idx = 0 ; idx < count_-1 ; idx += 1) tmpa[idx] = array_[idx]; @@ -166,24 +164,24 @@ char* hname_t::remove_tail_name() return tmpo; } -const char* hname_t::peek_name(unsigned idx) const +perm_string hname_t::peek_name(unsigned idx) const { if (idx >= count_) - return 0; + return perm_string(); if (count_ == 1) - return item_; + return item_ref1_(); return array_[idx]; } -const char* hname_t::peek_tail_name() const +perm_string hname_t::peek_tail_name() const { switch (count_) { case 0: - return 0; + return perm_string(); case 1: - return item_; + return item_ref1_(); default: return array_[count_-1]; } @@ -258,6 +256,9 @@ ostream& operator<< (ostream&out, const hname_t&that) /* * $Log: HName.cc,v $ + * Revision 1.6 2007/04/26 03:06:21 steve + * Rework hname_t to use perm_strings. + * * Revision 1.5 2002/11/02 03:27:52 steve * Allow named events to be referenced by * hierarchical names. diff --git a/HName.h b/HName.h index 8b6d480c4..ded2e6b2c 100644 --- a/HName.h +++ b/HName.h @@ -19,10 +19,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: HName.h,v 1.4 2002/11/02 03:27:51 steve Exp $" +#ident "$Id: HName.h,v 1.5 2007/04/26 03:06:21 steve Exp $" #endif # include +# include "StringHeap.h" #ifdef __GNUC__ #if __GNUC__ > 2 using namespace std; @@ -38,28 +39,28 @@ class hname_t { public: hname_t (); - explicit hname_t (const char*text); + explicit hname_t (perm_string text); hname_t (const hname_t&that); ~hname_t(); // This method adds a name to the end of the hierarchical // path. This becomes a new base name. - void append(const char*text); + void append(perm_string text); // This method adds a name to the *front* of the hierarchical // path. The base name remains the same, unless this is the // only component. - void prepend(const char*text); + void prepend(perm_string text); // This method removes the tail name from the hierarchy, and // returns a pointer to that tail name. That tail name now // must be removed by the caller. - char* remove_tail_name(); + perm_string remove_tail_name(); // Return the given component in the hierarchical name. If the // idx is too large, return 0. - const char*peek_name(unsigned idx) const; - const char*peek_tail_name() const; + perm_string peek_name(unsigned idx) const; + perm_string peek_tail_name() const; // Return the number of components in the hierarchical // name. If this is a simple name, this will return 1. @@ -69,11 +70,14 @@ class hname_t { private: union { - char**array_; - char* item_; + perm_string*array_; + char* item_[sizeof(perm_string)]; }; unsigned count_; + perm_string& item_ref1_() { return *(perm_string*)item_; } + const perm_string& item_ref1_() const { return *(perm_string*)item_; } + private: // not implemented hname_t& operator= (const hname_t&); }; @@ -83,6 +87,9 @@ extern bool operator == (const hname_t&, const hname_t&); /* * $Log: HName.h,v $ + * Revision 1.5 2007/04/26 03:06:21 steve + * Rework hname_t to use perm_strings. + * * Revision 1.4 2002/11/02 03:27:51 steve * Allow named events to be referenced by * hierarchical names. diff --git a/PWire.cc b/PWire.cc index 1b3d463bf..e5e1a845c 100644 --- a/PWire.cc +++ b/PWire.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: PWire.cc,v 1.12 2007/01/16 05:44:14 steve Exp $" +#ident "$Id: PWire.cc,v 1.13 2007/04/26 03:06:21 steve Exp $" #endif # include "config.h" @@ -39,7 +39,7 @@ lidx_(0), ridx_(0) } } -PWire::PWire(char*n, +PWire::PWire(perm_string n, NetNet::Type t, NetNet::PortType pt, ivl_variable_type_t dt) @@ -160,6 +160,9 @@ void PWire::set_memory_idx(PExpr*ldx, PExpr*rdx) /* * $Log: PWire.cc,v $ + * Revision 1.13 2007/04/26 03:06:21 steve + * Rework hname_t to use perm_strings. + * * Revision 1.12 2007/01/16 05:44:14 steve * Major rework of array handling. Memories are replaced with the * more general concept of arrays. The NetMemory and NetEMemory diff --git a/PWire.h b/PWire.h index 2ac181395..d471625a6 100644 --- a/PWire.h +++ b/PWire.h @@ -1,7 +1,7 @@ #ifndef __PWire_H #define __PWire_H /* - * Copyright (c) 1998-2000 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2007 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -19,13 +19,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: PWire.h,v 1.19 2006/04/10 00:37:42 steve Exp $" +#ident "$Id: PWire.h,v 1.20 2007/04/26 03:06:22 steve Exp $" #endif # include "netlist.h" # include "LineInfo.h" # include # include "svector.h" +# include "StringHeap.h" #ifdef HAVE_IOSFWD # include @@ -53,7 +54,7 @@ class PWire : public LineInfo { NetNet::Type t, NetNet::PortType pt, ivl_variable_type_t dt); - PWire(char*name, + PWire(perm_string name, NetNet::Type t, NetNet::PortType pt, ivl_variable_type_t dt); @@ -110,6 +111,9 @@ class PWire : public LineInfo { /* * $Log: PWire.h,v $ + * Revision 1.20 2007/04/26 03:06:22 steve + * Rework hname_t to use perm_strings. + * * Revision 1.19 2006/04/10 00:37:42 steve * Add support for generate loops w/ wires and gates. * @@ -146,40 +150,5 @@ class PWire : public LineInfo { * * Revision 1.10 2001/01/16 02:44:18 steve * Use the iosfwd header if available. - * - * Revision 1.9 2000/12/11 00:31:43 steve - * Add support for signed reg variables, - * simulate in t-vvm signed comparisons. - * - * Revision 1.8 2000/05/02 16:27:38 steve - * Move signal elaboration to a seperate pass. - * - * Revision 1.7 2000/02/23 02:56:54 steve - * Macintosh compilers do not support ident. - * - * Revision 1.6 1999/11/27 19:07:57 steve - * Support the creation of scopes. - * - * Revision 1.5 1999/06/17 05:34:42 steve - * Clean up interface of the PWire class, - * Properly match wire ranges. - * - * Revision 1.4 1999/06/02 15:38:46 steve - * Line information with nets. - * - * Revision 1.3 1999/04/19 01:59:36 steve - * Add memories to the parse and elaboration phases. - * - * Revision 1.2 1998/11/23 00:20:22 steve - * NetAssign handles lvalues as pin links - * instead of a signal pointer, - * Wire attributes added, - * Ability to parse UDP descriptions added, - * XNF generates EXT records for signals with - * the PAD attribute. - * - * Revision 1.1 1998/11/03 23:28:55 steve - * Introduce verilog to CVS. - * */ #endif diff --git a/elab_pexpr.cc b/elab_pexpr.cc index 7a21085cd..55b89202a 100644 --- a/elab_pexpr.cc +++ b/elab_pexpr.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elab_pexpr.cc,v 1.25 2006/11/04 06:19:25 steve Exp $" +#ident "$Id: elab_pexpr.cc,v 1.26 2007/04/26 03:06:22 steve Exp $" #endif # include "config.h" @@ -131,18 +131,15 @@ NetExpr*PEFNumber::elaborate_pexpr(Design*des, NetScope*scope) const NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const { hname_t path = path_; - char*name = path.remove_tail_name(); + perm_string name = path.remove_tail_name(); NetScope*pscope = scope; if (path.peek_name(0)) pscope = des->find_scope(scope, path); - perm_string perm_name = lex_strings.make(name); - delete name; - const NetExpr*ex_msb; const NetExpr*ex_lsb; - const NetExpr*ex = pscope->get_parameter(perm_name, ex_msb, ex_lsb); + const NetExpr*ex = pscope->get_parameter(name, ex_msb, ex_lsb); if (ex == 0) { cerr << get_line() << ": error: identifier ``" << path_ << "'' is not a parameter in " << scope->name() << "." << endl; @@ -150,7 +147,7 @@ NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const return 0; } - NetExpr*res = new NetEParam(des, pscope, perm_name); + NetExpr*res = new NetEParam(des, pscope, name); res->set_line(*this); assert(res); @@ -236,6 +233,9 @@ NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const /* * $Log: elab_pexpr.cc,v $ + * Revision 1.26 2007/04/26 03:06:22 steve + * Rework hname_t to use perm_strings. + * * Revision 1.25 2006/11/04 06:19:25 steve * Remove last bits of relax_width methods, and use test_width * to calculate the width of an r-value expression that may diff --git a/elab_sig.cc b/elab_sig.cc index 83c097dd0..0d0abf8fa 100644 --- a/elab_sig.cc +++ b/elab_sig.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: elab_sig.cc,v 1.49 2007/04/02 01:12:34 steve Exp $" +#ident "$Id: elab_sig.cc,v 1.50 2007/04/26 03:06:22 steve Exp $" #endif # include "config.h" @@ -63,6 +63,22 @@ static bool signal_is_in_port(const svector&ports, return false; } +static NetNet*find_signal_in_scope(NetScope*scope, const hname_t&path) +{ + NetScope*cur = scope; + unsigned idx = 0; + + while (path.peek_name(idx+1)) { + cur = cur->child(path.peek_name(idx)); + if (cur == 0) + return 0; + + idx += 1; + } + + return cur->find_signal(path.peek_name(idx)); +} + bool Module::elaborate_sig(Design*des, NetScope*scope) const { bool flag = true; @@ -110,7 +126,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const PWire*cur = (*wt).second; cur->elaborate_sig(des, scope); - NetNet*sig = scope->find_signal_in_child(cur->path()); + NetNet*sig = find_signal_in_scope(scope, cur->path()); // If this wire is a signal of the module (as opposed to // a port of a function) and is a port, then check that @@ -509,7 +525,7 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const follow the scopes down to the base where I actually want to elaborate the NetNet object. */ { hname_t tmp_path = hname_; - free(tmp_path.remove_tail_name()); + tmp_path.remove_tail_name(); for (unsigned idx = 0 ; tmp_path.peek_name(idx) ; idx += 1) { scope = scope->child(tmp_path.peek_name(idx)); @@ -742,6 +758,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const /* * $Log: elab_sig.cc,v $ + * Revision 1.50 2007/04/26 03:06:22 steve + * Rework hname_t to use perm_strings. + * * Revision 1.49 2007/04/02 01:12:34 steve * Seperate arrayness from word count * diff --git a/net_design.cc b/net_design.cc index b3e249205..b9bdb1d32 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: net_design.cc,v 1.50 2006/08/08 05:11:37 steve Exp $" +#ident "$Id: net_design.cc,v 1.51 2007/04/26 03:06:22 steve Exp $" #endif # include "config.h" @@ -201,9 +201,7 @@ void NetScope::run_defparams(Design*des) NetExpr*val = (*pp).second; hname_t path = (*pp).first; - char*tmp = path.remove_tail_name(); - perm_string perm_name = lex_strings.make(tmp); - delete[]tmp; + perm_string perm_name = path.remove_tail_name(); /* If there is no path on the name, then the targ_scope is the current scope. */ @@ -429,22 +427,20 @@ NetNet* Design::find_signal(NetScope*scope, hname_t path) { assert(scope); - char*key = path.remove_tail_name(); + perm_string key = path.remove_tail_name(); if (path.peek_name(0)) scope = find_scope(scope, path); while (scope) { - if (NetNet*net = scope->find_signal(key)) { - delete key; + if (NetNet*net = scope->find_signal(key)) return net; - } if (scope->type() == NetScope::MODULE) break; + scope = scope->parent(); } - delete key; return 0; } @@ -562,6 +558,9 @@ void Design::delete_process(NetProcTop*top) /* * $Log: net_design.cc,v $ + * Revision 1.51 2007/04/26 03:06:22 steve + * Rework hname_t to use perm_strings. + * * Revision 1.50 2006/08/08 05:11:37 steve * Handle 64bit delay constants. * diff --git a/net_scope.cc b/net_scope.cc index d0be84796..f32a0e144 100644 --- a/net_scope.cc +++ b/net_scope.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: net_scope.cc,v 1.36 2007/01/16 05:44:15 steve Exp $" +#ident "$Id: net_scope.cc,v 1.37 2007/04/26 03:06:22 steve Exp $" #endif # include "config.h" @@ -336,27 +336,6 @@ NetNet* NetScope::find_signal(const char*key) return 0; } -/* - * This method searches for the signal within this scope. If the path - * has hierarchy, I follow the child scopes until I get the base name, - * and look for the key in the deepest scope. - */ -NetNet* NetScope::find_signal_in_child(const hname_t&path) -{ - NetScope*cur = this; - unsigned idx = 0; - - while (path.peek_name(idx+1)) { - cur = cur->child(path.peek_name(idx)); - if (cur == 0) - return 0; - - idx += 1; - } - - return cur->find_signal(path.peek_name(idx)); -} - /* * This method locates a child scope by name. The name is the simple * name of the child, no hierarchy is searched. @@ -412,6 +391,9 @@ string NetScope::local_hsymbol() /* * $Log: net_scope.cc,v $ + * Revision 1.37 2007/04/26 03:06:22 steve + * Rework hname_t to use perm_strings. + * * Revision 1.36 2007/01/16 05:44:15 steve * Major rework of array handling. Memories are replaced with the * more general concept of arrays. The NetMemory and NetEMemory diff --git a/netlist.h b/netlist.h index fcdff3ecc..57961bf4d 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.377 2007/04/17 04:34:23 steve Exp $" +#ident "$Id: netlist.h,v 1.378 2007/04/26 03:06:22 steve Exp $" #endif /* @@ -3220,10 +3220,7 @@ class NetScope : public Attrib { void add_signal(NetNet*); void rem_signal(NetNet*); - NetNet* find_signal(const char*name); - NetNet* find_signal_in_child(const hname_t&name); - /* The parent and child() methods allow users of NetScope objects to locate nearby scopes. */ @@ -3503,6 +3500,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.378 2007/04/26 03:06:22 steve + * Rework hname_t to use perm_strings. + * * Revision 1.377 2007/04/17 04:34:23 steve * Fix handling calls to tasks in combinational always block * diff --git a/parse.y b/parse.y index 6d58a841c..83cabfa42 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: parse.y,v 1.235 2007/04/21 04:45:36 steve Exp $" +#ident "$Id: parse.y,v 1.236 2007/04/26 03:06:22 steve Exp $" #endif # include "config.h" @@ -605,7 +605,7 @@ delay_value_simple } } | IDENTIFIER - { PEIdent*tmp = new PEIdent(hname_t($1)); + { PEIdent*tmp = new PEIdent(hname_t(lex_strings.make($1))); tmp->set_file(@1.text); tmp->set_lineno(@1.first_line); $$ = tmp; @@ -1033,7 +1033,8 @@ expr_primary $$ = tmp; } | SYSTEM_IDENTIFIER - { PECallFunction*tmp = new PECallFunction(hname_t($1)); + { perm_string tn = lex_strings.make($1); + PECallFunction*tmp = new PECallFunction(hname_t(tn)); tmp->set_file(@1.text); tmp->set_lineno(@1.first_line); $$ = tmp; @@ -1087,7 +1088,8 @@ expr_primary $$ = tmp; } | SYSTEM_IDENTIFIER '(' expression_list_proper ')' - { PECallFunction*tmp = new PECallFunction(hname_t($1), *$3); + { perm_string tn = lex_strings.make($1); + PECallFunction*tmp = new PECallFunction(hname_t(tn), *$3); tmp->set_file(@1.text); tmp->set_lineno(@1.first_line); $$ = tmp; @@ -1346,12 +1348,12 @@ gatetype hierarchical name from left to right, forming a list of names. */ identifier : IDENTIFIER - { $$ = new hname_t($1); + { $$ = new hname_t(lex_strings.make($1)); delete $1; } | identifier '.' IDENTIFIER { hname_t * tmp = $1; - tmp->append($3); + tmp->append(lex_strings.make($3)); delete $3; $$ = tmp; } @@ -2313,7 +2315,7 @@ port_reference } | IDENTIFIER '[' expression ':' expression ']' - { PEIdent*wtmp = new PEIdent(hname_t($1)); + { PEIdent*wtmp = new PEIdent(hname_t(lex_strings.make($1))); wtmp->set_file(@1.text); wtmp->set_lineno(@1.first_line); if (!pform_expression_is_constant($3)) { @@ -2336,7 +2338,7 @@ port_reference } | IDENTIFIER '[' expression ']' - { PEIdent*tmp = new PEIdent(hname_t($1)); + { PEIdent*tmp = new PEIdent(hname_t(lex_strings.make($1))); tmp->set_file(@1.text); tmp->set_lineno(@1.first_line); if (!pform_expression_is_constant($3)) { @@ -2355,7 +2357,7 @@ port_reference | IDENTIFIER '[' error ']' { yyerror(@1, "error: invalid port bit select"); Module::port_t*ptmp = new Module::port_t; - PEIdent*wtmp = new PEIdent(hname_t($1)); + PEIdent*wtmp = new PEIdent(hname_t(lex_strings.make($1))); wtmp->set_file(@1.text); wtmp->set_lineno(@1.first_line); ptmp->name = lex_strings.make($1); @@ -3130,7 +3132,7 @@ statement $$ = tmp; } | SYSTEM_IDENTIFIER '(' expression_list_with_nuls ')' ';' - { PCallTask*tmp = new PCallTask(hname_t($1), *$3); + { PCallTask*tmp = new PCallTask(hname_t(lex_strings.make($1)), *$3); tmp->set_file(@1.text); tmp->set_lineno(@1.first_line); delete $1; @@ -3139,7 +3141,7 @@ statement } | SYSTEM_IDENTIFIER ';' { svectorpt (0); - PCallTask*tmp = new PCallTask(hname_t($1), pt); + PCallTask*tmp = new PCallTask(hname_t(lex_strings.make($1)), pt); tmp->set_file(@1.text); tmp->set_lineno(@1.first_line); delete $1; @@ -3521,7 +3523,7 @@ udp_sequ_entry udp_initial : K_initial IDENTIFIER '=' number ';' { PExpr*etmp = new PENumber($4); - PEIdent*itmp = new PEIdent(hname_t($2)); + PEIdent*itmp = new PEIdent(hname_t(lex_strings.make($2))); PAssign*atmp = new PAssign(itmp, etmp); atmp->set_file(@2.text); atmp->set_lineno(@2.first_line); @@ -3590,31 +3592,34 @@ udp_port_decl : K_input list_of_identifiers ';' { $$ = pform_make_udp_input_ports($2); } | K_output IDENTIFIER ';' - { PWire*pp = new PWire($2, + { PWire*pp = new PWire(lex_strings.make($2), NetNet::IMPLICIT, NetNet::POUTPUT, IVL_VT_LOGIC); svector*tmp = new svector(1); (*tmp)[0] = pp; $$ = tmp; + delete $2; } | K_reg IDENTIFIER ';' - { PWire*pp = new PWire($2, + { PWire*pp = new PWire(lex_strings.make($2), NetNet::REG, NetNet::PIMPLICIT, IVL_VT_LOGIC); svector*tmp = new svector(1); (*tmp)[0] = pp; $$ = tmp; + delete $2; } | K_reg K_output IDENTIFIER ';' - { PWire*pp = new PWire($3, + { PWire*pp = new PWire(lex_strings.make($3), NetNet::REG, NetNet::POUTPUT, IVL_VT_LOGIC); svector*tmp = new svector(1); (*tmp)[0] = pp; $$ = tmp; + delete $3; } ; diff --git a/pform.cc b/pform.cc index 504c3b7e6..44297d9ef 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform.cc,v 1.144 2007/04/19 02:52:53 steve Exp $" +#ident "$Id: pform.cc,v 1.145 2007/04/26 03:06:22 steve Exp $" #endif # include "config.h" @@ -91,20 +91,19 @@ static hname_t scope_stack; void pform_push_scope(char*name) { - scope_stack.append(name); + scope_stack.append(lex_strings.make(name)); } void pform_pop_scope() { - char*tmp = scope_stack.remove_tail_name(); + perm_string tmp = scope_stack.remove_tail_name(); assert(tmp); - free(tmp); } static hname_t hier_name(const char*tail) { hname_t name = scope_stack; - name.append(tail); + name.append(lex_strings.make(tail)); return name; } @@ -278,7 +277,7 @@ Module::port_t* pform_module_port_reference(char*name, unsigned lineno) { Module::port_t*ptmp = new Module::port_t; - PEIdent*tmp = new PEIdent(hname_t(name)); + PEIdent*tmp = new PEIdent(hname_t(lex_strings.make(name))); tmp->set_file(file); tmp->set_lineno(lineno); ptmp->name = lex_strings.make(name); @@ -514,7 +513,7 @@ void pform_make_udp(perm_string name, list*parms, hname_t pname = (*decl)[idx]->path(); - if (PWire*cur = defs[pname.peek_name(0)]) { + if (PWire*cur = defs[pname.peek_name(0).str()]) { bool rc = true; assert((*decl)[idx]); if ((*decl)[idx]->get_port_type() != NetNet::PIMPLICIT) { @@ -527,7 +526,7 @@ void pform_make_udp(perm_string name, list*parms, } } else { - defs[pname.peek_name(0)] = (*decl)[idx]; + defs[pname.peek_name(0).str()] = (*decl)[idx]; } } @@ -1286,10 +1285,11 @@ void pform_makewire(const vlltype&li, pform_makewire(li, first->name, type, NetNet::NOT_A_PORT, dt, 0); pform_set_net_range(first->name, range, signed_flag, dt); - hname_t name = hier_name(first->name); + perm_string first_name = lex_strings.make(first->name); + hname_t name = hier_name(first_name); PWire*cur = get_wire_in_module(name); if (cur != 0) { - PEIdent*lval = new PEIdent(hname_t(first->name)); + PEIdent*lval = new PEIdent(hname_t(first_name)); lval->set_file(li.text); lval->set_lineno(li.first_line); PGAssign*ass = pform_make_pgassign(lval, first->expr, @@ -1769,6 +1769,9 @@ int pform_parse(const char*path, FILE*file) /* * $Log: pform.cc,v $ + * Revision 1.145 2007/04/26 03:06:22 steve + * Rework hname_t to use perm_strings. + * * Revision 1.144 2007/04/19 02:52:53 steve * Add support for -v flag in command file. * diff --git a/symbol_search.cc b/symbol_search.cc index 25f461711..9784cbed4 100644 --- a/symbol_search.cc +++ b/symbol_search.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: symbol_search.cc,v 1.4 2007/01/16 05:44:15 steve Exp $" +#ident "$Id: symbol_search.cc,v 1.5 2007/04/26 03:06:22 steve Exp $" #endif # include "netlist.h" @@ -36,7 +36,7 @@ NetScope*symbol_search(const Design*des, NetScope*scope, hname_t path, assert(scope); /* Get the tail name of the object we are looking for. */ - char*key = path.remove_tail_name(); + perm_string key = path.remove_tail_name(); /* Initialize output argument to cleared. */ net = 0; @@ -49,20 +49,14 @@ NetScope*symbol_search(const Design*des, NetScope*scope, hname_t path, scope = des->find_scope(scope, path); while (scope) { - if ( (net = scope->find_signal(key)) ) { - delete key; + if ( (net = scope->find_signal(key)) ) return scope; - } - if ( (eve = scope->find_event(key)) ) { - delete key; + if ( (eve = scope->find_event(key)) ) return scope; - } - if ( (par = scope->get_parameter(key, ex1, ex2)) ) { - delete key; + if ( (par = scope->get_parameter(key, ex1, ex2)) ) return scope; - } if (scope->type() == NetScope::MODULE) scope = 0; @@ -70,12 +64,14 @@ NetScope*symbol_search(const Design*des, NetScope*scope, hname_t path, scope = scope->parent(); } - delete key; return 0; } /* * $Log: symbol_search.cc,v $ + * Revision 1.5 2007/04/26 03:06:22 steve + * Rework hname_t to use perm_strings. + * * Revision 1.4 2007/01/16 05:44:15 steve * Major rework of array handling. Memories are replaced with the * more general concept of arrays. The NetMemory and NetEMemory