Fix the debugger to finish correctly.
[iverilog.git] / HName.cc
blob891eb541e368b33ed9391cea30c4cdca62d86324
1 /*
2 * Copyright (c) 2001 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: HName.cc,v 1.8 2007/06/02 03:42:12 steve Exp $"
21 #endif
23 # include "config.h"
24 # include "HName.h"
25 # include <iostream>
26 # include <string.h>
27 # include <stdlib.h>
28 #ifdef HAVE_MALLOC_H
29 # include <malloc.h>
30 #endif
33 hname_t::hname_t()
35 number_ = INT_MIN;
38 hname_t::hname_t(perm_string text)
40 name_ = text;
41 number_ = INT_MIN;
44 hname_t::hname_t(perm_string text, int num)
46 name_ = text;
47 number_ = num;
50 hname_t::hname_t(const hname_t&that)
52 name_ = that.name_;
53 number_ = that.number_;
56 hname_t& hname_t::operator = (const hname_t&that)
58 name_ = that.name_;
59 number_ = that.number_;
60 return *this;
63 hname_t::~hname_t()
67 perm_string hname_t::peek_name(void) const
69 return name_;
72 bool hname_t::has_number() const
74 return number_ != INT_MIN;
77 int hname_t::peek_number() const
79 return number_;
82 bool operator < (const hname_t&l, const hname_t&r)
84 int cmp = strcmp(l.peek_name(), r.peek_name());
85 if (cmp < 0) return true;
86 if (cmp > 0) return false;
87 if (l.has_number() && r.has_number())
88 return l.peek_number() < r.peek_number();
89 else
90 return false;
93 bool operator == (const hname_t&l, const hname_t&r)
95 if (l.peek_name() == r.peek_name()) {
96 if (l.has_number() && r.has_number())
97 return l.peek_number() == r.peek_number();
98 else
99 return true;
102 return false;
105 bool operator != (const hname_t&l, const hname_t&r)
106 { return ! (l==r); }
108 ostream& operator<< (ostream&out, const hname_t&that)
110 if (that.peek_name() == 0) {
111 out << "";
112 return out;
115 out << that.peek_name();
116 if (that.has_number())
117 out << "[" << that.peek_number() << "]";
119 return out;
123 * $Log: HName.cc,v $
124 * Revision 1.8 2007/06/02 03:42:12 steve
125 * Properly evaluate scope path expressions.
127 * Revision 1.7 2007/05/16 19:12:33 steve
128 * Fix hname_t use of space for 1 perm_string.
130 * Revision 1.6 2007/04/26 03:06:21 steve
131 * Rework hname_t to use perm_strings.
133 * Revision 1.5 2002/11/02 03:27:52 steve
134 * Allow named events to be referenced by
135 * hierarchical names.
137 * Revision 1.4 2002/08/12 01:34:58 steve
138 * conditional ident string using autoconfig.
140 * Revision 1.3 2002/01/05 04:36:06 steve
141 * include malloc.h only when available.
143 * Revision 1.2 2001/12/18 04:52:45 steve
144 * Include config.h for namespace declaration.
146 * Revision 1.1 2001/12/03 04:47:14 steve
147 * Parser and pform use hierarchical names as hname_t
148 * objects instead of encoded strings.