gmCodeGen.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. _____ __ ___ __ ____ _ __
  3. / ___/__ ___ _ ___ / |/ /__ ___ / /_____ __ __/ __/_______(_)__ / /_
  4. / (_ / _ `/ ' \/ -_) /|_/ / _ \/ _ \/ '_/ -_) // /\ \/ __/ __/ / _ \/ __/
  5. \___/\_,_/_/_/_/\__/_/ /_/\___/_//_/_/\_\\__/\_, /___/\__/_/ /_/ .__/\__/
  6. /___/ /_/
  7. See Copyright Notice in gmMachine.h
  8. */
  9. #ifndef _GMCODEGEN_H_
  10. #define _GMCODEGEN_H_
  11. #include "gmConfig.h"
  12. #include "gmLog.h"
  13. #include "gmCodeGenHooks.h"
  14. // fwd decl
  15. struct gmCodeTreeNode;
  16. /// \class gmCodeGen
  17. /// \brief gmCodeGen will create byte code for a given code tree. after parsing script into a code tree using gmCodeTree,
  18. /// turn it into byte code using this class. After the code gen has been run, the gmCodeTree may be unlocked.
  19. /// Note that the code tree is parsed into a set of functions authored using a gmCodeGenHooks implementation.
  20. class gmCodeGen
  21. {
  22. public:
  23. /// \brief Get() will return the singleton code generator.
  24. static gmCodeGen& Get();
  25. /// \brief FreeMemory() will free all memory allocated by the code tree. must be unlocked
  26. virtual void FreeMemory() = 0;
  27. /// \brief Lock() will create the byte code for the given gode tree.
  28. /// \param a_codeTree is the code tree.
  29. /// \param a_hooks is the byte code authoring object.
  30. /// \param a_debug is true if debug info is required.
  31. /// \param a_log is the compile log.
  32. /// \return the number of errors encounted
  33. virtual int Lock(const gmCodeTreeNode * a_codeTree, gmCodeGenHooks * a_hooks, bool a_debug, gmLog * a_log) = 0;
  34. /// \brief Unlock() will reset the code generator.
  35. virtual int Unlock() = 0;
  36. };
  37. #endif // _GMCODEGEN_H_