Make your own free website on Tripod.com
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

ObjectModule::DataReader Class Reference

Class for read data on Module. More...

#include <module.h>

List of all members.

Public Methods

uint8_t ReadByte ()
uint16_t ReadWord ()
uint32_t ReadDword ()
void UnReadByte ()
vma_t Tell ()

Private Methods

 DataReader (const Section *sec, unsigned char *ptr)

Private Attributes

friend ObjectModule
const Sectionsec
unsigned char * ptr


Detailed Description

Class for read data on Module.

Definition at line 61 of file module.h.


Constructor & Destructor Documentation

ObjectModule::DataReader::DataReader const Section   sec,
unsigned char *    ptr
[private]
 

Definition at line 196 of file module.cpp.

00196                                                                          :
00197         sec(_sec),ptr(_ptr)
00198 {
00199 }


Member Function Documentation

uint8_t ObjectModule::DataReader::ReadByte  
 

Definition at line 201 of file module.cpp.

References _PRG_ASSERT, range< vma_t >::begin, ObjectModule::Section::data, ObjectModule::Section::data_end, range< vma_t >::end, ObjectModule::Section::next, ptr, and sec.

Referenced by InstructionDecoder::get_checkc(), CodeParser::GetBitStat(), CodeParser::GetStringStats(), CodeParser::Parse(), ObjectModule::ReadByte(), ReadWord(), CodeParser::WriteBegin(), CodeParser::WriteCode(), and CodeParser::WriteString().

00202 {
00203         _PRG_ASSERT(sec);
00204         _PRG_ASSERT(ptr >= sec->data && ptr <= sec->data_end);
00205 
00206   // test cell valid
00207         if (ptr < sec->data_end)
00208                 return *ptr++;
00209                 
00210         // next section continue this ??
00211         if (sec->next && sec->end == sec->next->begin)
00212         {
00213                 /* !!! is posible a empty section ??? */
00214                 sec = sec->next;
00215                 ptr = sec->data;
00216                 return *ptr++;
00217         }
00218 
00219   throw OutOfAddress(sec->end);
00220 }

uint32_t ObjectModule::DataReader::ReadDword  
 

Definition at line 229 of file module.cpp.

References ReadWord().

Referenced by CodeParser::ExecuteComplexReferenceMemory(), CodeParser::GetPointerArrayStats(), InstructionDecoder::getv_rel(), CodeParser::Parse(), ObjectModule::ReadDword(), InstructionDecoder::ReadVar(), and CodeParser::WriteCode().

00230 {
00231   // !!! define uint16fast_t
00232   uint16_t u = ReadWord();
00233   return u|(uint32_t(ReadWord())<<16);
00234 }

uint16_t ObjectModule::DataReader::ReadWord  
 

Definition at line 222 of file module.cpp.

References ReadByte().

Referenced by InstructionDecoder::getv_rel(), ReadDword(), InstructionDecoder::ReadVar(), ObjectModule::ReadWord(), and CodeParser::WriteCode().

00223 {
00224   // !!! define uint8fast_t
00225   uint8_t u = ReadByte();
00226   return uint16_t(u|(uint16_t(ReadByte())<<8));
00227 }

vma_t ObjectModule::DataReader::Tell  
 

Definition at line 236 of file module.cpp.

References range< vma_t >::begin, ObjectModule::Section::data, ptr, sec, and vma_t.

Referenced by CodeParser::ExecuteComplexReferenceMemory(), InstructionDecoder::get_checkc(), CodeParser::GetBitStat(), CodeParser::GetPointerArrayStats(), CodeParser::GetStringStats(), and InstructionDecoder::getv_rel().

00237 {
00238         return sec->begin + (ptr - sec->data);
00239 }

void ObjectModule::DataReader::UnReadByte  
 

Definition at line 241 of file module.cpp.

References _PRG_ASSERT, range< vma_t >::begin, ObjectModule::Section::data, ptr, and sec.

00242 {
00243         _PRG_ASSERT(sec);
00244         _PRG_ASSERT(ptr >= sec->data && ptr <= sec->data_end);
00245 
00246   // test cell valid
00247         if (ptr >= sec->data)
00248         {
00249                 --ptr;
00250                 return;
00251         }
00252                 
00253         // !!! finish, go to other section
00254   throw OutOfAddress(sec->begin);
00255 }


Member Data Documentation

friend ObjectModule::DataReader::ObjectModule [private]
 

Definition at line 62 of file module.h.

unsigned char* ObjectModule::DataReader::ptr [private]
 

Definition at line 64 of file module.h.

Referenced by ReadByte(), Tell(), and UnReadByte().

const Section* ObjectModule::DataReader::sec [private]
 

Definition at line 63 of file module.h.

Referenced by ReadByte(), Tell(), and UnReadByte().


The documentation for this class was generated from the following files:
Generated on Mon Jan 13 22:20:36 2003 for perdr by doxygen1.2.15