Commit 812bad96 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

from  Benoît Perrot  <benoit@lrde.epita.fr>

	Fix shell's `load' command.
	
	* src/shell.hh: Implement destructor in corresponding .cc.
	Aggregate the program being run.
	* src/shell.cc (do_load): Recover on parse or solve error.
	(do_load, do_run, do_continue, do-next, do_break) Use aggregated
	program pointer instead of global one.
parent fcb768de
2005-01-22 Benot Perrot <benoit@lrde.epita.fr>
Fix shell's `load' command.
* src/shell.hh: Implement destructor in corresponding .cc.
Aggregate the program being run.
* src/shell.cc (do_load): Recover on parse or solve error.
(do_load, do_run, do_continue, do-next, do_break) Use aggregated
program pointer instead of global one.
2005-01-17 Benot Perrot <benoit@lrde.epita.fr>
* src/shell.hh (is_register, is_label, get_next_word):
......
......@@ -19,12 +19,15 @@
#include <iomanip>
#include "modules.hh"
#include "parse-tasks.hh"
#include "misc/readline.hh"
#include "parse/libparse.hh"
#include "inst/program.hh"
#include "inst/program_solver.hh"
#include "shell/shell.hh"
#include "shell/cmd.hh"
......@@ -36,6 +39,7 @@ namespace shell
// --------------------------------------------------------------------------
Shell::Shell():
program_(0),
vm_(true, false)
{
......@@ -89,6 +93,12 @@ namespace shell
map_register_["ra"] = vm::Cpu::ra;
}
Shell::~Shell()
{
delete program_;
}
void
Shell::run()
{
......@@ -267,23 +277,50 @@ namespace shell
}
// --------------------------------------------------------------------------
// Execution engine
void
Shell::do_load(const Cmd &cmd)
{
// FIXME: introducing memory leak!
filename = strdup(cmd.get_args().begin()->c_str());
// Reset status
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);
//std::cerr << "#DEBUG: _load: filename == " << filename << std::endl;
program_solver.solve(*program_);
if (exit_status == exit_success)
{
vm_.load_program(*program_);
}
else
std::cerr << "Solving failed, program not loaded." << std::endl;
}
else
std::cerr << "Parsing failed, program not loaded." << std::endl;
parse::tasks::parse();
inst::tasks::prg_solve();
vm_.load_program(* parse::tasks::program);
//
if (exit_status != exit_success)
{
delete program_;
program_ = 0;
}
}
void
Shell::do_run()
{
if (!parse::tasks::program)
if (!program_)
{
std::cerr << "No program loaded." << std::endl;
return;
......@@ -302,7 +339,7 @@ namespace shell
void
Shell::do_continue()
{
if (!parse::tasks::program)
if (!program_)
{
std::cerr << "No program loaded." << std::endl;
return;
......@@ -320,7 +357,7 @@ namespace shell
void
Shell::do_next()
{
if (!parse::tasks::program)
if (!program_)
{
std::cerr << "No program loaded." << std::endl;
return;
......@@ -338,7 +375,7 @@ namespace shell
void
Shell::do_break(const Cmd &cmd)
{
if (!parse::tasks::program)
if (!program_)
{
std::cerr << "No program loaded." << std::endl;
return;
......
......@@ -57,8 +57,7 @@ namespace shell
Shell();
/// Destroy a Shell.
~Shell()
{}
~Shell();
/** \} */
public:
......@@ -151,7 +150,10 @@ namespace shell
/** \} */
private:
/// virtual machine link.
/// Program being run
inst::Program *program_;
/// Virtual machine.
vm::VirtualMachine vm_;
/// map of token word.
......
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