lscript_error.cpp

Go to the documentation of this file.
00001 
00032 #include "linden_common.h"
00033 
00034 #include "lscript_error.h"
00035 
00036 S32 gColumn = 0;
00037 S32 gLine = 0;
00038 S32 gInternalColumn = 0;
00039 S32 gInternalLine = 0;
00040 
00041 LLScriptGenerateErrorText gErrorToText;
00042 
00043 void LLScriptFilePosition::fdotabs(FILE *fp, S32 tabs, S32 tabsize)
00044 {
00045         S32 i;
00046         for (i = 0; i < tabs * tabsize; i++)
00047         {
00048                 fprintf(fp, " ");
00049         }
00050 }
00051 
00052 char* gWarningText[LSWARN_EOF] =                /*Flawfinder: ignore*/
00053 {
00054         "INVALID",
00055         "Dead code found beyond return statement"
00056 };
00057 
00058 char* gErrorText[LSERROR_EOF] =         /*Flawfinder: ignore*/
00059 {
00060         "INVALID",
00061         "Syntax error",
00062         "Not all code paths return a value",
00063         "Function returns a value but return statement doesn't",
00064         "Return statement type doesn't match function return type",
00065         "Global functions can't change state",
00066         "Name previously declared within scope",
00067         "Name not defined within scope",
00068         "Type mismatch",
00069         "Expression must act on LValue",
00070         "Byte code assembly failed -- out of memory",
00071         "Function call mismatches type or number of arguments",
00072         "Use of vector or quaternion method on incorrect type",
00073         "Lists can't be included in lists",
00074         "Unitialized variables can't be included in lists",
00075         "Declaration requires a new scope -- use { and }"
00076 };
00077 
00078 void LLScriptGenerateErrorText::writeWarning(FILE *fp, LLScriptFilePosition *pos, LSCRIPTWarnings warning)
00079 {
00080         fprintf(fp, "(%d, %d) : WARNING : %s\n", pos->mLineNumber, pos->mColumnNumber, gWarningText[warning]);
00081         mTotalWarnings++;
00082 }
00083 
00084 void LLScriptGenerateErrorText::writeWarning(FILE *fp, S32 line, S32 col, LSCRIPTWarnings warning)
00085 {
00086         fprintf(fp, "(%d, %d) : WARNING : %s\n", line, col, gWarningText[warning]);
00087         mTotalWarnings++;
00088 }
00089 
00090 void LLScriptGenerateErrorText::writeError(FILE *fp, LLScriptFilePosition *pos, LSCRIPTErrors error)
00091 {
00092         fprintf(fp, "(%d, %d) : ERROR : %s\n", pos->mLineNumber, pos->mColumnNumber, gErrorText[error]);
00093         mTotalErrors++;
00094 }
00095 
00096 void LLScriptGenerateErrorText::writeError(FILE *fp, S32 line, S32 col, LSCRIPTErrors error)
00097 {
00098         fprintf(fp, "(%d, %d) : ERROR : %s\n", line, col, gErrorText[error]);
00099         mTotalErrors++;
00100 }

Generated on Thu Jul 1 06:09:50 2010 for Second Life Viewer by  doxygen 1.4.7