Commit 661492f8 authored by Benoit Perrot's avatar Benoit Perrot
Browse files

Index: ChangeLog

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

	Copy the instruction list of text section when storing one.

	* src/inst/text_section.hh, dev/inst-solver-gen.py:
	Hide the concrete type of instruction list.
	* src/vm/mmu.hh: Aggregate the instructions instead of 
	a text section.
	(inst_store) Copy the instruction pointers into a local vector.
	(inst_load) Access the local vector instead of text section. 
parent 4de60919
2005-01-23 Benot Perrot <benoit@lrde.epita.fr>
Copy the instruction list of text section when storing one.
* src/inst/text_section.hh, dev/inst-solver-gen.py:
Hide the concrete type of instruction list.
* src/vm/mmu.hh: Aggregate the instructions instead of
a text section.
(inst_store) Copy the instruction pointers into a local vector.
(inst_load) Access the local vector instead of text section.
2005-01-23 Benot Perrot <benoit@lrde.epita.fr>
Hide the text section loaded in virtual machine's memory.
......@@ -643,7 +654,7 @@
* src/shell/cmd.hh,
* src/shell/shell.cc, src/shell/shell.hh:
Use references for composed attributes, and pointers for aggregated
Use references for aggregated attributes, and pointers for composed
attributes.
2004-04-25 Benot Perrot <benoit@lrde.epita.fr>
......
......@@ -87,9 +87,11 @@ namespace inst
{
program_ = &program;
int i;
for (i = 0, pc_ = 4; i < program.text_section().size(); ++i, pc_ += 4)
program_->text_section()[i].accept(*this);
pc_ = 4;
for (TextSection::instruction_list_type::const_iterator
it = program.text_section().begin();
it < program.text_section().end(); ++it, pc_ += 4)
(*it)->accept(*this);
}
protected:
int pc_;
......
......@@ -34,6 +34,9 @@ namespace inst
class TextSection:
public Section
{
public:
typedef std::vector<inst::Inst*> instruction_list_type;
public:
TextSection(const std::string &name = ".text"):
Section(name)
......@@ -41,9 +44,13 @@ namespace inst
virtual ~TextSection();
public:
int size() const
instruction_list_type::const_iterator begin() const
{
return insts_.begin();
}
instruction_list_type::const_iterator end() const
{
return insts_.size ();
return insts_.end();
}
public:
......@@ -58,28 +65,11 @@ namespace inst
insts_.push_back(inst);
}
public:
const inst::Inst& operator[](int offset) const
{
precondition(0 <= offset && (unsigned) offset < insts_.size());
assertion(insts_[offset]);
return *(insts_[offset]);
}
inst::Inst& operator[](int offset)
{
precondition(0 <= offset && (unsigned) offset < insts_.size());
assertion(insts_[offset]);
return *(insts_[offset]);
}
public:
virtual void print(std::ostream& ostr) const;
protected:
std::vector<inst::Inst*> insts_;
instruction_list_type insts_;
};
} // namespace inst
......
......@@ -128,20 +128,23 @@ namespace vm
public:
void inst_store(const inst::TextSection& text_section)
{
text_section_ = &text_section;
for (inst::TextSection::instruction_list_type::const_iterator
it = text_section.begin(); it != text_section.end(); ++it)
text_section_.push_back(*it);
}
const inst::Inst & inst_load(int offset) const
{
// Precondition
if (offset < 0 || text_section_->size() <= offset)
if (offset < 0 ||
text_section_.size() <= static_cast<unsigned>(offset))
{
std::cerr << "inst_load" << std::endl;
cp0_.raise_addr_load();
return (*text_section_)[0]; // FIXME: NO!
return *text_section_[0]; // FIXME: NO!
}
return (*text_section_)[offset];
return *text_section_[offset];
}
/** \} */
......@@ -151,7 +154,7 @@ namespace vm
/// Memory link.
Memory &memory_;
const inst::TextSection* text_section_;
std::vector<const inst::Inst*> text_section_;
};
} // namespace vm
......
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