/indra/lscript/lscript_compile/lscript_error.h

https://bitbucket.org/lindenlab/viewer-beta/ · C++ Header · 152 lines · 102 code · 24 blank · 26 comment · 0 complexity · 6c2efd38d8d9f254500263ed61ac5e7b MD5 · raw file

  1. /**
  2. * @file lscript_error.h
  3. * @brief error reporting class and strings
  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_ERROR_H
  27. #define LL_LSCRIPT_ERROR_H
  28. #include "lscript_scope.h"
  29. typedef enum e_lscript_compile_pass
  30. {
  31. LSCP_INVALID,
  32. LSCP_PRETTY_PRINT,
  33. LSCP_PRUNE,
  34. LSCP_SCOPE_PASS1,
  35. LSCP_SCOPE_PASS2,
  36. LSCP_TYPE,
  37. LSCP_RESOURCE,
  38. LSCP_EMIT_ASSEMBLY,
  39. LSCP_EMIT_BYTE_CODE,
  40. LSCP_DETERMINE_HANDLERS,
  41. LSCP_LIST_BUILD_SIMPLE,
  42. LSCP_TO_STACK,
  43. LSCP_BUILD_FUNCTION_ARGS,
  44. LSCP_EMIT_CIL_ASSEMBLY,
  45. LSCP_EOF
  46. } LSCRIPTCompilePass;
  47. typedef enum e_lscript_prune_type
  48. {
  49. LSPRUNE_INVALID,
  50. LSPRUNE_GLOBAL_VOIDS,
  51. LSPRUNE_GLOBAL_NON_VOIDS,
  52. LSPRUNE_EVENTS,
  53. LSPRUNE_DEAD_CODE,
  54. LSPRUNE_EOF
  55. } LSCRIPTPruneType;
  56. extern S32 gColumn;
  57. extern S32 gLine;
  58. extern S32 gInternalColumn;
  59. extern S32 gInternalLine;
  60. // used to describe where in the file this piece is
  61. class LLScriptByteCodeChunk;
  62. class LLScriptLibData;
  63. class LLScriptFilePosition
  64. {
  65. public:
  66. LLScriptFilePosition(S32 line, S32 col)
  67. : mLineNumber(line), mColumnNumber(col), mByteOffset(0), mByteSize(0)
  68. {
  69. }
  70. virtual ~LLScriptFilePosition() {}
  71. virtual void recurse(LLFILE *fp, S32 tabs, S32 tabsize,
  72. LSCRIPTCompilePass pass, LSCRIPTPruneType ptype, BOOL &prunearg,
  73. LLScriptScope *scope, LSCRIPTType &type, LSCRIPTType basetype, U64 &count,
  74. LLScriptByteCodeChunk *chunk, LLScriptByteCodeChunk *heap, S32 stacksize, LLScriptScopeEntry *entry, S32 entrycount, LLScriptLibData **ldata) = 0;
  75. virtual S32 getSize() = 0;
  76. void fdotabs(LLFILE *fp, S32 tabs, S32 tabsize);
  77. S32 mLineNumber;
  78. S32 mColumnNumber;
  79. S32 mByteOffset;
  80. S32 mByteSize;
  81. };
  82. typedef enum e_lscript_warnings
  83. {
  84. LSWARN_INVALID,
  85. LSWARN_DEAD_CODE,
  86. LSWARN_EOF
  87. } LSCRIPTWarnings;
  88. typedef enum e_lscript_errors
  89. {
  90. LSERROR_INVALID,
  91. LSERROR_SYNTAX_ERROR,
  92. LSERROR_NO_RETURN,
  93. LSERROR_INVALID_VOID_RETURN,
  94. LSERROR_INVALID_RETURN,
  95. LSERROR_STATE_CHANGE_IN_GLOBAL,
  96. LSERROR_DUPLICATE_NAME,
  97. LSERROR_UNDEFINED_NAME,
  98. LSERROR_TYPE_MISMATCH,
  99. LSERROR_EXPRESSION_ON_LVALUE,
  100. LSERROR_ASSEMBLE_OUT_OF_MEMORY,
  101. LSERROR_FUNCTION_TYPE_ERROR,
  102. LSERROR_VECTOR_METHOD_ERROR,
  103. LSERROR_NO_LISTS_IN_LISTS,
  104. LSERROR_NO_UNITIALIZED_VARIABLES_IN_LISTS,
  105. LSERROR_NEED_NEW_SCOPE,
  106. LSERROR_CIL_ASSEMBLER_FAILED = 16, // Mono build error.
  107. LSERROR_BYTECODE_TRANSFORM_FAILED = 17, // Mono build error.
  108. LSERROR_BYTECODE_VERIFICATION_FAILED, // Mono build error.
  109. LSERROR_EOF
  110. } LSCRIPTErrors;
  111. class LLScriptGenerateErrorText
  112. {
  113. public:
  114. LLScriptGenerateErrorText() { init(); }
  115. ~LLScriptGenerateErrorText() {}
  116. void init() { mTotalErrors = 0; mTotalWarnings = 0; }
  117. void writeWarning(LLFILE *fp, LLScriptFilePosition *pos, LSCRIPTWarnings warning);
  118. void writeWarning(LLFILE *fp, S32 line, S32 col, LSCRIPTWarnings warning);
  119. void writeError(LLFILE *fp, LLScriptFilePosition *pos, LSCRIPTErrors error);
  120. void writeError(LLFILE *fp, S32 line, S32 col, LSCRIPTErrors error);
  121. BOOL getErrors() { return mTotalErrors; }
  122. BOOL getWarnings() { return mTotalWarnings; }
  123. S32 mTotalErrors;
  124. S32 mTotalWarnings;
  125. };
  126. std::string getLScriptErrorString(LSCRIPTErrors error);
  127. extern LLScriptGenerateErrorText gErrorToText;
  128. #endif