WorldCodeGenerator.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * V-Gears
  3. * Copyright (C) 2022 V-Gears Team
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program 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. * You should have received a copy of the GNU General Public License
  16. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #pragma once
  19. #include "decompiler/CodeGenerator.h"
  20. class WorldCodeGenerator : public CodeGenerator{
  21. public:
  22. /**
  23. * Constructor.
  24. *
  25. * @param engine[in] The engine.
  26. * @param output[out] The generated script.
  27. */
  28. WorldCodeGenerator(Engine *engine, std::ostream &output);
  29. /**
  30. * Finds the first function call.
  31. *
  32. * @return A pointer to the first call instruction.
  33. */
  34. const InstPtr FindFirstCall();
  35. /**
  36. * Finds the last function call.
  37. *
  38. * @return A pointer to the last call instruction.
  39. */
  40. const InstPtr FindLastCall();
  41. /**
  42. * Processes special metadata in an instruction.
  43. *
  44. * @param inst[in] The instruction to process.
  45. * @param c[in]
  46. * @param pos[in]
  47. * @todo understand and document.
  48. */
  49. virtual void ProcessSpecialMetadata(const InstPtr inst, char c, int pos);
  50. protected:
  51. /**
  52. * Constructs the function signature.
  53. *
  54. * The function signature is the LUA function declaration, and it
  55. * looks like this:
  56. *
  57. * <function_name> = function(self)
  58. *
  59. * @param function[in] The function to construct the signature for.
  60. * @return The function signature.
  61. */
  62. std::string ConstructFuncSignature(const Function &function);
  63. };