exp.hh 1.73 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
22
23
#ifndef INST_EXP_HH
# define INST_EXP_HH

# include <iostream>

Benoit Perrot's avatar
Benoit Perrot committed
24
# include "misc/counted_ptr.hh"
25
26
27
28
29
30
31
32

# include "inst/exp-visitor.hh"

namespace inst
{

  class Exp
  {
33
  protected:
34
    Exp():
Benoit Perrot's avatar
Benoit Perrot committed
35
      immediate_(-2097) // Caracteristic initial value
36
37
    {
    }
38
  public:
Benoit Perrot's avatar
Benoit Perrot committed
39
    virtual ~Exp();
40
41
  
  public:
Benoit Perrot's avatar
Benoit Perrot committed
42
    virtual void	print(std::ostream& ostr) const;
43
44
45
46
47
48
49

    virtual void        accept (ConstExpVisitor& v) const = 0;
    virtual void        accept (ExpVisitor& v) = 0;

  public:
    operator int () const
    {
Benoit Perrot's avatar
Benoit Perrot committed
50
      return immediate_;
51
52
53
    }
    int		get_immediate()
    {
Benoit Perrot's avatar
Benoit Perrot committed
54
      return immediate_;
55
56
57
    }
    void	set_immediate(int i)
    {
Benoit Perrot's avatar
Benoit Perrot committed
58
      immediate_ = i;
59
60
    }
  protected:
Benoit Perrot's avatar
Benoit Perrot committed
61
    int		immediate_;
62
63
64
65
66
67
68
69
  };
  inline std::ostream&
  operator<<(std::ostream& ostr, const Exp& e)
  {
    e.print(ostr);
    return ostr;
  }

Benoit Perrot's avatar
Benoit Perrot committed
70
71
  typedef misc::counted_ptr<Exp> CountedExp;

72
73
74
} // namespace inst

#endif // !INST_EXP_HH