ChangeLog | 13 ++++++++++++
NEWS | 6 +++++
src/task/Makefile.am | 1
src/task/libtask.hh | 11 +++++++++-
src/task/string_task.cc | 47 +++++++++++++++++++++++++++++++++++++++++++++
src/task/string_task.hh | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
src/vm-tasks.cc | 36 ++++++++++++++++++++++++++++++++--
src/vm-tasks.hh | 11 +++++++++-
8 files changed, 171 insertions(+), 4 deletions(-)
Index: ChangeLog
from Benoît Perrot <benoit(a)lrde.epita.fr>
Provide --system-library option.
* src/task/string_task.hh, src/task/string_task.cc:
New.
* src/task/libtask.hh, src/task/Makefile.am:
Distribute them.
* src/vm-tasks.hh, src/vm-tasks.hh:
(select_system_library): Implement builtin system library
selection.
* NEWS: Update.
Index: src/vm-tasks.cc
--- src/vm-tasks.cc (révision 198)
+++ src/vm-tasks.cc (révision 199)
@@ -21,6 +21,7 @@
#include "inst/program.hh"
#include "vm/spim_system_library.hh"
+#include "vm/nolimips_system_library.hh"
#include "vm/virtual_machine.hh"
#include "parse-tasks.hh"
@@ -33,14 +34,45 @@
namespace tasks
{
+ // Default system library
+ static vm::SystemLibrary *system_library =
+ new vm::SpimSystemLibrary(std::cin, std::cout);
+
+ void
+ 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);
+ }
+ else if (library_name == "spim")
+ {
+// delete system_library;
+// system_library = new vm::SpimSystemLibrary(std::cin, std::cout);
+ }
+ else if (library_name == "none")
+ {
+ delete system_library;
+ system_library = 0;
+ }
+ else
+ {
+ std::cerr << program_name
+ << ": `" << library_name << "': no such system
library"
+ << std::endl;
+ exit_set (exit_failure);
+ }
+ }
+
void
execute ()
{
- vm::SpimSystemLibrary l(std::cin, std::cout);
vm::VirtualMachine vm;
vm.get_cpu().set_check_callee_save(check_callee_save_p);
vm.get_cpu().set_trace(trace_exec_p);
- vm.set_system_library(&l);
+ vm.set_system_library(system_library);
vm.load_program(* parse::tasks::program);
if (exit_status != exit_success)
exit(exit_status);
Index: src/task/string_task.hh
--- src/task/string_task.hh (révision 0)
+++ src/task/string_task.hh (révision 199)
@@ -0,0 +1,50 @@
+//
+// This file is part of Nolimips, a MIPS simulator with unlimited registers
+// Copyright (C) 2005 Akim Demaille <akim(a)epita.fr> and
+// 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 this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+#ifndef TASK_STRING_TASK_HH
+# define TASK_STRING_TASK_HH
+
+# include <string>
+
+# include "task/task.hh"
+
+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 = "");
+
+ public:
+ virtual bool set_value(const std::string &value) const;
+
+ virtual void execute() const;
+
+ private:
+ void (*execute_) (const std::string &);
+
+ mutable std::string s_;
+ };
+
+} // namespace task
+
+#endif // !TASK_STRING_TASK_HH
Index: src/task/libtask.hh
--- src/task/libtask.hh (révision 198)
+++ src/task/libtask.hh (révision 199)
@@ -1,6 +1,6 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
-// Copyright (C) 2004 Akim Demaille <akim(a)epita.fr> and
+// Copyright (C) 2004, 2005 Akim Demaille <akim(a)epita.fr> and
// Benoit Perrot <benoit(a)lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
@@ -24,6 +24,7 @@
# include "task/function_task.hh"
# include "task/boolean_task.hh"
# include "task/int_task.hh"
+# include "task/string_task.hh"
# ifdef NOLIMIPS_CC_
@@ -48,6 +49,12 @@
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_
@@ -58,6 +65,8 @@
extern bool Flag
# define INT_TASK_DECLARE(Option, Desc, Var, Default, Min, Max, Deps) \
extern int Var
+# define STRING_TASK_DECLARE(Option, Desc, Routine, Default, Deps) \
+ extern void (Routine) (const std::string &)
# endif // NOLIMIPS_CC_
Index: src/task/Makefile.am
--- src/task/Makefile.am (révision 198)
+++ src/task/Makefile.am (révision 199)
@@ -6,5 +6,6 @@
function_task.hh function_task.cc \
boolean_task.hh boolean_task.cc \
int_task.hh int_task.cc \
+ string_task.hh string_task.cc \
task_register.hh task_register.cc \
libtask.hh
Index: src/task/string_task.cc
--- src/task/string_task.cc (révision 0)
+++ src/task/string_task.cc (révision 199)
@@ -0,0 +1,47 @@
+//
+// 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>
+//
+// Nolimips is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// Nolimips is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+#include "task/string_task.hh"
+
+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):
+ Task(option, module_name, desc, deps, true),
+ execute_(execute)
+ {}
+
+ bool
+ StringTask::set_value(const std::string &value) const
+ {
+ s_ = value;
+ return true;
+ }
+
+ void
+ StringTask::execute() const
+ {
+ execute_(s_);
+ }
+
+} //namespace task
Index: src/vm-tasks.hh
--- src/vm-tasks.hh (révision 198)
+++ src/vm-tasks.hh (révision 199)
@@ -1,6 +1,6 @@
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
-// Copyright (C) 2003, 2004 Benoit Perrot <benoit(a)lrde.epita.fr>
+// Copyright (C) 2003, 2004, 2005 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
@@ -37,6 +37,15 @@
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",
+ "");
+
BOOLEAN_TASK_DECLARE ("E|trace-exec", "Trace the execution",
trace_exec_p, "");
TASK_DECLARE ("e|execute", "Execute the program on virtual
machine",
Index: NEWS
--- NEWS (révision 198)
+++ NEWS (révision 199)
@@ -1,3 +1,9 @@
+New in 0.8a:
+* `--system-library' option provides builtin system library selection,
+ so the user can use a spim-like or the nolimips-original syscall set.
+
+* `--argument-registers' is the new name of `--args'.
+
New in 0.8, 2005-07-11:
* The shell now has (some) completion.