codegen.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* ScummVM Tools
  2. *
  3. * ScummVM Tools is the legal property of its developers, whose
  4. * names are too numerous to list here. Please refer to the
  5. * COPYRIGHT file distributed with this source distribution.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  20. */
  21. #ifndef SCUMM_V6_CODEGEN_H
  22. #define SCUMM_V6_CODEGEN_H
  23. #include "../decompiler_codegen.h"
  24. namespace Scumm {
  25. namespace v6 {
  26. /**
  27. * SCUMM v6 list value.
  28. */
  29. class ListValue : public Value {
  30. protected:
  31. const ValueList _items; ///< The list items.
  32. public:
  33. ListValue(const ListValue&) = delete;
  34. ListValue& operator = (const ListValue&) = delete;
  35. /**
  36. * Constructor for ListValue.
  37. *
  38. * @param items The list items, stored left-to-right.
  39. */
  40. ListValue(ValueList items) : _items(items) { }
  41. virtual std::ostream &print(std::ostream &output) const;
  42. };
  43. /**
  44. * SCUMMv6 code generator.
  45. */
  46. class Scummv6CodeGenerator : public CodeGenerator {
  47. public:
  48. /**
  49. * Constructor for Scumm::v6::CodeGenerator.
  50. *
  51. * @param engine Pointer to the Engine used for the script.
  52. * @param output The std::ostream to output the code to.
  53. */
  54. Scummv6CodeGenerator(Engine *engine, std::ostream &output) : CodeGenerator(engine, output, kFIFOArgOrder, kFIFOArgOrder) {}
  55. /**
  56. * Get the name associated with a variable ID.
  57. *
  58. * @param varID The ID to get the name for.
  59. * @return Pointer to char array containing the name of the variable, or NULL if no name exists.
  60. */
  61. const char *getVarName(uint16 varID);
  62. /**
  63. * Decode a variable ID to a name.
  64. *
  65. * @param varID The ID to decode.
  66. * @return The decoded variable name.
  67. */
  68. std::string decodeVarName(uint16 varID);
  69. /**
  70. * Decode an array ID to a name.
  71. *
  72. * @param arrID The ID to decode.
  73. * @return The decoded array name.
  74. */
  75. std::string decodeArrayName(uint16 arrID);
  76. /**
  77. * Creates a ListValue from the stack.
  78. *
  79. * @return The ListValue created from the stack.
  80. */
  81. ValuePtr createListValue();
  82. virtual void processSpecialMetadata(const InstPtr inst, char c, int pos);
  83. };
  84. } // End of namespace v6
  85. } // End of namespace Scumm
  86. #endif