V-Gears 0
Free Final Fantasy VII engine.
Engine.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 <set>
19#include <string>
20#include <vector>
21#include "Function.h"
22#include "Graph.h"
23#include "CodeGenerator.h"
24#include "Disassembler.h"
25
29typedef std::map<uint32, Function> FuncMap;
30
34class Engine {
35
36 public:
37
38 virtual ~Engine() = default;
39
40 virtual std::unique_ptr<Disassembler> GetDisassembler(
41 InstVec& insts, const std::vector<unsigned char>& c
42 );
43
50 virtual std::unique_ptr<Disassembler> GetDisassembler(InstVec &insts) = 0;
51
59 virtual std::unique_ptr<CodeGenerator> GetCodeGenerator(
60 const InstVec& insts, std::ostream &output
61 ) = 0;
62
68 virtual void PostCFG(InstVec& insts, Graph graph);
69
76 virtual bool SupportsCodeFlow() const;
77
84 virtual bool SupportsCodeGen() const;
85
94 virtual void GetVariants(std::vector<std::string>& variants) const;
95
96
106 virtual bool UsePureGrouping() const;
107
108 // TODO: functions must probably be set to private, and have accessors, but...
109 // too much depends on it being public right now.
110 // Maybe at some point in the future...
111
116
117 protected:
118
122 std::string variant_;
123
124};
std::map< uint32, Function > FuncMap
Type representing a map of functions, indexed by starting address.
Definition: Engine.h:29
boost::adjacency_list< boost::setS, boost::listS, boost::bidirectionalS, GraphProperty, EdgeProperty > Graph
Definition: Graph.h:169
std::vector< InstPtr > InstVec
Type representing a vector of InstPtrs.
Definition: Instruction.h:382
Base class for engines.
Definition: Engine.h:34
virtual void GetVariants(std::vector< std::string > &variants) const
Retrieves the names of all variants supported for this engine.
Definition: Engine.cpp:30
virtual ~Engine()=default
virtual bool UsePureGrouping() const
Whether or not to use "pure" grouping during code flow analysis.
Definition: Engine.cpp:32
virtual std::unique_ptr< Disassembler > GetDisassembler(InstVec &insts)=0
Retrieve the disassembler for the engine.
virtual std::unique_ptr< Disassembler > GetDisassembler(InstVec &insts, const std::vector< unsigned char > &c)
Definition: Engine.cpp:18
std::string variant_
Engine variant to use for the script.
Definition: Engine.h:122
virtual std::unique_ptr< CodeGenerator > GetCodeGenerator(const InstVec &insts, std::ostream &output)=0
Retrieve the code generator for the engine.
virtual void PostCFG(InstVec &insts, Graph graph)
Post-processing step after CFG analysis.
Definition: Engine.cpp:24
virtual bool SupportsCodeFlow() const
Whether or not code flow analysis is supported for this engine.
Definition: Engine.cpp:26
FuncMap functions
Map to functions in the current script, indexed by start address.
Definition: Engine.h:115
virtual bool SupportsCodeGen() const
Whether or not code generation is supported for this engine.
Definition: Engine.cpp:28