WorldUncondJumpInstruction.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Copyright (C) 2022 V-Gears Team
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include "decompiler/instruction/UncondJumpInstruction.h"
  19. #include "decompiler/world/WorldEngine.h"
  20. /**
  21. * An unconditional jump instruction.
  22. */
  23. class WorldUncondJumpInstruction : public UncondJumpInstruction{
  24. public:
  25. /**
  26. * Constructor.
  27. */
  28. WorldUncondJumpInstruction();
  29. /**
  30. * Indicates if the instruction is a function call.
  31. *
  32. * @return true if the instruction is a function call, false if not.
  33. */
  34. virtual bool IsFuncCall() const;
  35. /**
  36. * Indicates if the instruction is an unconditional jump.
  37. *
  38. * @return true if the instruction is an unconditional jump, false if
  39. * it's not.
  40. */
  41. virtual bool IsUncondJump() const;
  42. /**
  43. * Retrieves the destination address of the jump.
  44. *
  45. * @return The offset (number of bytes) to jump from the beginning of
  46. * the instruction.
  47. */
  48. virtual uint32 GetDestAddress() const;
  49. /**
  50. * Prints the instruction
  51. *
  52. * @param[in] output The stream to print the instruction to.
  53. * @return The same output.
  54. */
  55. virtual std::ostream& Print(std::ostream &output) const override;
  56. /**
  57. * Processes the instruction.
  58. *
  59. * @param function[in] Function to process.
  60. * @param stack[out] Function stack.
  61. * @param engine[in] Engine.
  62. * @param code_gen[in] Code generator.
  63. */
  64. virtual void ProcessInst(
  65. Function& function, ValueStack &stack, Engine *engine, CodeGenerator *code_gen
  66. ) override;
  67. private:
  68. /**
  69. * Whether or not this is really a call to a script function.
  70. */
  71. bool is_call_;
  72. };