Fix for assertion error when expanding macro.
[iverilog.git] / HName.h
blobc436eeaf67dc10b5a8e5f1feffc0f02d6655fa09
1 #ifndef __HName_H
2 #define __HName_H
3 /*
4 * Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
6 * This source code is free software; you can redistribute it
7 * and/or modify it in source code form under the terms of the GNU
8 * General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
10 * any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
21 #ifdef HAVE_CVS_IDENT
22 #ident "$Id: HName.h,v 1.7 2007/06/02 03:42:12 steve Exp $"
23 #endif
25 # include <iostream>
26 # include "StringHeap.h"
27 #ifdef __GNUC__
28 #if __GNUC__ > 2
29 using namespace std;
30 #endif
31 #endif
34 * This class represents a component of a Verilog hierarchical name. A
35 * hierarchical component contains a name string (prepresented here
36 * with a perm_string) and an optional signed number. This signed
37 * number is used if the scope is part of an array, for example an
38 * array of module instances or a loop generated scope.
41 class hname_t {
43 public:
44 hname_t ();
45 explicit hname_t (perm_string text);
46 explicit hname_t (perm_string text, int num);
47 hname_t (const hname_t&that);
48 ~hname_t();
50 hname_t& operator= (const hname_t&);
52 // Return the string part of the hname_t.
53 perm_string peek_name(void) const;
55 bool has_number() const;
56 int peek_number() const;
58 private:
59 perm_string name_;
60 // If the number is anything other then INT_MIN, then this is
61 // the numeric part of the name. Otherwise, it is not part of
62 // the name at all.
63 int number_;
65 private: // not implemented
68 extern bool operator < (const hname_t&, const hname_t&);
69 extern bool operator == (const hname_t&, const hname_t&);
70 extern bool operator != (const hname_t&, const hname_t&);
71 extern ostream& operator<< (ostream&, const hname_t&);
74 * $Log: HName.h,v $
75 * Revision 1.7 2007/06/02 03:42:12 steve
76 * Properly evaluate scope path expressions.
78 * Revision 1.6 2007/05/16 19:12:33 steve
79 * Fix hname_t use of space for 1 perm_string.
81 * Revision 1.5 2007/04/26 03:06:21 steve
82 * Rework hname_t to use perm_strings.
84 * Revision 1.4 2002/11/02 03:27:51 steve
85 * Allow named events to be referenced by
86 * hierarchical names.
88 * Revision 1.3 2002/08/12 01:34:58 steve
89 * conditional ident string using autoconfig.
91 * Revision 1.2 2002/06/14 03:25:51 steve
92 * Compiler portability.
94 * Revision 1.1 2001/12/03 04:47:14 steve
95 * Parser and pform use hierarchical names as hname_t
96 * objects instead of encoded strings.
99 #endif