[465] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
| 3 | void Messenger::Output( const std::string &message )
|
---|
| 4 | {
|
---|
| 5 | ////////////////////////////////////////////////////////////////////
|
---|
| 6 | // エディットコントロールに出力
|
---|
| 7 | ////////////////////////////////////////////////////////////////////
|
---|
| 8 | extern HWND hMainDlg;
|
---|
| 9 |
|
---|
| 10 | // 出力先のエディットコントロールが無効化されていたときはクリアして有効化する
|
---|
| 11 | if( !IsWindowEnabled( GetDlgItem(hMainDlg,IDC_ERRORLIST) ) )
|
---|
| 12 | {
|
---|
| 13 | SetDlgItemText( hMainDlg, IDC_ERRORLIST, "" );
|
---|
| 14 | EnableWindow( GetDlgItem( hMainDlg, IDC_ERRORLIST ), TRUE );
|
---|
| 15 | }
|
---|
| 16 |
|
---|
| 17 | // エディットコントロールに出力
|
---|
| 18 | int i2 = GetWindowTextLength(GetDlgItem(hMainDlg,IDC_ERRORLIST));
|
---|
| 19 | SendDlgItemMessage(hMainDlg,IDC_ERRORLIST,EM_SETSEL,i2,i2);
|
---|
| 20 | SendDlgItemMessage(hMainDlg,IDC_ERRORLIST,EM_REPLACESEL,0,(LPARAM)(message + "\r\n").c_str());
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | // ログに出力
|
---|
| 24 | trace( message );
|
---|
| 25 |
|
---|
| 26 | // 標準出力
|
---|
[523] | 27 | std::cout << message << std::endl;
|
---|
[465] | 28 | }
|
---|
| 29 | int Messenger::GetNextErrorLine()
|
---|
| 30 | {
|
---|
| 31 | extern HWND hMainDlg;
|
---|
| 32 | int index = GetWindowTextLength(GetDlgItem(hMainDlg,IDC_ERRORLIST));
|
---|
[468] | 33 | return static_cast<int>(SendMessage(GetDlgItem(hMainDlg,IDC_ERRORLIST),EM_LINEFROMCHAR,index,0));
|
---|
[465] | 34 | }
|
---|
| 35 |
|
---|
| 36 | ErrorInfo::ErrorInfo( int errorCode, const std::string &keyword, int sourceIndex )
|
---|
| 37 | : errorCode( errorCode )
|
---|
| 38 | , keyword( keyword )
|
---|
| 39 | , sourceFilePath( "" )
|
---|
| 40 | , sourceLineNum( -1 )
|
---|
| 41 | {
|
---|
| 42 | if( sourceIndex != -1 )
|
---|
| 43 | {
|
---|
[587] | 44 | compiler.GetObjectModule().GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath );
|
---|
[465] | 45 | }
|
---|
| 46 |
|
---|
| 47 | errorLineNum = compiler.messenger.GetNextErrorLine();
|
---|
| 48 | }
|
---|
| 49 |
|
---|
| 50 | std::string ErrorInfo::GetMessageString() const
|
---|
| 51 | {
|
---|
| 52 | extern HANDLE hHeap;
|
---|
| 53 | int i2;
|
---|
| 54 | char temporary[64];
|
---|
| 55 |
|
---|
| 56 | char tempKeyWord[1024];
|
---|
| 57 | lstrcpy(tempKeyWord,keyword.c_str());
|
---|
| 58 | for(i2=0;;i2++){
|
---|
| 59 | if(tempKeyWord[i2]=='\0') break;
|
---|
| 60 | if(tempKeyWord[i2]==1){
|
---|
| 61 | GetDefaultNameFromES(tempKeyWord[i2+1],temporary);
|
---|
| 62 | SlideString(tempKeyWord+i2+2,lstrlen(temporary)-2);
|
---|
| 63 | memcpy(tempKeyWord+i2,temporary,lstrlen(temporary));
|
---|
| 64 | }
|
---|
| 65 | }
|
---|
| 66 |
|
---|
| 67 | if( errorCode == -1 || errorCode == -2 )
|
---|
| 68 | {
|
---|
| 69 | // 部分エラー
|
---|
| 70 | return keyword;
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | char msg[1024];
|
---|
| 74 | if(errorCode==3)
|
---|
| 75 | {
|
---|
| 76 | for( int i3=0; ; i3++ )
|
---|
| 77 | {
|
---|
[628] | 78 | if( !IsVariableChar( tempKeyWord[i3] ) )
|
---|
[465] | 79 | {
|
---|
| 80 | temporary[i3] = 0;
|
---|
| 81 | break;
|
---|
| 82 | }
|
---|
| 83 | temporary[i3] = tempKeyWord[i3];
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | #if defined(JPN)
|
---|
| 87 | //日本語
|
---|
| 88 | sprintf(msg,"\"%s\" 無効な識別子です",temporary);
|
---|
| 89 | #else
|
---|
| 90 | //英語
|
---|
| 91 | sprintf(msg,"\"%s\" Invalid identifier.",temporary);
|
---|
| 92 | #endif
|
---|
| 93 |
|
---|
| 94 | }
|
---|
| 95 | if(errorCode==30){
|
---|
| 96 | #if defined(JPN)
|
---|
| 97 | //日本語
|
---|
| 98 | if(temporary[0]) sprintf(msg,"\"%s\" の使い方が不正です",tempKeyWord);
|
---|
| 99 | else lstrcpy(msg,"文法が間違っています");
|
---|
| 100 | #else
|
---|
| 101 | //英語
|
---|
| 102 | if(temporary[0]) sprintf(msg,"How to use the \"%s\" is wrong.",tempKeyWord);
|
---|
| 103 | else lstrcpy(msg,"Syntax Error.");
|
---|
| 104 | #endif
|
---|
| 105 | }
|
---|
| 106 |
|
---|
| 107 |
|
---|
| 108 | /////////////////////
|
---|
| 109 | // ワーニングエラー
|
---|
| 110 | /////////////////////
|
---|
| 111 | #if defined(JPN)
|
---|
| 112 | ////////////////////
|
---|
| 113 | //日本語
|
---|
| 114 | ////////////////////
|
---|
| 115 | if(errorCode==-101) sprintf(msg,"[警告] %sに強制変換されています。データが失われる可能性があります。",tempKeyWord);
|
---|
| 116 | if(errorCode==-102) sprintf(msg,"[警告] %sに強制変換されています。",tempKeyWord);
|
---|
| 117 | if(errorCode==-103) sprintf(msg,"[警告] \"%s\" 型が指定されていません。Double型として扱います。",tempKeyWord);
|
---|
| 118 | if(errorCode==-104) sprintf(msg,"[警告] \"%s\" 戻り値の型が指定されていません。Double型として扱います。",tempKeyWord);
|
---|
| 119 | if(errorCode==-105) sprintf(msg,"[警告] 一時オブジェクトの解放を行えません。キャスト用オブジェクトを用意してください。",tempKeyWord);
|
---|
| 120 | if(errorCode==-106) sprintf(msg,"[警告] DLLファイル \"%s\" が見つかりません。",tempKeyWord);
|
---|
| 121 | if(errorCode==-107) sprintf(msg,"[警告] DLL関数 \"%s\" を参照できません。",tempKeyWord);
|
---|
| 122 | if(errorCode==-108) lstrcpy(msg,"[警告] Catch節、Finally節を持たない意味のないTryスコープです。");
|
---|
| 123 | if(errorCode==-120) sprintf(msg,"[警告] VarPtr関数の引数にオブジェクト インスタンスが指定されました。オブジェクトの先頭アドレスを取得したいときはObjPtr関数に切り替えをお願いします。m(__)m(この警告はVarPtr→ObjPtrへの切り替えが完了したら消します(切り替えは \"適材箇所に限り\" ですので、ご注意ください!))",tempKeyWord);
|
---|
| 124 | #else
|
---|
| 125 | #endif
|
---|
| 126 |
|
---|
| 127 |
|
---|
| 128 | ///////////////
|
---|
| 129 | // 一般エラー
|
---|
| 130 | ///////////////
|
---|
| 131 |
|
---|
| 132 | #if defined(JPN)
|
---|
| 133 | ////////////////////
|
---|
| 134 | //日本語
|
---|
| 135 | ////////////////////
|
---|
| 136 | if(errorCode==1) lstrcpy(msg,"文法が間違っています。");
|
---|
| 137 | if(errorCode==2) sprintf(msg,"左のオペランドが、左辺値になっていません。");
|
---|
| 138 | //errorCode==3は予約されています
|
---|
| 139 | if(errorCode==4) sprintf(msg,"%sの相互関係が一致しません。",tempKeyWord);
|
---|
| 140 | if(errorCode==5) sprintf(msg,"ダブルクォートの数が一致しません。");
|
---|
| 141 | if(errorCode==6) sprintf(msg,"\"%s\" ジャンプ先が不正です。",tempKeyWord);
|
---|
| 142 | if(errorCode==7) lstrcpy(msg,"DLL名が長すぎます(拡張子を含め、16文字以下にして下さい)。");
|
---|
| 143 | if(errorCode==8) lstrcpy(msg,"コンパイラが認識できない文字コードが含まれています。");
|
---|
| 144 | if(errorCode==9) sprintf(msg,"型が違います。");
|
---|
| 145 | if(errorCode==10) sprintf(msg,"\"%s\" のパラメータ指定が間違っています。",tempKeyWord);
|
---|
| 146 | if(errorCode==11) sprintf(msg,"\"%s\" 型が違います。",tempKeyWord);
|
---|
| 147 | if(errorCode==12) sprintf(msg,"%s の使い方が不正です。",tempKeyWord);
|
---|
| 148 | if(errorCode==13) sprintf(msg,"\"%s\" を参照できません。",tempKeyWord);
|
---|
| 149 | if(errorCode==14) sprintf(msg,"\"%s\" 配列指定が不正です。",tempKeyWord);
|
---|
| 150 | if(errorCode==15) sprintf(msg,"\"%s\" はすでに定義されています。",tempKeyWord);
|
---|
| 151 | if(errorCode==16) sprintf(msg,"\"%s\" 配列、またはポインタ以外の変数に添え字が指定されています。",tempKeyWord);
|
---|
| 152 | if(errorCode==17) sprintf(msg,"リソース データが不正です。");
|
---|
| 153 | if(errorCode==18) sprintf(msg,"\"%s\"はポインタ変数型です。文字列演算を指定することはできません。",tempKeyWord);
|
---|
| 154 | if(errorCode==19) sprintf(msg,"\"%s\"は値参照型です。ByVal指定することはできません。",tempKeyWord);
|
---|
| 155 | if(errorCode==20) lstrcpy(msg,"全角スペースが含まれています(全角スペースはコンパイラが認識できないので、半角スペースまたはタブ文字にしてください)。");
|
---|
| 156 | if(errorCode==21) sprintf(msg,"If制御のブロック指定が不正です。");
|
---|
| 157 | if(errorCode==22) sprintf(msg,"%s に対する End %s が見つかりません。",tempKeyWord,tempKeyWord);
|
---|
| 158 | if(errorCode==23) sprintf(msg,"リソース ファイル \"%s\" の読み込みに失敗。",tempKeyWord);
|
---|
| 159 | if(errorCode==24) lstrcpy(msg,"Export指定の関数のパラメータには実体オブジェクトを利用することはできません(BytePtr型などを利用して下さい)。");
|
---|
| 160 | if(errorCode==25) sprintf(msg,"DLL関数にオブジェクトを引き渡すことはできません(%s)。",tempKeyWord);
|
---|
| 161 | if(errorCode==26) sprintf(msg,"\"%s\" 戻り値の型が指定されていません。",tempKeyWord);
|
---|
| 162 | if(errorCode==27) sprintf(msg,"\"%s\" は定義されていません。",tempKeyWord);
|
---|
| 163 | if(errorCode==28) sprintf(msg,"構造体パラメータは参照渡しにしてください(%s)。",tempKeyWord);
|
---|
| 164 | if(errorCode==29) sprintf(msg,"配列ポインタを要素と同時に引渡すときは、ポインタ参照(ByRef)にしてください。");
|
---|
| 165 | //errorCode==30は予約されています
|
---|
| 166 | if(errorCode==31) sprintf(msg,"\"%s\" は構造体です(メンバの参照はピリオド \".\" で区切ってください)。",tempKeyWord);
|
---|
| 167 | if(errorCode==32) sprintf(msg,"\"%s\" は構造体ポインタです(メンバの参照は \"->\" で区切ってください)。",tempKeyWord);
|
---|
| 168 | if(errorCode==33) sprintf(msg,"定数式にリテラル値、または定数以外のものが含まれています。");
|
---|
| 169 | if(errorCode==34) sprintf(msg,"定数はモジュールレベルで宣言して下さい。");
|
---|
[555] | 170 | if(errorCode==35) sprintf(msg,"インクルードファイル \"%s\" をオープンできません",tempKeyWord);
|
---|
[465] | 171 | if(errorCode==38) sprintf(msg,"\"%s\" 戻り値が存在しないプロシージャです。",tempKeyWord);
|
---|
| 172 | if(errorCode==39) sprintf(msg,"\"%s\" はオブジェクトポインタではありません(\"->\" 参照はできません)。",tempKeyWord);
|
---|
| 173 | if(errorCode==40) lstrcpy(msg,"DLL関数の戻り値としてオブジェクトを受け取ることはできません。");
|
---|
| 174 | if(errorCode==41) lstrcpy(msg,"初期データが不正です。");
|
---|
| 175 | if(errorCode==42) lstrcpy(msg,"閉じカッコ \")\" の後に不正な文字が含まれています。");
|
---|
| 176 | if(errorCode==43) lstrcpy(msg,"ダブルクォートの後に不正な文字が含まれています。");
|
---|
| 177 | if(errorCode==45) sprintf(msg,"実数に対して \"%s\" 演算子は利用できません。",tempKeyWord);
|
---|
| 178 | if(errorCode==46) lstrcpy(msg,"配列の添え字に整数以外の値が与えられています。");
|
---|
| 179 | if(errorCode==47) lstrcpy(msg,"As演算子の右辺値に型名以外の識別子が指定されています。");
|
---|
| 180 | if(errorCode==48) sprintf(msg,"%s演算子に対して型名が指定されています。",tempKeyWord);
|
---|
| 181 | if(errorCode==49) lstrcpy(msg,"添え字に整数以外の型が指定されています。");
|
---|
| 182 | if(errorCode==50) sprintf(msg,"%sに変換できません。",tempKeyWord);
|
---|
| 183 | if(errorCode==51) lstrcpy(msg,"オブジェクト、構造体のアラインメント値は 1, 2, 4, 8, 16 のいずれかでなければなりません。");
|
---|
| 184 | if(errorCode==52) sprintf(msg,"\"%s\" オーバーロードを解決できません。",tempKeyWord);
|
---|
| 185 | if(errorCode==53) sprintf(msg,"\"%s\" 出力ファイルの書き込みに失敗しました。実行されている可能性があります。",tempKeyWord);
|
---|
| 186 | if(errorCode==54) sprintf(msg,"対応する%sが存在しません。",tempKeyWord);
|
---|
| 187 | if(errorCode==55) sprintf(msg,"\"%s\" は対応するForステートメントで利用されるカウンタ変数ではありません。",tempKeyWord);
|
---|
| 188 | if(errorCode==56) lstrcpy(msg,"ゼロ割りが行われました。");
|
---|
| 189 | if(errorCode==57) lstrcpy(msg,"8進数のリテラル表記が不正です。");
|
---|
| 190 | if(errorCode==58) lstrcpy(msg,"16進数のリテラル表記が不正です。");
|
---|
| 191 | if(errorCode==59) sprintf(msg,"マニフェスト ファイル \"%s\" の読み込みに失敗。",tempKeyWord);
|
---|
| 192 | if(errorCode==60) lstrcpy(msg,"Staticステートメントはグローバル領域では使用できません。");
|
---|
| 193 | if(errorCode==61) sprintf(msg,"\"%s\" は定数です。書き込みアクセスはできません。",tempKeyWord);
|
---|
| 194 | if(errorCode==62) sprintf(msg,"グローバル領域でのReturnは禁止されています。",tempKeyWord);
|
---|
| 195 | if(errorCode==63) lstrcpy(msg,"名前空間が正しく閉じられていません。");
|
---|
| 196 | if(errorCode==64) sprintf(msg,"\"%s\" 無効な名前空間です。",tempKeyWord);
|
---|
| 197 | if(errorCode==65) sprintf(msg,"ローカル領域で%sは使用できません。",tempKeyWord);
|
---|
| 198 | if(errorCode==66) sprintf(msg,"%s 要求されている関数ポインタのパラメータまたは戻り値が一致しません。", tempKeyWord );
|
---|
| 199 | if(errorCode==67) sprintf(msg,"%s 要求されているデリゲートのパラメータまたは戻り値が一致しません。", tempKeyWord );
|
---|
| 200 | if(errorCode==68) sprintf(msg,"\"%s\" 不正な関数名です。", tempKeyWord);
|
---|
| 201 | if(errorCode==69) sprintf(msg,"\"%s\" 不正なメソッド名です。", tempKeyWord);
|
---|
| 202 | if(errorCode==70) lstrcpy(msg,"一つのTryに対して複数のFinallyを記述できません。");
|
---|
| 203 | if(errorCode==71) lstrcpy(msg,"Finallyの後ろにCatchを記述することはできません。");
|
---|
| 204 | if(errorCode==72) lstrcpy(msg,"Catchのパラメータの型が指定されていません。");
|
---|
| 205 | if(errorCode==73) lstrcpy(msg,"\"%s\" Catchのパラメータの型はクラス型でなければなりません。");
|
---|
| 206 | if(errorCode==74) sprintf(msg,"\"%s\" 型として認識できません。",tempKeyWord);
|
---|
| 207 |
|
---|
| 208 |
|
---|
| 209 | //オブジェクト関連
|
---|
| 210 | if(errorCode==102) sprintf(msg,"\"%s\" オブジェクトは定義されていません。",tempKeyWord);
|
---|
| 211 | if(errorCode==103) sprintf(msg,"\"%s\" メンバは定義されていません。",tempKeyWord);
|
---|
| 212 | if(errorCode==104) sprintf(msg,"\"%s\" 参照方法が違います。",tempKeyWord);
|
---|
| 213 | if(errorCode==105) sprintf(msg,"\"%s\" 自身のクラスを継承することはできません。",tempKeyWord);
|
---|
| 214 | if(errorCode==106) sprintf(msg,"\"%s\" 存在しないクラスです。",tempKeyWord);
|
---|
| 215 | if(errorCode==107) sprintf(msg,"Privateメンバ \"%s\" にアクセスすることはできません。",tempKeyWord);
|
---|
| 216 | if(errorCode==108) sprintf(msg,"Protectedメンバ \"%s\" にアクセスすることはできません。",tempKeyWord);
|
---|
| 217 | if(errorCode==109) sprintf(msg,"Privateメンバ関数 \"%s\" を呼び出すことはできません。",tempKeyWord);
|
---|
| 218 | if(errorCode==110) sprintf(msg,"Protectedメンバ関数 \"%s\" を呼び出すことはできません。",tempKeyWord);
|
---|
| 219 | if(errorCode==111) lstrcpy(msg,"InheritsはClass定義内の先頭に記述する必要があります。");
|
---|
| 220 | if(errorCode==112) sprintf(msg,"\"%s\" はクラス型ではないため、初期パラメータを指定することはできません。",tempKeyWord);
|
---|
| 221 | if(errorCode==113) sprintf(msg,"\"%s\" コンストラクタへ渡すパラメータが不正です。",tempKeyWord);
|
---|
| 222 | if(errorCode==114) lstrcpy(msg,"デストラクタはパラメータを持てません。");
|
---|
| 223 | if(errorCode==115) lstrcpy(msg,"コンストラクタ及びデストラクタは戻り値を持てません。");
|
---|
| 224 | //if(errorCode==116) lstrcpy(msg,"コンストラクタ及びデストラクタはパブリックアクセスにしなければなりません。");
|
---|
| 225 | if(errorCode==117) lstrcpy(msg,"デストラクタの名前が \"~クラス名\" になっていません。");
|
---|
| 226 | if(errorCode==118) lstrcpy(msg,"参照する基底クラスが存在しません。");
|
---|
| 227 | if(errorCode==119) sprintf(msg,"\"%s\" メンバは基底クラスで定義されていません。",tempKeyWord);
|
---|
| 228 | if(errorCode==120) lstrcpy(msg,"デストラクトするオブジェクトの型が不明です。");
|
---|
| 229 | if(errorCode==121) lstrcpy(msg,"New演算子にはクラス以外の型を指定できません。");
|
---|
| 230 | if(errorCode==122) lstrcpy(msg,"Delete演算子にポインタ以外の型が指定されています。");
|
---|
| 231 | if(errorCode==123) lstrcpy(msg,"ループ継承が行われました。");
|
---|
| 232 | if(errorCode==124) lstrcpy(msg,"循環参照が行われました。");
|
---|
| 233 | if(errorCode==125) sprintf(msg,"\"%s\" は抽象クラスです。インスタンス化することはできません。",tempKeyWord);
|
---|
| 234 | if(errorCode==126) lstrcpy(msg,"オペレータのオーバーロードをクラスの外で行うことはできません。");
|
---|
| 235 | if(errorCode==127) lstrcpy(msg,"Override修飾子の指定が無い状況でオーバーライドを行うことはできません。");
|
---|
| 236 | if(errorCode==128) lstrcpy(msg,"オーバーライドを行うときはアクセシビリティを同一にしなければなりません。");
|
---|
| 237 | if(errorCode==129) sprintf(msg,"静的メンバ \"%s\" は定義されていません。",tempKeyWord);
|
---|
| 238 | if(errorCode==130) sprintf(msg,"\"%s\" はオブジェクト定数です。書き込みアクセスはできません。",tempKeyWord);
|
---|
| 239 | if(errorCode==131) lstrcpy(msg,"Const定義されたメソッド内でクラスメンバへの書き込みアクセスはできません。");
|
---|
| 240 | if(errorCode==132) lstrcpy(msg,"明示的なコンストラクタ呼び出しと初期値の指定を同時に行うことはできません。");
|
---|
| 241 | if(errorCode==133) lstrcpy(msg,"Thisに代入はできません。");
|
---|
| 242 | if(errorCode==134) lstrcpy( msg,"ObjPtr関数にはオブジェクト インスタンス以外を指定できません。" );
|
---|
| 243 | if(errorCode==135) lstrcpy( msg, "クラス以外の型を継承元として指定することはできません。" );
|
---|
| 244 | if(errorCode==136) sprintf( msg, "\"%s\" 非仮想関数に対してオーバーライドしようとしました。", tempKeyWord );
|
---|
| 245 | if(errorCode==137) lstrcpy(msg,"ImplementsはClass定義内の先頭に記述する必要があります。");
|
---|
| 246 | if(errorCode==138) sprintf(msg,"%s はインターフェイスではありません。Implementsできるのはインターフェイスに限ります。",tempKeyWord);
|
---|
| 247 | if(errorCode==139) sprintf(msg,"%s はインターフェイスではありません。",tempKeyWord);
|
---|
| 248 | if(errorCode==140) lstrcpy(msg,"Align修飾子を構造体以外の型に指定することはできません。");
|
---|
| 249 | if(errorCode==141) lstrcpy(msg,"Blittable修飾子をクラス以外の型に指定することはできません。");
|
---|
| 250 | if(errorCode==142) lstrcpy(msg,"不正なThis参照です。");
|
---|
[628] | 251 | if(errorCode==143) sprintf(msg,"\"%s\" ジェネリクス型に型パラメータが指定されていません。",tempKeyWord);
|
---|
[465] | 252 |
|
---|
| 253 | //Enum関連
|
---|
| 254 | if(errorCode==150) sprintf(msg,"\"%s\" 値が定義されていません。",tempKeyWord);
|
---|
| 255 | if(errorCode==151) sprintf(msg,"\"%s\" 列挙リストに登録されていません。",tempKeyWord);
|
---|
| 256 |
|
---|
| 257 | //リンカ
|
---|
| 258 | if(errorCode==200) sprintf(msg,"\"%s\" 未解決です (リンク エラー)。",tempKeyWord);
|
---|
| 259 | if(errorCode==201) sprintf(msg,"\"%s\" の読み込みに失敗。",tempKeyWord);
|
---|
[472] | 260 | if(errorCode==202) sprintf(msg,"\"%s\" は存在しません。",tempKeyWord);
|
---|
| 261 | if(errorCode==203) sprintf(msg,"\"%s\" は存在しますが、読み込めません(古いバージョンのコンパイラでビルドされた可能性があります)。",tempKeyWord);
|
---|
[465] | 262 |
|
---|
| 263 | //原因不明
|
---|
| 264 | if(errorCode==300) lstrcpy(msg,"内部エラー");
|
---|
| 265 |
|
---|
| 266 | // ベースライブラリ不整合
|
---|
| 267 | if( errorCode == 400 ) sprintf( msg, "\"%s\" が存在しません。標準ライブラリの内容が古い可能性があります。", tempKeyWord );
|
---|
| 268 |
|
---|
| 269 | #else
|
---|
| 270 | ////////////////////
|
---|
| 271 | //英語
|
---|
| 272 | ////////////////////
|
---|
| 273 | if(errorCode==1) lstrcpy(msg,"Syntax Error.");
|
---|
| 274 | if(errorCode==2) sprintf(msg,"Left operand must be l-value.");
|
---|
| 275 | //errorCode==3は予約されています
|
---|
| 276 | if(errorCode==4) sprintf(msg,"Correlation of %s is wrong.",tempKeyWord);
|
---|
| 277 | if(errorCode==5) sprintf(msg,"Correlation of double quotes is wrong.");
|
---|
| 278 | if(errorCode==6) sprintf(msg,"\"%s\" Label not found.",tempKeyWord);
|
---|
| 279 | if(errorCode==7) lstrcpy(msg,"The DLL name is too long. Must be 16 characters or less.");
|
---|
| 280 | if(errorCode==8) lstrcpy(msg,"The inaccurate characters are contained.");
|
---|
| 281 | if(errorCode==9) sprintf(msg,"Type is wrong.");
|
---|
| 282 | if(errorCode==10) sprintf(msg,"\"%s\" Rule of parameter is wrong.",tempKeyWord);
|
---|
| 283 | if(errorCode==11) sprintf(msg,"\"%s\" Type is wrong.",tempKeyWord);
|
---|
| 284 | if(errorCode==12) sprintf(msg,"\"%s\" Not a valid use.",tempKeyWord);
|
---|
| 285 | if(errorCode==13) sprintf(msg,"Cannot refer to \"%s\".",tempKeyWord);
|
---|
| 286 | if(errorCode==14) sprintf(msg,"\"%s\" Array argument(s) out of bound.",tempKeyWord);
|
---|
| 287 | if(errorCode==15) sprintf(msg,"\"%s\" is already defined.",tempKeyWord);
|
---|
| 288 | if(errorCode==16) sprintf(msg,"\"%s\" Argument(s) following variable which is not pointer or array.",tempKeyWord);
|
---|
| 289 | if(errorCode==17) sprintf(msg,"Invalid resource data.");
|
---|
| 290 | if(errorCode==18) sprintf(msg,"\"%s\" Invalid operation on a pointer variable.",tempKeyWord);
|
---|
| 291 | if(errorCode==19) sprintf(msg,"\"%s\" is already to be passed by value. You cannot use \"ByVal\".",tempKeyWord);
|
---|
| 292 | if(errorCode==21) sprintf(msg,"Wrong structure of \"If\" block.");
|
---|
| 293 | if(errorCode==22) sprintf(msg,"No matching \"End %s\" found for \"%s\".",tempKeyWord,tempKeyWord);
|
---|
| 294 | if(errorCode==23) sprintf(msg,"Cannot read the resource file \"%s\".",tempKeyWord);
|
---|
| 295 | if(errorCode==24) lstrcpy(msg,"Must not use String type as an argument for exported function. (Use BytePtr type instead.)");
|
---|
| 296 | if(errorCode==27) sprintf(msg,"\"%s\" Undefined procedure.",tempKeyWord);
|
---|
| 297 | if(errorCode==28) sprintf(msg,"\"%s\" Structure must not be passed by value. (Use \"ByRef\".)",tempKeyWord);
|
---|
| 298 | if(errorCode==29) sprintf(msg,"Array must not be passed by value. (Use \"ByRef\".)");
|
---|
| 299 | //errorCode==30は予約されています
|
---|
| 300 | if(errorCode==31) sprintf(msg,"\"%s\" is a struct. (Use period \".\" to refer to the members.)",tempKeyWord);
|
---|
| 301 | if(errorCode==32) sprintf(msg,"\"%s\" is a pointer of struct. (Use arrow \"->\" to refer to the members.)",tempKeyWord);
|
---|
| 302 | if(errorCode==33) sprintf(msg,"Constant formula has a thing that is not literal value or constant value.");
|
---|
| 303 | if(errorCode==34) sprintf(msg,"Constant formula must be defined in the module level.");
|
---|
| 304 | if(errorCode==38) sprintf(msg,"\"%s\" is a procedure without a return value.",tempKeyWord);
|
---|
| 305 | if(errorCode==39) sprintf(msg,"\"%s\" is not object pointer. \"->\" is invalid.",tempKeyWord);
|
---|
| 306 | if(errorCode==40) lstrcpy(msg,"Cannot set a object to return value.");
|
---|
| 307 | if(errorCode==41) lstrcpy(msg,"Init data is wrong.");
|
---|
| 308 | if(errorCode==42) lstrcpy(msg,"The inaccurate characters are contained after the closing parenthesis \")\".");
|
---|
| 309 | if(errorCode==43) lstrcpy(msg,"The inaccurate characters are contained after the double quote.");
|
---|
| 310 |
|
---|
| 311 | //オブジェクト関連
|
---|
| 312 | if(errorCode==102) sprintf(msg,"\"%s\" The object is not defined.",tempKeyWord);
|
---|
| 313 | if(errorCode==103) sprintf(msg,"\"%s\" The member is not defined.",tempKeyWord);
|
---|
| 314 | if(errorCode==104) sprintf(msg,"\"%s\" The reference character is different.",tempKeyWord);
|
---|
| 315 | if(errorCode==105) sprintf(msg,"\"%s\" An own class is not inheritable.",tempKeyWord);
|
---|
| 316 | if(errorCode==106) sprintf(msg,"\"%s\" It class is not defined.",tempKeyWord);
|
---|
| 317 | if(errorCode==107) sprintf(msg,"\"%s\" Cannot access the private member.",tempKeyWord);
|
---|
| 318 | if(errorCode==108) sprintf(msg,"\"%s\" Cannot access the protected member.",tempKeyWord);
|
---|
| 319 | if(errorCode==109) sprintf(msg,"\"%s\" Cannot call the private member.",tempKeyWord);
|
---|
| 320 | if(errorCode==110) sprintf(msg,"\"%s\" Cannot call the protected member.",tempKeyWord);
|
---|
| 321 | if(errorCode==111) lstrcpy(msg,"The Inherits phrase must be described to the 1st line of class module");
|
---|
| 322 | if(errorCode==112) sprintf(msg,"\"%s\" is not class object. Therefor you cannot set the parameter for constructor.",tempKeyWord);
|
---|
| 323 | if(errorCode==113) sprintf(msg,"\"%s\" The parameter for constructor is wrong.",tempKeyWord);
|
---|
| 324 | if(errorCode==114) lstrcpy(msg,"Destructor cannot have a parameter.");
|
---|
| 325 | if(errorCode==115) lstrcpy(msg,"Constructor and Destructor cannot have a return value.");
|
---|
| 326 | if(errorCode==116) lstrcpy(msg,"Constructor and Destructor must be public access.");
|
---|
| 327 | if(errorCode==117) lstrcpy(msg,"Destructors name must be \"~ClassName\".");
|
---|
| 328 | if(errorCode==118) lstrcpy(msg,"Super class is not found.");
|
---|
| 329 | if(errorCode==119) sprintf(msg,"\"%s\" The member is not defined in the super class.",tempKeyWord);
|
---|
| 330 |
|
---|
| 331 | //Enum関連
|
---|
| 332 | if(errorCode==150) sprintf(msg,"\"%s\" The value is not set",tempKeyWord);
|
---|
| 333 | if(errorCode==151) sprintf(msg,"\"%s\" is not found from enum lists.",tempKeyWord);
|
---|
| 334 |
|
---|
| 335 | //リンカ
|
---|
| 336 | if(errorCode==200) sprintf(msg,"\"%s\" Unknown error.",tempKeyWord);
|
---|
| 337 | #endif
|
---|
| 338 |
|
---|
| 339 | return msg;
|
---|
| 340 | }
|
---|
| 341 |
|
---|
| 342 | std::string ErrorInfo::GetFullMessageString() const
|
---|
| 343 | {
|
---|
| 344 | if( sourceLineNum != -1 )
|
---|
| 345 | {
|
---|
| 346 | char temporary[1024];
|
---|
[488] | 347 | sprintf( temporary, "%s(%d) : %s",
|
---|
| 348 | sourceFilePath.c_str(),
|
---|
[502] | 349 | sourceLineNum + 1,
|
---|
[465] | 350 | GetMessageString().c_str()
|
---|
| 351 | );
|
---|
| 352 |
|
---|
| 353 | return temporary;
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | return GetMessageString();
|
---|
| 357 | }
|
---|
| 358 |
|
---|
| 359 | void ErrorMessenger::Output( const ErrorInfo &errorInfo )
|
---|
| 360 | {
|
---|
| 361 | if( errorInfo.GetErrorCode() == 3 )
|
---|
| 362 | {
|
---|
| 363 | if( errorInfo.GetKeyword().size() <= 0 )
|
---|
| 364 | {
|
---|
| 365 | // ありえない
|
---|
| 366 | throw;
|
---|
| 367 | }
|
---|
| 368 |
|
---|
| 369 | if( Jenga::Common::IsExistString( synonymKeyWords, errorInfo.GetKeyword() ) )
|
---|
| 370 | {
|
---|
| 371 | // 既にエラーが出力されている場合は無視
|
---|
| 372 | return;
|
---|
| 373 | }
|
---|
| 374 |
|
---|
| 375 | synonymKeyWords.push_back( errorInfo.GetKeyword() );
|
---|
| 376 | }
|
---|
| 377 |
|
---|
| 378 | errorInfos.push_back( errorInfo );
|
---|
| 379 |
|
---|
| 380 | // 文字列を出力
|
---|
| 381 | Messenger::Output( errorInfo.GetFullMessageString() );
|
---|
| 382 | }
|
---|
| 383 | void ErrorMessenger::Output( int errorCode, const std::string &keyword, int sourceIndex )
|
---|
| 384 | {
|
---|
| 385 | Output( ErrorInfo( errorCode, keyword, sourceIndex ) );
|
---|
| 386 | }
|
---|
| 387 | void ErrorMessenger::Output( int errorCode, const char *keyword, int sourceIndex )
|
---|
| 388 | {
|
---|
| 389 | if( !keyword )
|
---|
| 390 | {
|
---|
| 391 | keyword = "";
|
---|
| 392 | }
|
---|
| 393 | Output( errorCode, std::string( keyword ), sourceIndex );
|
---|
| 394 | }
|
---|
| 395 | void ErrorMessenger::OutputFatalError()
|
---|
| 396 | {
|
---|
| 397 | Output( 300, "", cp );
|
---|
| 398 | }
|
---|
| 399 |
|
---|
[541] | 400 | void ErrorMessenger::ClearSynonymKeyWords()
|
---|
| 401 | {
|
---|
| 402 | synonymKeyWords.clear();
|
---|
| 403 | }
|
---|
| 404 |
|
---|
[465] | 405 | int ErrorMessenger::GetErrorCount() const
|
---|
| 406 | {
|
---|
| 407 | int count = 0;
|
---|
| 408 | BOOST_FOREACH( const ErrorInfo &errorInfo, errorInfos )
|
---|
| 409 | {
|
---|
| 410 | if( !errorInfo.IsWarning() )
|
---|
| 411 | {
|
---|
| 412 | count ++;
|
---|
| 413 | }
|
---|
| 414 | }
|
---|
| 415 | return count;
|
---|
| 416 | }
|
---|
| 417 | bool ErrorMessenger::HasError() const
|
---|
| 418 | {
|
---|
| 419 | return ( GetErrorCount() > 0 );
|
---|
| 420 | }
|
---|
| 421 | int ErrorMessenger::GetWarningCount() const
|
---|
| 422 | {
|
---|
| 423 | int count = 0;
|
---|
| 424 | BOOST_FOREACH( const ErrorInfo &errorInfo, errorInfos )
|
---|
| 425 | {
|
---|
| 426 | if( errorInfo.IsWarning() )
|
---|
| 427 | {
|
---|
| 428 | count ++;
|
---|
| 429 | }
|
---|
| 430 | }
|
---|
| 431 | return count;
|
---|
| 432 | }
|
---|
| 433 |
|
---|
| 434 | void ErrorMessenger::ShowErrorLine( int errorLineNum )
|
---|
| 435 | {
|
---|
| 436 | const ErrorInfo *pErrorInfo = NULL;
|
---|
| 437 | BOOST_FOREACH( const ErrorInfo &errorInfo, errorInfos )
|
---|
| 438 | {
|
---|
| 439 | if( errorInfo.GetErrorLineNum() == errorLineNum )
|
---|
| 440 | {
|
---|
| 441 | pErrorInfo = &errorInfo;
|
---|
| 442 | break;
|
---|
| 443 | }
|
---|
| 444 | }
|
---|
| 445 |
|
---|
| 446 | if( !pErrorInfo )
|
---|
| 447 | {
|
---|
| 448 | // 該当なし
|
---|
| 449 | return;
|
---|
| 450 | }
|
---|
| 451 | if( pErrorInfo->GetSourceLineNum() == -1 )
|
---|
| 452 | {
|
---|
| 453 | return;
|
---|
| 454 | }
|
---|
| 455 |
|
---|
| 456 | HANDLE hFile;
|
---|
| 457 | DWORD dw;
|
---|
| 458 | char FileName[MAX_PATH];
|
---|
| 459 | char temporary[MAX_PATH];
|
---|
| 460 |
|
---|
| 461 | lstrcpy( FileName, pErrorInfo->GetSourceFilePath().c_str() );
|
---|
| 462 |
|
---|
| 463 | if(IsWindow(hOwnerEditor)){
|
---|
| 464 | if(FileName){
|
---|
| 465 |
|
---|
| 466 | while( !IsFileExist( FileName ) ){
|
---|
| 467 | char temp2[MAX_PATH],temp3[MAX_PATH];
|
---|
| 468 | _splitpath(FileName,NULL,NULL,temp2,temp3);
|
---|
| 469 | lstrcat(temp2,temp3);
|
---|
| 470 |
|
---|
| 471 | sprintf(temporary,"\"%s\" が見つかりません。格納されているディレクトリを指定してください。",temp2);
|
---|
| 472 | if(!GetFolder(hOwnerEditor,temp3,temporary)) return;
|
---|
| 473 |
|
---|
| 474 | if(temp3[lstrlen(temp3)-1]!='\\') lstrcat(temp3,"\\");
|
---|
| 475 |
|
---|
| 476 | sprintf(FileName,"%s%s",temp3,temp2);
|
---|
| 477 | }
|
---|
| 478 |
|
---|
| 479 | hFile=CreateFile(
|
---|
[480] | 480 | ( ActiveBasic::Common::Environment::GetAbdevRootPath() + "\\pgm.tmp" ).c_str(),
|
---|
[465] | 481 | GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_TEMPORARY,NULL);
|
---|
| 482 | WriteFile(hFile,FileName,lstrlen(FileName),&dw,NULL);
|
---|
| 483 | CloseHandle(hFile);
|
---|
| 484 |
|
---|
| 485 | SendMessage(hOwnerEditor,WM_SHOWERROR,pErrorInfo->GetSourceLineNum(),0);
|
---|
| 486 | }
|
---|
| 487 | }
|
---|
| 488 | }
|
---|