1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Distributed under the terms of the MIT License. 4 */ 5#ifndef DISASSEMBLED_CODE_H 6#define DISASSEMBLED_CODE_H 7 8 9#include <ObjectList.h> 10 11#include "SourceCode.h" 12 13 14class BString; 15class ContiguousStatement; 16 17 18class DisassembledCode : public SourceCode { 19public: 20 DisassembledCode(SourceLanguage* language); 21 ~DisassembledCode(); 22 23 virtual bool Lock(); 24 virtual void Unlock(); 25 26 virtual SourceLanguage* GetSourceLanguage() const; 27 28 virtual bool GetStatementLocationRange( 29 const SourceLocation& location, 30 SourceLocation& _start, 31 SourceLocation& _end) const; 32 33 virtual LocatableFile* GetSourceFile() const; 34 35 Statement* StatementAtAddress(target_addr_t address) const; 36 Statement* StatementAtLocation( 37 const SourceLocation& location) const; 38 TargetAddressRange StatementAddressRange() const; 39 40 // LineDataSource 41 virtual int32 CountLines() const; 42 virtual const char* LineAt(int32 index) const; 43 virtual int32 LineLengthAt(int32 index) const; 44 45public: 46 bool AddCommentLine(const BString& line); 47 bool AddInstructionLine(const BString& line, 48 target_addr_t address, target_size_t size); 49 // instructions must be added in 50 // ascending address order 51 52private: 53 struct Line; 54 55 typedef BObjectList<Line> LineList; 56 typedef BObjectList<ContiguousStatement> StatementList; 57 58private: 59 bool _AddLine(const BString& line, 60 ContiguousStatement* statement); 61 static int _CompareAddressStatement( 62 const target_addr_t* address, 63 const ContiguousStatement* statement); 64 65private: 66 SourceLanguage* fLanguage; 67 LineList fLines; 68 StatementList fStatements; 69}; 70 71 72#endif // DISASSEMBLED_CODE_H 73