Forráskód Böngészése

Some more old SDUM code formatted and documented. Decompiler exceptions refactored.

Iñigo Valentin 3 éve
szülő
commit
d62cc893db
42 módosított fájl, 629 hozzáadás és 701 törlés
  1. 4 7
      V-Gears-Installer/CMakeLists.txt
  2. 12 11
      V-Gears-Installer/include/common/BinaryReader.h
  3. 1 1
      V-Gears-Installer/include/decompiler/CodeGenerator.h
  4. 247 0
      V-Gears-Installer/include/decompiler/DecompilerException.h
  5. 36 1
      V-Gears-Installer/include/decompiler/Disassembler.h
  6. 96 0
      V-Gears-Installer/include/decompiler/Stack.h
  7. 6 6
      V-Gears-Installer/include/decompiler/field/FieldDisassembler.h
  8. 2 2
      V-Gears-Installer/include/decompiler/field/FieldEngine.h
  9. 1 1
      V-Gears-Installer/include/decompiler/instruction/Instruction.h
  10. 0 119
      V-Gears-Installer/include/decompiler/simple_disassembler.h
  11. 0 101
      V-Gears-Installer/include/decompiler/stack.h
  12. 3 2
      V-Gears-Installer/include/decompiler/sudm.h
  13. 0 141
      V-Gears-Installer/include/decompiler/unknown_opcode_exception.h
  14. 2 2
      V-Gears-Installer/include/decompiler/value.h
  15. 3 3
      V-Gears-Installer/include/decompiler/world/WorldDisassembler.h
  16. 0 31
      V-Gears-Installer/include/decompiler/wrongtype.h
  17. 9 9
      V-Gears-Installer/src/decompiler/CodeGenerator.cpp
  18. 6 5
      V-Gears-Installer/src/decompiler/ControlFlow.cpp
  19. 54 0
      V-Gears-Installer/src/decompiler/DecompilerException.cpp
  20. 81 0
      V-Gears-Installer/src/decompiler/Disassembler.cpp
  21. 1 1
      V-Gears-Installer/src/decompiler/field/FieldCodeGenerator.cpp
  22. 4 5
      V-Gears-Installer/src/decompiler/field/FieldDisassembler.cpp
  23. 2 2
      V-Gears-Installer/src/decompiler/field/FieldEngine.cpp
  24. 4 4
      V-Gears-Installer/src/decompiler/field/instruction/FieldCondJumpInstruction.cpp
  25. 1 1
      V-Gears-Installer/src/decompiler/field/instruction/FieldControlFlowInstruction.cpp
  26. 4 4
      V-Gears-Installer/src/decompiler/instruction/BinaryOpStackInstruction.cpp
  27. 1 1
      V-Gears-Installer/src/decompiler/instruction/BoolNegateStackInstruction.cpp
  28. 3 3
      V-Gears-Installer/src/decompiler/instruction/DupStackInstruction.cpp
  29. 2 2
      V-Gears-Installer/src/decompiler/instruction/KernelCallStackInstruction.cpp
  30. 1 1
      V-Gears-Installer/src/decompiler/instruction/UnaryOpPostfixStackInstruction.cpp
  31. 1 1
      V-Gears-Installer/src/decompiler/instruction/UnaryOpPrefixStackInstruction.cpp
  32. 0 156
      V-Gears-Installer/src/decompiler/simple_disassembler.cpp
  33. 0 34
      V-Gears-Installer/src/decompiler/unknown_opcode_exception.cpp
  34. 2 2
      V-Gears-Installer/src/decompiler/world/WorldDisassembler.cpp
  35. 27 27
      V-Gears-Installer/src/decompiler/world/instruction/WorldKernelCallInstruction.cpp
  36. 1 3
      V-Gears-Installer/src/decompiler/world/instruction/WorldLoadBankInstruction.cpp
  37. 1 1
      V-Gears-Installer/src/decompiler/world/instruction/WorldLoadInstruction.cpp
  38. 1 1
      V-Gears-Installer/src/decompiler/world/instruction/WorldStackInstruction.cpp
  39. 3 3
      V-Gears-Installer/src/decompiler/world/instruction/WorldStoreInstruction.cpp
  40. 3 3
      V-Gears-Installer/src/decompiler/world/instruction/WorldSubStackInstruction.cpp
  41. 1 1
      V-Gears-Installer/src/decompiler/world/instruction/WorldUncondJumpInstruction.cpp
  42. 3 3
      V-Gears-Installer/src/ff7DataInstaller.cpp

+ 4 - 7
V-Gears-Installer/CMakeLists.txt

