Files
iverilog/HName.h
T

84 lines
2.4 KiB
C++
Raw Permalink Normal View History

#ifndef __HName_H
#define __HName_H
/*
2008-06-25 22:02:22 -07:00
* Copyright (c) 2001-2008 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
2002-06-14 03:25:51 +00:00
# include <iostream>
2008-06-25 22:02:22 -07:00
# include <list>
2007-04-26 03:06:21 +00:00
# include "StringHeap.h"
2002-06-14 03:25:51 +00:00
#ifdef __GNUC__
#if __GNUC__ > 2
using namespace std;
#endif
#endif
/*
2007-06-02 03:42:12 +00:00
* This class represents a component of a Verilog hierarchical name. A
2008-01-25 13:34:51 -08:00
* hierarchical component contains a name string (represented here
2007-06-02 03:42:12 +00:00
* with a perm_string) and an optional signed number. This signed
* number is used if the scope is part of an array, for example an
* array of module instances or a loop generated scope.
*/
class hname_t {
public:
hname_t ();
2007-04-26 03:06:21 +00:00
explicit hname_t (perm_string text);
2007-06-02 03:42:12 +00:00
explicit hname_t (perm_string text, int num);
hname_t (const hname_t&that);
~hname_t();
2007-06-02 03:42:12 +00:00
hname_t& operator= (const hname_t&);
2007-06-02 03:42:12 +00:00
// Return the string part of the hname_t.
perm_string peek_name(void) const;
2002-11-02 03:27:51 +00:00
2007-06-02 03:42:12 +00:00
bool has_number() const;
int peek_number() const;
private:
2007-06-02 03:42:12 +00:00
perm_string name_;
2008-06-10 09:02:24 -07:00
// If the number is anything other than INT_MIN, then this is
2007-06-02 03:42:12 +00:00
// the numeric part of the name. Otherwise, it is not part of
// the name at all.
int number_;
2007-04-26 03:06:21 +00:00
private: // not implemented
};
extern bool operator < (const hname_t&, const hname_t&);
extern bool operator == (const hname_t&, const hname_t&);
2007-06-02 03:42:12 +00:00
extern bool operator != (const hname_t&, const hname_t&);
extern ostream& operator<< (ostream&, const hname_t&);
2008-06-25 22:02:22 -07:00
inline ostream& operator<< (ostream&out, const list<hname_t>&ll)
{
list<hname_t>::const_iterator cur = ll.begin();
out << *cur;
cur ++;
while (cur != ll.end()) {
out << "." << *cur;
cur ++;
}
return out;
}
#endif