PageRenderTime 21ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/lscript/lscript_compile/lscript_bytecode.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 89 lines | 50 code | 14 blank | 25 comment | 0 complexity | f8aa74befabb6c6159b228bcc7778dfb MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file lscript_bytecode.h
  3. * @brief classes to build actual bytecode
  4. *
  5. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LSCRIPT_BYTECODE_H
  27. #define LL_LSCRIPT_BYTECODE_H
  28. #include "lscript_byteconvert.h"
  29. #include "lscript_scope.h"
  30. class LLScriptJumpTable
  31. {
  32. public:
  33. LLScriptJumpTable();
  34. ~LLScriptJumpTable();
  35. void addLabel(char *name, S32 offset);
  36. void addJump(char *name, S32 offset);
  37. LLMap<char *, S32 *> mLabelMap;
  38. LLMap<char *, S32 *> mJumpMap;
  39. };
  40. class LLScriptByteCodeChunk
  41. {
  42. public:
  43. LLScriptByteCodeChunk(BOOL b_need_jumps);
  44. ~LLScriptByteCodeChunk();
  45. void addByte(U8 byte);
  46. void addU16(U16 data);
  47. void addBytes(const U8 *bytes, S32 size);
  48. void addBytes(const char *bytes, S32 size);
  49. void addBytes(S32 size);
  50. void addBytesDontInc(S32 size);
  51. void addInteger(S32 value);
  52. void addFloat(F32 value);
  53. void addLabel(char *name);
  54. void addJump(char *name);
  55. void connectJumps();
  56. U8 *mCodeChunk;
  57. S32 mCurrentOffset;
  58. LLScriptJumpTable *mJumpTable;
  59. };
  60. class LLScriptScriptCodeChunk
  61. {
  62. public:
  63. LLScriptScriptCodeChunk(S32 total_size);
  64. ~LLScriptScriptCodeChunk();
  65. void build(LLFILE *efp, LLFILE *bcfp);
  66. LLScriptByteCodeChunk *mRegisters;
  67. LLScriptByteCodeChunk *mGlobalVariables;
  68. LLScriptByteCodeChunk *mGlobalFunctions;
  69. LLScriptByteCodeChunk *mStates;
  70. LLScriptByteCodeChunk *mHeap;
  71. S32 mTotalSize;
  72. U8 *mCompleteCode;
  73. };
  74. extern LLScriptScriptCodeChunk *gScriptCodeChunk;
  75. #endif