@@ -50,12 +50,10 @@ set(HEADER_FILES
     include/decompiler/instruction/UnaryOpPrefixStackInstruction.h
     include/decompiler/instruction/UncondJumpInstruction.h
     include/decompiler/ObjectFactory.h
-    include/decompiler/refcounted.h
-    include/decompiler/simple_disassembler.h
-    include/decompiler/stack.h
-    include/decompiler/unknown_opcode_exception.h
+    include/decompiler/RefCounted.h
+    include/decompiler/Stack.h
+    include/decompiler/DecompilerException.h
     include/decompiler/value.h
-    include/decompiler/wrongtype.h
     include/decompiler/field/instruction/FieldBackgroundInstruction.h
     include/decompiler/field/instruction/FieldCameraInstruction.h
     include/decompiler/field/instruction/FieldCondJumpInstruction.h
@@ -125,8 +123,7 @@ set(SOURCE_FILES
     src/decompiler/instruction/UnaryOpPostfixStackInstruction.cpp
     src/decompiler/instruction/UnaryOpPrefixStackInstruction.cpp
     src/decompiler/instruction/UncondJumpInstruction.cpp
-    src/decompiler/simple_disassembler.cpp
-    src/decompiler/unknown_opcode_exception.cpp
+    src/decompiler/DecompilerException.cpp
     src/decompiler/value.cpp
     src/decompiler/field/instruction/FieldBackgroundInstruction.cpp
     src/decompiler/field/instruction/FieldCameraInstruction.cpp

+ 12 - 11
V-Gears-Installer/include/common/BinaryReader.h

@@ -18,7 +18,8 @@
 #include <fstream> 
 #include <sstream>
 #include <iterator>
-#include "decompiler/unknown_opcode_exception.h"
+
+#include "decompiler/DecompilerException.h"
 
 /**
  * Reader for binary files.
@@ -68,10 +69,10 @@ class BinaryReader{
          * Moves the stream cursor.
          *
          * @param position[in] Position (offset) of the cursor.
-         * @throws InternalDecompilerError if the position is invalid.
+         * @throws DecompilerException if the position is invalid.
          */
         void Seek(unsigned int position){
-            if (!stream_.seekg(position)) throw InternalDecompilerError();
+            if (!stream_.seekg(position)) throw DecompilerException();
         }
 
         /**
@@ -87,7 +88,7 @@ class BinaryReader{
          * It advances the stream cursor.
          *
          * @return Read bits.
-         * @throws InternalDecompilerError if there is not enough data.
+         * @throws DecompilerException if there is not enough data.
          */
         unsigned int ReadU32(){return InternalRead<unsigned int>();}
 
@@ -97,7 +98,7 @@ class BinaryReader{
          * It advances the stream cursor.
          *
          * @return Read bits.
-         * @throws InternalDecompilerError if there is not enough data.
+         * @throws DecompilerException if there is not enough data.
          */
         signed int ReadS32(){return InternalRead<signed int>();}
 
@@ -107,7 +108,7 @@ class BinaryReader{
          * It advances the stream cursor.
          *
          * @return Read bits.
-         * @throws InternalDecompilerError if there is not enough data.
+         * @throws DecompilerException if there is not enough data.
          */
         signed short int ReadS16(){return InternalRead<signed short int>();}
 
@@ -117,7 +118,7 @@ class BinaryReader{
          * It advances the stream cursor.
          *
          * @return Read bits.
-         * @throws InternalDecompilerError if there is not enough data.
+         * @throws DecompilerException if there is not enough data.
          */
         unsigned short int ReadU16(){return InternalRead<unsigned short int>();}
 
@@ -127,7 +128,7 @@ class BinaryReader{
          * It advances the stream cursor.
          *
          * @return Read bits.
-         * @throws InternalDecompilerError if there is not enough data.
+         * @throws DecompilerException if there is not enough data.
          */
         unsigned char ReadU8(){return InternalRead<unsigned char>();}
 
@@ -137,7 +138,7 @@ class BinaryReader{
          * It advances the stream cursor.
          *
          * @return Read bits.
-         * @throws InternalDecompilerError if there is not enough data.
+         * @throws DecompilerException if there is not enough data.
          */
         signed char ReadS8(){return InternalRead<signed char>();}
 
@@ -149,12 +150,12 @@ class BinaryReader{
          * It advances the stream cursor.
          *
          * @return Read bits.
-         * @throws InternalDecompilerError if there is not enough data.
+         * @throws DecompilerException if there is not enough data.
          */
         template<class T> T InternalRead(){
             T r = {};
             if (!stream_.read(reinterpret_cast<char*>(&r), sizeof(r)))
-                throw InternalDecompilerError();
+                throw DecompilerException();
             return r;
         }
 

+ 1 - 1
V-Gears-Installer/include/decompiler/CodeGenerator.h

@@ -20,10 +20,10 @@
 #include <memory>
 #include <boost/intrusive_ptr.hpp>
 
+#include "DecompilerException.h"
 #include "Graph.h"
 #include "LuaLanguage.h"
 #include "value.h"
-#include "unknown_opcode_exception.h"
 
 
 class Engine;

+ 247 - 0
V-Gears-Installer/include/decompiler/DecompilerException.h

@@ -0,0 +1,247 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears 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.
+ */
+
+#pragma once
+
+#include <exception>
+#include <string>
+
+class DecompilerException : public std::exception{};
+
+/**
+ * Wrong type exception.
+ *
+ * Signals that an operation was performed on a Value that doesn't support the
+ * operation.
+ */
+class WrongTypeException : public DecompilerException{};
+
+/**
+ * Not implemented exception.
+ *
+ * Signals that a function is not implemented in the decompiler.
+ */
+class NotImplementedException : public DecompilerException{
+
+    public:
+
+        /**
+         * Constructor.
+         */
+        NotImplementedException() = default;
+};
+
+/**
+ * Invalid header exception.
+ *
+ * Signals that a script has an invalid header.
+ */
+class ScriptHeaderInvalidException : public DecompilerException{
+
+    public:
+
+        /**
+         * Constructor.
+         */
+        ScriptHeaderInvalidException() = default;
+};
+
+/**
+ * Unknown bank exception.
+ *
+ * Signals that an unknown bank has been tried to access.
+ */
+class UnknownBankException : public DecompilerException{
+
+    public:
+
+        /**
+         * Constructor.
+         */
+        UnknownBankException() = default;
+};
+
+/**
+ * Unknown opcode parameter exception.
+ *
+ * Signals that an opcode has an invalid parameter in a script.
+ */
+class UnknownOpcodeParameterException : public DecompilerException{
+
+    public:
+
+        /**
+         * Constructor.
+         *
+         * @param param[in] The unknown parameter.
+         */
+        UnknownOpcodeParameterException(std::string param);
+
+        /**
+         * Produces an error message.
+         *
+         * @return The error message.
+         */
+        virtual const char *what() const noexcept override;
+
+    private:
+
+        /**
+         * The error message.
+         */
+        std::string what_;
+};
+
+/**
+ * Unknown conditional operator exception.
+ *
+ * Signals that an unknown conditional operator has been found in a script.
+ */
+class UnknownConditionalOperatorException : public DecompilerException{
+
+    public:
+
+        /**
+         * Constructor.
+         *
+         * @param address[in] Address at which the operator has been found.
+         * @param op[in] The unknown operator.
+         */
+        UnknownConditionalOperatorException(unsigned int address, unsigned int op);
+
+        /**
+         * Produces an error message.
+         *
+         * @return The error message.
+         */
+        virtual const char *what() const noexcept override;
+
+    private:
+
+        /**
+         * The error message.
+         */
+        std::string what_;
+};
+
+/**
+ * Unknown opcode exception.
+ *
+ * Signals that an unknown opcode has been found in a script.
+ */
+class UnknownOpcodeException : public DecompilerException{
+
+    public:
+
+        /**
+         * Constructor.
+         *
+         * @param address[in] Address where the invalid opcode was found.
+         * @param opcode[in] The value of the invalid opcode.
+         */
+        UnknownOpcodeException(unsigned int address, unsigned int opcode);
+
+        /**
+         * Produces an error message.
+         *
+         * @return The error message.
+         */
+        virtual const char* what() const noexcept override;
+
+    private:
+
+        /**
+         * Retrieves an exception identifier.
+         *
+         * @return "Opcode".
+         */
+        virtual const char* Type() const;
+
+        /**
+         * Address where the invalid opcode was found.
+         */
+        unsigned int address_;
+
+        /**
+         * The value of the invalid opcode.
+         */
+        unsigned int opcode_;
+
+        /**
+         * Buffer for formatting the error message.
+         */
+        mutable char buffer_[255];
+};
+
+/**
+ * Unknown jump type exception.
+ *
+ * Signals that a jump is not a conditional jump neither an unconditional
+ * jump.
+ */
+class UnknownJumpTypeException : public DecompilerException{
+
+    public:
+
+        /**
+         * Constructor.
+         *
+         * @param address[in] Address where the jump opcode was found.
+         * @param opcode[in] The value of the jump opcode.
+         */
+        UnknownJumpTypeException(unsigned int address, unsigned int opcode);
+
+        /**
+         * Produces an error message.
+         *
+         * @return The error message.
+         */
+        virtual const char* what() const noexcept override;
+
+    private:
+
+        /**
+         * The error message.
+         */
+        std::string what_;
+};
+
+/**
+ * Unknown subopcode exception.
+ *
+ * Signals that an unknown subopcode has been found in a script.
+ */
+class UnknownSubOpcodeException : public UnknownOpcodeException{
+
+    public:
+
+        /**
+         * Constructor.
+         *
+         * @param address[in] Address where the invalid subopcode was found.
+         * @param opcode[in] The value of the invalid subopcode.
+         */
+        UnknownSubOpcodeException(unsigned int address, unsigned int opcode);
+
+    private:
+
+        /**
+         * Retrieves an exception identifier.
+         *
+         * @return "Subopcode".
+         */
+        virtual const char* Type() const override;
+
+};

+ 36 - 1
V-Gears-Installer/include/decompiler/Disassembler.h

@@ -18,9 +18,9 @@
 #include <iostream>
 #include <vector>
 #include "common/BinaryReader.h"
+#include "DecompilerException.h"
 #include "instruction/Instruction.h"
 #include "ObjectFactory.h"
-#include "unknown_opcode_exception.h"
 
 /**
  * Base class for disassemblers.
@@ -79,6 +79,35 @@ class Disassembler{
          */
         virtual void DoDumpDisassembly(std::ostream &output);
 
+        /**
+         * Read parameters and associate them with an instruction.
+         *
+         * @param inst[in] The instruction to associate the parameters with.
+         * @param types[in] NUL-terminated string describing the type of each
+         * parameter.
+         */
+        void ReadParams(InstPtr inst, const char *types);
+
+        /**
+         * Read parameters but it doesn't associate them with an instruction.
+         *
+         * @param inst[in] The instruction to associate the parameters with.
+         * Unused.
+         * @param types[in] NUL-terminated string describing the type of each
+         * parameter.
+         * @param params[in] Unused.
+         */
+        void ReadParams(InstPtr inst, const char *types, const std::vector<std::string>& params);
+
+        /**
+         * Reads data for a single parameter.
+         *
+         * @param inst The instruction the parameter will belong to. Unused.
+         * @param type Character describing the type of the parameter.
+         * @return The read data.
+         */
+        virtual ValuePtr ReadParameter(InstPtr inst, std::string type);
+
         /**
          * Used to perform file I/O.
          */
@@ -93,4 +122,10 @@ class Disassembler{
          * Base address where the script starts.
          */
         uint32 address_base_;
+
+        /**
+         * The current address.
+         */
+        uint32 address_;
+
 };

+ 96 - 0
V-Gears-Installer/include/decompiler/Stack.h

@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears 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.
+ */
+
+#pragma once
+
+#include <deque>
+#include <iostream>
+
+/**
+ * Stack class based on a deque.
+ */
+template<typename T> class Stack {
+
+    public:
+
+        /**
+         * Returns whether or not the stack is empty.
+         *
+         * @return True if the stack is empty, false if it is not.
+         */
+        bool IsEmpty() const{return stack_.empty();}
+
+        /**
+         * Push an item onto the stack.
+         *
+         * @param item[in] The item to push.
+         */
+        void Push(const T &item){stack_.push_front(item);}
+
+        /**
+         * Pop an item from the stack and return it.
+         *
+         * @return The value popped from the stack.
+         */
+        T Pop(){
+            T retval = stack_.front();
+            stack_.pop_front();
+            return retval;
+        }
+
+        /**
+         * Return the topmost item on the stack without removing it.
+         *
+         * @return The topmost item on the stack.
+         */
+        T &Peek(){return stack_.front();}
+
+        /**
+         * Return the topmost item on the stack without removing it.
+         *
+         * @return The topmost item on the stack.
+         */
+        const T &Peek() const{return stack_.front();}
+
+        /**
+         * Gets item on a specified stack position without removing it.
+         *
+         * @param pos[in] The number of items to skip on the stack.
+         * @return The desired item from the stack.
+         */
+        T &PeekPos(size_t pos){
+            if (pos >= stack_.size()) std::cerr << "WARNING: Looking outside stack\n";
+            return stack_.at(pos);
+        }
+
+        /**
+         * Gets item on a specified stack position without removing it.
+         *
+         * @param pos[in] The number of items to skip on the stack.
+         * @return The desired item from the stack.
+         */
+        const T &PeekPos(size_t pos) const{
+            if (pos >= stack_.size()) std::cerr << "WARNING: Looking outside stack\n";
+            return stack_.at(pos);
+        }
+
+    private:
+
+        /**
+         * The stack.
+         */
+        std::deque<T> stack_;
+};
+

+ 6 - 6
V-Gears-Installer/include/decompiler/field/FieldDisassembler.h

@@ -15,7 +15,7 @@
 
 #pragma once
 
-#include "decompiler/simple_disassembler.h"
+#include "decompiler/Disassembler.h"
 #include "decompiler/sudm.h"
 #include <array>
 
@@ -326,7 +326,7 @@ namespace FF7{
     /**
      * A disassebler for field maps.
      */
-    class FieldDisassembler : public SimpleDisassembler{
+    class FieldDisassembler : public Disassembler{
 
         public:
 
@@ -579,12 +579,12 @@ namespace FF7{
                  * Reads the header.
                  *
                  * @param reader[in] The reader used to read the header.
-                 * @throws FF7ScriptHeaderInvalidException If the magic number for
+                 * @throws ScriptHeaderInvalidException If the magic number for
                  * the field is wrong.
                  */
                 void Read(BinaryReader& reader){
                     magic = reader.ReadU16();
-                    if (magic != MAGIC) throw FF7ScriptHeaderInvalidException();
+                    if (magic != MAGIC) throw ScriptHeaderInvalidException();
                     number_of_entities = reader.ReadU8();
                     number_of_models = reader.ReadU8();
                     offset_to_strings = reader.ReadU16();
@@ -636,7 +636,7 @@ namespace FF7{
              * for it's entity.
              * @param is_end[in] Indicates if the script is the last one for
              * it's entity.
-             * @throws InternalDecompilerError for malformed scripts.
+             * @throws DecompilerException for malformed scripts.
              */
             void DisassembleIndivdualScript(
               std::string entity_name, size_t entity_index, size_t script_index,
@@ -740,7 +740,7 @@ namespace FF7{
                 this->insts_.back()->SetStackChange(0);
                 this->insts_.back()->SetName(std::string(name));
                 this->insts_.back()->SetCodeGenData("");
-                this->readParams(this->insts_.back(), argument_format);
+                this->ReadParams(this->insts_.back(), argument_format);
             }
 
             /**

+ 2 - 2
V-Gears-Installer/include/decompiler/field/FieldEngine.h

@@ -82,7 +82,7 @@ namespace FF7{
                      *
                      * @param index[in] Function index.
                      * @return Function name.
-                     * @throws InternalDecompilerError if there is no function
+                     * @throws DecompilerException if there is no function
                      * with the specified index.
                      * @todo What is a function here? An Opcode?
                      */
@@ -322,7 +322,7 @@ namespace FF7{
              * Retrieves an entity.
              *
              * @param index[in] Index of the entity to retrieve.
-             * @throws InternalDecompilerError if there is no entity at the
+             * @throws DecompilerException if there is no entity at the
              * specified index.
              */
             const Entity& EntityByIndex(size_t index) const;

+ 1 - 1
V-Gears-Installer/include/decompiler/instruction/Instruction.h

@@ -23,7 +23,7 @@
 #include "../RefCounted.h"
 #include "common/scummsys.h"
 #include "decompiler/value.h"
-#include "decompiler/wrongtype.h"
+#include "decompiler/DecompilerException.h"
 
 class CodeGenerator;
 

+ 0 - 119
V-Gears-Installer/include/decompiler/simple_disassembler.h

@@ -1,119 +0,0 @@
-/* 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_SIMPLE_DISASSEMBLER_H
-#define DEC_SIMPLE_DISASSEMBLER_H
-
-#include "Disassembler.h"
-
-/**
- * Simple disassembler acting as a base for instruction sets only consisting of simple instructions (opcode params...).
- */
-class SimpleDisassembler : public Disassembler {
-protected:
-	uint32 address_; ///< Variable to maintain the current address.
-
-	/**
-	 * Read parameters and associate them with an instruction.
-	 *
-	 * @param inst       The instruction to associate the parameters with.
-	 * @param typeString NUL-terminated string describing the type of each parameter.
-	 */
-	void readParams(InstPtr inst, const char *typeString);
-    void readParams(InstPtr inst, const char *typeString, const std::vector<std::string>& params);
-
-	/**
-	 * Reads data for a single parameter.
-	 *
-	 * @param inst The instruction the parameter will belong to. Used for reference in parameter reading.
-	 * @param type Character describing the type of the parameter.
-	 * @return The read data as a ValuePtr.
-	 */
-    virtual ValuePtr readParameter(InstPtr inst, std::string type);
-
-public:
-	/**
-	 * Constructor for SimpleDisassembler.
-	 *
-	 * @param insts Reference to the vector in which disassembled instructions should be placed.
-	 */
-	SimpleDisassembler(InstVec &insts);
-};
-
-#define INC_ADDR this->address_++;
-#define ADD_INST(category) this->insts_.push_back(new category());
-#define LAST_INST (this->insts_.back())
-
-#define START_OPCODES \
-	this->address_ = this->address_base_; \
-            	while (this->stream_->Position() != (unsigned int)this->stream_->Size()) { \
-		uint32 full_opcode = 0; \
-		uint8 opcode = this->stream_->ReadU8(); \
-		std::string opcodePrefix; \
-		switch (opcode) {
-#define END_OPCODES \
-		default: \
-			throw UnknownOpcodeException(this->address_, opcode);\
-		} \
-		INC_ADDR; \
-	}
-
-
-#define OPCODE_BASE(val) \
-	case val: \
-		full_opcode = (full_opcode << 8) + val;
-
-#define OPCODE_END break;
-
-#define OPCODE_BODY(name, category, stackChange, params, codeGenData) \
-		ADD_INST(category); \
-		LAST_INST->_opcode = full_opcode; \
-		LAST_INST->_address = this->address_; \
-		LAST_INST->_stackChange = stackChange; \
-		LAST_INST->_name = opcodePrefix + std::string(name); \
-		LAST_INST->_codeGenData = codeGenData; \
-		this->readParams(LAST_INST, params); \
-
-#define OPCODE_MD(val, name, category, stackChange, params, codeGenData) \
-	OPCODE_BASE(val)\
-		OPCODE_BODY(name, category, stackChange, params, codeGenData)\
-		OPCODE_END;
-
-#define OPCODE(val, name, category, stackChange, params) \
-	OPCODE_MD(val, name, category, stackChange, params, "")
-
-#define START_SUBOPCODE_WITH_PREFIX(val,prefix) \
-	OPCODE_BASE(val) \
-		opcodePrefix = prefix + std::string("."); \
-		opcode = this->stream_->ReadU8(); \
-		switch (opcode) {
-#define START_SUBOPCODE(val) \
-	OPCODE_BASE(val) \
-		opcode = this->stream_->ReadU8(); \
-		switch (opcode) {
-#define END_SUBOPCODE \
-		default: \
-			throw UnknownSubOpcodeException(this->address_, opcode);\
-		} \
-		INC_ADDR; \
-		OPCODE_END;
-
-#endif

+ 0 - 101
V-Gears-Installer/include/decompiler/stack.h

@@ -1,101 +0,0 @@
-/* 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_STACK_H
-#define DEC_STACK_H
-
-#include <deque>
-#include <iostream>
-
-/**
- * Stack class based on a deque.
- */
-template<typename T>
-class Stack {
-private:
-	std::deque<T> _stack; ///< Container used for the stack.
-public:
-
-	/**
-	 * Returns whether or not the stack is empty.
-	 *
-	 * @return true if the stack is empty, false if it is not.
-	 */
-	bool empty() const { return _stack.empty(); }
-
-	/**
-	 * Push an item onto the stack.
-	 *
-	 * @param item The item to push.
-	 */
-	void push(const T &item) { _stack.push_front(item); }
-
-	/**
-	 * Pop an item from the stack and return it.
-	 *
-	 * @return The value popped from the stack.
-	 */
-	T pop() {
-		T retval = _stack.front();
-		_stack.pop_front();
-		return retval;
-	}
-
-	/**
-	 * Return the topmost item on the stack without removing it.
-	 *
-	 * @return The topmost item on the stack.
-	 */
-	T &peek() { return _stack.front(); }
-
-	/**
-	 * Return the topmost item on the stack without removing it.
-	 *
-	 * @return The topmost item on the stack.
-	 */
-	const T &peek() const { return _stack.front(); }
-
-	/**
-	 * Return the item on the specificed stack position without removing it.
-	 *
-	 * @param pos The number of items to skip on the stack.
-	 * @return The desired item from the stack.
-	 */
-	T &peekPos(size_t pos) {
-		if (pos >= _stack.size())
-			std::cerr << "WARNING: Looking outside stack\n";
-		return _stack.at(pos);
-	}
-
-	/**
-	 * Return the item on the specificed stack position without removing it.
-	 *
-	 * @param pos The number of items to skip on the stack.
-	 * @return The desired item from the stack.
-	 */
-	const T &peekPos(size_t pos) const {
-		if (pos >= _stack.size())
-			std::cerr << "WARNING: Looking outside stack\n";
-		return _stack.at(pos);
-	}
-};
-
-#endif

+ 3 - 2
V-Gears-Installer/include/decompiler/sudm.h

@@ -18,7 +18,8 @@
 #include <map>
 #include <vector>
 #include <string>
-#include "unknown_opcode_exception.h"
+
+#include "DecompilerException.h"
 
 namespace SUDM{
 
@@ -232,7 +233,7 @@ namespace SUDM{
              * @param text_before[in] Raw text that is added at to the start of
              * the decompiled output.
              * @return A string with the decompiled script.
-             * @throws InternalDecompilerError on failure.
+             * @throws DecompilerException on failure.
              */
             DecompiledScript Decompile(
               std::string script_name, const std::vector<unsigned char>& script_bytes,

+ 0 - 141
V-Gears-Installer/include/decompiler/unknown_opcode_exception.h

@@ -1,141 +0,0 @@
-/* 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.
- */
-
-#pragma once
-
-#include <exception>
-#include <string>
-
-class InternalDecompilerError : public std::exception
-{
-public:
-
-};
-
-class NotImplementedException : public InternalDecompilerError
-{
-public:
-    NotImplementedException() = default;
-};
-
-class FF7ScriptHeaderInvalidException : public InternalDecompilerError
-{
-public:
-    FF7ScriptHeaderInvalidException() = default;
-};
-
-class UnknownBankException : public InternalDecompilerError
-{
-public:
-    UnknownBankException() = default;
-};
-
-class UnknownOpcodeParameterException : public InternalDecompilerError
-{
-public:
-    UnknownOpcodeParameterException(std::string param)
-    {
-        mWhat = "unknown opcode parameter string: " + param;
-    }
-
-    virtual const char *what() const noexcept override
-    {
-        return mWhat.c_str();
-    }
-
-private:
-    std::string mWhat = "Unknonw opcode";
-};
-
-class UnknownConditionalOperatorException : public InternalDecompilerError
-{
-public:
-    UnknownConditionalOperatorException(unsigned int address, unsigned int op)
-    {
-        mWhat = "unknown conditional operator: " + std::to_string(op) + " at address " + std::to_string(address);
-    }
-
-    virtual const char *what() const noexcept override
-    {
-        return mWhat.c_str();
-    }
-
-private:
-    std::string mWhat = "Unknown condicional operator";
-};
-
-
-/**
- * Exception representing an unknown opcode.
- */
-class UnknownOpcodeException : public InternalDecompilerError
-{
-    unsigned int _address; ///< Address where the invalid opcode was found.
-    unsigned int _opcode;   ///< The value of the invalid opcode.
-	mutable char _buf[255];  ///< Buffer for formatting the error message.
-
-public:
-	/**
-	 * Constructor for UnknownOpcodeException.
-	 *
-	 * @param address Address where the invalid opcode was found.
-	 * @param opcode  The value of the invalid opcode.
-	 */
-    UnknownOpcodeException(unsigned int address, unsigned int opcode);
-
-	/**
-	 * Description of the exception.
-	 */
-    virtual const char *what() const noexcept override;
-
-private:
-    virtual const char* Type() const { return "Opcode"; }
-};
-
-class UnknownJumpTypeException : public InternalDecompilerError
-{
-public:
-    UnknownJumpTypeException(unsigned int address, unsigned int opcode)
-    {
-        mWhat = "unknown jump type: " + std::to_string(opcode) + " at address " + std::to_string(address);
-    }
-
-    virtual const char *what() const noexcept override
-    {
-        return mWhat.c_str();
-    }
-
-private:
-    std::string mWhat = "Unknonw Jump type";
-};
-
-class UnknownSubOpcodeException : public UnknownOpcodeException
-{
-public:
-    UnknownSubOpcodeException(unsigned int address, unsigned int opcode)
-        : UnknownOpcodeException(address, opcode)
-    {
-
-    }
-private:
-    virtual const char* Type() const override { return "SubOpcode"; }
-
-};

+ 2 - 2
V-Gears-Installer/include/decompiler/value.h

@@ -30,8 +30,8 @@
 
 #include "common/scummsys.h"
 #include "RefCounted.h"
-#include "stack.h"
-#include "wrongtype.h"
+#include "Stack.h"
+#include "DecompilerException.h"
 
 class Value;
 

+ 3 - 3
V-Gears-Installer/include/decompiler/world/WorldDisassembler.h

@@ -15,13 +15,13 @@
 
 #pragma once
 
-#include "decompiler/simple_disassembler.h"
+#include "decompiler/Disassembler.h"
 
 namespace FF7{
 
     class WorldEngine;
 
-    class WorldDisassembler : public SimpleDisassembler{
+    class WorldDisassembler : public Disassembler{
 
         public:
 
@@ -71,7 +71,7 @@ namespace FF7{
                 this->insts_.back()->SetStackChange(0);
                 this->insts_.back()->SetName(std::string(name));
                 this->insts_.back()->SetCodeGenData("");
-                this->readParams(this->insts_.back(), argument_format);
+                this->ReadParams(this->insts_.back(), argument_format);
             }
 
             /**

+ 0 - 31
V-Gears-Installer/include/decompiler/wrongtype.h

@@ -1,31 +0,0 @@
-/* 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 WRONGTYPE_H
-#define WRONGTYPE_H
-
-/**
- * Exception signalling that an operation was performed on a Value that doesn't support the operation.
- */
-class WrongTypeException : public std::exception {
-};
-
-#endif

+ 9 - 9
V-Gears-Installer/src/decompiler/CodeGenerator.cpp

@@ -105,7 +105,7 @@ void CodeGenerator::AddArg(ValuePtr arg) {
 
 void CodeGenerator::ProcessSpecialMetadata(const InstPtr inst, char c, int) {
     switch (c){
-    case 'p': AddArg(stack_.pop()); break;
+    case 'p': AddArg(stack_.Pop()); break;
     default:
         std::cerr << boost::format("WARNING: Unknown character in metadata: %c\n") % c;
         break;
@@ -217,18 +217,18 @@ void CodeGenerator::ProcessCondJumpInst(const InstPtr inst){
                       << " " << target_lang_->Else() << " ";
                 }
             }
-            s << target_lang_->If(true) << stack_.pop()->negate() << target_lang_->If(false);
+            s << target_lang_->If(true) << stack_.Pop()->negate() << target_lang_->If(false);
             AddOutputLine(s.str(), cur_group_->coalesced_else, true);
             break;
         case GROUP_TYPE_WHILE:
-            s << target_lang_->WhileHeader(true) << stack_.pop()->negate()
+            s << target_lang_->WhileHeader(true) << stack_.Pop()->negate()
               << target_lang_->WhileHeader(false) << " "
               << target_lang_->StartBlock(LuaLanguage::BEGIN_WHILE);
             AddOutputLine(s.str(), false, true);
             break;
         case GROUP_TYPE_DO_WHILE:
             s << target_lang_->EndBlock(LuaLanguage::END_WHILE) <<  " "
-              << target_lang_->WhileHeader(true) << stack_.pop()
+              << target_lang_->WhileHeader(true) << stack_.Pop()
               << target_lang_->WhileHeader(false);
             AddOutputLine(s.str(), true, false);
             break;
@@ -262,7 +262,7 @@ void CodeGenerator::GeneratePass(InstVec& insts, const Graph& graph){
       fn != engine_->functions.end();
       ++ fn
     ){
-        while (!stack_.empty()) stack_.pop();
+        while (!stack_.IsEmpty()) stack_.Pop();
         GraphVertex entry_point = fn->second.vertex;
         std::string func_signature = ConstructFuncSignature(fn->second);
         // Write the function start.
@@ -278,10 +278,10 @@ void CodeGenerator::GeneratePass(InstVec& insts, const Graph& graph){
         // DFS from entry point to process each vertex.
         Stack<DFSEntry> dfs_stack;
         std::set<GraphVertex> seen;
-        dfs_stack.push(DFSEntry(entry_point, ValueStack()));
+        dfs_stack.Push(DFSEntry(entry_point, ValueStack()));
         seen.insert(entry_point);
-        while (!dfs_stack.empty()){
-            DFSEntry e = dfs_stack.pop();
+        while (!dfs_stack.IsEmpty()){
+            DFSEntry e = dfs_stack.Pop();
             GroupPtr tmp = GET(e.first);
             if ((*tmp->start)->GetAddress() > (*last_group->start)->GetAddress()) last_group = tmp;
             stack_ = e.second;
@@ -291,7 +291,7 @@ void CodeGenerator::GeneratePass(InstVec& insts, const Graph& graph){
             for (OutEdgeIterator i = r.first; i != r.second; ++ i){
                 GraphVertex target = boost::target(*i, graph_);
                 if (seen.find(target) == seen.end()){
-                    dfs_stack.push(DFSEntry(target, stack_));
+                    dfs_stack.Push(DFSEntry(target, stack_));
                     seen.insert(target);
                 }
             }

+ 6 - 5
V-Gears-Installer/src/decompiler/ControlFlow.cpp

@@ -18,7 +18,8 @@
 #include <set>
 #include <boost/format.hpp>
 #include "decompiler/ControlFlow.h"
-#include "decompiler/stack.h"
+
+#include "../../include/decompiler/Stack.h"
 
 /**
  * Adds a vertex to a group.
@@ -159,10 +160,10 @@ typedef std::pair<GraphVertex, int> LevelEntry;
 void ControlFlow::SetStackLevel(GraphVertex graph, int level){
     Stack<LevelEntry> level_stack;
     std::set<GraphVertex> seen;
-    level_stack.push(LevelEntry(graph, level));
+    level_stack.Push(LevelEntry(graph, level));
     seen.insert(graph);
-    while (!level_stack.empty()){
-        LevelEntry e = level_stack.pop();
+    while (!level_stack.IsEmpty()){
+        LevelEntry e = level_stack.Pop();
         GroupPtr gr = GET(e.first);
         if (gr->stack_level != -1){
             if (gr->stack_level != e.second)
@@ -177,7 +178,7 @@ void ControlFlow::SetStackLevel(GraphVertex graph, int level){
         for (OutEdgeIterator oe = r.first; oe != r.second; ++ oe){
             GraphVertex target = boost::target(*oe, graph_);
             if (seen.find(target) == seen.end()){
-                level_stack.push(LevelEntry(target, e.second + (*gr->start)->GetStackChange()));
+                level_stack.Push(LevelEntry(target, e.second + (*gr->start)->GetStackChange()));
                 seen.insert(target);
             }
         }

+ 54 - 0
V-Gears-Installer/src/decompiler/DecompilerException.cpp

@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2022 The V-Gears Team
+ *
+ * This file is part of V-Gears
+ *
+ * V-Gears is free software: you can redistribute it and/or modify it under
+ * terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.0 (GPLv3) of the License.
+ *
+ * V-Gears 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.
+ */
+
+#include "decompiler/DecompilerException.h"
+#include "common/scummsys.h"
+
+UnknownOpcodeParameterException::UnknownOpcodeParameterException(std::string param){
+    what_ = "Unknown opcode parameter string: " + param;
+}
+
+const char* UnknownOpcodeParameterException::what() const noexcept{return what_.c_str();}
+
+UnknownConditionalOperatorException::UnknownConditionalOperatorException(
+  unsigned int address, unsigned int op
+){
+    what_ = "Unknown conditional operator: " + std::to_string(op)
+      + " at address " + std::to_string(address);
+}
+
+const char* UnknownConditionalOperatorException::what() const noexcept{return what_.c_str();}
+
+UnknownOpcodeException::UnknownOpcodeException(uint32 address, uint32 opcode):
+  address_(address), opcode_(opcode){}
+
+const char* UnknownOpcodeException::what() const noexcept{
+    sprintf(buffer_, "Unknown %s (address: 0x%08x, opcode: 0x%04x)", Type(), address_, opcode_);
+    return buffer_;
+}
+
+const char*  UnknownOpcodeException::Type() const{return "Opcode";}
+
+UnknownJumpTypeException::UnknownJumpTypeException(unsigned int address, unsigned int opcode){
+    what_ = "Unknown jump type: " + std::to_string(opcode)
+      + " at address " + std::to_string(address);
+}
+
+const char* UnknownJumpTypeException::what() const noexcept{return what_.c_str();}
+
+UnknownSubOpcodeException::UnknownSubOpcodeException(unsigned int address, unsigned int opcode)
+  : UnknownOpcodeException(address, opcode){}
+
+const char* UnknownSubOpcodeException::Type() const{return "SubOpcode";}

+ 81 - 0
V-Gears-Installer/src/decompiler/Disassembler.cpp

@@ -37,3 +37,84 @@ void Disassembler::DumpDisassembly(std::ostream &output){
     Disassemble();
     DoDumpDisassembly(output);
 }
+
+/**
+ * NIB is probably for nibble.
+ *
+ * @param v[in] @todo Understand and document.
+ * @return @todo Understand and document.
+ */
+static inline unsigned int Nib2(unsigned int v){return (v & 0xF);}
+
+/**
+ * NIB is probably for nibble.
+ *
+ * @param v[in] @todo Understand and document.
+ * @return @todo Understand and document.
+ */
+static inline unsigned int Nib1(unsigned int v){return (v >> 4) & 0xF;}
+
+
+void Disassembler::ReadParams(InstPtr inst, const char *types){
+    // Handle [] blocks as working on an individual element (i.e a BYTE,WORD etc)
+    // this syntax allows picking of nibbles and bit fields into their own parameters.
+    while (*types){
+        std::string type(types, 1);
+        if (type == "N"){ // Read nibbles
+            const uint8 byte = stream_->ReadU8();
+            inst->AddParam(new IntValue(Nib1(byte), false));
+            inst->AddParam(new IntValue(Nib2(byte), false));
+            address_ ++;
+        }
+        else if (type == "U"){
+            const uint8 byte = stream_->ReadU8();
+            inst->AddParam(new IntValue((byte >> 5) & 0x7, false));
+            inst->AddParam(new IntValue((byte & 0x1F), false));
+            address_ ++;
+        }
+        else inst->AddParam(ReadParameter(inst, type));
+        types ++;
+    }
+}
+
+void Disassembler::ReadParams(
+  InstPtr inst, const char *types, const std::vector<std::string>& params
+){
+    while (*types){
+        std::string type(types, 1);
+        if (type == "N") address_ ++;
+        else if (type == "U") address_ ++;
+        types++;
+    }
+}
+
+ValuePtr Disassembler::ReadParameter(InstPtr inst, std::string type){
+    ValuePtr ret_val = NULL;
+    if (type == "b"){ // signed byte.
+        ret_val = new IntValue(stream_->ReadS8(), true);
+        address_++;
+    }
+    else if (type == "B"){ // unsigned byte.
+        ret_val = new IntValue((uint32)stream_->ReadU8(), false);
+        address_++;
+    }
+    else if (type == "s"){ // 16-bit signed integer (short), little-endian.
+        ret_val = new IntValue(stream_->ReadS16(), true);
+        address_ += 2;
+    }
+    else if (type == "w"){ // 16-bit unsigned integer (word), little-endian.
+        ret_val = new IntValue((uint32)stream_->ReadU16(), false);
+        address_ += 2;
+    }
+    else if (type == "i"){ // 32-bit signed integer (int), little-endian.
+        ret_val = new IntValue(stream_->ReadS32(), true);
+        address_ += 4;
+    }
+    else if (type == "d"){ // 32-bit unsigned integer (dword), little-endian.
+        ret_val = new IntValue(stream_->ReadU32(), false);
+        address_ += 4;
+    }
+    else throw UnknownOpcodeParameterException(type);
+    return ret_val;
+}
+

+ 1 - 1
V-Gears-Installer/src/decompiler/field/FieldCodeGenerator.cpp

@@ -154,7 +154,7 @@ void FF7::FieldCodeGenerator::Generate(InstVec& insts, const Graph& graph){
             }
             if ((*instruction)->IsCondJump()){
                 AddOutputLine(
-                  (boost::format("if (%s) then") % stack.pop()->getString()).str(), false, true
+                  (boost::format("if (%s) then") % stack.Pop()->getString()).str(), false, true
                 );
                 // If the next instruction is the last in the function, mark the next pass to
                 // add an 'end' after the instruction to close the if.

+ 4 - 5
V-Gears-Installer/src/decompiler/field/FieldDisassembler.cpp

@@ -19,8 +19,7 @@
 #include <boost/algorithm/string.hpp>
 #include "decompiler/field/FieldCodeGenerator.h"
 #include "decompiler/field/FieldDisassembler.h"
-
-#include "../../../include/decompiler/Engine.h"
+#include "decompiler/Engine.h"
 #include "decompiler/field/FieldEngine.h"
 #include "decompiler/field/instruction/FieldBackgroundInstruction.h"
 #include "decompiler/field/instruction/FieldCameraInstruction.h"
@@ -46,7 +45,7 @@ const int FF7::FieldDisassembler::NUM_SECTIONS(7);
 FF7::FieldDisassembler::FieldDisassembler(
   SUDM::IScriptFormatter& formatter, FieldEngine* engine,
   InstVec& insts, const std::vector<unsigned char>& raw_script_data
-): SimpleDisassembler(insts), engine_(engine), formatter_(formatter){
+): Disassembler(insts), engine_(engine), formatter_(formatter){
     loaded_from_raw_data_ = true;
     // If loading a raw section then skip the header section.
     section_pointers_size_ = 0;
@@ -57,7 +56,7 @@ FF7::FieldDisassembler::FieldDisassembler(
 
 FF7::FieldDisassembler::FieldDisassembler(
   SUDM::IScriptFormatter& formatter, FieldEngine *engine, InstVec &insts
-): SimpleDisassembler(insts), engine_(engine), formatter_(formatter){
+): Disassembler(insts), engine_(engine), formatter_(formatter){
     section_pointers_size_ = (sizeof(uint32) * NUM_SECTIONS);
 }
 
@@ -289,7 +288,7 @@ void FF7::FieldDisassembler::DisassembleIndivdualScript(
             );
             stream_pos = stream_->GetPosition();
             // ... but should end exactly on the end pos
-            if (stream_pos != end_pos) throw InternalDecompilerError();
+            if (stream_pos != end_pos) throw DecompilerException();
         }
     }
 }

+ 2 - 2
V-Gears-Installer/src/decompiler/field/FieldEngine.cpp

@@ -62,7 +62,7 @@ size_t FF7::FieldEngine::Entity::GetIndex() const{return index_;}
 
 std::string FF7::FieldEngine::Entity::FunctionByIndex(size_t index) const{
     auto it = functions_.find(index);
-    if (it == std::end(functions_)) throw InternalDecompilerError();
+    if (it == std::end(functions_)) throw DecompilerException();
     return it->second;
 }
 
@@ -230,7 +230,7 @@ bool FF7::FieldEngine::EntityIsLine(size_t entity_index){
 
 const FF7::FieldEngine::Entity& FF7::FieldEngine::EntityByIndex(size_t index) const{
     auto it = entity_index_map_.find(index);
-    if (it == std::end(entity_index_map_)) throw InternalDecompilerError();
+    if (it == std::end(entity_index_map_)) throw DecompilerException();
     return it->second;
 }
 

+ 4 - 4
V-Gears-Installer/src/decompiler/field/instruction/FieldCondJumpInstruction.cpp

@@ -50,7 +50,7 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
             if (param >= 512) param = param ^ 512;
         }
         ValuePtr v = new UnqotedStringValue(func_name + "(" + std::to_string(param) + ")");
-        stack.push(v);
+        stack.Push(v);
         return;
     }
     std::string op;
@@ -77,7 +77,7 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
                 op = "bit(" + params_[0]->getString() + ", " + params_[2]->getString()
                   + ", " + destination + ") == 1";
                 ValuePtr v = new UnqotedStringValue(op);
-                stack.push(v);
+                stack.Push(v);
             }
             return;
         case 0xA:
@@ -85,13 +85,13 @@ void FF7::FieldCondJumpInstruction::ProcessInst(
                 op = "bit(" + params_[0]->getString() + ", " + params_[2]->getString()
                   + ", " + destination + ") == 0";
                 ValuePtr v = new UnqotedStringValue(op);
-                stack.push(v);
+                stack.Push(v);
             }
             return;
         default: throw UnknownConditionalOperatorException(address_, type);
     }
     ValuePtr v = new BinaryOpValue(new VarValue(source), new VarValue(destination), op);
-    stack.push(v);
+    stack.Push(v);
 }
 
 uint32 FF7::FieldCondJumpInstruction::GetDestAddress() const{

+ 1 - 1
V-Gears-Installer/src/decompiler/field/instruction/FieldControlFlowInstruction.cpp

@@ -101,7 +101,7 @@ void FF7::FF7ControlFlowInstruction::ProcessREQEW(
           % entity.GetName() % script_name % priority
         ).str());
     }
-    catch (const InternalDecompilerError&){
+    catch (const DecompilerException&){
         code_gen->AddOutputLine((
           boost::format("-- ERROR call to non existing function index %1%")
           % params_[2]->getUnsigned()

+ 4 - 4
V-Gears-Installer/src/decompiler/instruction/BinaryOpStackInstruction.cpp

@@ -19,10 +19,10 @@
 void BinaryOpStackInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine* engine, CodeGenerator *code_gen
 ){
-    ValuePtr op1 = stack.pop();
-    ValuePtr op2 = stack.pop();
+    ValuePtr op1 = stack.Pop();
+    ValuePtr op2 = stack.Pop();
     if (code_gen->GetBinaryOrder() == FIFO_ARGUMENT_ORDER)
-        stack.push(new BinaryOpValue(op2, op1, code_gen_data_));
+        stack.Push(new BinaryOpValue(op2, op1, code_gen_data_));
     else if (code_gen->GetBinaryOrder() == LIFO_ARGUMENT_ORDER)
-        stack.push(new BinaryOpValue(op1, op2, code_gen_data_));
+        stack.Push(new BinaryOpValue(op1, op2, code_gen_data_));
 }

+ 1 - 1
V-Gears-Installer/src/decompiler/instruction/BoolNegateStackInstruction.cpp

@@ -17,4 +17,4 @@
 
 void BoolNegateStackInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine* engine, CodeGenerator* code_gen
-){stack.push(stack.pop()->negate());}
+){stack.Push(stack.Pop()->negate());}

+ 3 - 3
V-Gears-Installer/src/decompiler/instruction/DupStackInstruction.cpp

@@ -20,8 +20,8 @@ void DupStackInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine* engine, CodeGenerator *code_gen
 ){
     std::stringstream s;
-    ValuePtr p = stack.pop()->dup(s);
+    ValuePtr p = stack.Pop()->dup(s);
     if (s.str().length() > 0) code_gen->AddOutputLine(s.str());
-    stack.push(p);
-    stack.push(p);
+    stack.Push(p);
+    stack.Push(p);
 }

+ 2 - 2
V-Gears-Installer/src/decompiler/instruction/KernelCallStackInstruction.cpp

@@ -24,10 +24,10 @@ void KernelCallStackInstruction::ProcessInst(
     std::string metadata = (!returns_value ? code_gen_data_ : code_gen_data_.substr(1));
     for (size_t i = 0; i < metadata.length(); i ++)
         code_gen->ProcessSpecialMetadata(this, metadata[i], i);
-    stack.push(new CallValue(name_, code_gen->GetArgList()));
+    stack.Push(new CallValue(name_, code_gen->GetArgList()));
     if (!returns_value){
         std::stringstream stream;
-        stream << stack.pop() << ";";
+        stream << stack.Pop() << ";";
         code_gen->AddOutputLine(stream.str());
     }
 }

+ 1 - 1
V-Gears-Installer/src/decompiler/instruction/UnaryOpPostfixStackInstruction.cpp

@@ -17,4 +17,4 @@
 
 void UnaryOpPostfixStackInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine* engine, CodeGenerator* code_gen
-){stack.push(new UnaryOpValue(stack.pop(), code_gen_data_, true));}
+){stack.Push(new UnaryOpValue(stack.Pop(), code_gen_data_, true));}

+ 1 - 1
V-Gears-Installer/src/decompiler/instruction/UnaryOpPrefixStackInstruction.cpp

@@ -17,4 +17,4 @@
 
 void UnaryOpPrefixStackInstruction::ProcessInst(
   Function& function, ValueStack &stack, Engine* engine, CodeGenerator* code_gen
-){stack.push(new UnaryOpValue(stack.pop(), code_gen_data_, false));}
+){stack.Push(new UnaryOpValue(stack.Pop(), code_gen_data_, false));}

+ 0 - 156
V-Gears-Installer/src/decompiler/simple_disassembler.cpp

@@ -1,156 +0,0 @@
-/* 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.
- */
-
-#include "decompiler/simple_disassembler.h"
-
-SimpleDisassembler::SimpleDisassembler(InstVec &insts) 
-    : Disassembler(insts) 
-{
-
-}
-
-static inline unsigned int Nib2(unsigned int v)
-{
-    return (v & 0xF);
-}
-
-static inline unsigned int Nib1(unsigned int v)
-{
-    return (v >> 4) & 0xF;
-}
-
-// [8s]
-// [8u]
-// [16s]
-// [16u]
-// [32s]
-// [32u]
-// [4,4]
-// [8u...8u]
-
-// NBwwB
-// NBdB when N == 0
-// [ [8u EQ 0], [8u][8s][16s][8u] , [8u][8s][32u][8s] ]
-// j prefix = jump/label
-
-void SimpleDisassembler::readParams(InstPtr inst, const char *typeString)
-{
-    // Handle [] blocks as working on an individual element (i.e a BYTE,WORD etc)
-    // this syntax allows picking of nibbles and bit fields into their own parameters.
-    while (*typeString)
-    {
-        std::string typeStr(typeString, 1);
-        if (typeStr == "N") // Read nibbles 
-        {
-            const uint8 byte = stream_->ReadU8();
-
-            //inst->GetParams().push_back(new IntValue(Nib1(byte), false));
-            //inst->GetParams().push_back(new IntValue(Nib2(byte), false));
-            //inst->_params.push_back(new IntValue(Nib1(byte), false));
-            //inst->_params.push_back(new IntValue(Nib2(byte), false));
-            inst->AddParam(new IntValue(Nib1(byte), false));
-            inst->AddParam(new IntValue(Nib2(byte), false));
-
-            address_++;
-        }
-        else if (typeStr == "U")
-        {
-            const uint8 byte = stream_->ReadU8();
-            //inst->GetParams().push_back( new IntValue((byte >> 5) & 0x7, false));
-            //inst->GetParams().push_back( new IntValue((byte & 0x1F), false));
-            //inst->_params.push_back( new IntValue((byte >> 5) & 0x7, false));
-            //inst->_params.push_back( new IntValue((byte & 0x1F), false));
-            inst->AddParam( new IntValue((byte >> 5) & 0x7, false));
-            inst->AddParam( new IntValue((byte & 0x1F), false));
-            address_++;
-        }
-        else
-        {
-            //inst->GetParams().push_back(readParameter(inst, typeStr));
-            //inst->_params.push_back(readParameter(inst, typeStr));
-            inst->AddParam(readParameter(inst, typeStr));
-        }
-        typeString++;
-    }
-}
-
-void SimpleDisassembler::readParams(InstPtr inst, const char *typeString, const std::vector<std::string>& params)
-{
-    while (*typeString)
-    {
-        std::string typeStr(typeString, 1);
-        if (typeStr == "N") // Read nibbles 
-        {
-         
-            address_++;
-        }
-        else if (typeStr == "U")
-        {
-            address_++;
-        }
-        else
-        {
-           // inst->_params.push_back(readParameter(inst, typeStr));
-        }
-        typeString++;
-    }
-}
-
-ValuePtr SimpleDisassembler::readParameter(InstPtr inst, std::string type) {
-    ValuePtr retval = NULL;
-
-    if (type == "b") // signed byte
-    {
-        retval = new IntValue(stream_->ReadS8(), true);
-        address_++;
-    }
-    else if (type == "B") // unsigned byte
-    {
-        retval = new IntValue((uint32)stream_->ReadU8(), false);
-        address_++;
-    }
-    else if (type == "s") // 16-bit signed integer (short), little-endian
-    {
-        retval = new IntValue(stream_->ReadS16(), true);
-        address_ += 2;
-    }
-    else if (type == "w") // 16-bit unsigned integer (word), little-endian
-    {
-        retval = new IntValue((uint32)stream_->ReadU16(), false);
-        address_ += 2;
-    }
-    else if (type == "i") // 32-bit signed integer (int), little-endian
-    {
-        retval = new IntValue(stream_->ReadS32(), true);
-        address_ += 4;
-    }
-    else if (type == "d") // 32-bit unsigned integer (dword), little-endian
-    {
-        retval = new IntValue(stream_->ReadU32(), false);
-        address_ += 4;
-    }
-    else
-    {
-        throw UnknownOpcodeParameterException(type);
-    }
-    return retval;
-}
-

+ 0 - 34
V-Gears-Installer/src/decompiler/unknown_opcode_exception.cpp

@@ -1,34 +0,0 @@
-/* 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.
- */
-
-#include "decompiler/unknown_opcode_exception.h"
-#include "common/scummsys.h"
-
-UnknownOpcodeException::UnknownOpcodeException(uint32 address, uint32 opcode) {
-	_address = address;
-	_opcode = opcode;
-}
-
-const char *UnknownOpcodeException::what() const noexcept
-{
-	sprintf(_buf, "Unknown %s (address: 0x%08x, opcode: 0x%04x)", Type(), _address, _opcode);
-	return _buf;
-}

+ 2 - 2
V-Gears-Installer/src/decompiler/world/WorldDisassembler.cpp

@@ -27,8 +27,8 @@
 #include "decompiler/world/instruction/WorldSubStackInstruction.h"
 #include "decompiler/world/instruction/WorldUncondJumpInstruction.h"
 
-FF7::WorldDisassembler::WorldDisassembler(WorldEngine*, InstVec &insts, int script_number)
-  : SimpleDisassembler(insts), script_number_(script_number){}
+FF7::WorldDisassembler::WorldDisassembler(WorldEngine*, InstVec &insts, int script_number):
+  Disassembler(insts), script_number_(script_number){}
 
 FF7::WorldDisassembler::~WorldDisassembler(){}
 

+ 27 - 27
V-Gears-Installer/src/decompiler/world/instruction/WorldKernelCallInstruction.cpp

@@ -31,72 +31,72 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
     std::string func;
     switch (opcode_){
         case 0x203: func = "return;"; break;
-        case 0x317: func = "TriggerBattle(" + stack.pop()->getString() + ");"; break;
+        case 0x317: func = "TriggerBattle(" + stack.Pop()->getString() + ");"; break;
         case 0x324:
             // x, y, w, h
             func = "SetWindowDimensions("
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ", "
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ", "
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x32D: func = "WaitForWindowReady();"; break;
-        case 0x325: func = "SetWindowMessage(" + stack.pop()->getString() + ");"; break;
+        case 0x325: func = "SetWindowMessage(" + stack.Pop()->getString() + ");"; break;
         case 0x333:
             func = "Unknown333("
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x308:
             func = "SetActiveEntityMeshCoordinates("
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x309:
             func = "SetActiveEntityMeshCoordinatesInMesh("
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x32e: func = "WaitForMessageAcknowledge();"; break;
         case 0x32c:
             // Mode, Permanency.
             func = "SetWindowParameters("
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x318:
             func = "EnterFieldScene("
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x348:
-            func = "FadeIn(" + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+            func = "FadeIn(" + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x33b:
-            func = "FadeOut(" + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+            func = "FadeOut(" + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x310:
             func = "SetActivePoint("
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x311:
             func = "SetLightMeshCoordinates("
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
         case 0x312:
             func = "SetLightMeshCoordinatesInMesh("
-              + stack.pop()->getString() + ", " + stack.pop()->getString() + ");";
+              + stack.Pop()->getString() + ", " + stack.Pop()->getString() + ");";
             break;
-        case 0x31D: func = "PlaySoundEffect(" + stack.pop()->getString() + ");"; break;
-        case 0x328: func = "SetActiveEntityDirection(" + stack.pop()->getString() + ");"; break;
+        case 0x31D: func = "PlaySoundEffect(" + stack.Pop()->getString() + ");"; break;
+        case 0x328: func = "SetActiveEntityDirection(" + stack.Pop()->getString() + ");"; break;
         case 0x336: // Honor walk mesh.
         case 0x303:
-            func = "SetActiveEntityMovespeed(" + stack.pop()->getString() + ");";
+            func = "SetActiveEntityMovespeed(" + stack.Pop()->getString() + ");";
             break;
         case 0x304:
-            func = "SetActiveEntityDirectionAndFacing(" + stack.pop()->getString() + ");";
+            func = "SetActiveEntityDirectionAndFacing(" + stack.Pop()->getString() + ");";
             break;
-        case 0x32b: func = "SetBattleLock(" + stack.pop()->getString() + ");"; break;
-        case 0x305: func = "SetWaitFrames(" + stack.pop()->getString() + ");"; break;
-        case 0x33e: func = "Unknown_AKAO(" + stack.pop()->getString() + ");"; break;
+        case 0x32b: func = "SetBattleLock(" + stack.Pop()->getString() + ");"; break;
+        case 0x305: func = "SetWaitFrames(" + stack.Pop()->getString() + ");"; break;
+        case 0x33e: func = "Unknown_AKAO(" + stack.Pop()->getString() + ");"; break;
         case 0x306: func = "Wait();"; break;
-        case 0x350: func = "SetMeteorTexture(" + stack.pop()->getString() + ");"; break;
+        case 0x350: func = "SetMeteorTexture(" + stack.Pop()->getString() + ");"; break;
         case 0x34b:
             {
-                std::string type = stack.pop()->getString();
+                std::string type = stack.Pop()->getString();
                 switch (std::stoi(type)){
                     case 0: type = "yellow"; break;
                     case 1: type = "green"; break;
@@ -109,7 +109,7 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
             break;
         case 0x34c:
             {
-                std::string type = stack.pop()->getString();
+                std::string type = stack.Pop()->getString();
                 switch (std::stoi(type)){
                     case 0: type = "red"; break;
                     case 1: type = "blue"; break;
@@ -122,7 +122,7 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
             break;
         case 0x349:
             {
-                std::string type = stack.pop()->getString();
+                std::string type = stack.Pop()->getString();
                 std::string comment = "// ";
                 switch (std::stoi(type)){
                     case 0: comment += "before temple of the ancients,"; break;
@@ -137,7 +137,7 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
             break;
         case 0x300:
             {
-                std::string type = stack.pop()->getString();
+                std::string type = stack.Pop()->getString();
                 std::string comment = "// ";
                 try{
                     switch (std::stoi(type)){
@@ -174,7 +174,7 @@ void FF7::WorldKernelCallInstruction::ProcessInst(
                 func = "LoadModel(" + type + "); " + comment;
             }
             break;
-        case 0x307: func = "SetControlLock(" + stack.pop()->getString() + ");"; break;
+        case 0x307: func = "SetControlLock(" + stack.Pop()->getString() + ");"; break;
         case 0x30c: func = "EnterVehicle();"; break;
         default: func = "kernel_unknown_" + AddressValue(opcode_).getString() + "();"; break;
     }

+ 1 - 3
V-Gears-Installer/src/decompiler/world/instruction/WorldLoadBankInstruction.cpp

@@ -26,6 +26,4 @@
 
 void FF7::WorldLoadBankInstruction::ProcessInst(
   Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
-){
-    stack.push(new WorldEngine::BankValue("Read(" + params_[0]->getString() + ")"));
-}
+){stack.Push(new WorldEngine::BankValue("Read(" + params_[0]->getString() + ")"));}

+ 1 - 1
V-Gears-Installer/src/decompiler/world/instruction/WorldLoadInstruction.cpp

@@ -27,5 +27,5 @@
 void FF7::WorldLoadInstruction::ProcessInst(
   Function &function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
-    stack.push(new VarValue(params_[0]->getString()));
+    stack.Push(new VarValue(params_[0]->getString()));
 }

+ 1 - 1
V-Gears-Installer/src/decompiler/world/instruction/WorldStackInstruction.cpp

@@ -26,7 +26,7 @@
 #include "decompiler/world/WorldDisassembler.h"
 
 void FF7::WorldStackInstruction::ProcessInst(
-    Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+  Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
     // TODO
 }

+ 3 - 3
V-Gears-Installer/src/decompiler/world/instruction/WorldStoreInstruction.cpp

@@ -26,11 +26,11 @@
 #include "decompiler/world/WorldDisassembler.h"
 
 void FF7::WorldStoreInstruction::ProcessInst(
-    Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+  Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
-    std::string value = stack.pop()->getString();
+    std::string value = stack.Pop()->getString();
     // If the bank address is from a load bank instruction, then only
     // the bank address is needed, not whats *at* the bank address.
-    ValuePtr bank_addr = stack.pop();
+    ValuePtr bank_addr = stack.Pop();
     code_gen->AddOutputLine("Write(" + bank_addr->getString() + ", " + value + ");");
 }

+ 3 - 3
V-Gears-Installer/src/decompiler/world/instruction/WorldSubStackInstruction.cpp

@@ -36,7 +36,7 @@ void FF7::WorldSubStackInstruction::ProcessInst(
         case 0xc0: op = "|"; break;
         case 0x15: // neg
         case 0x17: // not
-            stack.push(stack.pop()->negate());
+            stack.Push(stack.Pop()->negate());
             return;
             break;
         case 0x30: op = "*";break;
@@ -48,6 +48,6 @@ void FF7::WorldSubStackInstruction::ProcessInst(
         case 0x51: op = "<<"; break;
         default:op = "unknown_operation";
     }
-    std::string value = stack.pop()->getString() + " " + op + " " + stack.pop()->getString();
-    stack.push(new VarValue(value));
+    std::string value = stack.Pop()->getString() + " " + op + " " + stack.Pop()->getString();
+    stack.Push(new VarValue(value));
 }

+ 1 - 1
V-Gears-Installer/src/decompiler/world/instruction/WorldUncondJumpInstruction.cpp

@@ -44,7 +44,7 @@ std::ostream& FF7::WorldUncondJumpInstruction::Print(std::ostream &output) const
 
 
 void FF7::WorldUncondJumpInstruction::ProcessInst(
-    Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
+  Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
 ){
     // TODO
 }

+ 3 - 3
V-Gears-Installer/src/ff7DataInstaller.cpp

@@ -657,7 +657,7 @@ static void FF7PcFieldToVGearsField(
               << field->getName() << "for writing." << std::endl;
         }
     }
-    catch (const ::InternalDecompilerError& ex){
+    catch (const ::DecompilerException& ex){
         write_output_line(
           "[ERROR] Internal decompiler error in field " + field->getName() + ": " + ex.what()
         );
@@ -1108,8 +1108,8 @@ static void CollectSpawnPoints(
           field->getName(), raw_field_data, formatter, "", "EntityContainer = {}\n\n"
         );
     }
-    catch (const ::InternalDecompilerError& ex){
-        std::cerr << "CollectSpawnPoints: InternalDecompilerError: " << ex.what() << std::endl;
+    catch (const ::DecompilerException& ex){
+        std::cerr << "CollectSpawnPoints: DecompilerException: " << ex.what() << std::endl;
     }
     const VGears::TriggersFilePtr& triggers = field->GetTriggers();
     const auto& gateways = triggers->GetGateways();