inst.hh 1.6 KB
Newer Older
Benoit Perrot's avatar
Benoit Perrot committed
1
//
Benoit Perrot's avatar
Benoit Perrot committed
2
// This file is part of Nolimips, a MIPS simulator with unlimited registers
3
// Copyright (C) 2003, 2004, 2005 Benoit Perrot <benoit@lrde.epita.fr>
Benoit Perrot's avatar
Benoit Perrot committed
4
//
Benoit Perrot's avatar
Benoit Perrot committed
5
// Nolimips is free software; you can redistribute it and/or modify
Benoit Perrot's avatar
Benoit Perrot committed
6
7
8
9
// 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.
// 
Benoit Perrot's avatar
Benoit Perrot committed
10
// Nolimips is distributed in the hope that it will be useful,
Benoit Perrot's avatar
Benoit Perrot committed
11
12
13
14
15
16
17
18
// 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
//
19
20
21
#ifndef INST_INST_HH
# define INST_INST_HH

22
# include <ostream>
23
24
25
26
27
28
29
30
31

# include "inst/visitor.hh"

namespace inst
{
  
  class Inst
  {
  public:
32
33
34
35
36
37
38
39
40
41
42
    enum format_type
      {
	i_type = 0,
	r_type = 1,
	j_type = 2
      };

  public:
    Inst(format_type format):
      format_(format)
    {}
43
44
45
46
47
48
49
50
51
52
    virtual ~Inst()
    {
    }

  public:
    virtual void	accept (ConstVisitor& v) const = 0;
    virtual void	accept (Visitor& v) = 0;

  public:
    virtual void	print(std::ostream&) const = 0;
53
54
55
56
57
58
59
60
61

  public:
    format_type	get_format() const
    {
      return format_;
    }

  private:
    const format_type	format_;
62
63
64
65
66
67
68
69
70
71
72
73
  };

  inline std::ostream&
  operator<<(std::ostream& ostr, const Inst& i)
  {
    i.print(ostr);
    return ostr;
  }

} // namespace inst

#endif // !INST_INST_HH