Index: trunk/ChangeLog
from Benoît Perrot <benoit(a)lrde.epita.fr>
Factor boolean tasks.
* src/task/boolean_task.hh, src/task/boolean_task.cc:
* src/task/Makefile.am:
Distribute new files.
* src/vm/vm-tasks.hh, src/vm/vm-tasks.cc,
* src/task/libtask.hh:
Use boolean tasks.
2004-09-18 Benoît Perrot <benoit(a)lrde.epita.fr>
Index: trunk/src/task/boolean_task.hh
--- trunk/src/task/boolean_task.hh (revision 0)
+++ trunk/src/task/boolean_task.hh (revision 122)
@@ -0,0 +1,44 @@
+//
+// 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
+//
+#ifndef TASK_BOOLEAN_TASK_HH
+# define TASK_BOOLEAN_TASK_HH
+
+#include "task/task.hh"
+
+namespace task
+{
+
+ class BooleanTask: public Task
+ {
+ public:
+ BooleanTask(bool &flag,
+ const std::string& option, const std::string& module_name,
+ const std::string& desc, const std::string& deps = "");
+
+ public:
+ virtual void execute() const;
+
+ private:
+ mutable bool &flag_;
+ };
+
+} // namespace task
+
+#endif // !TASK_BOOLEAN_TASK_HH
Index: trunk/src/task/boolean_task.cc
--- trunk/src/task/boolean_task.cc (revision 0)
+++ trunk/src/task/boolean_task.cc (revision 122)
@@ -0,0 +1,41 @@
+//
+// 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/boolean_task.hh"
+
+namespace task
+{
+
+ BooleanTask::BooleanTask(bool &flag,
+ 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)
+ {}
+
+ void
+ BooleanTask::execute (void) const
+ {
+ flag_ = true;
+ }
+
+} //namespace task
Index: trunk/src/task/libtask.hh
--- trunk/src/task/libtask.hh (revision 121)
+++ trunk/src/task/libtask.hh (revision 122)
@@ -22,21 +22,32 @@
# define TASK_LIBTASK_HH
# include "task/function_task.hh"
+# include "task/boolean_task.hh"
# ifdef NOLIMIPS_CC_
# define TASK_MODULE(Name) \
const char module_name [] = Name;
+
# define TASK_DECLARE(Option, Desc, Routine, Deps) \
extern void (Routine) (void); \
- task::FunctionTask task_##Routine (Routine, \
+ static task::FunctionTask task_##Routine (Routine, \
Option, module_name, \
Desc, Deps)
+
+# define BOOLEAN_TASK_DECLARE(Option, Desc, Flag, Deps) \
+ bool Flag; \
+ static task::BooleanTask task_##Flag(Flag, \
+ Option, module_name, \
+ Desc, Deps)
+
# else // !NOLIMIPS_CC_
# define TASK_MODULE(Name)
# define TASK_DECLARE(Name, Help, Routine, Dependencies) \
extern void (Routine) (void)
+# define BOOLEAN_TASK_DECLARE(Name, Help, Flag, Dependencies)\
+ extern bool Flag
# endif // NOLIMIPS_CC_
Index: trunk/src/task/Makefile.am
--- trunk/src/task/Makefile.am (revision 121)
+++ trunk/src/task/Makefile.am (revision 122)
@@ -4,6 +4,7 @@
libtask_a_SOURCES = \
task.hh task.cc \
function_task.hh function_task.cc \
+ boolean_task.hh boolean_task.cc \
task_register.hh task_register.cc \
libtask.hh \
task-tasks.hh task-tasks.cc
Index: trunk/src/vm/vm-tasks.hh
--- trunk/src/vm/vm-tasks.hh (revision 121)
+++ trunk/src/vm/vm-tasks.hh (revision 122)
@@ -29,13 +29,13 @@
TASK_MODULE ("3. Virtual Machine");
- TASK_DECLARE ("check-callee-save",
+ BOOLEAN_TASK_DECLARE ("check-callee-save",
"Warn if a callee save register "
"is not preserved across a call",
- check_callee_save, "");
+ check_callee_save_p, "");
- TASK_DECLARE ("E|trace-exec", "Trace the execution",
- trace_exec, "");
+ BOOLEAN_TASK_DECLARE ("E|trace-exec", "Trace the execution",
+ trace_exec_p, "");
TASK_DECLARE ("e|execute", "Execute the program on virtual
machine",
execute, "prg-solve");
Index: trunk/src/vm/vm-tasks.cc
--- trunk/src/vm/vm-tasks.cc (revision 121)
+++ trunk/src/vm/vm-tasks.cc (revision 122)
@@ -29,20 +29,6 @@
namespace tasks
{
- static bool check_callee_save_p = false;
- void
- check_callee_save ()
- {
- check_callee_save_p = true;
- }
-
- static bool trace_exec_p = false;
- void
- trace_exec ()
- {
- trace_exec_p = true;
- }
-
void
execute ()
{