V-Gears 0
Free Final Fantasy VII engine.
Disassembler.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2022 The V-Gears Team
3 *
4 * This file is part of V-Gears
5 *
6 * V-Gears is free software: you can redistribute it and/or modify it under
7 * terms of the GNU General Public License as published by the Free Software
8 * Foundation, version 3.0 (GPLv3) of the License.
9 *
10 * V-Gears is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 */
15
16#pragma once
17
18#include <iostream>
19#include <vector>
20#include "common/BinaryReader.h"
21#include "DecompilerException.h"
23#include "ObjectFactory.h"
24
29
30 public:
31
37 Disassembler(InstVec &insts);
38
42 virtual ~Disassembler() = default;
43
49 virtual void Open(const char *filename);
50
54 void Disassemble();
55
63 void DumpDisassembly(std::ostream &output);
64
65 protected:
66
73 virtual void DoDisassemble() = 0;
74
80 virtual void DoDumpDisassembly(std::ostream &output);
81
89 void ReadParams(InstPtr inst, const char *types);
90
100 void ReadParams(InstPtr inst, const char *types, const std::vector<std::string>& params);
101
110 virtual ValuePtr ReadParameter(InstPtr inst, std::string type);
111
115 std::unique_ptr<BinaryReader> stream_;
116
121
126
131
132};
boost::intrusive_ptr< Instruction > InstPtr
Pointer to an Instruction.
Definition: Instruction.h:43
std::vector< InstPtr > InstVec
Type representing a vector of InstPtrs.
Definition: Instruction.h:382
boost::intrusive_ptr< Value > ValuePtr
Pointer to a Value.
Definition: Value.h:93
Base class for disassemblers.
Definition: Disassembler.h:28
uint32 address_
The current address.
Definition: Disassembler.h:130
std::unique_ptr< BinaryReader > stream_
Used to perform file I/O.
Definition: Disassembler.h:115
Disassembler(InstVec &insts)
Constructor for Disassembler.
Definition: Disassembler.cpp:18
void DumpDisassembly(std::ostream &output)
Outputs the disassembled code.
Definition: Disassembler.cpp:36
virtual void DoDisassemble()=0
Performs disassembly.
virtual ~Disassembler()=default
Destructor.
void ReadParams(InstPtr inst, const char *types)
Read parameters and associate them with an instruction.
Definition: Disassembler.cpp:58
virtual void Open(const char *filename)
Open a file for disassembly.
Definition: Disassembler.cpp:20
void Disassemble()
Request disassembled instructions.
Definition: Disassembler.cpp:29
InstVec & insts_
List of disassembled instructions.
Definition: Disassembler.h:120
uint32 address_base_
Base address where the script starts.
Definition: Disassembler.h:125
virtual ValuePtr ReadParameter(InstPtr inst, std::string type)
Reads data for a single parameter.
Definition: Disassembler.cpp:91
virtual void DoDumpDisassembly(std::ostream &output)
Outputs the disassembled code.
Definition: Disassembler.cpp:24
unsigned int uint32
Definition: scummsys.h:435