Commit 39afac5e authored by Benoit Perrot's avatar Benoit Perrot
Browse files

label.hh, label.cc: populate.

parent 006a4166
//
// This file is part of Mipsy, a tiny MIPS simulator
// Copyright (C) 2003 Benoit Perrot <benoit@lrde.epita.fr>
//
// Mipsy is free software; you can redistribute it and/or modify
// it 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.
//
// Mipsy 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
//
#include "inst/label.hh"
namespace inst
{
Label::string_set_t Label::_set;
} // namespace inst
//
// This file is part of Mipsy, a tiny MIPS simulator
// Copyright (C) 2003 Benoit Perrot <benoit@lrde.epita.fr>
//
// Mipsy is free software; you can redistribute it and/or modify
// it 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.
//
// Mipsy 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
//
#ifndef INST_LABEL_HH
# define INST_LABEL_HH
# include <set>
# include <string>
# include <iostream>
namespace inst
{
class Label
{
typedef std::set<std::string> string_set_t;
typedef string_set_t::size_type size_type;
public:
explicit Label (const std::string &s):
_set_node (_set.insert (s).first)
{
}
public:
const std::string& get_name () const
{
return *_set_node;
}
public:
static size_type map_size ()
{
return _set.size ();
}
public:
bool operator== (const Label &rhs) const
{
return _set_node == rhs._set_node;
}
bool operator!= (const Label &rhs) const
{
return !this->operator== (rhs);
}
bool operator< (const Label &rhs) const
{
return &this->get_name () < &rhs.get_name ();
}
private:
static string_set_t _set;
const string_set_t::const_iterator _set_node;
};
inline std::ostream&
operator<< (std::ostream &ostr, const Label &l)
{
return ostr << l.get_name ();
}
} // namespace inst
#endif // !INST_LABEL_HH
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment