Commit 11416d95 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

2005-10-16 Benoît Perrot <benoit@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.
parent 21381805
2005-10-16 Benot Perrot <benoit@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.
2005-10-03 Benot Perrot <benoit@nrde.epita.fr> 2005-10-03 Benot Perrot <benoit@nrde.epita.fr>
* src/vm/nolimips_system_library.cc: Provide a stub for free(). * src/vm/nolimips_system_library.cc: Provide a stub for free().
......
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: New in 0.8, 2005-07-11:
* The shell now has (some) completion. * The shell now has (some) completion.
......
...@@ -6,5 +6,6 @@ libtask_a_SOURCES = \ ...@@ -6,5 +6,6 @@ libtask_a_SOURCES = \
function_task.hh function_task.cc \ function_task.hh function_task.cc \
boolean_task.hh boolean_task.cc \ boolean_task.hh boolean_task.cc \
int_task.hh int_task.cc \ int_task.hh int_task.cc \
string_task.hh string_task.cc \
task_register.hh task_register.cc \ task_register.hh task_register.cc \
libtask.hh libtask.hh
// //
// This file is part of Nolimips, a MIPS simulator with unlimited registers // This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004 Akim Demaille <akim@epita.fr> and // Copyright (C) 2004, 2005 Akim Demaille <akim@epita.fr> and
// Benoit Perrot <benoit@lrde.epita.fr> // Benoit Perrot <benoit@lrde.epita.fr>
// //
// Nolimips is free software; you can redistribute it and/or modify // Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
# include "task/function_task.hh" # include "task/function_task.hh"
# include "task/boolean_task.hh" # include "task/boolean_task.hh"
# include "task/int_task.hh" # include "task/int_task.hh"
# include "task/string_task.hh"
# ifdef NOLIMIPS_CC_ # ifdef NOLIMIPS_CC_
...@@ -48,6 +49,12 @@ ...@@ -48,6 +49,12 @@
Option, module_name, \ Option, module_name, \
Desc, Deps) 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_ # else // !NOLIMIPS_CC_
...@@ -58,6 +65,8 @@ ...@@ -58,6 +65,8 @@
extern bool Flag 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 extern int Var
# define STRING_TASK_DECLARE(Option, Desc, Routine, Default, Deps) \
extern void (Routine) (const std::string &)
# endif // NOLIMIPS_CC_ # endif // NOLIMIPS_CC_
......
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2004 Akim Demaille <akim@epita.fr> and
// Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Nolimips is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "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
//
// This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2005 Akim Demaille <akim@epita.fr> and
// Benoit Perrot <benoit@lrde.epita.fr>
//
// Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// Nolimips is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#ifndef 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
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "inst/program.hh" #include "inst/program.hh"
#include "vm/spim_system_library.hh" #include "vm/spim_system_library.hh"
#include "vm/nolimips_system_library.hh"
#include "vm/virtual_machine.hh" #include "vm/virtual_machine.hh"
#include "parse-tasks.hh" #include "parse-tasks.hh"
...@@ -33,14 +34,45 @@ namespace vm ...@@ -33,14 +34,45 @@ namespace vm
namespace tasks 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 void
execute () execute()
{ {
vm::SpimSystemLibrary l(std::cin, std::cout);
vm::VirtualMachine vm; vm::VirtualMachine vm;
vm.get_cpu().set_check_callee_save(check_callee_save_p); vm.get_cpu().set_check_callee_save(check_callee_save_p);
vm.get_cpu().set_trace(trace_exec_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); vm.load_program(* parse::tasks::program);
if (exit_status != exit_success) if (exit_status != exit_success)
exit(exit_status); exit(exit_status);
......
// //
// This file is part of Nolimips, a MIPS simulator with unlimited registers // This file is part of Nolimips, a MIPS simulator with unlimited registers
// Copyright (C) 2003, 2004 Benoit Perrot <benoit@lrde.epita.fr> // Copyright (C) 2003, 2004, 2005 Benoit Perrot <benoit@lrde.epita.fr>
// //
// Nolimips is free software; you can redistribute it and/or modify // Nolimips is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by // it under the terms of the GNU General Public License as published by
...@@ -36,6 +36,15 @@ namespace vm ...@@ -36,6 +36,15 @@ namespace vm
BOOLEAN_TASK_DECLARE ("profile", "Enable program profiling", BOOLEAN_TASK_DECLARE ("profile", "Enable program profiling",
profile_p, ""); 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", BOOLEAN_TASK_DECLARE ("E|trace-exec", "Trace the execution",
trace_exec_p, ""); trace_exec_p, "");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment