| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /* ScummVM Tools
- *
- * ScummVM Tools is the legal property of its developers, whose
- * names are too numerous to list here. Please refer to the
- * COPYRIGHT file distributed with this source distribution.
- *
- * This program 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.
- *
- * This program 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
- #ifndef DEC_DISASSEMBLER_H
- #define DEC_DISASSEMBLER_H
- #include <iostream>
- #include <vector>
- #include "../common/BinaryReader.h"
- #include "instruction.h"
- #include "unknown_opcode_exception.h"
- #include "objectFactory.h"
- /**
- * Base class for disassemblers.
- */
- class Disassembler {
- protected:
- std::unique_ptr<BinaryReader> stream_; ///< Used to perform file I/O.
- InstVec &insts_; ///< Container for disassembled instructions.
- uint32 address_base_; ///< Base address where the script starts.
- /**
- * Performs disassembly.
- *
- * @throws UnknownOpcodeException on unknown opcode. May throw std::exception on other failures.
- */
- virtual void DoDisassemble() = 0;
- /**
- * Outputs the disassembled code.
- *
- * @param output The std::ostream to output to.
- */
- virtual void doDumpDisassembly(std::ostream &output);
- public:
- /**
- * Constructor for Disassembler.
- *
- * @param insts Reference to the vector in which disassembled instructions should be placed.
- */
- Disassembler(InstVec &insts);
- virtual ~Disassembler() = default;
- /**
- * Open a file for disassembly.
- *
- * @param filename The file to disassemble.
- */
- virtual void Open(const char *filename);
- /**
- * Request disassembled instructions.
- *
- * @return An std::vector containing the disassembled instructions.
- */
- void disassemble();
- /**
- * Outputs the disassembled code. Disassembles code if this has not already been done.
- *
- * @param output The std::ostream to output to.
- */
- void dumpDisassembly(std::ostream &output);
- };
- #endif
|