PageRenderTime 360ms CodeModel.GetById 112ms app.highlight 116ms RepoModel.GetById 129ms app.codeStats 0ms

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