Commit 956e2a0e authored by Benoit Perrot's avatar Benoit Perrot
Browse files

2005-04-02 Benoît Perrot <benoit@lrde.epita.fr>

	Split `exp' files.

	* src/inst/exp.hh, src/inst/exp.cc:
	Split into...
	* src/inst/label_exp.hh, src/inst/label_exp.cc,
	* src/inst/op_exp.hh, src/inst/op_exp.cc,
	* src/inst/int_exp.hh, src/inst/exp.hh:
	These files.
	* src/inst/Makefile.am:	Distribute them.
	* src/vm/cpu.cc, dev/inst-builder-gen.py, dev/inst-solver-gen.py:
	Update accordingly.
	
parent 9c517382
2005-04-02 Benoît Perrot <benoit@lrde.epita.fr>
Split `exp' files.
* src/inst/exp.hh, src/inst/exp.cc:
Split into...
* src/inst/label_exp.hh, src/inst/label_exp.cc,
* src/inst/op_exp.hh, src/inst/op_exp.cc,
* src/inst/int_exp.hh, src/inst/exp.hh:
These files.
* src/inst/Makefile.am: Distribute them.
* src/vm/cpu.cc, dev/inst-builder-gen.py, dev/inst-solver-gen.py:
Update accordingly.
2005-04-02 Benoît Perrot <benoit@lrde.epita.fr>
Fix distcheck broken since 2005-03-08's patch.
......
......@@ -41,6 +41,9 @@ print """#ifndef INST_PROGRAM_BUILDER_HH
# define INST_PROGRAM_BUILDER_HH
# include \"inst/all.hh\"
# include \"inst/int_exp.hh\"
# include \"inst/label_exp.hh\"
# include \"inst/op_exp.hh\"
# include \"inst/program.hh\"
# include \"vm/cpu.hh\"
......
......@@ -142,6 +142,10 @@ sys.stdout = file("program_solver.cc.tmp", "w")
print license
print """#include \"inst/program_solver.hh\"
#include \"inst/int_exp.hh\"
#include \"inst/label_exp.hh\"
#include \"inst/op_exp.hh\"
#include \"vm/cpu.hh\"
namespace inst
......
......@@ -46,6 +46,9 @@ libinst_a_SOURCES = \
$(FROM_INST_NODES_GEN_PY) inst-nodes-gen.stamp \
register.hh \
exp.hh exp.cc \
int_exp.hh int_exp.cc \
label_exp.hh label_exp.cc \
op_exp.hh op_exp.cc \
exp-visitor.hh \
inst.hh \
program.hh \
......
......@@ -21,138 +21,14 @@
namespace inst
{
// --------------------------------------------------------------------------
// Exp: Constructor & Destructor
// --------------------------------------------------------------------------
Exp::~Exp()
{
}
// --------------------------------------------------------------------------
// Exp: Print operator
// --------------------------------------------------------------------------
void
Exp::print(std::ostream& ostr) const
{
ostr << immediate_;
}
// --------------------------------------------------------------------------
// IntExp: Constructor & Destructor
// --------------------------------------------------------------------------
IntExp::~IntExp()
{
}
// --------------------------------------------------------------------------
// IntExp: Visitor entry points
// --------------------------------------------------------------------------
void
IntExp::accept (ConstExpVisitor& v) const
{
v.visit(*this);
}
void
IntExp::accept (ExpVisitor& v)
{
v.visit(*this);
}
// --------------------------------------------------------------------------
// IntExp: Print operator
// --------------------------------------------------------------------------
void
IntExp::print(std::ostream& ostr) const
{
ostr << integer_;
}
// --------------------------------------------------------------------------
// LabelExp: Constructor & Destructor
// --------------------------------------------------------------------------
LabelExp::~LabelExp()
{
// FIXME: delete label;
}
// --------------------------------------------------------------------------
// LabelExp: Visitor entry points
// --------------------------------------------------------------------------
void
LabelExp::accept (ConstExpVisitor& v) const
{
v.visit(*this);
}
void
LabelExp::accept (ExpVisitor& v)
{
v.visit(*this);
}
// --------------------------------------------------------------------------
// LabelExp: Print operator
// --------------------------------------------------------------------------
void
LabelExp::print(std::ostream& ostr) const
{
ostr << *name_;
}
// --------------------------------------------------------------------------
// OpExp: Constructor & Destructor
// --------------------------------------------------------------------------
OpExp::~OpExp()
{
// FIXME: delete left;
// FIXME: delete right;
}
// --------------------------------------------------------------------------
// OpExp: Visitor entry points
// --------------------------------------------------------------------------
void
OpExp::accept (ConstExpVisitor& v) const
{
v.visit(*this);
}
void
OpExp::accept (ExpVisitor& v)
{
v.visit(*this);
}
// --------------------------------------------------------------------------
// OpExp: Print operator
// --------------------------------------------------------------------------
void
OpExp::print(std::ostream& ostr) const
{
ostr << *left_;
switch (kind_)
{
case add: ostr << " + "; break;
case sub: ostr << " - "; break;
case mul: ostr << " * "; break;
case div: ostr << " / "; break;
}
ostr << *right_;
}
} // namespace inst
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2003, 2004 Benoit Perrot <benoit@lrde.epita.fr>
// Copyright (C) 2003, 2004, 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
......@@ -21,9 +21,7 @@
# include <iostream>
# include "misc/contract.hh"
# include "misc/counted_ptr.hh"
# include "misc/unique_string.hh"
# include "inst/exp-visitor.hh"
......@@ -32,11 +30,12 @@ namespace inst
class Exp
{
public:
protected:
Exp():
immediate_(-2097) // Caracteristic initial value
{
}
public:
virtual ~Exp();
public:
......@@ -70,106 +69,6 @@ namespace inst
typedef misc::counted_ptr<Exp> CountedExp;
class IntExp:
public Exp
{
public:
IntExp(int integer):
integer_(integer)
{
}
virtual ~IntExp();
public:
virtual void accept (ConstExpVisitor& v) const;
virtual void accept (ExpVisitor& v);
public:
int get_integer() const
{
return integer_;
}
public:
virtual void print(std::ostream& ostr) const;
protected:
int integer_;
};
class LabelExp:
public Exp
{
public:
LabelExp(const misc::unique_string &name):
name_(name)
{}
virtual ~LabelExp();
public:
virtual void accept (ConstExpVisitor& v) const;
virtual void accept (ExpVisitor& v);
public:
const misc::unique_string &get_name() const
{
return name_;
}
public:
virtual void print(std::ostream& ostr) const;
protected:
const misc::unique_string &name_;
};
class OpExp:
public Exp
{
public:
enum kind_type { add, sub, mul, div };
public:
OpExp(const CountedExp &left, kind_type kind, const CountedExp &right):
kind_(kind), left_(left), right_(right)
{
// assertion(left && right);
}
virtual ~OpExp();
public:
virtual void accept (ConstExpVisitor& v) const;
virtual void accept (ExpVisitor& v);
public:
const Exp& get_left() const
{
return *left_;
}
Exp& get_left()
{
return *left_;
}
const Exp& get_right() const
{
return *right_;
}
Exp& get_right()
{
return *right_;
}
public:
virtual void print(std::ostream& ostr) const;
public:
const kind_type kind_;
protected:
CountedExp left_;
CountedExp right_;
};
} // namespace inst
#endif // !INST_EXP_HH
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips 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.
//
// Nolimips 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/int_exp.hh"
namespace inst
{
IntExp::~IntExp()
{
}
void
IntExp::accept (ConstExpVisitor& v) const
{
v.visit(*this);
}
void
IntExp::accept (ExpVisitor& v)
{
v.visit(*this);
}
void
IntExp::print(std::ostream& ostr) const
{
ostr << integer_;
}
} // namespace inst
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips 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.
//
// Nolimips 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_INT_EXP_HH
# define INST_INT_EXP_HH
# include "inst/exp.hh"
namespace inst
{
class IntExp:
public Exp
{
public:
IntExp(int integer):
integer_(integer)
{
}
virtual ~IntExp();
public:
virtual void accept(ConstExpVisitor& v) const;
virtual void accept(ExpVisitor& v);
public:
int get_integer() const
{
return integer_;
}
public:
virtual void print(std::ostream& ostr) const;
protected:
int integer_;
};
} // namespace inst
#endif // !INST_INT_EXP_HH
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips 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.
//
// Nolimips 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_exp.hh"
namespace inst
{
LabelExp::~LabelExp()
{
// FIXME: delete label;
}
void
LabelExp::accept (ConstExpVisitor& v) const
{
v.visit(*this);
}
void
LabelExp::accept (ExpVisitor& v)
{
v.visit(*this);
}
void
LabelExp::print(std::ostream& ostr) const
{
ostr << *name_;
}
} // namespace inst
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips 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.
//
// Nolimips 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_EXP_HH
# define INST_LABEL_EXP_HH
# include "misc/unique_string.hh"
# include "inst/exp.hh"
namespace inst
{
class LabelExp:
public Exp
{
public:
LabelExp(const misc::unique_string &name):
name_(name)
{}
virtual ~LabelExp();
public:
virtual void accept(ConstExpVisitor& v) const;
virtual void accept(ExpVisitor& v);
public:
const misc::unique_string &get_name() const
{
return name_;
}
public:
virtual void print(std::ostream& ostr) const;
protected:
const misc::unique_string &name_;
};
} // namespace inst
#endif // !INST_LABEL_EXP_HH
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips 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.
//
// Nolimips 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 "op_exp.hh"
namespace inst
{
OpExp::~OpExp()
{
// FIXME: delete left;
// FIXME: delete right;
}
void
OpExp::accept (ConstExpVisitor& v) const
{
v.visit(*this);
}
void
OpExp::accept (ExpVisitor& v)
{
v.visit(*this);
}
void
OpExp::print(std::ostream& ostr) const
{
ostr << *left_;
switch (kind_)
{
case add: ostr << " + "; break;
case sub: ostr << " - "; break;
case mul: ostr << " * "; break;
case div: ostr << " / "; break;
}
ostr << *right_;
}
} // namespace inst
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2003, 2004, 2005 Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips 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.
//
// Nolimips 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_OP_EXP_HH
# define INST_OP_EXP_HH
# include "inst/exp.hh"
namespace inst
{
class OpExp:
public Exp
{
public:
enum kind_type { add, sub, mul, div };
public:
OpExp(const CountedExp &left, kind_type kind, const CountedExp &right):
kind_(kind), left_(left), right_(right)
{
// assertion(left && right);
}
virtual ~OpExp();
public:
virtual void accept (ConstExpVisitor& v) const;
virtual void accept (ExpVisitor& v);
public:
const Exp& get_left() const