* common.hh, inst-tasks.cc, inst-tasks.hh, inst/data_section.cc,
* inst/inst.hh, inst/op_exp.cc, inst/op_exp.hxx,
* inst/program_builder.cc, inst/program_builder.hxx,
* inst/program_solver.hxx, inst/register.hh, inst/section.cc,
* inst/section.hh, inst/text_label.hh, inst/text_label.hxx,
* inst/text_section.cc, misc/contract.hh, misc/counted_ptr.hh,
* misc/deref.hh, misc/escape.hh, misc/has.hh, misc/lexutils.cc,
* misc/lexutils.hh, misc/select_const.hh, misc/table.hh,
* misc/test-unique_string.cc, misc/unique_string.cc,
* misc/unique_string.hh, modules.hh, nolimips-tasks.cc,
* nolimips-tasks.hh, nolimips.cc, parse-tasks.cc, parse-tasks.hh,
* parse/asm-scan.hh, parse/fwd.hh, parse/libparse.cc,
* parse/libparse.hh, shell-tasks.cc, shell-tasks.hh, shell/cmd.hh,
* shell/cmd.hxx, shell/shell.cc, shell/shell.hh, shell/shell.hxx,
* task-tasks.cc, task-tasks.hh, task/boolean_task.cc,
* task/boolean_task.hh, task/function_task.cc, task/function_task.hh,
* task/int_task.cc, task/int_task.hh, task/libtask.hh,
* task/string_task.cc, task/string_task.hh, task/task.cc,
* task/task.hh, task/task.hxx, task/task_register.cc,
* task/task_register.hh, task/task_register.hxx, vm-tasks.cc,
* vm-tasks.hh, vm/cp0.hh, vm/cpu.cc, vm/cpu.hh, vm/cpu.hxx, vm/fwd.hh,
* vm/memory.hh, vm/memory.hxx, vm/mmu.hh, vm/mmu.hxx,
* vm/nolimips_system_library.cc, vm/nolimips_system_library.hh,
* vm/nolimips_system_library.hxx, vm/segment.hxx,
* vm/spim_system_library.cc, vm/spim_system_library.hxx,
* vm/virtual_machine.cc, vm/virtual_machine.hh:
Untabify (using GNU expand).
Remove trailing spaces.
---
src/common.hh | 4 +-
src/inst-tasks.cc | 6 +-
src/inst-tasks.hh | 18 +-
src/inst/data_section.cc | 68 +++---
src/inst/inst.hh | 8 +-
src/inst/op_exp.cc | 6 +-
src/inst/op_exp.hxx | 6 +-
src/inst/program_builder.cc | 166 +++++++-------
src/inst/program_builder.hxx | 18 +-
src/inst/program_solver.hxx | 4 +-
src/inst/register.hh | 12 +-
src/inst/section.cc | 8 +-
src/inst/section.hh | 2 +-
src/inst/text_label.hh | 2 +-
src/inst/text_label.hxx | 2 +-
src/inst/text_section.cc | 28 ++--
src/misc/contract.hh | 28 ++--
src/misc/counted_ptr.hh | 54 +++---
src/misc/deref.hh | 24 +-
src/misc/escape.hh | 24 +-
src/misc/has.hh | 12 +-
src/misc/lexutils.cc | 4 +-
src/misc/lexutils.hh | 4 +-
src/misc/select_const.hh | 8 +-
src/misc/table.hh | 36 ++--
src/misc/test-unique_string.cc | 4 +-
src/misc/unique_string.cc | 4 +-
src/misc/unique_string.hh | 10 +-
src/modules.hh | 4 +-
src/nolimips-tasks.cc | 4 +-
src/nolimips-tasks.hh | 12 +-
src/nolimips.cc | 8 +-
src/parse-tasks.cc | 30 ++--
src/parse-tasks.hh | 20 +-
src/parse/asm-scan.hh | 6 +-
src/parse/fwd.hh | 4 +-
src/parse/libparse.cc | 4 +-
src/parse/libparse.hh | 4 +-
src/shell-tasks.cc | 4 +-
src/shell-tasks.hh | 6 +-
src/shell/cmd.hh | 44 ++--
src/shell/cmd.hxx | 4 +-
src/shell/shell.cc | 424 ++++++++++++++++++------------------
src/shell/shell.hh | 12 +-
src/shell/shell.hxx | 14 +-
src/task-tasks.cc | 4 +-
src/task-tasks.hh | 6 +-
src/task/boolean_task.cc | 14 +-
src/task/boolean_task.hh | 6 +-
src/task/function_task.cc | 14 +-
src/task/function_task.hh | 6 +-
src/task/int_task.cc | 14 +-
src/task/int_task.hh | 6 +-
src/task/libtask.hh | 54 +++---
src/task/string_task.cc | 14 +-
src/task/string_task.hh | 12 +-
src/task/task.cc | 44 ++--
src/task/task.hh | 4 +-
src/task/task.hxx | 6 +-
src/task/task_register.cc | 318 ++++++++++++++--------------
src/task/task_register.hh | 6 +-
src/task/task_register.hxx | 6 +-
src/vm-tasks.cc | 74 +++---
src/vm-tasks.hh | 36 ++--
src/vm/cp0.hh | 102 +++++-----
src/vm/cpu.cc | 352 +++++++++++++++---------------
src/vm/cpu.hh | 174 ++++++++--------
src/vm/cpu.hxx | 50 ++--
src/vm/fwd.hh | 4 +-
src/vm/memory.hh | 10 +-
src/vm/memory.hxx | 2 +-
src/vm/mmu.hh | 6 +-
src/vm/mmu.hxx | 34 ++--
src/vm/nolimips_system_library.cc | 68 +++---
src/vm/nolimips_system_library.hh | 4 +-
src/vm/nolimips_system_library.hxx | 4 +-
src/vm/segment.hxx | 24 +-
src/vm/spim_system_library.cc | 96 ++++----
src/vm/spim_system_library.hxx | 2 +-
src/vm/virtual_machine.cc | 40 ++--
src/vm/virtual_machine.hh | 22 +-
81 files changed, 1406 insertions(+), 1406 deletions(-)
diff --git a/src/common.hh b/src/common.hh
index b9fbaba..fa1e823 100644
--- a/src/common.hh
+++ b/src/common.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/inst-tasks.cc b/src/inst-tasks.cc
index 500dce3..2a90e6f 100644
--- a/src/inst-tasks.cc
+++ b/src/inst-tasks.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -47,7 +47,7 @@ namespace inst
program_solver.enable_unlimited_regs(parse::unlimited_regs_p);
program_solver.solve(* parse::tasks::program);
if (exit_status != exit_success)
- exit (exit_status);
+ exit (exit_status);
}
} // namespace tasks
diff --git a/src/inst-tasks.hh b/src/inst-tasks.hh
index fe593ce..f99d611 100644
--- a/src/inst-tasks.hh
+++ b/src/inst-tasks.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -29,25 +29,25 @@ namespace inst
TASK_MODULE ("2. Instructions");
TASK_DECLARE ("prg-display",
- "Display the read program",
- prg_display, "parse");
+ "Display the read program",
+ prg_display, "parse");
TASK_DECLARE ("prg-solve",
- "Resolve jump offsets and check bounds of immediates",
- prg_solve, "parse");
+ "Resolve jump offsets and check bounds of immediates",
+ prg_solve, "parse");
INT_TASK_DECLARE ("callee-save",
"Set max number of callee-save registers",
max_callee_save, 8, 0, 8,
- "");
+ "");
INT_TASK_DECLARE ("caller-save",
"Set max number of caller-save registers",
max_caller_save, 10, 0, 10,
- "");
+ "");
INT_TASK_DECLARE ("argument-registers",
"Set max number of argument registers",
max_args, 4, 0, 4,
- "");
+ "");
} // namespace tasks
} // namespace inst
diff --git a/src/inst/data_section.cc b/src/inst/data_section.cc
index 6cf21da..b13396c 100644
--- a/src/inst/data_section.cc
+++ b/src/inst/data_section.cc
@@ -48,40 +48,40 @@ namespace inst
{
if (0 < size())
{
- ostr << "\t" << name_ << std::endl;
-
- std::vector<const Label*>::const_iterator label_it = labels_.begin();
-
- int next_labeled_offset = size();
- if (!labels_.empty())
- next_labeled_offset = (*label_it)->get_offset();
-
- for (int i = 0; i < size(); ++i)
- {
- while (i == next_labeled_offset)
- {
- ostr << *(*label_it) << ':' << std::endl;
- ++label_it;
-
- if (label_it != labels_.end())
- next_labeled_offset = (*label_it)->get_offset();
- else // No more labels
- break;
- }
-
- ostr << "\t.byte\t0x"
- << std::hex << static_cast<unsigned>(bytes_[i])
- << std::endl;
- }
-
- // Print labels that point right after the last data
- while (label_it != labels_.end())
- {
- ostr << *(*label_it) << ':' << std::endl;
- ++label_it;
- }
-
- ostr << std::dec;
+ ostr << "\t" << name_ << std::endl;
+
+ std::vector<const Label*>::const_iterator label_it = labels_.begin();
+
+ int next_labeled_offset = size();
+ if (!labels_.empty())
+ next_labeled_offset = (*label_it)->get_offset();
+
+ for (int i = 0; i < size(); ++i)
+ {
+ while (i == next_labeled_offset)
+ {
+ ostr << *(*label_it) << ':' << std::endl;
+ ++label_it;
+
+ if (label_it != labels_.end())
+ next_labeled_offset = (*label_it)->get_offset();
+ else // No more labels
+ break;
+ }
+
+ ostr << "\t.byte\t0x"
+ << std::hex << static_cast<unsigned>(bytes_[i])
+ << std::endl;
+ }
+
+ // Print labels that point right after the last data
+ while (label_it != labels_.end())
+ {
+ ostr << *(*label_it) << ':' << std::endl;
+ ++label_it;
+ }
+
+ ostr << std::dec;
}
}
diff --git a/src/inst/inst.hh b/src/inst/inst.hh
index 9503913..be8015c 100644
--- a/src/inst/inst.hh
+++ b/src/inst/inst.hh
@@ -30,9 +30,9 @@ namespace inst
public:
enum format_type
{
- i_type = 0,
- r_type = 1,
- j_type = 2
+ i_type = 0,
+ r_type = 1,
+ j_type = 2
};
public:
@@ -47,7 +47,7 @@ namespace inst
virtual void write(std::ostream&) const = 0;
public:
- format_type get_format() const;
+ format_type get_format() const;
private:
const format_type format_;
diff --git a/src/inst/op_exp.cc b/src/inst/op_exp.cc
index 7f64df3..a97f69a 100644
--- a/src/inst/op_exp.cc
+++ b/src/inst/op_exp.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -49,7 +49,7 @@ namespace inst
case sub: ostr << " - "; break;
case mul: ostr << " * "; break;
case div: ostr << " / "; break;
- }
+ }
ostr << *right_;
}
diff --git a/src/inst/op_exp.hxx b/src/inst/op_exp.hxx
index 8f4ce72..78f2ec8 100644
--- a/src/inst/op_exp.hxx
+++ b/src/inst/op_exp.hxx
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -26,7 +26,7 @@ namespace inst
//
inline
OpExp::OpExp(const CountedExp &left, kind_type kind,
- const CountedExp &right):
+ const CountedExp &right):
kind_(kind), left_(left), right_(right)
{
// assertion(left && right);
diff --git a/src/inst/program_builder.cc b/src/inst/program_builder.cc
index 9e906a2..39081ba 100644
--- a/src/inst/program_builder.cc
+++ b/src/inst/program_builder.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -37,9 +37,9 @@ namespace inst
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll
- (Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ (Register(Register::general, Cpu::zero),
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
program_->text_section ().
add_inst(new Sub(*dest, Register(Register::general, Cpu::zero), *src));
}
@@ -50,7 +50,7 @@ namespace inst
// Warning: is not implemented in as for mips, check why.
program_->text_section ().
add_inst(new Addiu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), src2));
+ Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Mul(*dest, *src1, Register(Register::general, Cpu::at)));
}
@@ -68,7 +68,7 @@ namespace inst
// FIXME: program_solver must warn and/or break when exp is zero
program_->text_section ().
add_inst(new Addiu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), src2));
+ Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Div(*src1, Register(Register::general, Cpu::at)));
program_->text_section ().add_inst(new Mflo(*dest));
@@ -86,7 +86,7 @@ namespace inst
// FIXME: program_solver must warn and/or break when exp is zero
program_->text_section ().
add_inst(new Addiu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), src2));
+ Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Divu(*src1, Register(Register::general, Cpu::at)));
program_->text_section ().add_inst(new Mflo(*dest));
@@ -106,7 +106,7 @@ namespace inst
program_->text_section ().add_inst(new Divu(*src1, *src2));
program_->text_section ().add_inst(new Mfhi(*dest));
}
-
+
// Bitwise instructions -------------------------------------
@@ -115,10 +115,10 @@ namespace inst
{
program_->text_section ().
add_inst(new Subu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), *src2));
+ Register(Register::general, Cpu::zero), *src2));
program_->text_section ().
add_inst(new Srlv(Register(Register::general, Cpu::at), *src1,
- Register(Register::general, Cpu::at)));
+ Register(Register::general, Cpu::at)));
program_->text_section ().add_inst(new Sllv(*dest, *src1, *src2));
program_->text_section ().
add_inst(new Or(*dest, *dest, Register(Register::general, Cpu::at)));
@@ -131,10 +131,10 @@ namespace inst
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::at), *src1,
- counted_exp));
+ counted_exp));
program_->text_section ().
add_inst(new Srl(*dest, *src1,
- new OpExp(new IntExp(32), OpExp::sub, counted_exp)));
+ new OpExp(new IntExp(32), OpExp::sub, counted_exp)));
program_->text_section ().
add_inst(new Or(*dest, *dest, Register(Register::general, Cpu::at)));
}
@@ -143,10 +143,10 @@ namespace inst
{
program_->text_section ().
add_inst(new Subu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), *src2));
+ Register(Register::general, Cpu::zero), *src2));
program_->text_section ().
add_inst(new Sllv(Register(Register::general, Cpu::at),
- *src1, Register(Register::general, Cpu::at)));
+ *src1, Register(Register::general, Cpu::at)));
program_->text_section ().add_inst(new Srlv(*dest, *src1, *src2));
program_->text_section ().
add_inst(new Or(*dest, *dest, Register(Register::general, Cpu::at)));
@@ -158,14 +158,14 @@ namespace inst
program_->text_section ().
add_inst(new Srl(Register(Register::general, Cpu::at), *src1,
- counted_exp));
+ counted_exp));
program_->text_section ().
add_inst(new Sll(*dest, *src1,
- new OpExp(new IntExp(32), OpExp::sub, counted_exp)));
+ new OpExp(new IntExp(32), OpExp::sub, counted_exp)));
program_->text_section ().
add_inst(new Or(*dest, *dest, Register(Register::general, Cpu::at)));
}
-
+
void
ProgramBuilder::add_nor(Register *dest, Register *src1, Exp *src2)
{
@@ -195,8 +195,8 @@ namespace inst
{
program_->text_section ().add_inst(new Xor(*dest, *src1, *src2));
program_->text_section ().
- add_inst(new Sltu(*dest,
- Register(Register::general, Cpu::zero), *dest));
+ add_inst(new Sltu(*dest,
+ Register(Register::general, Cpu::zero), *dest));
}
void
ProgramBuilder::add_sne(Register *dest, Register *src, Exp *exp)
@@ -237,7 +237,7 @@ namespace inst
{
program_->text_section ().
add_inst(new Addiu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), src2));
+ Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Slt(*dest, Register(Register::general, Cpu::at), *src1));
}
@@ -246,7 +246,7 @@ namespace inst
{
program_->text_section ().
add_inst(new Addiu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), src2));
+ Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Sltu(*dest, Register(Register::general, Cpu::at), *src1));
}
@@ -263,7 +263,7 @@ namespace inst
{
program_->text_section ().
add_inst(new Addiu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), src2));
+ Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Slt(*dest, Register(Register::general, Cpu::at), *src1));
program_->text_section ().add_inst(new Xori(*dest, *dest, new IntExp(1)));
@@ -279,13 +279,13 @@ namespace inst
{
program_->text_section ().
add_inst(new Addiu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), src2));
+ Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Sltu(*dest, Register(Register::general, Cpu::at), *src1));
program_->text_section ().
add_inst(new Xori(*dest, *dest, new IntExp(1)));
}
-
+
// Branch instructions -----------------------------------
@@ -295,28 +295,28 @@ namespace inst
{
program_->text_section ().
add_inst(new Addiu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), src2));
+ Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Bne(*src1, Register(Register::general, Cpu::at), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_beq(Register *src1, Exp *src2, Exp *dest)
{
program_->text_section ().
add_inst(new Addiu(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), src2));
+ Register(Register::general, Cpu::zero), src2));
program_->text_section ().
add_inst(new Beq(*src1, Register(Register::general, Cpu::at), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
// Greater
@@ -327,12 +327,12 @@ namespace inst
add_inst(new Slt(Register(Register::general, Cpu::at), *src1, *src2));
program_->text_section ().
add_inst(new Beq(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bge(Register *src1, Exp *src2, Exp *dest)
@@ -341,12 +341,12 @@ namespace inst
add_inst(new Slti(Register(Register::general, Cpu::at), *src1, src2));
program_->text_section ().
add_inst(new Beq(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bgeu(Register *src1, Register *src2, Exp *dest)
@@ -355,12 +355,12 @@ namespace inst
add_inst(new Sltu(Register(Register::general, Cpu::at), *src1, *src2));
program_->text_section ().
add_inst(new Beq(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bgeu(Register *src1, Exp *src2, Exp *dest)
@@ -369,12 +369,12 @@ namespace inst
add_inst(new Sltiu(Register(Register::general, Cpu::at), *src1, src2));
program_->text_section ().
add_inst(new Beq(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
@@ -384,27 +384,27 @@ namespace inst
add_inst(new Slt(Register(Register::general, Cpu::at), *src2, *src1));
program_->text_section ().
add_inst(new Bne(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bgt(Register *src1, Exp *src2, Exp *dest)
{
program_->text_section ().
add_inst(new Slti(Register(Register::general, Cpu::at), *src1,
- new OpExp(src2, OpExp::add, new IntExp(1))));
+ new OpExp(src2, OpExp::add, new IntExp(1))));
program_->text_section ().
add_inst(new Beq(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bgtu(Register *src1, Register *src2, Exp *dest)
@@ -413,27 +413,27 @@ namespace inst
add_inst(new Sltu(Register(Register::general, Cpu::at), *src2, *src1));
program_->text_section ().
add_inst(new Bne(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bgtu(Register *src1, Exp *src2, Exp *dest)
{
program_->text_section ().
add_inst(new Sltiu(Register(Register::general, Cpu::at), *src1,
- new OpExp(src2, OpExp::add, new IntExp(1))));
+ new OpExp(src2, OpExp::add, new IntExp(1))));
program_->text_section ().
add_inst(new Beq(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
// Lower
@@ -444,27 +444,27 @@ namespace inst
add_inst(new Slt(Register(Register::general, Cpu::at), *src2, *src1));
program_->text_section ().
add_inst(new Beq(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_ble(Register *src1, Exp *src2, Exp *dest)
{
program_->text_section ().
add_inst(new Slti(Register(Register::general, Cpu::at), *src1,
- new OpExp(src2, OpExp::add, new IntExp(1))));
+ new OpExp(src2, OpExp::add, new IntExp(1))));
program_->text_section ().
add_inst(new Bne(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bleu(Register *src1, Register *src2, Exp *dest)
@@ -473,27 +473,27 @@ namespace inst
add_inst(new Sltu(Register(Register::general, Cpu::at), *src2, *src1));
program_->text_section ().
add_inst(new Beq(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bleu(Register *src1, Exp *src2, Exp *dest)
{
program_->text_section ().
add_inst(new Sltiu(Register(Register::general, Cpu::at), *src1,
- new OpExp(src2, OpExp::add, new IntExp(1))));
+ new OpExp(src2, OpExp::add, new IntExp(1))));
program_->text_section ().
add_inst(new Bne(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
@@ -503,12 +503,12 @@ namespace inst
add_inst(new Slt(Register(Register::general, Cpu::at), *src1, *src2));
program_->text_section ().
add_inst(new Bne(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_blt(Register *src1, Exp *src2, Exp *dest)
@@ -517,12 +517,12 @@ namespace inst
add_inst(new Slti(Register(Register::general, Cpu::at), *src1, src2));
program_->text_section ().
add_inst(new Bne(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bltu(Register *src1, Register *src2, Exp *dest)
@@ -531,12 +531,12 @@ namespace inst
add_inst(new Sltu(Register(Register::general, Cpu::at), *src1, *src2));
program_->text_section ().
add_inst(new Bne(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
void
ProgramBuilder::add_bltu(Register *src1, Exp *src2, Exp *dest)
@@ -545,12 +545,12 @@ namespace inst
add_inst(new Sltiu(Register(Register::general, Cpu::at), *src1, src2));
program_->text_section ().
add_inst(new Bne(Register(Register::general, Cpu::at),
- Register(Register::general, Cpu::zero), dest));
+ Register(Register::general, Cpu::zero), dest));
// This nop is in the delay slot
program_->text_section ().
add_inst(new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
}
// Load --------------------------------------------------
diff --git a/src/inst/program_builder.hxx b/src/inst/program_builder.hxx
index bb6a8d7..f50cf96 100644
--- a/src/inst/program_builder.hxx
+++ b/src/inst/program_builder.hxx
@@ -49,9 +49,9 @@ namespace inst
// FIXME: fill end of program with NOPs for pipeline (really dirty!)
for (unsigned i = 0; i < 6; ++i)
program_->text_section().
- add_inst (new Sll(Register(Register::general, Cpu::zero),
- Register(Register::general, Cpu::zero),
- new IntExp(0)));
+ add_inst (new Sll(Register(Register::general, Cpu::zero),
+ Register(Register::general, Cpu::zero),
+ new IntExp(0)));
return program_;
}
@@ -61,9 +61,9 @@ namespace inst
{
if (!program_->text_section ().define_label(id))
{
- std::cerr << "Instruction label already defined in this section."
- << std::endl;
- exit_set(exit_solve);
+ std::cerr << "Instruction label already defined in this
section."
+ << std::endl;
+ exit_set(exit_solve);
}
}
@@ -72,9 +72,9 @@ namespace inst
{
if (!program_->data_section ().define_label(id))
{
- std::cerr << "Data label already defined in this section."
- << std::endl;
- exit_set(exit_solve);
+ std::cerr << "Data label already defined in this section."
+ << std::endl;
+ exit_set(exit_solve);
}
}
diff --git a/src/inst/program_solver.hxx b/src/inst/program_solver.hxx
index 19d5d34..a43d2cc 100644
--- a/src/inst/program_solver.hxx
+++ b/src/inst/program_solver.hxx
@@ -65,8 +65,8 @@ namespace inst
pc_ = 4;
for (TextSection::instruction_list_type::const_iterator
- it = program.text_section().begin();
- it != program.text_section().end(); ++it, pc_ += 4)
+ it = program.text_section().begin();
+ it != program.text_section().end(); ++it, pc_ += 4)
(*it)->accept(*this);
}
diff --git a/src/inst/register.hh b/src/inst/register.hh
index 80278bf..28e391b 100644
--- a/src/inst/register.hh
+++ b/src/inst/register.hh
@@ -28,12 +28,12 @@ namespace inst
public:
enum kind_type
{
- /// Generic (processor, coprocessor) kind ($0, $1, etc.)
- generic,
- /// General purpose (processor) register ($zero, $a0, etc.)
- general,
- /// Unlimited (processor) register ($x2097, etc.)
- unlimited
+ /// Generic (processor, coprocessor) kind ($0, $1, etc.)
+ generic,
+ /// General purpose (processor) register ($zero, $a0, etc.)
+ general,
+ /// Unlimited (processor) register ($x2097, etc.)
+ unlimited
};
public:
diff --git a/src/inst/section.cc b/src/inst/section.cc
index 49003ec..80d6ec1 100644
--- a/src/inst/section.cc
+++ b/src/inst/section.cc
@@ -23,7 +23,7 @@ namespace inst
Section::~Section()
{
// for (label_set_type::iterator
-// it = sorted_labels_.begin(); it != sorted_labels_.end(); ++it)
+// it = sorted_labels_.begin(); it != sorted_labels_.end(); ++it)
// delete *it;
}
@@ -32,10 +32,10 @@ namespace inst
{
label_set_type::const_iterator it(sorted_labels_.find(label));
if (it == sorted_labels_.end()
- || *(*it) < *label)
+ || *(*it) < *label)
{
- it = sorted_labels_.insert(it, label);
- return true;
+ it = sorted_labels_.insert(it, label);
+ return true;
}
return false;
}
diff --git a/src/inst/section.hh b/src/inst/section.hh
index 9372d86..f11313e 100644
--- a/src/inst/section.hh
+++ b/src/inst/section.hh
@@ -42,7 +42,7 @@ namespace inst
protected:
/** Return false if the label already exists in this section, true
- otherwise */
+ otherwise */
bool register_label(Label *label);
public:
diff --git a/src/inst/text_label.hh b/src/inst/text_label.hh
index 32efdb7..5f273cb 100644
--- a/src/inst/text_label.hh
+++ b/src/inst/text_label.hh
@@ -29,7 +29,7 @@ namespace inst
{
public:
TextLabel(const std::string &s,
- TextSection::instruction_list_type::iterator it);
+ TextSection::instruction_list_type::iterator it);
virtual ~TextLabel();
public:
diff --git a/src/inst/text_label.hxx b/src/inst/text_label.hxx
index fccc59b..6ae417e 100644
--- a/src/inst/text_label.hxx
+++ b/src/inst/text_label.hxx
@@ -28,7 +28,7 @@ namespace inst
//
inline
TextLabel::TextLabel(const std::string &s,
- TextSection::instruction_list_type::iterator it):
+ TextSection::instruction_list_type::iterator it):
Label(s), it_(it)
{
}
diff --git a/src/inst/text_section.cc b/src/inst/text_section.cc
index af92627..5da786c 100644
--- a/src/inst/text_section.cc
+++ b/src/inst/text_section.cc
@@ -29,7 +29,7 @@ namespace inst
TextSection::~TextSection()
{
for (instruction_list_type::const_iterator
- it = insts_.begin(); it != insts_.end(); ++it)
+ it = insts_.begin(); it != insts_.end(); ++it)
delete (*it);
}
@@ -62,27 +62,27 @@ namespace inst
next_labeled_it = (*label_it)->get_iterator();
for (instruction_list_type::const_iterator
- inst_it = begin(); inst_it != end(); ++inst_it)
+ inst_it = begin(); inst_it != end(); ++inst_it)
{
- while (inst_it == next_labeled_it)
- {
- ostr << *(*label_it) << ':' << std::endl;
- ++label_it;
+ while (inst_it == next_labeled_it)
+ {
+ ostr << *(*label_it) << ':' << std::endl;
+ ++label_it;
- if (label_it != labels_.end())
- next_labeled_it = (*label_it)->get_iterator();
- else // No more labels
- break;
- }
+ if (label_it != labels_.end())
+ next_labeled_it = (*label_it)->get_iterator();
+ else // No more labels
+ break;
+ }
- ostr << '\t' << *(*inst_it) << std::endl;
+ ostr << '\t' << *(*inst_it) << std::endl;
}
// Print labels that point right after the last instruction
while (label_it != labels_.end())
{
- ostr << *(*label_it) << ':' << std::endl;
- ++label_it;
+ ostr << *(*label_it) << ':' << std::endl;
+ ++label_it;
}
}
diff --git a/src/misc/contract.hh b/src/misc/contract.hh
index 994ceba..441344d 100644
--- a/src/misc/contract.hh
+++ b/src/misc/contract.hh
@@ -6,19 +6,19 @@
// 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
/** \file misc/contract.hh
- \brief Replacement for cassert.
-
+ \brief Replacement for cassert.
+
The implementation is inspired from LRDE's contract.hh/contract.cc
provided in the Tiger Compiler and the Vaucanson project.
*/
@@ -39,21 +39,21 @@
# include <cstdlib>
inline void __FailedCondition(const char* condType,
- const char* condText,
- const char* fileName,
- int fileLine)
+ const char* condText,
+ const char* fileName,
+ int fileLine)
{
std::cerr << fileName << ':'
- << fileLine
- << ": "
- << condType << " `"
- << condText << "' failed." << std::endl;
+ << fileLine
+ << ": "
+ << condType << " `"
+ << condText << "' failed." << std::endl;
abort();
}
-# define __TestCondition(condType,expr) \
- ((void) ((expr) ? 0 : (__FailedCondition( #condType, #expr, \
- __FILE__, __LINE__ ), 0)))
+# define __TestCondition(condType,expr) \
+ ((void) ((expr) ? 0 : (__FailedCondition( #condType, #expr, \
+ __FILE__, __LINE__ ), 0)))
# define assertion(expr) __TestCondition(Assertion,expr)
# define invariant(expr) __TestCondition(Invariant,expr)
diff --git a/src/misc/counted_ptr.hh b/src/misc/counted_ptr.hh
index e87c04b..fd61137 100644
--- a/src/misc/counted_ptr.hh
+++ b/src/misc/counted_ptr.hh
@@ -6,12 +6,12 @@
// 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -19,7 +19,7 @@
/** \file misc/counted_ptr.hh
\brief Counted reference wrapper.
- A great part of the implementation comes from LRDE's ref.hh/ref.hxx,
+ A great part of the implementation comes from LRDE's ref.hh/ref.hxx,
provided in Tiger Compiler by Raphael Poss. */
#ifndef MISC_COUNTED_PTR_HH
@@ -35,7 +35,7 @@ namespace misc
of garbage collection.
This class implements the proposal of Gregory Colvin in Exception
- Safe Smart Pointers, C++ committee document 94-168/N0555, July, 1994.
+ Safe Smart Pointers, C++ committee document 94-168/N0555, July, 1994.
The concept of counted pointers is very similar to the concept of
file links in file systems, that is why I choose to use the
@@ -58,18 +58,18 @@ namespace misc
friend class counted_ptr;
/** \name Constructor and destructor
- \{ */
+ \{ */
public:
/** \brief A counted_ptr is usually constructed from a raw pointer.
- \param ptr A pointer (defaults to NULL). */
+ \param ptr A pointer (defaults to NULL). */
counted_ptr(element_type *ptr = 0):
ptr_(ptr)
{
count_ = new long(1);
}
-
+
/** \brief A counted_ptr can be constructed from another counted_ptr.
- \param c Another %auto_ptr of the same type. */
+ \param c Another %auto_ptr of the same type. */
counted_ptr(const counted_ptr &c):
ptr_(c.ptr_), count_(c.count_)
{
@@ -87,13 +87,13 @@ namespace misc
/** \} */
/** \name Conversion, assignement, comparison
- \{ */
+ \{ */
public:
/** \brief counted_ptr conversion operator.
-
- This conversion operator avoids having to define several
- constructors and test operators for creation from or comparison with
- counted pointers of a different but related type.
+
+ This conversion operator avoids having to define several
+ constructors and test operators for creation from or comparison with
+ counted pointers of a different but related type.
*/
template < typename U >
operator counted_ptr< U >() const
@@ -102,14 +102,14 @@ namespace misc
}
/** \brief counted_ptr assignment operator.
- \param c Another counted_ptr of the same type. */
+ \param c Another counted_ptr of the same type. */
counted_ptr&
operator=(const counted_ptr &c)
{
link(c.ptr_, c.count_);
return *this;
}
-
+
/** \brief Return true if \a c and this share the same data. */
bool
operator==(const counted_ptr &c)
@@ -129,25 +129,25 @@ namespace misc
{
--(*count_);
if (!*count_)
- {
- delete ptr_;
- delete count_;
- }
+ {
+ delete ptr_;
+ delete count_;
+ }
}
void link(T *ptr, long *count)
{
if (count_ != count)
- {
- ++(*count);
- unlink();
- ptr_ = ptr;
- count_ = count;
- }
+ {
+ ++(*count);
+ unlink();
+ ptr_ = ptr;
+ count_ = count;
+ }
}
/** \name Dereferencing
- \{ */
+ \{ */
public:
bool
exists() const
@@ -172,7 +172,7 @@ namespace misc
precondition(ptr_ != 0);
return ptr_;
}
- /** \} */
+ /** \} */
private:
diff --git a/src/misc/deref.hh b/src/misc/deref.hh
index c6678ce..799b5fd 100644
--- a/src/misc/deref.hh
+++ b/src/misc/deref.hh
@@ -1,18 +1,18 @@
//
// deref.hh: pretty printing pointers
-// Copyright (C) 2003, 2004 Akim Demaille <akim(a)epita.fr> and
+// Copyright (C) 2003, 2004 Akim Demaille <akim(a)epita.fr> and
// Benoit Perrot <benoit(a)lrde.epita.fr>
//
// This 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -33,9 +33,9 @@ namespace misc
postr_(0)
{}
public:
- static Deref& instance()
+ static Deref& instance()
{
- static Deref unique;
+ static Deref unique;
return unique;
}
virtual ~Deref()
@@ -44,28 +44,28 @@ namespace misc
public:
template <class T>
- std::ostream& operator<<(const T* t) const
+ std::ostream& operator<<(const T* t) const
{
assertion(postr_);
(*postr_) << *t;
return (*postr_);
}
template <class T>
- std::ostream& operator<<(T* t) const
+ std::ostream& operator<<(T* t) const
{
assertion(postr_);
(*postr_) << *t;
return (*postr_);
}
template <class T>
- std::ostream& operator<<(const T& t) const
+ std::ostream& operator<<(const T& t) const
{
assertion(postr_);
(*postr_) << t;
return (*postr_);
}
template <class T>
- std::ostream& operator<<(T& t) const
+ std::ostream& operator<<(T& t) const
{
assertion(postr_);
(*postr_) << t;
@@ -73,13 +73,13 @@ namespace misc
}
public:
- void ostr_set(std::ostream& ostr)
+ void ostr_set(std::ostream& ostr)
{
postr_ = &ostr;
}
protected:
- std::ostream* postr_;
+ std::ostream* postr_;
};
inline Deref&
@@ -91,6 +91,6 @@ namespace misc
} // namespace misc
-# define deref misc::Deref::instance()
+# define deref misc::Deref::instance()
#endif // !MISC_DEREF_HH
diff --git a/src/misc/escape.hh b/src/misc/escape.hh
index 5ca2ffb..83efd6a 100644
--- a/src/misc/escape.hh
+++ b/src/misc/escape.hh
@@ -1,18 +1,18 @@
//
// escape.hh: escaping special characters for output
-// Copyright (C) 2003, 2004, 2012 Akim Demaille <akim(a)epita.fr> and
+// Copyright (C) 2003, 2004, 2012 Akim Demaille <akim(a)epita.fr> and
// Benoit Perrot <benoit(a)lrde.epita.fr>
//
// This 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -40,17 +40,17 @@ operator<<(std::ostream& o, const escape& e)
{
/* For some reason, when we use std::locale on Mac OS X, the
following exception may be thrown:
-
+
terminate called after throwing an instance of 'std::runtime_error'
what(): locale::facet::_S_create_c_locale name not valid
-
+
A workaround is to unset the environment variable `LANG' prior to
using std::locale, but this is cumbersome.
-
+
So we use the C locale-agnostic version of isprint() from header
`cctype', instead of C++ isprint() from header `locale' taking a
locale as second argument.
-
+
See also
http://stackoverflow.com/questions/1745045/stdlocale-breakage-on-macos-10-6…
on this topic. */
@@ -68,11 +68,11 @@ operator<<(std::ostream& o, const escape& e)
case '\\': o << "\\\\"; break;
case '\"': o << "\\\""; break;
default:
- if (std::isprint (*p))
- o << *p;
- else
- o << "\\x"
- << std::setfill ('0') << std::setw (2) << (int) (unsigned
char) *p;
+ if (std::isprint (*p))
+ o << *p;
+ else
+ o << "\\x"
+ << std::setfill ('0') << std::setw (2) << (int)
(unsigned char) *p;
}
o.flags (flags);
return o;
diff --git a/src/misc/has.hh b/src/misc/has.hh
index de07773..09e24a2 100644
--- a/src/misc/has.hh
+++ b/src/misc/has.hh
@@ -1,18 +1,18 @@
//
-// has.hh: finding element or key in STL containers.
-// Copyright (C) 2003, 2004 Akim Demaille <akim(a)epita.fr> and
+// has.hh: finding element or key in STL containers.
+// Copyright (C) 2003, 2004 Akim Demaille <akim(a)epita.fr> and
// Benoit Perrot <benoit(a)lrde.epita.fr>
//
// This 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -38,7 +38,7 @@ find (Container &c, const typename Container::value_type &v)
template <class Container>
inline bool
has (const Container &c, const typename Container::value_type &v)
-{
+{
// We specify the instance to solve a conflict between the
// two finds above, that compete against each other because
// the parameter Container can embed a "const".
@@ -48,7 +48,7 @@ has (const Container &c, const typename Container::value_type
&v)
template <class Associative>
inline bool
has_key (const Associative &a, const typename Associative::key_type &k)
-{
+{
// We specify the instance to solve a conflict between the
// two finds above, that compete against each other because
// the parameter Container can embed a "const".
diff --git a/src/misc/lexutils.cc b/src/misc/lexutils.cc
index e2bbb83..981fd75 100644
--- a/src/misc/lexutils.cc
+++ b/src/misc/lexutils.cc
@@ -6,12 +6,12 @@
// 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/misc/lexutils.hh b/src/misc/lexutils.hh
index 5eb9676..4c216d2 100644
--- a/src/misc/lexutils.hh
+++ b/src/misc/lexutils.hh
@@ -6,12 +6,12 @@
// 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/misc/select_const.hh b/src/misc/select_const.hh
index 91efbd8..cbb091f 100644
--- a/src/misc/select_const.hh
+++ b/src/misc/select_const.hh
@@ -1,18 +1,18 @@
-//
+//
// select_const.hh: select between a const and a non-const type.
-// Copyright (C) 2003, 2004 Akim Demaille <akim(a)epita.fr> and
+// Copyright (C) 2003, 2004 Akim Demaille <akim(a)epita.fr> and
// Benoit Perrot <benoit(a)lrde.epita.fr>
//
// This 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/misc/table.hh b/src/misc/table.hh
index 7228db0..c846a12 100644
--- a/src/misc/table.hh
+++ b/src/misc/table.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -31,8 +31,8 @@ namespace misc
class Table
{
public:
- typedef std::map<Key_T, Entry_T> scope_type;
- typedef std::list<scope_type> scopes_type;
+ typedef std::map<Key_T, Entry_T> scope_type;
+ typedef std::list<scope_type> scopes_type;
Table ()
{
@@ -40,18 +40,18 @@ namespace misc
}
public:
- void put (Key_T key, Entry_T value)
+ void put (Key_T key, Entry_T value)
{
scopes_.front ()[key] = value;
}
- bool has (Key_T key) const
+ bool has (Key_T key) const
{
typename scope_type::const_iterator im = scopes_.front ().find (key);
return (im != scopes_.front ().end ());
}
-
- Entry_T get (Key_T key) const
+
+ Entry_T get (Key_T key) const
{
typename scope_type::const_iterator im = scopes_.front ().find (key);
assertion (im != scopes_.front ().end ());
@@ -78,20 +78,20 @@ namespace misc
bool first = true;
for (typename scopes_type::const_iterator
- s = scopes_.begin (); s != scopes_.end (); ++s)
- {
- if (!first)
- ostr << "------------------------------" << std::endl;
- for (typename scope_type::const_iterator
- i = s->begin (); i != s->end (); ++i)
- ostr << i->first << " = " << i->second <<
std::endl;
- first = false;
- }
+ s = scopes_.begin (); s != scopes_.end (); ++s)
+ {
+ if (!first)
+ ostr << "------------------------------" << std::endl;
+ for (typename scope_type::const_iterator
+ i = s->begin (); i != s->end (); ++i)
+ ostr << i->first << " = " << i->second
<< std::endl;
+ first = false;
+ }
ostr << "==============================" << std::endl;
}
protected:
- scopes_type scopes_;
+ scopes_type scopes_;
};
template<class K, class E>
diff --git a/src/misc/test-unique_string.cc b/src/misc/test-unique_string.cc
index d0aac45..cfa48c0 100644
--- a/src/misc/test-unique_string.cc
+++ b/src/misc/test-unique_string.cc
@@ -6,12 +6,12 @@
// 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/misc/unique_string.cc b/src/misc/unique_string.cc
index a792544..a1fae1c 100644
--- a/src/misc/unique_string.cc
+++ b/src/misc/unique_string.cc
@@ -6,12 +6,12 @@
// 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/misc/unique_string.hh b/src/misc/unique_string.hh
index bce57c4..168660d 100644
--- a/src/misc/unique_string.hh
+++ b/src/misc/unique_string.hh
@@ -6,12 +6,12 @@
// 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.
-//
+//
// It 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -21,7 +21,7 @@
/** \file misc/unique_string.hh
\brief String uniquifier.
- The idea of this class comes from TC's LRDE's Symbol class, but
+ The idea of this class comes from TC's LRDE's Symbol class, but
the implementation is quite different. */
#include <string>
@@ -78,14 +78,14 @@ namespace misc
bool operator<(const unique_string &rhs) const
{
if (it_ == rhs.it_)
- return false;
+ return false;
return *it_ < *rhs.it_;
}
private:
static string_to_unique_type::const_iterator insert_in_pool(const std::string
&str);
-
+
private:
static string_to_unique_type pool_;
diff --git a/src/modules.hh b/src/modules.hh
index e097419..16fddbc 100644
--- a/src/modules.hh
+++ b/src/modules.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/nolimips-tasks.cc b/src/nolimips-tasks.cc
index 0c680df..6da777d 100644
--- a/src/nolimips-tasks.cc
+++ b/src/nolimips-tasks.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/nolimips-tasks.hh b/src/nolimips-tasks.hh
index 7325293..cd6efb6 100644
--- a/src/nolimips-tasks.hh
+++ b/src/nolimips-tasks.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -27,13 +27,13 @@ namespace nolimips
{
TASK_MODULE ("");
-
+
TASK_DECLARE ("usage", "Give a short usage message",
- usage, "");
+ usage, "");
TASK_DECLARE ("V|version", "Print program version",
- version, "");
+ version, "");
TASK_DECLARE ("h|help", "Give this help list",
- help, "usage version");
+ help, "usage version");
} // namespace tasks
diff --git a/src/nolimips.cc b/src/nolimips.cc
index 10f86ad..fac32c1 100644
--- a/src/nolimips.cc
+++ b/src/nolimips.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -32,14 +32,14 @@
exit_type exit_status = exit_success;
const char* program_name;
-int main(int argc, char* argv[])
+int main(int argc, char* argv[])
{
program_name = argv[0];
filename = task::TaskRegister::instance().parse_args(argc, argv);
if (task::TaskRegister::instance().enabled_tasks ().size () == 0)
task::TaskRegister::instance().enable_task("execute");
-
+
exit_status = exit_success;
task::TaskRegister::instance().execute();
if (exit_status != exit_success)
diff --git a/src/parse-tasks.cc b/src/parse-tasks.cc
index 6b11754..451880c 100644
--- a/src/parse-tasks.cc
+++ b/src/parse-tasks.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -54,26 +54,26 @@ namespace parse
nop_after_branch_p = true;
}
- inst::Program* program = 0;
+ inst::Program* program = 0;
void
parse ()
{
if (filename == NULL)
- {
- std::cerr << "You must specify an input file." << std::endl;
- exit (exit_failure);
- }
-
+ {
+ std::cerr << "You must specify an input file." <<
std::endl;
+ exit (exit_failure);
+ }
+
program = ::parse::parse(filename);
if (!program)
- {
- std::cerr << "Parsing Failed" << std::endl;
- if (!exit_status)
- exit_status = exit_parse;
- exit (exit_status);
- }
+ {
+ std::cerr << "Parsing Failed" << std::endl;
+ if (!exit_status)
+ exit_status = exit_parse;
+ exit (exit_status);
+ }
}
-
+
} // namespace tasks
} // namespace parse
diff --git a/src/parse-tasks.hh b/src/parse-tasks.hh
index 5aa1553..ac89b35 100644
--- a/src/parse-tasks.hh
+++ b/src/parse-tasks.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -27,22 +27,22 @@ namespace parse
namespace tasks
{
- extern inst::Program* program;
+ extern inst::Program* program;
TASK_MODULE ("1. Parsing");
TASK_DECLARE ("trace-scan", "Trace the scanning",
- trace_scan, "");
+ trace_scan, "");
TASK_DECLARE ("u|unlimited-regs", "Authorize unlimited
registers",
- unlimited_regs, "");
+ unlimited_regs, "");
TASK_DECLARE ("trace-parse", "Trace the parse",
- trace_parse, "");
- TASK_DECLARE ("N|nop-after-branch",
- "Fill delay slot of branch instructions with a NOP",
- nop_after_branch, "");
+ trace_parse, "");
+ TASK_DECLARE ("N|nop-after-branch",
+ "Fill delay slot of branch instructions with a NOP",
+ nop_after_branch, "");
TASK_DECLARE ("parse", "Parse a file",
- parse, "");
+ parse, "");
} // namespace tasks
diff --git a/src/parse/asm-scan.hh b/src/parse/asm-scan.hh
index ce736f6..428b29b 100644
--- a/src/parse/asm-scan.hh
+++ b/src/parse/asm-scan.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -22,7 +22,7 @@
# define YY_DECL \
int yylex (yy::parser::semantic_type *yylval, \
- yy::parser::location_type *yylloc)
+ yy::parser::location_type *yylloc)
YY_DECL;
namespace parse
diff --git a/src/parse/fwd.hh b/src/parse/fwd.hh
index 103a209..5278f52 100644
--- a/src/parse/fwd.hh
+++ b/src/parse/fwd.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/parse/libparse.cc b/src/parse/libparse.cc
index 0a51e0e..66c72b7 100644
--- a/src/parse/libparse.cc
+++ b/src/parse/libparse.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/parse/libparse.hh b/src/parse/libparse.hh
index e3b850e..d801d1e 100644
--- a/src/parse/libparse.hh
+++ b/src/parse/libparse.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/shell-tasks.cc b/src/shell-tasks.cc
index dfe80ac..38a6a65 100644
--- a/src/shell-tasks.cc
+++ b/src/shell-tasks.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/shell-tasks.hh b/src/shell-tasks.hh
index e0cf93d..0dc02c4 100644
--- a/src/shell-tasks.hh
+++ b/src/shell-tasks.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -29,7 +29,7 @@ namespace shell
TASK_MODULE ("4. Shell");
TASK_DECLARE ("i|shell", "Enable shell interpreter",
- shell_exec, "");
+ shell_exec, "");
} // namespace tasks
diff --git a/src/shell/cmd.hh b/src/shell/cmd.hh
index c031d61..8b29b30 100644
--- a/src/shell/cmd.hh
+++ b/src/shell/cmd.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -34,29 +34,29 @@ namespace shell
/// Command identifier.
enum identifier_type
{
- id_unknown,
- id_ambiguous,
- id_null,
- id_load,
- id_run,
- id_quit,
- id_continue,
- id_break,
- id_next,
- id_print,
- id_display,
- id_undisplay,
- id_dump,
- id_mem,
- id_backtrace,
- id_nop_after_branch,
- id_help
+ id_unknown,
+ id_ambiguous,
+ id_null,
+ id_load,
+ id_run,
+ id_quit,
+ id_continue,
+ id_break,
+ id_next,
+ id_print,
+ id_display,
+ id_undisplay,
+ id_dump,
+ id_mem,
+ id_backtrace,
+ id_nop_after_branch,
+ id_help
};
typedef std::list<std::string> list_args_type;
- /**\name Constructor and destructor
- \{ */
+ /**\name Constructor and destructor
+ \{ */
public:
/// Construct a Cmd.
Cmd(const identifier_type id);
@@ -65,7 +65,7 @@ namespace shell
/** \} */
/** \name Accessors
- \{ */
+ \{ */
public:
/// Add an argument
void push_arg(const std::string &arg);
diff --git a/src/shell/cmd.hxx b/src/shell/cmd.hxx
index cdf21fe..0b6e892 100644
--- a/src/shell/cmd.hxx
+++ b/src/shell/cmd.hxx
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/shell/shell.cc b/src/shell/shell.cc
index 3f75bdb..955c3c7 100644
--- a/src/shell/shell.cc
+++ b/src/shell/shell.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -55,18 +55,18 @@ namespace shell
{
if (0 < l.size())
{
- unsigned nb_common_chars = l[0].size();
-
- for (std::vector<std::string>::const_iterator
- e = l.begin(); e != l.end() && 0 < nb_common_chars; ++e)
- {
- unsigned c = 0;
- while (c < nb_common_chars && l.front()[c] == (*e)[c])
- ++c;
- nb_common_chars = c;
- }
-
- return std::string(l.front(), 0, nb_common_chars);
+ unsigned nb_common_chars = l[0].size();
+
+ for (std::vector<std::string>::const_iterator
+ e = l.begin(); e != l.end() && 0 < nb_common_chars; ++e)
+ {
+ unsigned c = 0;
+ while (c < nb_common_chars && l.front()[c] == (*e)[c])
+ ++c;
+ nb_common_chars = c;
+ }
+
+ return std::string(l.front(), 0, nb_common_chars);
}
return std::string();
@@ -82,37 +82,37 @@ namespace shell
std::string line_to_complete(rl_line_buffer, end);
std::vector<std::string> completions;
delete Shell::instance().parse(line_to_complete,
- &completions); // wonderfull
+ &completions); // wonderfull
char **matches = 0;
if (0 < completions.size())
{
- matches = (char**) malloc(sizeof(char*) * (completions.size() + 2));
- if (matches)
- {
- // Extract max common characters
- std::string substitution = find_common_prefix(completions);
-
- // Fill matches array
- if (!substitution.empty())
- matches[0] = strdup(substitution.c_str());
- else
- matches[0] = strdup(text);
- ++matches;
- for (unsigned c = 0; c < completions.size(); ++c)
- matches[c] = strdup(completions[c].c_str());
- matches[completions.size()] = 0;
- --matches;
- }
+ matches = (char**) malloc(sizeof(char*) * (completions.size() + 2));
+ if (matches)
+ {
+ // Extract max common characters
+ std::string substitution = find_common_prefix(completions);
+
+ // Fill matches array
+ if (!substitution.empty())
+ matches[0] = strdup(substitution.c_str());
+ else
+ matches[0] = strdup(text);
+ ++matches;
+ for (unsigned c = 0; c < completions.size(); ++c)
+ matches[c] = strdup(completions[c].c_str());
+ matches[completions.size()] = 0;
+ --matches;
+ }
}
-
+
return matches;
}
#endif // !HAVE_READLINE_READLINE_H
// --------------------------------------------------------------------------
- // Shell
+ // Shell
// --------------------------------------------------------------------------
Shell::Shell():
@@ -189,13 +189,13 @@ namespace shell
std::string line;
while (execute(*command) == 0 && misc::readline("(nolimips) ",
line))
{
- display();
+ display();
- if (!line.empty())
- {
- delete command;
- command = parse(line);
- }
+ if (!line.empty())
+ {
+ delete command;
+ command = parse(line);
+ }
}
delete command;
@@ -209,10 +209,10 @@ namespace shell
std::string res;
while (!isblank(iss.peek()))
{
- char c = static_cast<char>(iss.get());
- if (iss.eof())
- break;
- res += c;
+ char c = static_cast<char>(iss.get());
+ if (iss.eof())
+ break;
+ res += c;
}
return res;
}
@@ -246,7 +246,7 @@ namespace shell
Cmd::identifier_type
Shell::eat_command_id(std::istringstream &iss,
- std::vector<std::string> *completions)
+ std::vector<std::string> *completions)
{
Cmd::identifier_type id = Cmd::id_null;
@@ -255,39 +255,39 @@ namespace shell
if (!word.empty())
{
- map_token_type::const_iterator it = map_token_.lower_bound(word);
- if (it == map_token_.end() || it->first.find(word) != 0)
- id = Cmd::id_unknown;
- else
- {
- id = it->second;
-
- map_token_type::const_iterator next(it);
- while (next != map_token_.end() && next->first.find(word) == 0)
- {
- if (complete_p)
- completions->push_back(next->first);
-
- if (it->first != next->first)
- id = Cmd::id_ambiguous;
- ++next;
- }
-
- return id;
- }
+ map_token_type::const_iterator it = map_token_.lower_bound(word);
+ if (it == map_token_.end() || it->first.find(word) != 0)
+ id = Cmd::id_unknown;
+ else
+ {
+ id = it->second;
+
+ map_token_type::const_iterator next(it);
+ while (next != map_token_.end() && next->first.find(word) == 0)
+ {
+ if (complete_p)
+ completions->push_back(next->first);
+
+ if (it->first != next->first)
+ id = Cmd::id_ambiguous;
+ ++next;
+ }
+
+ return id;
+ }
}
if (complete_p)
- for (map_token_type::const_iterator
- it = map_token_.begin(); it != map_token_.end(); ++it)
- completions->push_back(it->first);
+ for (map_token_type::const_iterator
+ it = map_token_.begin(); it != map_token_.end(); ++it)
+ completions->push_back(it->first);
return id;
}
Cmd*
Shell::parse(const std::string &str,
- std::vector<std::string> *completions)
+ std::vector<std::string> *completions)
{
std::istringstream iss(str);
Cmd* command = 0;
@@ -296,71 +296,71 @@ namespace shell
switch (id)
{
case Cmd::id_run:
- {
- command = new Cmd(Cmd::id_run);
- std::string tmp = eat_word(iss);
- while (0 < tmp.length())
- {
- command->push_arg(tmp);
- tmp = eat_word(iss);
- }
- return command;
- }
+ {
+ command = new Cmd(Cmd::id_run);
+ std::string tmp = eat_word(iss);
+ while (0 < tmp.length())
+ {
+ command->push_arg(tmp);
+ tmp = eat_word(iss);
+ }
+ return command;
+ }
case Cmd::id_break:
- {
- command = new Cmd(Cmd::id_break);
- std::string tmp;
- if (eat_label(iss, tmp))
- {
- command->push_arg(tmp);
- return command;
- }
- delete command;
- break;
- }
+ {
+ command = new Cmd(Cmd::id_break);
+ std::string tmp;
+ if (eat_label(iss, tmp))
+ {
+ command->push_arg(tmp);
+ return command;
+ }
+ delete command;
+ break;
+ }
case Cmd::id_load:
- {
- command = new Cmd(Cmd::id_load);
- std::string tmp = eat_word(iss);
- if (!tmp.empty())
- {
- command->push_arg(tmp);
- return command;
- }
- delete command;
- break;
- }
+ {
+ command = new Cmd(Cmd::id_load);
+ std::string tmp = eat_word(iss);
+ if (!tmp.empty())
+ {
+ command->push_arg(tmp);
+ return command;
+ }
+ delete command;
+ break;
+ }
case Cmd::id_print:
case Cmd::id_display:
case Cmd::id_undisplay:
- {
- command = new Cmd(id);
- std::string tmp;
- if (eat_register(iss, tmp))
- {
- command->push_arg(tmp);
- return command;
- }
- delete command;
- break;
- }
+ {
+ command = new Cmd(id);
+ std::string tmp;
+ if (eat_register(iss, tmp))
+ {
+ command->push_arg(tmp);
+ return command;
+ }
+ delete command;
+ break;
+ }
case Cmd::id_mem:
- {
- command = new Cmd(Cmd::id_mem);
-
- // FIXME: check tmp is a memory address: eat_memory_address()
- std::string tmp = eat_word(iss);
- if (!tmp.empty())
- {
- command->push_arg(tmp);
- return command;
- }
- delete command;
- break;
- }
+ {
+ command = new Cmd(Cmd::id_mem);
+
+ // FIXME: check tmp is a memory address: eat_memory_address()
+ std::string tmp = eat_word(iss);
+ if (!tmp.empty())
+ {
+ command->push_arg(tmp);
+ return command;
+ }
+ delete command;
+ break;
+ }
case Cmd::id_quit:
case Cmd::id_continue:
@@ -373,9 +373,9 @@ namespace shell
case Cmd::id_unknown:
case Cmd::id_ambiguous:
case Cmd::id_null:
- return new Cmd(id);
+ return new Cmd(id);
}
-
+
return new Cmd(Cmd::id_unknown);
}
@@ -390,32 +390,32 @@ namespace shell
delete program_;
exit_status = exit_success;
- //
+ //
program_ = ::parse::parse(*cmd.get_args().begin());
if (exit_status == exit_success)
{
- // FIXME: as soon as possible, put here nop-after-branches filling
-
- inst::ProgramSolver program_solver;
- // program_solver.set_max_callee_save(max_callee_save);
- // program_solver.set_max_caller_save(max_caller_save);
-
- program_solver.solve(*program_);
- if (exit_status == exit_success)
- {
- vm_.load_program(*program_);
- }
- else
- std::cerr << "Solving failed, program not loaded." <<
std::endl;
+ // FIXME: as soon as possible, put here nop-after-branches filling
+
+ inst::ProgramSolver program_solver;
+ // program_solver.set_max_callee_save(max_callee_save);
+ // program_solver.set_max_caller_save(max_caller_save);
+
+ program_solver.solve(*program_);
+ if (exit_status == exit_success)
+ {
+ vm_.load_program(*program_);
+ }
+ else
+ std::cerr << "Solving failed, program not loaded." <<
std::endl;
}
- else
+ else
std::cerr << "Parsing failed, program not loaded." <<
std::endl;
//
if (exit_status != exit_success)
{
- delete program_;
- program_ = 0;
+ delete program_;
+ program_ = 0;
}
}
@@ -425,16 +425,16 @@ namespace shell
{
if (!program_)
{
- std::cerr << "No program loaded." << std::endl;
- return;
+ std::cerr << "No program loaded." << std::endl;
+ return;
}
if (vm_.get_status() != vm::VirtualMachine::halt)
vm_.set_runnable();
else
{
- vm_.reset();
- vm_.set_runnable();
+ vm_.reset();
+ vm_.set_runnable();
}
vm_.execute(false);
}
@@ -444,14 +444,14 @@ namespace shell
{
if (!program_)
{
- std::cerr << "No program loaded." << std::endl;
- return;
+ std::cerr << "No program loaded." << std::endl;
+ return;
}
if (vm_.get_status() != vm::VirtualMachine::halt)
{
- vm_.set_runnable();
- vm_.execute(false);
+ vm_.set_runnable();
+ vm_.execute(false);
}
else
std::cerr << "The program is not being run." << std::endl;
@@ -462,14 +462,14 @@ namespace shell
{
if (!program_)
{
- std::cerr << "No program loaded." << std::endl;
- return;
+ std::cerr << "No program loaded." << std::endl;
+ return;
}
if (vm_.get_status() != vm::VirtualMachine::halt)
{
- vm_.set_run_next();
- vm_.execute(true);
+ vm_.set_run_next();
+ vm_.execute(true);
}
else
std::cerr << "The program is not being run." << std::endl;
@@ -479,23 +479,23 @@ namespace shell
Shell::do_break(const Cmd &cmd)
{
if (!program_)
- std::cerr << "No program loaded." << std::endl;
+ std::cerr << "No program loaded." << std::endl;
else
{
- misc::unique_string label(*cmd.get_args().begin());
-
- if (!program_->text_section().has_label(label))
- std::cerr << "Label " << label
- << " not found." << std::endl;
- else
- {
- int offset =
- program_->text_section().get_offset(label);
-
- std::cout << "Breakpoint " << label
- << " at " << offset << " (+4)." <<
std::endl;
- vm_.add_breakpoint(offset + 4);
- }
+ misc::unique_string label(*cmd.get_args().begin());
+
+ if (!program_->text_section().has_label(label))
+ std::cerr << "Label " << label
+ << " not found." << std::endl;
+ else
+ {
+ int offset =
+ program_->text_section().get_offset(label);
+
+ std::cout << "Breakpoint " << label
+ << " at " << offset << "
(+4)." << std::endl;
+ vm_.add_breakpoint(offset + 4);
+ }
}
}
@@ -547,16 +547,16 @@ namespace shell
std::cout << "No stack." << std::endl;
else
{
- unsigned level = 0;
- for (std::vector<vm::register_type>::const_reverse_iterator
- it = call_stack.rbegin(); it != call_stack.rend(); ++it)
- {
- std::cout
- << "#" << level << " 0x"
- << std::hex << std::setfill('0') << std::setw(8)
<< (*it)
- << std::endl;
- ++level;
- }
+ unsigned level = 0;
+ for (std::vector<vm::register_type>::const_reverse_iterator
+ it = call_stack.rbegin(); it != call_stack.rend(); ++it)
+ {
+ std::cout
+ << "#" << level << " 0x"
+ << std::hex << std::setfill('0') << std::setw(8)
<< (*it)
+ << std::endl;
+ ++level;
+ }
}
}
@@ -613,53 +613,53 @@ namespace shell
switch (cmd.get_identifier())
{
case Cmd::id_quit:
- return 1;
+ return 1;
case Cmd::id_unknown:
- do_unknown();
- break;
+ do_unknown();
+ break;
case Cmd::id_ambiguous:
- do_ambiguous();
- break;
+ do_ambiguous();
+ break;
case Cmd::id_load:
- do_load(cmd);
- break;
+ do_load(cmd);
+ break;
case Cmd::id_run:
- do_run();
- break;
+ do_run();
+ break;
case Cmd::id_continue:
- do_continue();
- break;
+ do_continue();
+ break;
case Cmd::id_next:
- do_next();
- break;
+ do_next();
+ break;
case Cmd::id_dump:
- do_dump();
- break;
+ do_dump();
+ break;
case Cmd::id_print:
- do_print(cmd);
- break;
+ do_print(cmd);
+ break;
case Cmd::id_display:
- do_display(cmd);
- break;
+ do_display(cmd);
+ break;
case Cmd::id_undisplay:
- do_undisplay(cmd);
- break;
+ do_undisplay(cmd);
+ break;
case Cmd::id_mem:
- do_mem();
- break;
+ do_mem();
+ break;
case Cmd::id_backtrace:
- do_backtrace();
- break;
+ do_backtrace();
+ break;
case Cmd::id_break:
- do_break(cmd);
- break;
+ do_break(cmd);
+ break;
case Cmd::id_nop_after_branch:
- do_nop_after_branch();
- break;
+ do_nop_after_branch();
+ break;
case Cmd::id_null:
- break;
+ break;
case Cmd::id_help:
- do_help();
+ do_help();
}
return 0;
}
diff --git a/src/shell/shell.hh b/src/shell/shell.hh
index c964724..3e50e51 100644
--- a/src/shell/shell.hh
+++ b/src/shell/shell.hh
@@ -38,14 +38,14 @@ namespace shell
{
public:
/** \name Shortand type definition
- \{ */
+ \{ */
typedef std::map<std::string, Cmd::identifier_type> map_token_type;
typedef std::map<std::string, vm::Cpu::kind_type> map_register_type;
typedef std::list<std::string> list_disp_type;
/** \} */
/** \name Constructor and destructor
- \{ */
+ \{ */
protected:
/// Construct a Shell
Shell();
@@ -63,14 +63,14 @@ namespace shell
/// Build a command
Cmd *parse(const std::string &str,
- std::vector<std::string> *completions = 0);
+ std::vector<std::string> *completions = 0);
public:
/// Access a register
int get_register(const std::string &r);
/** \name Display list
- \{ */
+ \{ */
public:
/// Add a register in the display list
void add_display(const std::string &r);
@@ -96,10 +96,10 @@ namespace shell
/// Eat a word from input stringstream and return the
/// corresponding keyword
Cmd::identifier_type eat_command_id(std::istringstream &iss,
- std::vector<std::string> *completions);
+ std::vector<std::string> *completions);
/** \name Execution engine
- \{ */
+ \{ */
protected:
void do_load(const Cmd &cmd);
void do_run();
diff --git a/src/shell/shell.hxx b/src/shell/shell.hxx
index 9308fbe..eb5cbb5 100644
--- a/src/shell/shell.hxx
+++ b/src/shell/shell.hxx
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -47,12 +47,12 @@ namespace shell
{
list_disp_type::iterator i = find(list_displayable_, r);
// for (i = list_displayable_.begin(); i != list_displayable_.end(); ++i)
- // if (*i == *r)
- // break;
-
+ // if (*i == *r)
+ // break;
+
if (i != list_displayable_.end())
{
- list_displayable_.erase(i);
+ list_displayable_.erase(i);
}
}
@@ -60,7 +60,7 @@ namespace shell
Shell::display()
{
for (list_disp_type::const_iterator
- i = list_displayable_.begin(); i != list_displayable_.end(); ++i)
+ i = list_displayable_.begin(); i != list_displayable_.end(); ++i)
std::cout << *i << " = " << get_register(*i) <<
std::endl;
}
diff --git a/src/task-tasks.cc b/src/task-tasks.cc
index 7bd1107..da49d6e 100644
--- a/src/task-tasks.cc
+++ b/src/task-tasks.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/task-tasks.hh b/src/task-tasks.hh
index 8d240f6..417025a 100644
--- a/src/task-tasks.hh
+++ b/src/task-tasks.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -28,7 +28,7 @@ namespace task
TASK_MODULE ("0. Tasks");
TASK_DECLARE ("tasks-selection", "Display sorted list of tasks to be
run",
- tasks_selection, "");
+ tasks_selection, "");
} // namespace tasks
} // namespace task
diff --git a/src/task/boolean_task.cc b/src/task/boolean_task.cc
index 895dd87..76b49b3 100644
--- a/src/task/boolean_task.cc
+++ b/src/task/boolean_task.cc
@@ -1,18 +1,18 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004 Akim Demaille <akim(a)epita.fr> and
-// Benoit Perrot <benoit(a)lrde.epita.fr>
+// Benoit Perrot <benoit(a)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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -23,10 +23,10 @@ namespace task
{
BooleanTask::BooleanTask(bool &flag,
- const std::string& option,
- const std::string& module_name,
- const std::string& desc,
- const std::string& deps):
+ const std::string& option,
+ const std::string& module_name,
+ const std::string& desc,
+ const std::string& deps):
Task(option, module_name, desc, deps),
flag_(flag)
{}
diff --git a/src/task/boolean_task.hh b/src/task/boolean_task.hh
index 1afcfe8..cc52aec 100644
--- a/src/task/boolean_task.hh
+++ b/src/task/boolean_task.hh
@@ -1,7 +1,7 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004, 2006, 2012 Akim Demaille <akim(a)epita.fr> and
-// Benoit Perrot <benoit(a)lrde.epita.fr>
+// Benoit Perrot <benoit(a)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
@@ -29,8 +29,8 @@ namespace task
{
public:
BooleanTask(bool &flag,
- const std::string &option, const std::string &module_name,
- const std::string &desc, const std::string &deps = "");
+ const std::string &option, const std::string &module_name,
+ const std::string &desc, const std::string &deps =
"");
public:
virtual void execute() const;
diff --git a/src/task/function_task.cc b/src/task/function_task.cc
index fa73f66..ff0e2ff 100644
--- a/src/task/function_task.cc
+++ b/src/task/function_task.cc
@@ -1,18 +1,18 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004 Akim Demaille <akim(a)epita.fr> and
-// Benoit Perrot <benoit(a)lrde.epita.fr>
+// Benoit Perrot <benoit(a)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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -23,10 +23,10 @@ namespace task
{
FunctionTask::FunctionTask(void (*execute) (void),
- const std::string& option,
- const std::string& module_name,
- const std::string& desc,
- const std::string& deps):
+ const std::string& option,
+ const std::string& module_name,
+ const std::string& desc,
+ const std::string& deps):
Task(option, module_name, desc, deps),
execute_(execute)
{}
diff --git a/src/task/function_task.hh b/src/task/function_task.hh
index f5e40ae..7eb16d4 100644
--- a/src/task/function_task.hh
+++ b/src/task/function_task.hh
@@ -1,7 +1,7 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004, 2006 Akim Demaille <akim(a)epita.fr> and
-// Benoit Perrot <benoit(a)lrde.epita.fr>
+// Benoit Perrot <benoit(a)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
@@ -29,8 +29,8 @@ namespace task
{
public:
FunctionTask(void (*execute) (void),
- const std::string &option, const std::string &module_name,
- const std::string &desc, const std::string &deps = "");
+ const std::string &option, const std::string &module_name,
+ const std::string &desc, const std::string &deps =
"");
public:
virtual void execute() const;
diff --git a/src/task/int_task.cc b/src/task/int_task.cc
index fefc7c2..0e0926a 100644
--- a/src/task/int_task.cc
+++ b/src/task/int_task.cc
@@ -1,18 +1,18 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004 Akim Demaille <akim(a)epita.fr> and
-// Benoit Perrot <benoit(a)lrde.epita.fr>
+// Benoit Perrot <benoit(a)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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -26,10 +26,10 @@ namespace task
{
IntTask::IntTask(int &var, int min, int max,
- const std::string& option,
- const std::string& module_name,
- const std::string& desc,
- const std::string& deps):
+ const std::string& option,
+ const std::string& module_name,
+ const std::string& desc,
+ const std::string& deps):
Task(option, module_name, desc, deps, true),
var_(var), min_(min), max_(max)
{}
diff --git a/src/task/int_task.hh b/src/task/int_task.hh
index b8b6506..774f6f2 100644
--- a/src/task/int_task.hh
+++ b/src/task/int_task.hh
@@ -1,7 +1,7 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004, 2006, 2012 Akim Demaille <akim(a)epita.fr> and
-// Benoit Perrot <benoit(a)lrde.epita.fr>
+// Benoit Perrot <benoit(a)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
@@ -29,8 +29,8 @@ namespace task
{
public:
IntTask(int &var, int min, int max,
- const std::string &option, const std::string &module_name,
- const std::string &desc, const std::string &deps = "");
+ const std::string &option, const std::string &module_name,
+ const std::string &desc, const std::string &deps = "");
public:
virtual bool set_value(const std::string &value) const;
diff --git a/src/task/libtask.hh b/src/task/libtask.hh
index 59286bd..dc3f46f 100644
--- a/src/task/libtask.hh
+++ b/src/task/libtask.hh
@@ -1,18 +1,18 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004, 2005 Akim Demaille <akim(a)epita.fr> and
-// Benoit Perrot <benoit(a)lrde.epita.fr>
+// Benoit Perrot <benoit(a)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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -27,44 +27,44 @@
# ifdef NOLIMIPS_CC_
-# define TASK_MODULE(Name) \
+# define TASK_MODULE(Name) \
const char module_name [] = Name;
-# define TASK_DECLARE(Option, Desc, Routine, Deps) \
- extern void (Routine) (void); \
- static task::FunctionTask task_##Routine(Routine, \
- Option, module_name, \
- Desc, Deps)
+# define TASK_DECLARE(Option, Desc, Routine, Deps) \
+ extern void (Routine) (void); \
+ static task::FunctionTask task_##Routine(Routine, \
+ Option, module_name, \
+ Desc, Deps)
-# define BOOLEAN_TASK_DECLARE(Option, Desc, Flag, Deps) \
- bool Flag = false; \
- static task::BooleanTask task_##Flag(Flag, \
- Option, module_name, \
- Desc, Deps)
+# define BOOLEAN_TASK_DECLARE(Option, Desc, Flag, Deps) \
+ bool Flag = false; \
+ static task::BooleanTask task_##Flag(Flag, \
+ Option, module_name, \
+ Desc, Deps)
-# define INT_TASK_DECLARE(Option, Desc, Var, Default, Min, Max, Deps) \
- int Var = Default; \
- static task::IntTask task_##Var(Var, Min, Max, \
- Option, module_name, \
+# define INT_TASK_DECLARE(Option, Desc, Var, Default, Min, Max, Deps) \
+ int Var = Default; \
+ static task::IntTask task_##Var(Var, Min, Max, \
+ Option, module_name, \
Desc, Deps)
-# define STRING_TASK_DECLARE(Option, Desc, Routine, Default, Deps) \
- extern void (Routine) (const std::string &); \
- static task::StringTask task_##Routine(Routine, \
- Option, module_name, \
- Desc, Deps)
+# define STRING_TASK_DECLARE(Option, Desc, Routine, Default, Deps) \
+ extern void (Routine) (const std::string &); \
+ static task::StringTask task_##Routine(Routine, \
+ Option, module_name, \
+ Desc, Deps)
# else // !NOLIMIPS_CC_
# define TASK_MODULE(Name)
-# define TASK_DECLARE(Name, Help, Routine, Dependencies) \
+# define TASK_DECLARE(Name, Help, Routine, Dependencies) \
extern void (Routine) (void)
-# define BOOLEAN_TASK_DECLARE(Name, Help, Flag, Dependencies) \
+# define BOOLEAN_TASK_DECLARE(Name, Help, Flag, Dependencies) \
extern bool Flag
-# define INT_TASK_DECLARE(Option, Desc, Var, Default, Min, Max, Deps) \
+# define INT_TASK_DECLARE(Option, Desc, Var, Default, Min, Max, Deps) \
extern int Var
-# define STRING_TASK_DECLARE(Option, Desc, Routine, Default, Deps) \
+# define STRING_TASK_DECLARE(Option, Desc, Routine, Default, Deps) \
extern void (Routine) (const std::string &)
# endif // NOLIMIPS_CC_
diff --git a/src/task/string_task.cc b/src/task/string_task.cc
index b444d04..58fbd7e 100644
--- a/src/task/string_task.cc
+++ b/src/task/string_task.cc
@@ -1,18 +1,18 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004 Akim Demaille <akim(a)epita.fr> and
-// Benoit Perrot <benoit(a)lrde.epita.fr>
+// Benoit Perrot <benoit(a)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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -22,10 +22,10 @@ namespace task
{
StringTask::StringTask(void (*execute) (const std::string &),
- const std::string &option,
- const std::string &module_name,
- const std::string &desc,
- const std::string &deps):
+ const std::string &option,
+ const std::string &module_name,
+ const std::string &desc,
+ const std::string &deps):
Task(option, module_name, desc, deps, true),
execute_(execute)
{}
diff --git a/src/task/string_task.hh b/src/task/string_task.hh
index bb00692..344ffa3 100644
--- a/src/task/string_task.hh
+++ b/src/task/string_task.hh
@@ -1,18 +1,18 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2005, 2006 Akim Demaille <akim(a)epita.fr> and
-// Benoit Perrot <benoit(a)lrde.epita.fr>
+// Benoit Perrot <benoit(a)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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -25,14 +25,14 @@
namespace task
{
-
+
class StringTask:
public Task
{
public:
StringTask(void (*execute)(const std::string &),
- const std::string &option, const std::string &module_name,
- const std::string &desc, const std::string &deps = "");
+ const std::string &option, const std::string &module_name,
+ const std::string &desc, const std::string &deps = "");
public:
virtual bool set_value(const std::string &value) const;
diff --git a/src/task/task.cc b/src/task/task.cc
index f3ea23d..6d49ad8 100644
--- a/src/task/task.cc
+++ b/src/task/task.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -26,8 +26,8 @@ namespace task
{
Task::Task (const std::string &option, const std::string &module_name,
- const std::string &desc, const std::string &deps,
- bool needs_value):
+ const std::string &desc, const std::string &deps,
+ bool needs_value):
module_(module_name), description_(desc),
needs_value_(needs_value)
{
@@ -35,31 +35,31 @@ namespace task
std::string::size_type start = 0, end = 0;
while (start < deps.size())
{
- end = deps.find (' ', start);
- if (end > deps.size ())
- end = deps.size ();
- dependencies_.push_back (deps.substr (start, end - start));
- start = end + 1;
+ end = deps.find (' ', start);
+ if (end > deps.size ())
+ end = deps.size ();
+ dependencies_.push_back (deps.substr (start, end - start));
+ start = end + 1;
}
// See if it has a short option, such as "h|help".
if (option.size () > 1 && option[1] == '|')
{
-// if (key)
-// {
-// std::cerr
-// << program_name
-// << ": Task::Task (" << name
-// << "): both key and short option are provided"
-// << std::endl;
-// exit_set (exit_failure);
-// }
- short_opt_ = option.substr(0, 1);
- long_opt_ = option.substr(2);
+// if (key)
+// {
+// std::cerr
+// << program_name
+// << ": Task::Task (" << name
+// << "): both key and short option are provided"
+// << std::endl;
+// exit_set (exit_failure);
+// }
+ short_opt_ = option.substr(0, 1);
+ long_opt_ = option.substr(2);
}
else
long_opt_ = option;
-
+
// Register this task.
TaskRegister::instance ().register_task (*this);
}
@@ -77,7 +77,7 @@ namespace task
// {
// std::cout << "Dependencies for task " << _name <<
":" << std::endl;
// for (deps_t::const_iterator i = _dependencies.begin();
-// i != _dependencies.end(); ++i)
+// i != _dependencies.end(); ++i)
// std::cout << "\t" << *i << std::endl;
// }
diff --git a/src/task/task.hh b/src/task/task.hh
index c3c62f2..ee72692 100644
--- a/src/task/task.hh
+++ b/src/task/task.hh
@@ -28,8 +28,8 @@ namespace task
{
public:
Task(const std::string &option, const std::string &module_name,
- const std::string &desc, const std::string &deps = "",
- bool needs_value = false);
+ const std::string &desc, const std::string &deps = "",
+ bool needs_value = false);
virtual ~Task();
public:
diff --git a/src/task/task.hxx b/src/task/task.hxx
index bf124ca..3ec456b 100644
--- a/src/task/task.hxx
+++ b/src/task/task.hxx
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -46,7 +46,7 @@ namespace task
{
return module_;
}
-
+
inline const std::string &
Task::description(void) const
{
diff --git a/src/task/task_register.cc b/src/task/task_register.cc
index ffcc296..c117ea1 100644
--- a/src/task/task_register.cc
+++ b/src/task/task_register.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -44,19 +44,19 @@ namespace task
void
TaskRegister::register_task (const Task& task)
{
- std::string long_opt = "--" + task.long_opt();
- std::string short_opt = "-" + task.short_opt();
+ std::string long_opt = "--" + task.long_opt();
+ std::string short_opt = "-" + task.short_opt();
assertion(! has_key(tasks_, long_opt));
tasks_[long_opt] = &task;
if (short_opt.size () > 1)
{
- assertion(! has_key(tasks_, short_opt));
- tasks_[short_opt] = &task;
+ assertion(! has_key(tasks_, short_opt));
+ tasks_[short_opt] = &task;
}
modules_[task.module()].push_back(&task);
}
-
+
// Enable a task
void
TaskRegister::enable_task (const Task& task)
@@ -69,43 +69,43 @@ namespace task
assertion(task_name.size() > 0);
if (task_name[0] != '-')
{
- if (task_name.size() > 1)
- task_name = "--" + task_name;
- else
- task_name = "-" + task_name;
+ if (task_name.size() > 1)
+ task_name = "--" + task_name;
+ else
+ task_name = "-" + task_name;
}
assertion(has_key(tasks_, task_name));
- enabled_tasks_.push_back(tasks_[task_name]);
+ enabled_tasks_.push_back(tasks_[task_name]);
}
// Resolve dependencies by a simple topological sort
void
TaskRegister::resolve_dependencies(const Task* task,
- std::set<Task const*>& visited_tasks,
- std::list<Task const*>& sorted_tasks)
+ std::set<Task const*>& visited_tasks,
+ std::list<Task const*>& sorted_tasks)
{
if (has(visited_tasks, task))
return;
visited_tasks.insert(task);
-
+
for (Task::deps_type::const_iterator it = task->dependencies ().begin ();
- it != task->dependencies ().end (); ++it)
+ it != task->dependencies ().end (); ++it)
{
- std::string name = "--" + (*it);
- assertion(has_key(tasks_, name));
- const Task* dependency = tasks_[name];
- resolve_dependencies(dependency, visited_tasks, sorted_tasks);
+ std::string name = "--" + (*it);
+ assertion(has_key(tasks_, name));
+ const Task* dependency = tasks_[name];
+ resolve_dependencies(dependency, visited_tasks, sorted_tasks);
}
sorted_tasks.push_back (task);
}
void
TaskRegister::resolve_dependencies()
{
- std::list<Task const*> sorted_tasks;
- std::set<Task const*> visited_tasks;
+ std::list<Task const*> sorted_tasks;
+ std::set<Task const*> visited_tasks;
for (std::list<Task const*>::const_iterator
- it = enabled_tasks_.begin (); it != enabled_tasks_.end (); ++it)
+ it = enabled_tasks_.begin (); it != enabled_tasks_.end (); ++it)
resolve_dependencies ((*it), visited_tasks, sorted_tasks);
enabled_tasks_ = sorted_tasks;
}
@@ -119,20 +119,20 @@ namespace task
if (it == tasks_.end() || it->first.find(option) != 0)
{
- std::cerr << program_name << ": unrecognized option `"
- << option << "'" << std::endl;
- it = tasks_.end();
+ std::cerr << program_name << ": unrecognized option `"
+ << option << "'" << std::endl;
+ it = tasks_.end();
}
else
{
- TaskRegister::const_task_iterator next(it);
- ++next;
- if (next != tasks_.end() && next->first.find(option) == 0)
- {
- std::cerr << program_name << ": ambiguous option `"
- << option << "'" << std::endl;
- it = tasks_.end();
- }
+ TaskRegister::const_task_iterator next(it);
+ ++next;
+ if (next != tasks_.end() && next->first.find(option) == 0)
+ {
+ std::cerr << program_name << ": ambiguous option `"
+ << option << "'" << std::endl;
+ it = tasks_.end();
+ }
}
return it;
@@ -146,98 +146,98 @@ namespace task
for (int i = 1; i < argc; ++i)
{
- std::string arg(argv[i]);
-
- if ((1 < arg.size ()) && (arg[0] == '-'))
- {
- std::string *value = 0;
-
- // Identify option
- TaskRegister::const_task_iterator it(tasks_.end());
- if (arg[1] == '-') // Long option
- {
- // Split on `=' for value
- unsigned eq = arg.find('=');
- if (eq < arg.size())
- {
- // +1: do not include `=' in value
- value = new std::string(arg, eq + 1);
- arg.resize(eq);
- }
-
- // Search for long option
- it = find_task(arg);
- }
- else // Short option(s)
- {
- for (unsigned l = 1; l < arg.size() && !value; ++l)
- {
- std::string short_option("-");
- short_option += arg[l];
-
- // Search for short option
- it = find_task(short_option);
-
- // Let last task fall through the remaining of the
- // routine
- if (l + 1 < arg.size())
- if (it != tasks_.end())
- {
- if (it->second->needs_value())
- // Split here for value
- value = new std::string(arg, l + 1);
- else
- // Enable task
- enable_task(*(it->second));
- }
- }
- }
-
- // Enable (long or last short) task and set value if needed
- if (it != tasks_.end())
- {
- const Task *task = it->second;
-
- if (task->needs_value())
- {
- if (!value)
- {
- ++i;
- if (i < argc)
- value = new std::string(argv[i]);
- }
-
- if (!value)
- std::cerr
- << program_name
- << ": option `" << task->long_opt()
- << "' takes a value" << std::endl;
- else
- {
- task->set_value(*value);
- enable_task(*task);
- }
- }
- else
- {
- if (value)
- std::cerr
- << program_name
- << ": option `" << task->long_opt()
- << "' does not take a value" << std::endl;
- else
- enable_task(*task);
- }
- }
- else if (value)
- std::cerr
- << program_name
- << ": `"<< *value << "': unexpected value"
<< std::endl;
-
- delete value;
- }
- else
- res = argv[i];
+ std::string arg(argv[i]);
+
+ if ((1 < arg.size ()) && (arg[0] == '-'))
+ {
+ std::string *value = 0;
+
+ // Identify option
+ TaskRegister::const_task_iterator it(tasks_.end());
+ if (arg[1] == '-') // Long option
+ {
+ // Split on `=' for value
+ unsigned eq = arg.find('=');
+ if (eq < arg.size())
+ {
+ // +1: do not include `=' in value
+ value = new std::string(arg, eq + 1);
+ arg.resize(eq);
+ }
+
+ // Search for long option
+ it = find_task(arg);
+ }
+ else // Short option(s)
+ {
+ for (unsigned l = 1; l < arg.size() && !value; ++l)
+ {
+ std::string short_option("-");
+ short_option += arg[l];
+
+ // Search for short option
+ it = find_task(short_option);
+
+ // Let last task fall through the remaining of the
+ // routine
+ if (l + 1 < arg.size())
+ if (it != tasks_.end())
+ {
+ if (it->second->needs_value())
+ // Split here for value
+ value = new std::string(arg, l + 1);
+ else
+ // Enable task
+ enable_task(*(it->second));
+ }
+ }
+ }
+
+ // Enable (long or last short) task and set value if needed
+ if (it != tasks_.end())
+ {
+ const Task *task = it->second;
+
+ if (task->needs_value())
+ {
+ if (!value)
+ {
+ ++i;
+ if (i < argc)
+ value = new std::string(argv[i]);
+ }
+
+ if (!value)
+ std::cerr
+ << program_name
+ << ": option `" << task->long_opt()
+ << "' takes a value" << std::endl;
+ else
+ {
+ task->set_value(*value);
+ enable_task(*task);
+ }
+ }
+ else
+ {
+ if (value)
+ std::cerr
+ << program_name
+ << ": option `" << task->long_opt()
+ << "' does not take a value" <<
std::endl;
+ else
+ enable_task(*task);
+ }
+ }
+ else if (value)
+ std::cerr
+ << program_name
+ << ": `"<< *value << "': unexpected
value" << std::endl;
+
+ delete value;
+ }
+ else
+ res = argv[i];
}
return res;
@@ -250,7 +250,7 @@ namespace task
{
resolve_dependencies();
for (std::list<Task const *>::const_iterator
- it = enabled_tasks_.begin (); it != enabled_tasks_.end (); ++it)
+ it = enabled_tasks_.begin (); it != enabled_tasks_.end (); ++it)
(*it)->execute ();
}
@@ -282,25 +282,25 @@ namespace task
{
ostr << "Usage: " << program_name << " [-";
for (std::map<std::string, Task const*>::const_iterator
- it = tasks_.begin(); it != tasks_.end(); ++it)
+ it = tasks_.begin(); it != tasks_.end(); ++it)
if ((*it).first.size() == 2)
- ostr << (*it).second->short_opt();
+ ostr << (*it).second->short_opt();
ostr << "] ";
unsigned len = 80;
const char tab[] = " ";
for (std::map<std::string, Task const*>::const_iterator
- it = tasks_.begin(); it != tasks_.end(); ++it)
+ it = tasks_.begin(); it != tasks_.end(); ++it)
if ((*it).first.size () > 2)
- {
- if (len + (*it).first.size () + 3 >= 80)
- {
- ostr << std::endl << tab;
- len = sizeof (tab);
- }
- ostr << "[" << (*it).first << "] ";
- len += (*it).first.size () + 3;
- }
+ {
+ if (len + (*it).first.size () + 3 >= 80)
+ {
+ ostr << std::endl << tab;
+ len = sizeof (tab);
+ }
+ ostr << "[" << (*it).first << "] ";
+ len += (*it).first.size () + 3;
+ }
ostr << std::endl;
}
@@ -309,26 +309,26 @@ namespace task
TaskRegister::help(std::ostream& ostr)
{
for (std::map<std::string, std::list<Task const*> >::const_iterator
- it = modules_.begin(); it != modules_.end(); ++it)
+ it = modules_.begin(); it != modules_.end(); ++it)
{
- if ((*it).first.size () > 0)
- ostr << " " << (*it).first << std::endl;
- for (std::list<Task const*>::const_iterator
- jt = (*it).second.begin(); jt != (*it).second.end(); ++jt)
- {
- ostr << " ";
- if ((*jt)->short_opt ().size() > 0)
- ostr << "-" << (*jt)->short_opt() << ",
";
- else
- ostr << " ";
- ostr << "--" << (*jt)->long_opt();
- if ((*jt)->needs_value())
- ostr << "=ARG";
- if ((*jt)->long_opt().size () <= 8)
- ostr << '\t';
- ostr << '\t' << (*jt)->description() << std::endl;
- }
- ostr << std::endl;
+ if ((*it).first.size () > 0)
+ ostr << " " << (*it).first << std::endl;
+ for (std::list<Task const*>::const_iterator
+ jt = (*it).second.begin(); jt != (*it).second.end(); ++jt)
+ {
+ ostr << " ";
+ if ((*jt)->short_opt ().size() > 0)
+ ostr << "-" << (*jt)->short_opt() << ",
";
+ else
+ ostr << " ";
+ ostr << "--" << (*jt)->long_opt();
+ if ((*jt)->needs_value())
+ ostr << "=ARG";
+ if ((*jt)->long_opt().size () <= 8)
+ ostr << '\t';
+ ostr << '\t' << (*jt)->description() <<
std::endl;
+ }
+ ostr << std::endl;
}
ostr << "Reports bugs to "PACKAGE_BUGREPORT << std::endl;
}
@@ -339,7 +339,7 @@ namespace task
{
ostr << "Sorted tasks selection:" << std::endl;
for (std::list<Task const*>::const_iterator
- it = enabled_tasks_.begin (); it != enabled_tasks_.end (); ++it)
+ it = enabled_tasks_.begin (); it != enabled_tasks_.end (); ++it)
ostr << "\t* " << (*it)->long_opt() << std::endl;
}
diff --git a/src/task/task_register.hh b/src/task/task_register.hh
index 6205982..ac0a513 100644
--- a/src/task/task_register.hh
+++ b/src/task/task_register.hh
@@ -32,7 +32,7 @@ namespace task
{
protected:
typedef std::map<std::string,
- Task const*>::const_iterator const_task_iterator;
+ Task const*>::const_iterator const_task_iterator;
private:
TaskRegister();
@@ -56,8 +56,8 @@ namespace task
void execute (void);
private:
void resolve_dependencies(const Task* task,
- std::set<Task const*>& visited_tasks,
- std::list<Task const*>& sorted_tasks);
+ std::set<Task const*>& visited_tasks,
+ std::list<Task const*>& sorted_tasks);
void resolve_dependencies();
public:
diff --git a/src/task/task_register.hxx b/src/task/task_register.hxx
index 2f72ff6..0fa0117 100644
--- a/src/task/task_register.hxx
+++ b/src/task/task_register.hxx
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -28,7 +28,7 @@ namespace task
TaskRegister::TaskRegister()
{
}
-
+
//
inline const std::list<Task const*> &
TaskRegister::enabled_tasks() const
diff --git a/src/vm-tasks.cc b/src/vm-tasks.cc
index 5c1fae2..1ad9f38 100644
--- a/src/vm-tasks.cc
+++ b/src/vm-tasks.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -41,28 +41,28 @@ namespace vm
select_system_library(const std::string &library_name)
{
if (library_name == "nolimips")
- {
- delete system_library;
- system_library = new vm::NolimipsSystemLibrary(std::cin,
- std::cout, std::cerr);
- }
+ {
+ delete system_library;
+ system_library = new vm::NolimipsSystemLibrary(std::cin,
+ std::cout, std::cerr);
+ }
else if (library_name == "spim")
- {
-// delete system_library;
-// system_library = new vm::SpimSystemLibrary(std::cin, std::cout);
- }
+ {
+// delete system_library;
+// system_library = new vm::SpimSystemLibrary(std::cin, std::cout);
+ }
else if (library_name == "none")
- {
- delete system_library;
- system_library = 0;
- }
+ {
+ delete system_library;
+ system_library = 0;
+ }
else
- {
- std::cerr << program_name
- << ": `" << library_name << "': no such system
library"
- << std::endl;
- exit_set (exit_failure);
- }
+ {
+ std::cerr << program_name
+ << ": `" << library_name << "':
no such system library"
+ << std::endl;
+ exit_set (exit_failure);
+ }
}
void
@@ -74,29 +74,29 @@ namespace vm
vm.get_cp0().set_system_library(system_library);
vm.load_program(* parse::tasks::program);
if (exit_status != exit_success)
- exit(exit_status);
+ exit(exit_status);
vm.execute();
if (profile_p)
- {
- std::cerr
- << "Number of cycles: " << vm.get_cp0().get_count() <<
std::endl
- << "Number of executed R-type CPU instructions: "
- << vm.get_cpu().get_instruction_counter(inst::Inst::r_type)
- << std::endl
- << "Number of executed I-type CPU instructions: "
- << vm.get_cpu().get_instruction_counter(inst::Inst::i_type)
- << std::endl
- << "Number of executed J-type CPU instructions: "
- << vm.get_cpu().get_instruction_counter(inst::Inst::j_type)
- << std::endl;
- }
-
+ {
+ std::cerr
+ << "Number of cycles: " << vm.get_cp0().get_count()
<< std::endl
+ << "Number of executed R-type CPU instructions: "
+ << vm.get_cpu().get_instruction_counter(inst::Inst::r_type)
+ << std::endl
+ << "Number of executed I-type CPU instructions: "
+ << vm.get_cpu().get_instruction_counter(inst::Inst::i_type)
+ << std::endl
+ << "Number of executed J-type CPU instructions: "
+ << vm.get_cpu().get_instruction_counter(inst::Inst::j_type)
+ << std::endl;
+ }
+
// FIXME: Quick and dirty, this should not be done here
delete parse::tasks::program;
parse::tasks::program = 0;
}
-
+
} // namespace tasks
} // namespace vm
diff --git a/src/vm-tasks.hh b/src/vm-tasks.hh
index 91e425b..8e64920 100644
--- a/src/vm-tasks.hh
+++ b/src/vm-tasks.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -29,26 +29,26 @@ namespace vm
TASK_MODULE ("3. Virtual Machine");
BOOLEAN_TASK_DECLARE ("check-callee-save",
- "Warn if a callee save register "
- "is not preserved across a call",
- check_callee_save_p, "");
+ "Warn if a callee save register "
+ "is not preserved across a call",
+ check_callee_save_p, "");
BOOLEAN_TASK_DECLARE ("profile", "Enable program profiling",
- profile_p, "");
-
- STRING_TASK_DECLARE ("l|system-library",
- "\n"
- "\t\t\tSpecify the builtin system library to use;\n"
- "\t\t\tvalid library names are: `spim' (default), "
- "`nolimips', \n"
- "\t\t\tand `none'\n",
- select_system_library, "spim",
- "");
-
+ profile_p, "");
+
+ STRING_TASK_DECLARE ("l|system-library",
+ "\n"
+ "\t\t\tSpecify the builtin system library to use;\n"
+ "\t\t\tvalid library names are: `spim' (default),
"
+ "`nolimips', \n"
+ "\t\t\tand `none'\n",
+ select_system_library, "spim",
+ "");
+
BOOLEAN_TASK_DECLARE ("E|trace-exec", "Trace the execution",
- trace_exec_p, "");
+ trace_exec_p, "");
TASK_DECLARE ("e|execute", "Execute the program on virtual
machine",
- execute, "prg-solve");
+ execute, "prg-solve");
} // namespace tasks
diff --git a/src/vm/cp0.hh b/src/vm/cp0.hh
index dbd3033..4094e99 100644
--- a/src/vm/cp0.hh
+++ b/src/vm/cp0.hh
@@ -31,69 +31,69 @@ namespace vm
class Cp0
{
public:
- typedef uint32_t register_type;
+ typedef uint32_t register_type;
public:
/// Coprocessor 0 registers indices
enum kind_type
{
- index = 0, ///< Index register
- random = 1, ///< Random register
- entry_lo0 = 2, ///< Entry for even pages
- entry_lo1 = 3, ///< Entry for odd pages
- context = 4, ///< Context register
- page_mask = 5, ///< Page mask register
- wired = 6, ///< Wired register
- error = 7, ///< Status/control register
- bad_vaddr = 8, ///< Bad virtual address register
- count = 9, ///< Count register
- entry_hi = 10, ///< Entry high
- compare = 11, ///< Compare register
- status = 12, ///< Status (kernel/user mode, etc.) register
- cause = 13, ///< Cause of exception register
- epc = 14, ///< Exception program counter
- pr_id = 15, ///< Processor identification
- config = 16, ///< Configuration register (64 bits)
- lladdr = 17, ///< Loaded linked address
- watch_lo = 18, ///< Watch point debug facility, low part
- watch_hi = 19, ///< Watch point debug facility, high part
- x_context = 20, ///< X context register
- reserved0 = 21, ///< (Reserved register)
- reserved1 = 22, ///< (Reserved register)
- debug = 23, ///< Debug register
- depc = 24, ///< Debug exception program counter
- perf_cnt = 25, ///< Performance counter register
- err_ctl = 26, ///< Error control register
- cache_err = 27, ///< Cache error register
- cache_tag_lo = 28, ///< Cache tag/data low
- cache_tag_hi = 29, ///< Cache tag/data high
- error_epc = 30, ///< Error exception program counter
- desave = 31 ///< Debug exception SAVE
+ index = 0, ///< Index register
+ random = 1, ///< Random register
+ entry_lo0 = 2, ///< Entry for even pages
+ entry_lo1 = 3, ///< Entry for odd pages
+ context = 4, ///< Context register
+ page_mask = 5, ///< Page mask register
+ wired = 6, ///< Wired register
+ error = 7, ///< Status/control register
+ bad_vaddr = 8, ///< Bad virtual address register
+ count = 9, ///< Count register
+ entry_hi = 10, ///< Entry high
+ compare = 11, ///< Compare register
+ status = 12, ///< Status (kernel/user mode, etc.) register
+ cause = 13, ///< Cause of exception register
+ epc = 14, ///< Exception program counter
+ pr_id = 15, ///< Processor identification
+ config = 16, ///< Configuration register (64 bits)
+ lladdr = 17, ///< Loaded linked address
+ watch_lo = 18, ///< Watch point debug facility, low part
+ watch_hi = 19, ///< Watch point debug facility, high part
+ x_context = 20, ///< X context register
+ reserved0 = 21, ///< (Reserved register)
+ reserved1 = 22, ///< (Reserved register)
+ debug = 23, ///< Debug register
+ depc = 24, ///< Debug exception program counter
+ perf_cnt = 25, ///< Performance counter register
+ err_ctl = 26, ///< Error control register
+ cache_err = 27, ///< Cache error register
+ cache_tag_lo = 28, ///< Cache tag/data low
+ cache_tag_hi = 29, ///< Cache tag/data high
+ error_epc = 30, ///< Error exception program counter
+ desave = 31 ///< Debug exception SAVE
};
public:
/// Cause exception codes
enum exception_type
{
- interrupt = 0, ///< Interrupt
- tlb_modified = 1, ///< TLB modified
- tlb_load = 2, ///< TLB load
- tlb_store = 3, ///< TLB store
- addr_load = 4, ///< Address error on load
- addr_store = 5, ///< Address error on store
- bus_inst = 6, ///< Bus error on instruction fetch
- bus_data = 7, ///< Bus error on data load or store
- syscall = 8, ///< System call
- breakpoint = 9, ///< Breakpoint
- reserved_inst = 10, ///< Reserved instruction
- cop_unusable = 11, ///< Coprocessor unusable
- overflow = 12, ///< Arithmetic overflow
- trap = 13, ///< Trap
- floating_point = 15 ///< Floating point exception
+ interrupt = 0, ///< Interrupt
+ tlb_modified = 1, ///< TLB modified
+ tlb_load = 2, ///< TLB load
+ tlb_store = 3, ///< TLB store
+ addr_load = 4, ///< Address error on load
+ addr_store = 5, ///< Address error on store
+ bus_inst = 6, ///< Bus error on instruction fetch
+ bus_data = 7, ///< Bus error on data load or store
+ syscall = 8, ///< System call
+ breakpoint = 9, ///< Breakpoint
+ reserved_inst = 10, ///< Reserved instruction
+ cop_unusable = 11, ///< Coprocessor unusable
+ overflow = 12, ///< Arithmetic overflow
+ trap = 13, ///< Trap
+ floating_point = 15 ///< Floating point exception
};
/** \name Constructor and destructor
- \{ */
+ \{ */
public:
Cp0(Cpu &cpu);
/** \} */
@@ -105,14 +105,14 @@ namespace vm
void set_system_library(SystemLibrary *l);
/** \name Explicit register accessors
- \{ */
+ \{ */
public:
void set_count(register_type r);
register_type get_count() const;
/** \} */
/** \name Unified register accessors
- \{ */
+ \{ */
public:
/// Set the register identified by \a reg to \a r.
void set_register(const inst::Register ®, register_type r);
diff --git a/src/vm/cpu.cc b/src/vm/cpu.cc
index d17c05f..e7276ae 100644
--- a/src/vm/cpu.cc
+++ b/src/vm/cpu.cc
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
@@ -34,8 +34,8 @@ namespace vm
check_callee_save_p_(false),
trace_p_(false),
bubble_(new inst::Sll(inst::Register(inst::Register::general, Cpu::zero),
- inst::Register(inst::Register::general, Cpu::zero),
- new inst::IntExp(0)))
+ inst::Register(inst::Register::general, Cpu::zero),
+ new inst::IntExp(0)))
{
reset();
}
@@ -61,7 +61,7 @@ namespace vm
lo_ = 0;
hi_ = 0;
pc_ = 0;
-
+
// Initialize pipeline with nops
for (unsigned i = 0; i < 6; ++i)
pipeline_[i] = bubble_;
@@ -80,38 +80,38 @@ namespace vm
std::ios_base::fmtflags flags = os.flags (std::ios_base::hex);
os << "Register Map: \tpc = " << std::setfill('0')
<< std::setw(8) << pc_ << std::endl
- << "zero ($0) = " << std::setfill('0') <<
std::setw(8) << GPR_[zero]
- << " t0 ($8) = " << std::setfill('0') <<
std::setw(8) << GPR_[t0]
- << " s0($16) = " << std::setfill('0') <<
std::setw(8) << GPR_[s0]
- << " t8($24) = " << std::setfill('0') <<
std::setw(8) << GPR_[t8] << std::endl
- << " at ($1) = " << std::setfill('0') <<
std::setw(8) << GPR_[at]
- << " t1 ($9) = " << std::setfill('0') <<
std::setw(8) << GPR_[t1]
- << " s1($17) = " << std::setfill('0') <<
std::setw(8) << GPR_[s1]
- << " t9($25) = " << std::setfill('0') <<
std::setw(8) << GPR_[t9] << std::endl
- << " v0 ($2) = " << std::setfill('0') <<
std::setw(8) << GPR_[v0]
- << " t2($10) = " << std::setfill('0') <<
std::setw(8) << GPR_[t2]
- << " s2($18) = " << std::setfill('0') <<
std::setw(8) << GPR_[s2]
- << " k0($26) = " << std::setfill('0') <<
std::setw(8) << GPR_[k0] << std::endl
- << " v1 ($3) = " << std::setfill('0') <<
std::setw(8) << GPR_[v1]
- << " t3($11) = " << std::setfill('0') <<
std::setw(8) << GPR_[t3]
- << " s3($19) = " << std::setfill('0') <<
std::setw(8) << GPR_[s3]
- << " k1($27) = " << std::setfill('0') <<
std::setw(8) << GPR_[k1] << std::endl
- << " a0 ($4) = " << std::setfill('0') <<
std::setw(8) << GPR_[a0]
- << " t4($12) = " << std::setfill('0') <<
std::setw(8) << GPR_[t4]
- << " s4($20) = " << std::setfill('0') <<
std::setw(8) << GPR_[s4]
- << " gp($28) = " << std::setfill('0') <<
std::setw(8) << GPR_[gp] << std::endl
- << " a1 ($5) = " << std::setfill('0') <<
std::setw(8) << GPR_[a1]
- << " t5($13) = " << std::setfill('0') <<
std::setw(8) << GPR_[t5]
- << " s5($21) = " << std::setfill('0') <<
std::setw(8) << GPR_[s5]
- << " sp($29) = " << std::setfill('0') <<
std::setw(8) << GPR_[sp] << std::endl
- << " a2 ($6) = " << std::setfill('0') <<
std::setw(8) << GPR_[a2]
- << " t6($14) = " << std::setfill('0') <<
std::setw(8) << GPR_[t6]
- << " s6($22) = " << std::setfill('0') <<
std::setw(8) << GPR_[s6]
- << " fp($30) = " << std::setfill('0') <<
std::setw(8) << GPR_[fp] << std::endl
- << " a3 ($7) = " << std::setfill('0') <<
std::setw(8) << GPR_[a3]
- << " t7($15) = " << std::setfill('0') <<
std::setw(8) << GPR_[t7]
- << " s7($23) = " << std::setfill('0') <<
std::setw(8) << GPR_[s7]
- << " ra($31) = " << std::setfill('0') <<
std::setw(8) << GPR_[ra] << std::endl;
+ << "zero ($0) = " << std::setfill('0') <<
std::setw(8) << GPR_[zero]
+ << " t0 ($8) = " << std::setfill('0') <<
std::setw(8) << GPR_[t0]
+ << " s0($16) = " << std::setfill('0') <<
std::setw(8) << GPR_[s0]
+ << " t8($24) = " << std::setfill('0') <<
std::setw(8) << GPR_[t8] << std::endl
+ << " at ($1) = " << std::setfill('0') <<
std::setw(8) << GPR_[at]
+ << " t1 ($9) = " << std::setfill('0') <<
std::setw(8) << GPR_[t1]
+ << " s1($17) = " << std::setfill('0') <<
std::setw(8) << GPR_[s1]
+ << " t9($25) = " << std::setfill('0') <<
std::setw(8) << GPR_[t9] << std::endl
+ << " v0 ($2) = " << std::setfill('0') <<
std::setw(8) << GPR_[v0]
+ << " t2($10) = " << std::setfill('0') <<
std::setw(8) << GPR_[t2]
+ << " s2($18) = " << std::setfill('0') <<
std::setw(8) << GPR_[s2]
+ << " k0($26) = " << std::setfill('0') <<
std::setw(8) << GPR_[k0] << std::endl
+ << " v1 ($3) = " << std::setfill('0') <<
std::setw(8) << GPR_[v1]
+ << " t3($11) = " << std::setfill('0') <<
std::setw(8) << GPR_[t3]
+ << " s3($19) = " << std::setfill('0') <<
std::setw(8) << GPR_[s3]
+ << " k1($27) = " << std::setfill('0') <<
std::setw(8) << GPR_[k1] << std::endl
+ << " a0 ($4) = " << std::setfill('0') <<
std::setw(8) << GPR_[a0]
+ << " t4($12) = " << std::setfill('0') <<
std::setw(8) << GPR_[t4]
+ << " s4($20) = " << std::setfill('0') <<
std::setw(8) << GPR_[s4]
+ << " gp($28) = " << std::setfill('0') <<
std::setw(8) << GPR_[gp] << std::endl
+ << " a1 ($5) = " << std::setfill('0') <<
std::setw(8) << GPR_[a1]
+ << " t5($13) = " << std::setfill('0') <<
std::setw(8) << GPR_[t5]
+ << " s5($21) = " << std::setfill('0') <<
std::setw(8) << GPR_[s5]
+ << " sp($29) = " << std::setfill('0') <<
std::setw(8) << GPR_[sp] << std::endl
+ << " a2 ($6) = " << std::setfill('0') <<
std::setw(8) << GPR_[a2]
+ << " t6($14) = " << std::setfill('0') <<
std::setw(8) << GPR_[t6]
+ << " s6($22) = " << std::setfill('0') <<
std::setw(8) << GPR_[s6]
+ << " fp($30) = " << std::setfill('0') <<
std::setw(8) << GPR_[fp] << std::endl
+ << " a3 ($7) = " << std::setfill('0') <<
std::setw(8) << GPR_[a3]
+ << " t7($15) = " << std::setfill('0') <<
std::setw(8) << GPR_[t7]
+ << " s7($23) = " << std::setfill('0') <<
std::setw(8) << GPR_[s7]
+ << " ra($31) = " << std::setfill('0') <<
std::setw(8) << GPR_[ra] << std::endl;
os.flags(flags);
}
@@ -122,52 +122,52 @@ namespace vm
void
Cpu::visit(const inst::Add& add)
{
- register_type a = get_register(add.get_src1 ());
- register_type b = get_register(add.get_src2 ());
+ register_type a = get_register(add.get_src1 ());
+ register_type b = get_register(add.get_src2 ());
- register_type c = a + b;
+ register_type c = a + b;
set_register(add.get_dest (), c);
-
+
// FIXME: might be accelerated by testing only the sign bit.
if ((a < 0 && b < 0 && c > 0) ||
- (a > 0 && b > 0 && c < 0))
+ (a > 0 && b > 0 && c < 0))
cp0_.raise_overflow();
}
void
Cpu::visit(const inst::Addi& addi)
{
- register_type a = get_register(addi.get_src ());
- int b = addi.get_imm ();
+ register_type a = get_register(addi.get_src ());
+ int b = addi.get_imm ();
- register_type c = a + b;
+ register_type c = a + b;
set_register(addi.get_dest (), c);
-
+
// FIXME: might be accelerated by testing only the sign bit.
if ((a < 0 && b < 0 && c > 0) ||
- (a > 0 && b > 0 && c < 0))
+ (a > 0 && b > 0 && c < 0))
cp0_.raise_overflow();
}
void
Cpu::visit(const inst::Addu& addu)
{
set_register(addu.get_dest (),
- get_register(addu.get_src1 ()) +
- get_register(addu.get_src2 ()));
+ get_register(addu.get_src1 ()) +
+ get_register(addu.get_src2 ()));
}
void
Cpu::visit(const inst::Addiu& addiu)
{
set_register(addiu.get_dest (),
- get_register(addiu.get_src ()) + addiu.get_imm ());
+ get_register(addiu.get_src ()) + addiu.get_imm ());
}
void
Cpu::visit(const inst::Sub& sub)
{
- register_type a = get_register(sub.get_src1 ());
- register_type b = get_register(sub.get_src2 ());
+ register_type a = get_register(sub.get_src1 ());
+ register_type b = get_register(sub.get_src2 ());
- register_type c = a - b;
+ register_type c = a - b;
set_register(sub.get_dest (), c);
if ((a < b && c > 0) || (a > b && c < 0))
@@ -177,16 +177,16 @@ namespace vm
Cpu::visit(const inst::Subu& subu)
{
set_register(subu.get_dest (),
- get_register(subu.get_src1 ()) -
- get_register(subu.get_src2 ()));
+ get_register(subu.get_src1 ()) -
+ get_register(subu.get_src2 ()));
}
void
Cpu::visit(const inst::Sll& sll)
{
- uregister_type a = get_register(sll.get_src ());
- unsigned i = sll.get_imm ();
- register_type c = a << i;
+ uregister_type a = get_register(sll.get_src ());
+ unsigned i = sll.get_imm ();
+ register_type c = a << i;
set_register(sll.get_dest (), c);
// FIXME: Check overflow !
@@ -194,10 +194,10 @@ namespace vm
void
Cpu::visit(const inst::Sllv& slv)
{
- uregister_type a = get_register(slv.get_src1 ());
- uregister_type b = get_register(slv.get_src2 ());
+ uregister_type a = get_register(slv.get_src1 ());
+ uregister_type b = get_register(slv.get_src2 ());
- register_type c = a << b;
+ register_type c = a << b;
set_register(slv.get_dest (), c);
// FIXME: Check overflow !
@@ -206,9 +206,9 @@ namespace vm
void
Cpu::visit(const inst::Sra& sra)
{
- register_type a = get_register(sra.get_src ());
- unsigned b = sra.get_imm ();
- register_type c = a >> b;
+ register_type a = get_register(sra.get_src ());
+ unsigned b = sra.get_imm ();
+ register_type c = a >> b;
set_register(sra.get_dest (), c);
// FIXME: Check overflow !
@@ -216,10 +216,10 @@ namespace vm
void
Cpu::visit(const inst::Srav& srav)
{
- register_type a = get_register(srav.get_src1 ());
- register_type b = get_register(srav.get_src2 ());
+ register_type a = get_register(srav.get_src1 ());
+ register_type b = get_register(srav.get_src2 ());
- register_type c = a >> b;
+ register_type c = a >> b;
set_register(srav.get_dest (), c);
// FIXME: Check overflow !
@@ -228,9 +228,9 @@ namespace vm
void
Cpu::visit(const inst::Srl& srl)
{
- uregister_type a = get_register(srl.get_src ());
- unsigned i = srl.get_imm ();
- uregister_type c = a >> i;
+ uregister_type a = get_register(srl.get_src ());
+ unsigned i = srl.get_imm ();
+ uregister_type c = a >> i;
set_register(srl.get_dest (), c);
// FIXME: Check overflow !
@@ -238,9 +238,9 @@ namespace vm
void
Cpu::visit(const inst::Srlv& srlv)
{
- uregister_type a = get_register(srlv.get_src1 ());
- uregister_type b = get_register(srlv.get_src2 ());
- uregister_type c = a >> b;
+ uregister_type a = get_register(srlv.get_src1 ());
+ uregister_type b = get_register(srlv.get_src2 ());
+ uregister_type c = a >> b;
set_register(srlv.get_dest (), c);
// FIXME: Check overflow !
@@ -250,10 +250,10 @@ namespace vm
void
Cpu::visit(const inst::Mul& mul)
{
- register_type a = get_register(mul.get_src1 ());
- register_type b = get_register(mul.get_src2 ());
+ register_type a = get_register(mul.get_src1 ());
+ register_type b = get_register(mul.get_src2 ());
- register_type c = a * b;
+ register_type c = a * b;
set_register(mul.get_dest (), c);
// FIXME: Check overflow !
@@ -262,10 +262,10 @@ namespace vm
void
Cpu::visit(const inst::Div& div)
{
- register_type a = get_register(div.get_src1 ());
- register_type b = get_register(div.get_src2 ());
+ register_type a = get_register(div.get_src1 ());
+ register_type b = get_register(div.get_src2 ());
- register_type c = a / b;
+ register_type c = a / b;
set_lo(c);
c = a % b;
@@ -276,8 +276,8 @@ namespace vm
void
Cpu::visit(const inst::Divu& divu)
{
- uregister_type a = get_register(divu.get_src1 ());
- uregister_type b = get_register(divu.get_src2 ());
+ uregister_type a = get_register(divu.get_src1 ());
+ uregister_type b = get_register(divu.get_src2 ());
set_lo(a / b);
set_hi(a % b);
@@ -291,67 +291,67 @@ namespace vm
void
Cpu::visit(const inst::And& _and)
{
- register_type a = get_register(_and.get_src1 ());
- register_type b = get_register(_and.get_src2 ());
+ register_type a = get_register(_and.get_src1 ());
+ register_type b = get_register(_and.get_src2 ());
- register_type c = a & b;
+ register_type c = a & b;
set_register(_and.get_dest (), c);
}
void
Cpu::visit(const inst::Andi& andi)
{
- register_type a = get_register(andi.get_src ());
- int b = andi.get_imm ();
+ register_type a = get_register(andi.get_src ());
+ int b = andi.get_imm ();
- register_type c = a & b;
+ register_type c = a & b;
set_register(andi.get_dest (), c);
}
void
Cpu::visit(const inst::Or& _or)
{
- register_type a = get_register(_or.get_src1 ());
- register_type b = get_register(_or.get_src2 ());
+ register_type a = get_register(_or.get_src1 ());
+ register_type b = get_register(_or.get_src2 ());
- register_type c = a | b;
+ register_type c = a | b;
set_register(_or.get_dest (), c);
}
void
Cpu::visit(const inst::Ori& ori)
{
- register_type a = get_register(ori.get_src ());
- int b = ori.get_imm ();
+ register_type a = get_register(ori.get_src ());
+ int b = ori.get_imm ();
- register_type c = a | b;
+ register_type c = a | b;
set_register(ori.get_dest (), c);
}
void
Cpu::visit(const inst::Nor& nor)
{
- register_type a = get_register(nor.get_src1 ());
- register_type b = get_register(nor.get_src2 ());
+ register_type a = get_register(nor.get_src1 ());
+ register_type b = get_register(nor.get_src2 ());
- register_type c = a | b;
+ register_type c = a | b;
set_register(nor.get_dest (), ~c);
}
void
Cpu::visit(const inst::Xor& _xor)
{
- register_type a = get_register(_xor.get_src1 ());
- register_type b = get_register(_xor.get_src2 ());
+ register_type a = get_register(_xor.get_src1 ());
+ register_type b = get_register(_xor.get_src2 ());
- register_type c = a ^ b;
+ register_type c = a ^ b;
set_register(_xor.get_dest (), c);
}
void
Cpu::visit(const inst::Xori& xori)
{
- register_type a = get_register(xori.get_src ());
- int b = xori.get_imm ();
+ register_type a = get_register(xori.get_src ());
+ int b = xori.get_imm ();
- register_type c = a ^ b;
+ register_type c = a ^ b;
set_register(xori.get_dest (), c);
}
@@ -359,7 +359,7 @@ namespace vm
// --------------------------------------------------------------------------
// Move instructions
// --------------------------------------------------------------------------
-
+
void
Cpu::visit(const inst::Lui& lui)
{
@@ -370,14 +370,14 @@ namespace vm
void
Cpu::visit(const inst::Sb& sb)
{
- register_type addr = get_register(sb.get_base ()) + sb.get_offset ();
+ register_type addr = get_register(sb.get_base ()) + sb.get_offset ();
mmu_.data_store_byte(addr, get_register(sb.get_src ()));
}
void
Cpu::visit(const inst::Sw& sw)
{
- register_type addr = get_register(sw.get_base ()) + sw.get_offset ();
+ register_type addr = get_register(sw.get_base ()) + sw.get_offset ();
mmu_.data_store_word(addr, get_register(sw.get_src ()));
}
@@ -385,22 +385,22 @@ namespace vm
void
Cpu::visit(const inst::Lb& lb)
{
- register_type addr = get_register(lb.get_base ()) + lb.get_offset ();
+ register_type addr = get_register(lb.get_base ()) + lb.get_offset ();
set_register(lb.get_dest (), mmu_.data_load_byte(addr));
}
void
Cpu::visit(const inst::Lbu& lbu)
{
- register_type addr = get_register(lbu.get_base ()) + lbu.get_offset ();
- unsigned b = mmu_.data_load_byte(addr);
+ register_type addr = get_register(lbu.get_base ()) + lbu.get_offset ();
+ unsigned b = mmu_.data_load_byte(addr);
set_register(lbu.get_dest (), b % 256);
}
void
Cpu::visit(const inst::Lw& lw)
{
- register_type addr = get_register(lw.get_base ()) + lw.get_offset ();
+ register_type addr = get_register(lw.get_base ()) + lw.get_offset ();
set_register(lw.get_dest (), mmu_.data_load_word(addr));
}
@@ -427,8 +427,8 @@ namespace vm
void
Cpu::visit(const inst::Sltu& sltu)
{
- if ((uregister_type) get_register(sltu.get_src1 ()) <
- (uregister_type) get_register(sltu.get_src2 ()))
+ if ((uregister_type) get_register(sltu.get_src1 ()) <
+ (uregister_type) get_register(sltu.get_src2 ()))
set_register(sltu.get_dest(), 1);
else
set_register(sltu.get_dest(), 0);
@@ -436,13 +436,13 @@ namespace vm
void
Cpu::visit(const inst::Sltiu& sltiu)
{
- if ((uregister_type) get_register(sltiu.get_src ()) <
- (uregister_type) sltiu.get_imm ())
+ if ((uregister_type) get_register(sltiu.get_src ()) <
+ (uregister_type) sltiu.get_imm ())
set_register(sltiu.get_dest(), 1);
else
set_register(sltiu.get_dest(), 0);
}
-
+
// --------------------------------------------------------------------------
// Branch and jump instructions
@@ -487,7 +487,7 @@ namespace vm
pipeline_[d_stage] = bubble_;
// Speculatively fetched instruction
pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
-
+
// Assume it is a call
call();
}
@@ -515,13 +515,13 @@ namespace vm
{
if (get_register(beq.get_src1 ()) == get_register(beq.get_src2 ()))
{
- // Jump
- set_pc(get_pc() + beq.get_label() - 8);
-
- // Bubble in decode stage
- pipeline_[d_stage] = bubble_;
- // Speculatively fetched instruction
- pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
+ // Jump
+ set_pc(get_pc() + beq.get_label() - 8);
+
+ // Bubble in decode stage
+ pipeline_[d_stage] = bubble_;
+ // Speculatively fetched instruction
+ pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
}
}
void
@@ -529,13 +529,13 @@ namespace vm
{
if (get_register(bne.get_src1 ()) != get_register(bne.get_src2 ()))
{
- // Jump
- set_pc(get_pc() + bne.get_label() - 8);
+ // Jump
+ set_pc(get_pc() + bne.get_label() - 8);
- // Bubble in decode stage
- pipeline_[d_stage] = bubble_;
- // Speculatively fetched instruction
- pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
+ // Bubble in decode stage
+ pipeline_[d_stage] = bubble_;
+ // Speculatively fetched instruction
+ pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
}
}
@@ -545,13 +545,13 @@ namespace vm
{
if (get_register(bgez.get_src ()) >= 0)
{
- // Jump
- set_pc(get_pc() + bgez.get_label() - 8);
+ // Jump
+ set_pc(get_pc() + bgez.get_label() - 8);
- // Bubble in decode stage
- pipeline_[d_stage] = bubble_;
- // Speculatively fetched instruction
- pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
+ // Bubble in decode stage
+ pipeline_[d_stage] = bubble_;
+ // Speculatively fetched instruction
+ pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
}
}
void
@@ -559,18 +559,18 @@ namespace vm
{
if (get_register(bgezal.get_src ()) >= 0)
{
- // Assume it is a call
- call();
-
- // Save return address
- set_register(Cpu::ra, get_pc());
- // Jump
- set_pc(get_pc() + bgezal.get_label() - 8);
-
- // Bubble in decode stage
- pipeline_[d_stage] = bubble_;
- // Speculatively fetched instruction
- pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
+ // Assume it is a call
+ call();
+
+ // Save return address
+ set_register(Cpu::ra, get_pc());
+ // Jump
+ set_pc(get_pc() + bgezal.get_label() - 8);
+
+ // Bubble in decode stage
+ pipeline_[d_stage] = bubble_;
+ // Speculatively fetched instruction
+ pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
}
}
void
@@ -578,13 +578,13 @@ namespace vm
{
if (get_register(bgtz.get_src ()) > 0)
{
- // Jump
- set_pc(get_pc() + bgtz.get_label() - 8);
+ // Jump
+ set_pc(get_pc() + bgtz.get_label() - 8);
- // Bubble in decode stage
- pipeline_[d_stage] = bubble_;
- // Speculatively fetched instruction
- pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
+ // Bubble in decode stage
+ pipeline_[d_stage] = bubble_;
+ // Speculatively fetched instruction
+ pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
}
}
@@ -594,13 +594,13 @@ namespace vm
{
if (get_register(blez.get_src ()) <= 0)
{
- // Jump
- set_pc(get_pc() + blez.get_label() - 8);
+ // Jump
+ set_pc(get_pc() + blez.get_label() - 8);
- // Bubble in decode stage
- pipeline_[d_stage] = bubble_;
- // Speculatively fetched instruction
- pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
+ // Bubble in decode stage
+ pipeline_[d_stage] = bubble_;
+ // Speculatively fetched instruction
+ pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
}
}
void
@@ -608,13 +608,13 @@ namespace vm
{
if (get_register(bltz.get_src ()) < 0)
{
- // Jump
- set_pc(get_pc() + bltz.get_label() - 8);
+ // Jump
+ set_pc(get_pc() + bltz.get_label() - 8);
- // Bubble in decode stage
- pipeline_[d_stage] = bubble_;
- // Speculatively fetched instruction
- pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
+ // Bubble in decode stage
+ pipeline_[d_stage] = bubble_;
+ // Speculatively fetched instruction
+ pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
}
}
void
@@ -622,18 +622,18 @@ namespace vm
{
if (get_register(bltzal.get_src ()) < 0)
{
- // Assume it is a call
- call();
-
- // Save return address
- set_register(Cpu::ra, get_pc());
- // Jump
- set_pc(get_pc() + bltzal.get_label() - 8);
-
- // Bubble in decode stage
- pipeline_[d_stage] = bubble_;
- // Speculatively fetched instruction
- pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
+ // Assume it is a call
+ call();
+
+ // Save return address
+ set_register(Cpu::ra, get_pc());
+ // Jump
+ set_pc(get_pc() + bltzal.get_label() - 8);
+
+ // Bubble in decode stage
+ pipeline_[d_stage] = bubble_;
+ // Speculatively fetched instruction
+ pipeline_[i_stage] = & mmu_.inst_load(pc_ / 4);
}
}
diff --git a/src/vm/cpu.hh b/src/vm/cpu.hh
index c51bcdb..78d11d7 100644
--- a/src/vm/cpu.hh
+++ b/src/vm/cpu.hh
@@ -33,8 +33,8 @@
namespace vm
{
- typedef int32_t register_type;
- typedef uint32_t uregister_type;
+ typedef int32_t register_type;
+ typedef uint32_t uregister_type;
/// Central Processor Unit abstraction
class Cpu:
@@ -44,22 +44,22 @@ namespace vm
/// General purpose registers indices
enum kind_type
{
- zero = 0,
- at,
- v0, v1,
- a0, a1, a2, a3,
- t0, t1, t2, t3, t4, t5, t6, t7,
- s0, s1, s2, s3, s4, s5, s6, s7,
- t8, t9,
- k0, k1,
- gp,
- sp,
- fp,
- ra = 31
+ zero = 0,
+ at,
+ v0, v1,
+ a0, a1, a2, a3,
+ t0, t1, t2, t3, t4, t5, t6, t7,
+ s0, s1, s2, s3, s4, s5, s6, s7,
+ t8, t9,
+ k0, k1,
+ gp,
+ sp,
+ fp,
+ ra = 31
};
/** \name Constructor and destructor
- \{ */
+ \{ */
public:
/// Construct a CPU.
Cpu(Mmu &mmu, Cp0 &cp0);
@@ -75,7 +75,7 @@ namespace vm
void write(std::ostream &os) const;
/** \name General purpose registers accessors.
- \{ */
+ \{ */
public:
/// Set the general purpose register \a k to \a r.
void set_register(kind_type k, register_type r);
@@ -84,7 +84,7 @@ namespace vm
/** \} */
/** \name Unlimited registers accessors.
- \{ */
+ \{ */
public:
/// Set the unlimited register indexed by \a i to \a r.
void set_unlimited(int i, register_type r);
@@ -95,7 +95,7 @@ namespace vm
/** \} */
/** \name Registers unified accessors.
- \{ */
+ \{ */
public:
/// Set the register identified by \a reg to \a r.
void set_register(const inst::Register ®, register_type r);
@@ -104,7 +104,7 @@ namespace vm
/** \} */
/** \name Special registers accessors.
- \{ */
+ \{ */
public:
/// Set the HI register to \a r.
void set_hi(register_type r);
@@ -140,68 +140,68 @@ namespace vm
void step();
protected:
- virtual void visit(const inst::Add& add);
- virtual void visit(const inst::Addi& addi);
- virtual void visit(const inst::Addu& addu);
- virtual void visit(const inst::Addiu& addiu);
- virtual void visit(const inst::Sub& sub);
- virtual void visit(const inst::Subu& subu);
-
- virtual void visit(const inst::Sll& sll);
- virtual void visit(const inst::Sllv& slv);
- virtual void visit(const inst::Sra& sra);
- virtual void visit(const inst::Srav& srav);
- virtual void visit(const inst::Srl& srl);
- virtual void visit(const inst::Srlv& srlv);
-
- virtual void visit(const inst::Mul& mul);
- virtual void visit(const inst::Div& div);
- virtual void visit(const inst::Divu& divu);
-
- virtual void visit(const inst::Lb& lb);
- virtual void visit(const inst::Lbu& Lbu);
- virtual void visit(const inst::Lw& lw);
- virtual void visit(const inst::Lui& lui);
- virtual void visit(const inst::Sb& sb);
- virtual void visit(const inst::Sw& sw);
-
- virtual void visit(const inst::And& _and);
- virtual void visit(const inst::Andi& andi);
- virtual void visit(const inst::Or& _or);
- virtual void visit(const inst::Ori& ori);
- virtual void visit(const inst::Nor& nor);
- virtual void visit(const inst::Xor& _xor);
- virtual void visit(const inst::Xori& xori);
-
- virtual void visit(const inst::Slt& slt);
- virtual void visit(const inst::Slti& slti);
- virtual void visit(const inst::Sltu&);
- virtual void visit(const inst::Sltiu& sltiu);
-
- virtual void visit(const inst::Jmp& jmp);
- virtual void visit(const inst::Jr& jr);
- virtual void visit(const inst::Jal& jal);
- virtual void visit(const inst::Jalr& jalr);
-
- virtual void visit(const inst::Beq& beq);
- virtual void visit(const inst::Bne& bne);
-
- virtual void visit(const inst::Bgez& bgez);
- virtual void visit(const inst::Bgezal& bgezal);
- virtual void visit(const inst::Bgtz& bgtz);
-
- virtual void visit(const inst::Blez& blez);
- virtual void visit(const inst::Bltz& bltz);
- virtual void visit(const inst::Bltzal& bltzal);
-
- virtual void visit(const inst::Mfhi& mfhi);
- virtual void visit(const inst::Mflo& mflo);
- virtual void visit(const inst::Mthi& mthi);
- virtual void visit(const inst::Mtlo& mtlo);
- virtual void visit(const inst::Mfc0& mfc0);
- virtual void visit(const inst::Mtc0& mtc0);
-
- virtual void visit(const inst::Syscall& sycall);
+ virtual void visit(const inst::Add& add);
+ virtual void visit(const inst::Addi& addi);
+ virtual void visit(const inst::Addu& addu);
+ virtual void visit(const inst::Addiu& addiu);
+ virtual void visit(const inst::Sub& sub);
+ virtual void visit(const inst::Subu& subu);
+
+ virtual void visit(const inst::Sll& sll);
+ virtual void visit(const inst::Sllv& slv);
+ virtual void visit(const inst::Sra& sra);
+ virtual void visit(const inst::Srav& srav);
+ virtual void visit(const inst::Srl& srl);
+ virtual void visit(const inst::Srlv& srlv);
+
+ virtual void visit(const inst::Mul& mul);
+ virtual void visit(const inst::Div& div);
+ virtual void visit(const inst::Divu& divu);
+
+ virtual void visit(const inst::Lb& lb);
+ virtual void visit(const inst::Lbu& Lbu);
+ virtual void visit(const inst::Lw& lw);
+ virtual void visit(const inst::Lui& lui);
+ virtual void visit(const inst::Sb& sb);
+ virtual void visit(const inst::Sw& sw);
+
+ virtual void visit(const inst::And& _and);
+ virtual void visit(const inst::Andi& andi);
+ virtual void visit(const inst::Or& _or);
+ virtual void visit(const inst::Ori& ori);
+ virtual void visit(const inst::Nor& nor);
+ virtual void visit(const inst::Xor& _xor);
+ virtual void visit(const inst::Xori& xori);
+
+ virtual void visit(const inst::Slt& slt);
+ virtual void visit(const inst::Slti& slti);
+ virtual void visit(const inst::Sltu&);
+ virtual void visit(const inst::Sltiu& sltiu);
+
+ virtual void visit(const inst::Jmp& jmp);
+ virtual void visit(const inst::Jr& jr);
+ virtual void visit(const inst::Jal& jal);
+ virtual void visit(const inst::Jalr& jalr);
+
+ virtual void visit(const inst::Beq& beq);
+ virtual void visit(const inst::Bne& bne);
+
+ virtual void visit(const inst::Bgez& bgez);
+ virtual void visit(const inst::Bgezal& bgezal);
+ virtual void visit(const inst::Bgtz& bgtz);
+
+ virtual void visit(const inst::Blez& blez);
+ virtual void visit(const inst::Bltz& bltz);
+ virtual void visit(const inst::Bltzal& bltzal);
+
+ virtual void visit(const inst::Mfhi& mfhi);
+ virtual void visit(const inst::Mflo& mflo);
+ virtual void visit(const inst::Mthi& mthi);
+ virtual void visit(const inst::Mtlo& mtlo);
+ virtual void visit(const inst::Mfc0& mfc0);
+ virtual void visit(const inst::Mtc0& mtc0);
+
+ virtual void visit(const inst::Syscall& sycall);
void call();
void ret();
@@ -233,12 +233,12 @@ namespace vm
enum pipeline_stage_type
{
- i_stage = 0, ///< Instruction fetch stage
- d_stage, ///< Instruction dispatch stage
- r_stage, ///< Regoster file read stage
- e_stage, ///< Execution stage
- m_stage, ///< Memory access stage
- w_stage ///< Writeback stage
+ i_stage = 0, ///< Instruction fetch stage
+ d_stage, ///< Instruction dispatch stage
+ r_stage, ///< Regoster file read stage
+ e_stage, ///< Execution stage
+ m_stage, ///< Memory access stage
+ w_stage ///< Writeback stage
};
inst::Inst *bubble_;
diff --git a/src/vm/cpu.hxx b/src/vm/cpu.hxx
index 919741e..91ba7d8 100644
--- a/src/vm/cpu.hxx
+++ b/src/vm/cpu.hxx
@@ -57,10 +57,10 @@ namespace vm
{
if (!has_unlimited(i))
{
- std::cerr
- << "Warning: unlimited register `$x" << i
- << "' used before initialized" << std::endl;
- exit(exit_runtime);
+ std::cerr
+ << "Warning: unlimited register `$x" << i
+ << "' used before initialized" << std::endl;
+ exit(exit_runtime);
}
return unlimited_.get(i);
}
@@ -72,10 +72,10 @@ namespace vm
unlimited_.put(reg.get_index(), r);
else
{
- precondition(reg.get_kind() == inst::Register::general &&
- Cpu::zero <= reg.get_index() &&
- reg.get_index() <= Cpu::ra);
- set_register((kind_type) reg.get_index(), r);
+ precondition(reg.get_kind() == inst::Register::general &&
+ Cpu::zero <= reg.get_index() &&
+ reg.get_index() <= Cpu::ra);
+ set_register((kind_type) reg.get_index(), r);
}
}
inline register_type
@@ -85,7 +85,7 @@ namespace vm
return get_unlimited(reg.get_index());
precondition(reg.get_kind() == inst::Register::general &&
- Cpu::zero <= reg.get_index() && reg.get_index() <= Cpu::ra);
+ Cpu::zero <= reg.get_index() && reg.get_index() <=
Cpu::ra);
return get_register((kind_type) reg.get_index());
}
@@ -146,7 +146,7 @@ namespace vm
{
if (check_callee_save_p_)
for (int i = Cpu::s0; i <= Cpu::s7; ++i)
- set_unlimited(-i, get_register((Cpu::kind_type) i));
+ set_unlimited(-i, get_register((Cpu::kind_type) i));
call_stack_.push_back(get_pc ());
unlimited_.begin_scope();
@@ -158,15 +158,15 @@ namespace vm
if (check_callee_save_p_)
for (int i = Cpu::s0; i <= Cpu::s7; ++i)
- if (get_unlimited(-i) != get_register((Cpu::kind_type) i))
- {
- std::cerr
- << "Warning: callee save register `$s" << i - Cpu::s0
- << "' was not preserved across last call to 0x"
- << std::hex << *call_stack_.rbegin() << std::dec <<
std::endl;
- set_register((Cpu::kind_type) i, get_unlimited(-i));
- exit_set(exit_runtime);
- }
+ if (get_unlimited(-i) != get_register((Cpu::kind_type) i))
+ {
+ std::cerr
+ << "Warning: callee save register `$s" << i -
Cpu::s0
+ << "' was not preserved across last call to 0x"
+ << std::hex << *call_stack_.rbegin() << std::dec <<
std::endl;
+ set_register((Cpu::kind_type) i, get_unlimited(-i));
+ exit_set(exit_runtime);
+ }
call_stack_.pop_back();
}
@@ -191,12 +191,12 @@ namespace vm
{
if (trace_p_)
std::cout << "[I :: " << *pipeline_[i_stage] << "]
" << std::endl
- << "[D :: " << *pipeline_[d_stage] << "] "
<< std::endl
- << "[R :: " << *pipeline_[r_stage] << "] "
<< std::endl
- << "[E :: " << *pipeline_[e_stage] << "] "
<< std::endl
- << "[M :: " << *pipeline_[m_stage] << "] "
<< std::endl
- << "[W :: " << *pipeline_[w_stage] << "] "
<< std::endl
- << std::endl;
+ << "[D :: " << *pipeline_[d_stage] << "]
" << std::endl
+ << "[R :: " << *pipeline_[r_stage] << "]
" << std::endl
+ << "[E :: " << *pipeline_[e_stage] << "]
" << std::endl
+ << "[M :: " << *pipeline_[m_stage] << "]
" << std::endl
+ << "[W :: " << *pipeline_[w_stage] << "]
" << std::endl
+ << std::endl;
pipeline_[w_stage] = pipeline_[m_stage];
pipeline_[m_stage] = pipeline_[e_stage];
diff --git a/src/vm/fwd.hh b/src/vm/fwd.hh
index ee2a146..843583f 100644
--- a/src/vm/fwd.hh
+++ b/src/vm/fwd.hh
@@ -6,12 +6,12 @@
// 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 Nolimips. If not, see <http://www.gnu.org/licenses/>.
//
diff --git a/src/vm/memory.hh b/src/vm/memory.hh
index fcbe02a..44dd496 100644
--- a/src/vm/memory.hh
+++ b/src/vm/memory.hh
@@ -38,12 +38,12 @@ namespace vm
enum segment_kind
{
- heap = 0,
- stack = 1
+ heap = 0,
+ stack = 1
};
/** \name Constructor and destructor
- \{ */
+ \{ */
public:
/// Construct a Memory
Memory(int stack_size = default_stack_size);
@@ -61,7 +61,7 @@ namespace vm
int get_stack_top() const;
/** \name Store instructions
- \{ */
+ \{ */
public:
void store(const inst::DataSection& data_section);
@@ -72,7 +72,7 @@ namespace vm
/** \} */
/** \name Load instructions
- \{ */
+ \{ */
public:
/// Load a byte from memory
int load_byte(segment_kind k, int offset) const;
diff --git a/src/vm/memory.hxx b/src/vm/memory.hxx
index de9269f..d329f06 100644
--- a/src/vm/memory.hxx
+++ b/src/vm/memory.hxx
@@ -47,7 +47,7 @@ namespace vm
Memory::sbrk(int size)
{
precondition(size >= 0);
- int ptr = segments_[heap].size();
+ int ptr = segments_[heap].size();
if (size)
// FIXME: check collision with stack
segments_[heap].resize(size + segments_[heap].size());
diff --git a/src/vm/mmu.hh b/src/vm/mmu.hh
index cd9ec7d..4f6e8ec 100644
--- a/src/vm/mmu.hh
+++ b/src/vm/mmu.hh
@@ -34,7 +34,7 @@ namespace vm
class Mmu
{
/** \name Constructor and destructor
- \{ */
+ \{ */
public:
Mmu(Cp0 &cp0, Memory &memory);
/** \} */
@@ -43,7 +43,7 @@ namespace vm
void reset();
/** \name Proxy for memory data access.
- \{ */
+ \{ */
protected:
bool translate(int &offset, Memory::segment_kind &k) const;
@@ -65,7 +65,7 @@ namespace vm
/** \} */
/** \name Proxy for memory instruction access.
- \{ */
+ \{ */
public:
void inst_store(const inst::TextSection& text_section);
diff --git a/src/vm/mmu.hxx b/src/vm/mmu.hxx
index b686bf8..948da20 100644
--- a/src/vm/mmu.hxx
+++ b/src/vm/mmu.hxx
@@ -47,18 +47,18 @@ namespace vm
{
if (0 <= offset)
{
- if (offset < memory_.heap_size())
- {
- k = Memory::heap;
- return true;
- }
- if (memory_.get_stack_top() <= offset)
- {
- k = Memory::stack;
- // Stack grows down
- offset = offset - memory_.get_stack_top();
- return true;
- }
+ if (offset < memory_.heap_size())
+ {
+ k = Memory::heap;
+ return true;
+ }
+ if (memory_.get_stack_top() <= offset)
+ {
+ k = Memory::stack;
+ // Stack grows down
+ offset = offset - memory_.get_stack_top();
+ return true;
+ }
}
return false;
}
@@ -123,7 +123,7 @@ namespace vm
Mmu::inst_store(const inst::TextSection& text_section)
{
for (inst::TextSection::instruction_list_type::const_iterator
- it = text_section.begin(); it != text_section.end(); ++it)
+ it = text_section.begin(); it != text_section.end(); ++it)
text_section_.push_back(*it);
}
@@ -132,11 +132,11 @@ namespace vm
{
// Precondition
if (offset < 0 ||
- text_section_.size() <= static_cast<unsigned>(offset))
+ text_section_.size() <= static_cast<unsigned>(offset))
{
- std::cerr << "inst_load" << std::endl;
- cp0_.raise_addr_load();
- return *text_section_[0]; // FIXME: NO!
+ std::cerr << "inst_load" << std::endl;
+ cp0_.raise_addr_load();
+ return *text_section_[0]; // FIXME: NO!
}
return *text_section_[offset];
diff --git a/src/vm/nolimips_system_library.cc b/src/vm/nolimips_system_library.cc
index 7b22a81..167f8d9 100644
--- a/src/vm/nolimips_system_library.cc
+++ b/src/vm/nolimips_system_library.cc
@@ -40,17 +40,17 @@ namespace vm
int i = -1;
if (istr)
{
- istr->peek();
+ istr->peek();
- if (!istr->eof())
- for (i = 0; i < count; ++i, ++offset)
- {
- int c = istr->get();
- if (istr->eof())
- break;
+ if (!istr->eof())
+ for (i = 0; i < count; ++i, ++offset)
+ {
+ int c = istr->get();
+ if (istr->eof())
+ break;
- mmu.data_store_byte(offset, c);
- }
+ mmu.data_store_byte(offset, c);
+ }
}
return i;
@@ -69,8 +69,8 @@ namespace vm
int i = -1;
if (ostr)
{
- for (i = 0; i < count; ++i, ++offset)
- ostr->put(static_cast<char>(mmu.data_load_byte(offset)));
+ for (i = 0; i < count; ++i, ++offset)
+ ostr->put(static_cast<char>(mmu.data_load_byte(offset)));
}
return i;
@@ -82,40 +82,40 @@ namespace vm
switch (cpu.get_register(Cpu::v0))
{
case 0x02: // read(fd: $a0, buf: $a1, count: $a2): $v0
- {
- cpu.set_register(Cpu::v0,
- read(cpu.get_register(Cpu::a0),
- cpu.get_mmu(), cpu.get_register(Cpu::a1),
- cpu.get_register(Cpu::a2)));
- }
+ {
+ cpu.set_register(Cpu::v0,
+ read(cpu.get_register(Cpu::a0),
+ cpu.get_mmu(), cpu.get_register(Cpu::a1),
+ cpu.get_register(Cpu::a2)));
+ }
break;
case 0x03: // write(fd: $a0, buf: $a1, count: $a2): $v0
- {
- cpu.set_register(Cpu::v0,
- write(cpu.get_register(Cpu::a0),
- cpu.get_mmu(), cpu.get_register(Cpu::a1),
- cpu.get_register(Cpu::a2)));
- }
+ {
+ cpu.set_register(Cpu::v0,
+ write(cpu.get_register(Cpu::a0),
+ cpu.get_mmu(), cpu.get_register(Cpu::a1),
+ cpu.get_register(Cpu::a2)));
+ }
break;
case 0x06: // exit(status: $a0)
- cpu.get_cp0().set_fatal_exception();
- if (!exit_status)
- exit_status = (exit_type) cpu.get_register(Cpu::a0);
- break;
+ cpu.get_cp0().set_fatal_exception();
+ if (!exit_status)
+ exit_status = (exit_type) cpu.get_register(Cpu::a0);
+ break;
case 0x33: // malloc(size: $a0)
- cpu.set_register(Cpu::v0,
- cpu.get_mmu().data_sbrk(cpu.get_register(Cpu::a0)));
- break;
+ cpu.set_register(Cpu::v0,
+ cpu.get_mmu().data_sbrk(cpu.get_register(Cpu::a0)));
+ break;
case 0x34: // free(buf: $a0)
- // FIXME
- break;
+ // FIXME
+ break;
default:
- assertion(!"syscall: Not implemented yet");
- break;
+ assertion(!"syscall: Not implemented yet");
+ break;
}
}
diff --git a/src/vm/nolimips_system_library.hh b/src/vm/nolimips_system_library.hh
index 7f0e855..256678c 100644
--- a/src/vm/nolimips_system_library.hh
+++ b/src/vm/nolimips_system_library.hh
@@ -31,8 +31,8 @@ namespace vm
{
public:
NolimipsSystemLibrary(std::istream &istr,
- std::ostream &ostr,
- std::ostream &estr);
+ std::ostream &ostr,
+ std::ostream &estr);
virtual ~NolimipsSystemLibrary();
public:
diff --git a/src/vm/nolimips_system_library.hxx b/src/vm/nolimips_system_library.hxx
index c6c6349..362eacd 100644
--- a/src/vm/nolimips_system_library.hxx
+++ b/src/vm/nolimips_system_library.hxx
@@ -25,8 +25,8 @@ namespace vm
inline
NolimipsSystemLibrary::NolimipsSystemLibrary(std::istream &istr,
- std::ostream &ostr,
- std::ostream &estr):
+ std::ostream &ostr,
+ std::ostream &estr):
istr_(istr), ostr_(ostr), estr_(estr)
{
}
diff --git a/src/vm/segment.hxx b/src/vm/segment.hxx
index 5c67b16..35e79e9 100644
--- a/src/vm/segment.hxx
+++ b/src/vm/segment.hxx
@@ -43,14 +43,14 @@ namespace vm
inline void
Segment::resize(int new_size)
{
- uint8_t* new_bytes = new uint8_t[new_size];
+ uint8_t* new_bytes = new uint8_t[new_size];
if (bytes_)
{
- int min = new_size < size_ ? new_size : size_;
- // FIXME: may be accelerated with memcpy
- for (int i = 0; i < min; ++i)
- new_bytes[i] = bytes_[i];
- delete [] bytes_;
+ int min = new_size < size_ ? new_size : size_;
+ // FIXME: may be accelerated with memcpy
+ for (int i = 0; i < min; ++i)
+ new_bytes[i] = bytes_[i];
+ delete [] bytes_;
}
bytes_ = new_bytes;
size_ = new_size;
@@ -74,11 +74,11 @@ namespace vm
inline void
Segment::store_word(int offset, int w)
{
- unsigned pow = 256 * 256 * 256;
+ unsigned pow = 256 * 256 * 256;
for (unsigned i = 0; i < 4; ++i, ++offset, pow /= 256)
{
- assertion(offset < size_);
- bytes_[offset] = w / pow;
+ assertion(offset < size_);
+ bytes_[offset] = w / pow;
}
}
@@ -93,11 +93,11 @@ namespace vm
inline int
Segment::load_word(int offset) const
{
- int w = 0;
+ int w = 0;
for (unsigned i = 0; i < 4; ++i, ++offset)
{
- assertion(offset < size_);
- w = (w * 256) + bytes_[offset];
+ assertion(offset < size_);
+ w = (w * 256) + bytes_[offset];
}
return w;
}
diff --git a/src/vm/spim_system_library.cc b/src/vm/spim_system_library.cc
index d9f72fd..dfa1d76 100644
--- a/src/vm/spim_system_library.cc
+++ b/src/vm/spim_system_library.cc
@@ -36,67 +36,67 @@ namespace vm
switch (cpu.get_register(Cpu::v0))
{
- // print_int (integer: $a0)
+ // print_int (integer: $a0)
case 1:
- ostr_ << cpu.get_register(Cpu::a0);
- break;
+ ostr_ << cpu.get_register(Cpu::a0);
+ break;
- // print_string (buffer: $a0)
+ // print_string (buffer: $a0)
case 4:
- for (int i = cpu.get_register(Cpu::a0); true; ++i)
- {
- char b = mmu.data_load_byte(i);
- if (b == 0)
- break;
- ostr_ << b;
- }
- break;
+ for (int i = cpu.get_register(Cpu::a0); true; ++i)
+ {
+ char b = mmu.data_load_byte(i);
+ if (b == 0)
+ break;
+ ostr_ << b;
+ }
+ break;
- // read_string (buffer: $a0, length: $a1)
+ // read_string (buffer: $a0, length: $a1)
case 8:
- {
- int i = 0;
- int c = 0;
- for (; (i < cpu.get_register(Cpu::a1) - 1)
- && (c != '\n') && (c != '\r');
- ++i)
- {
- c = istr_.get();
- if (istr_.eof())
- break;
- mmu.data_store_byte(cpu.get_register(Cpu::a0) + i, c);
- }
- mmu.data_store_byte(cpu.get_register(Cpu::a0) + i, 0);
- }
- break;
+ {
+ int i = 0;
+ int c = 0;
+ for (; (i < cpu.get_register(Cpu::a1) - 1)
+ && (c != '\n') && (c != '\r');
+ ++i)
+ {
+ c = istr_.get();
+ if (istr_.eof())
+ break;
+ mmu.data_store_byte(cpu.get_register(Cpu::a0) + i, c);
+ }
+ mmu.data_store_byte(cpu.get_register(Cpu::a0) + i, 0);
+ }
+ break;
- // sbrk (size: $a0)
+ // sbrk (size: $a0)
case 9:
- cpu.set_register(Cpu::v0, mmu.data_sbrk(cpu.get_register(Cpu::a0)));
- break;
+ cpu.set_register(Cpu::v0, mmu.data_sbrk(cpu.get_register(Cpu::a0)));
+ break;
- // exit (status : $a0)
+ // exit (status : $a0)
case 10:
- {
- cpu.get_cp0().set_fatal_exception();
- if (!exit_status)
- exit_status = (exit_type) cpu.get_register(Cpu::a0);
- }
- break;
+ {
+ cpu.get_cp0().set_fatal_exception();
+ if (!exit_status)
+ exit_status = (exit_type) cpu.get_register(Cpu::a0);
+ }
+ break;
- // print_err (buffer: $a0)
+ // print_err (buffer: $a0)
case 15:
- for (int i = cpu.get_register(Cpu::a0); true; ++i)
- {
- char b = mmu.data_load_byte(i);
- if (b == 0)
- break;
- std::cerr << b;
- }
- break;
+ for (int i = cpu.get_register(Cpu::a0); true; ++i)
+ {
+ char b = mmu.data_load_byte(i);
+ if (b == 0)
+ break;
+ std::cerr << b;
+ }
+ break;
default:
- assertion(!"syscall: Not implemented yet");
+ assertion(!"syscall: Not implemented yet");
};
ostr_.flush();
}
diff --git a/src/vm/spim_system_library.hxx b/src/vm/spim_system_library.hxx
index b60dab0..306773b 100644
--- a/src/vm/spim_system_library.hxx
+++ b/src/vm/spim_system_library.hxx
@@ -25,7 +25,7 @@ namespace vm
inline
SpimSystemLibrary::SpimSystemLibrary(std::istream &istr,
- std::ostream &ostr):
+ std::ostream &ostr):
istr_(istr), ostr_(ostr)
{
}
diff --git a/src/vm/virtual_machine.cc b/src/vm/virtual_machine.cc
index 0d68d19..13a3848 100644
--- a/src/vm/virtual_machine.cc
+++ b/src/vm/virtual_machine.cc
@@ -42,9 +42,9 @@ namespace vm
misc::unique_string main("main");
if (! program.text_section ().has_label(main))
{
- std::cerr << "No `main' label in assembly file." <<
std::endl;
- exit_set(exit_runtime);
- return;
+ std::cerr << "No `main' label in assembly file." <<
std::endl;
+ exit_set(exit_runtime);
+ return;
}
main_offset_ = program.text_section().get_offset(main);
mmu_.data_store(program.data_section());
@@ -62,8 +62,8 @@ namespace vm
cpu_.set_pc(main_offset_);
while (!cp0_.fatal_exception())
{
- cpu_.step();
- cp0_.set_count(cp0_.get_count() + 1);
+ cpu_.step();
+ cp0_.set_count(cp0_.get_count() + 1);
}
// FIXME: this is not the good test, but for the moment it suffices
@@ -85,21 +85,21 @@ namespace vm
cpu_.set_trace(trace_p);
while (status_ == run)
{
- cpu_.step();
- cp0_.set_count(cp0_.get_count() + 1);
- if (cp0_.fatal_exception())
- {
- status_ = halt;
- std::cerr << "Program exited." << std::endl;
- break;
- }
- if (has(breakpoints_, cpu_.get_pc()))
- {
- std::cout << "Breakpoint at pc = " << cpu_.get_pc() <<
std::endl;
- status_ = pause;
- }
- if (mode_ == step)
- status_ = pause;
+ cpu_.step();
+ cp0_.set_count(cp0_.get_count() + 1);
+ if (cp0_.fatal_exception())
+ {
+ status_ = halt;
+ std::cerr << "Program exited." << std::endl;
+ break;
+ }
+ if (has(breakpoints_, cpu_.get_pc()))
+ {
+ std::cout << "Breakpoint at pc = " << cpu_.get_pc()
<< std::endl;
+ status_ = pause;
+ }
+ if (mode_ == step)
+ status_ = pause;
}
}
diff --git a/src/vm/virtual_machine.hh b/src/vm/virtual_machine.hh
index 6866d2c..7498f6d 100644
--- a/src/vm/virtual_machine.hh
+++ b/src/vm/virtual_machine.hh
@@ -39,20 +39,20 @@ namespace vm
public:
enum mode_type
{
- normal,
- step
+ normal,
+ step
};
enum status_type
{
- run,
- pause,
- stop,
- halt
+ run,
+ pause,
+ stop,
+ halt
};
/** \name Constructor and destructor.
- \{ */
+ \{ */
public:
VirtualMachine(mode_type mode = normal);
/** \} */
@@ -73,7 +73,7 @@ namespace vm
void execute();
/** \name Shell entry point
- \{ */
+ \{ */
public:
/// Execute a program
void execute(bool trace_p);
@@ -98,13 +98,13 @@ namespace vm
Cp0 &get_cp0();
const Cpu &get_cpu() const;
- Cpu &get_cpu();
+ Cpu &get_cpu();
protected:
/// The virtual machine mode.
- mode_type mode_;
+ mode_type mode_;
/// The virtual machine status.
- status_type status_;
+ status_type status_;
/** \} */
protected:
--
1.7.2.5