|
|
@@ -31,83 +31,92 @@ typedef std::map<uint32, Function> FuncMap;
|
|
|
* Base class for engines.
|
|
|
*/
|
|
|
class Engine {
|
|
|
+
|
|
|
public:
|
|
|
|
|
|
virtual ~Engine() = default;
|
|
|
|
|
|
- virtual std::unique_ptr<Disassembler> GetDisassembler(InstVec &, const std::vector<unsigned char>& )
|
|
|
- {
|
|
|
- throw NotImplementedException();
|
|
|
- }
|
|
|
+ virtual std::unique_ptr<Disassembler> GetDisassembler(
|
|
|
+ InstVec& insts, const std::vector<unsigned char>& c
|
|
|
+ );
|
|
|
|
|
|
/**
|
|
|
* Retrieve the disassembler for the engine.
|
|
|
*
|
|
|
- * @param insts Reference to the std::vector to place the Instructions in.
|
|
|
- * @return Pointer to a Disassembler for the engine.
|
|
|
+ * @param insts[out] Vector to place the Instructions in.
|
|
|
+ * @return Pointer to a disassembler for the engine.
|
|
|
*/
|
|
|
virtual std::unique_ptr<Disassembler> GetDisassembler(InstVec &insts) = 0;
|
|
|
|
|
|
/**
|
|
|
* Retrieve the code generator for the engine.
|
|
|
*
|
|
|
- * @param output The std::ostream to output the code to.
|
|
|
+ * @param output[out] Stream to output the code to.
|
|
|
* @return Pointer to a CodeGenerator for the engine.
|
|
|
*/
|
|
|
- virtual std::unique_ptr<CodeGenerator> GetCodeGenerator(const InstVec& insts, std::ostream &output) = 0;
|
|
|
+ virtual std::unique_ptr<CodeGenerator> GetCodeGenerator(
|
|
|
+ const InstVec& insts, std::ostream &output
|
|
|
+ ) = 0;
|
|
|
|
|
|
/**
|
|
|
* Post-processing step after CFG analysis.
|
|
|
- * @param insts Reference to the std::vector to place the Instructions in.
|
|
|
- * @param g Graph generated from the CFG analysis.
|
|
|
+ * @param insts[out] Vector to place the Instructions in.
|
|
|
+ * @param graph[in] Graph generated from the CFG analysis.
|
|
|
*/
|
|
|
- virtual void PostCFG(InstVec&, Graph) { }
|
|
|
+ virtual void PostCFG(InstVec& insts, Graph graph);
|
|
|
|
|
|
/**
|
|
|
* Whether or not code flow analysis is supported for this engine.
|
|
|
*
|
|
|
- * @return True if supported, false if not. If false is returned, code flow analysis should not take place, and -D should be implied.
|
|
|
+ * @return True if supported, false if not. If false is returned, code
|
|
|
+ * flow analysis should not take place.
|
|
|
*/
|
|
|
- virtual bool SupportsCodeFlow() const { return true; }
|
|
|
+ virtual bool SupportsCodeFlow() const;
|
|
|
|
|
|
/**
|
|
|
* Whether or not code generation is supported for this engine.
|
|
|
*
|
|
|
- * @return True if supported, false if not. If false is returned, code generation should not take place, and -G should be implied.
|
|
|
+ * @return True if supported, false if not. If false is returned, code
|
|
|
+ * generation should not take place.
|
|
|
*/
|
|
|
- virtual bool SupportsCodeGen() const { return true; }
|
|
|
-
|
|
|
-
|
|
|
+ virtual bool SupportsCodeGen() const;
|
|
|
|
|
|
/**
|
|
|
- * Fill a vector with the names of all variants supported for this engine.
|
|
|
- * If variants are not used by this engine, leave the vector empty (default implementation).
|
|
|
+ * Retrieves the names of all variants supported for this engine.
|
|
|
*
|
|
|
- * @param variants Vector to add the supported variants to.
|
|
|
+ * If variants are not used by this engine, it will be empty (default
|
|
|
+ * implementation).
|
|
|
+ *
|
|
|
+ * @param variants Vector with the supported variants.
|
|
|
*/
|
|
|
- virtual void GetVariants(std::vector<std::string>&) const { };
|
|
|
+ virtual void GetVariants(std::vector<std::string>&) const;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* Whether or not to use "pure" grouping during code flow analysis.
|
|
|
- * With pure grouping, code flow analysis only looks at branches when merging.
|
|
|
- * This method may be more appropriate for non-stack-based engines.
|
|
|
+ *
|
|
|
+ * With pure grouping, code flow analysis only looks at branches when
|
|
|
+ * merging. This method may be more appropriate for non-stack-based
|
|
|
+ * engines.
|
|
|
*
|
|
|
* @return True if pure grouping should be used, false if not.
|
|
|
*/
|
|
|
- virtual bool UsePureGrouping() const { return false; }
|
|
|
+ virtual bool UsePureGrouping() const;
|
|
|
|
|
|
- virtual FuncMap GetFunctions() const{return _functions;}
|
|
|
+ // TODO: functions must probably be set to private, and have accessors, but...
|
|
|
+ // too much depends on it being public right now.
|
|
|
+ // Maybe at some point in the future...
|
|
|
|
|
|
- virtual void SetFunction(uint32 index, Function function){
|
|
|
- _functions[index] = function;
|
|
|
- }
|
|
|
-
|
|
|
- FuncMap _functions;
|
|
|
+ /**
|
|
|
+ * Map to functions in the current script, indexed by start address.
|
|
|
+ */
|
|
|
+ FuncMap functions;
|
|
|
|
|
|
protected:
|
|
|
|
|
|
- //FuncMap _functions; ///< Map to functions in the current script, indexed by starting address.
|
|
|
- std::string _variant; ///< Engine variant to use for the script.
|
|
|
+ /**
|
|
|
+ * Engine variant to use for the script.
|
|
|
+ */
|
|
|
+ std::string variant_;
|
|
|
|
|
|
};
|