source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/src/Messenger.cpp@ 719

Last change on this file since 719 was 719, checked in by dai, 16 years ago
  • ab_breakpoint.tmpをテンポラリディレクトリに生成するようにした。
  • pgm.tmpをユーザ空間に生成するようにした。
  • GetUserAppDir/GetIdeUserAppDir/GetAbcUserAppDirの各メソッドを用意。用途別に呼び出し側の制御を分けた。
File size: 23.4 KB
Line 
1#include "stdafx.h"
2
3void 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 // 標準出力
27 std::cout << message << std::endl;
28}
29int Messenger::GetNextErrorLine()
30{
31 extern HWND hMainDlg;
32 int index = GetWindowTextLength(GetDlgItem(hMainDlg,IDC_ERRORLIST));
33 return static_cast<int>(SendMessage(GetDlgItem(hMainDlg,IDC_ERRORLIST),EM_LINEFROMCHAR,index,0));
34}
35
36ErrorInfo::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 {
44 compiler.GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath );
45 }
46
47 errorLineNum = compiler.messenger.GetNextErrorLine();
48}
49
50std::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 {
78 if( !IsVariableChar( tempKeyWord[i3] ) )
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,"定数はモジュールレベルで宣言して下さい。");
170 if(errorCode==35) sprintf(msg,"インクルードファイル \"%s\" をオープンできません",tempKeyWord);
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参照です。");
251 if(errorCode==143) sprintf(msg,"\"%s\" ジェネリクス型に型パラメータが指定されていません。",tempKeyWord);
252 if(errorCode==144) sprintf(msg,"Thisの変数ポインタを取得することはできません。",tempKeyWord);
253 if(errorCode==145) sprintf(msg,"コンストラクタを直接呼び出すことはできません。。",tempKeyWord);
254 if(errorCode==146) sprintf(msg,"デストラクタを直接呼び出すことはできません。。",tempKeyWord);
255
256 //Enum関連
257 if(errorCode==150) sprintf(msg,"\"%s\" 値が定義されていません。",tempKeyWord);
258 if(errorCode==151) sprintf(msg,"\"%s\" 列挙リストに登録されていません。",tempKeyWord);
259
260 //リンカ
261 if(errorCode==200) sprintf(msg,"\"%s\" 未解決です (リンク エラー)。",tempKeyWord);
262 if(errorCode==201) sprintf(msg,"\"%s\" の読み込みに失敗。",tempKeyWord);
263 if(errorCode==202) sprintf(msg,"\"%s\" は存在しません。",tempKeyWord);
264 if(errorCode==203) sprintf(msg,"\"%s\" は存在しますが、読み込めません(古いバージョンのコンパイラでビルドされた可能性があります)。",tempKeyWord);
265
266 //原因不明
267 if(errorCode==300) lstrcpy(msg,"内部エラー");
268
269 // ベースライブラリ不整合
270 if( errorCode == 400 ) sprintf( msg, "\"%s\" が存在しません。標準ライブラリの内容が古い可能性があります。", tempKeyWord );
271
272#else
273 ////////////////////
274 //英語
275 ////////////////////
276 if(errorCode==1) lstrcpy(msg,"Syntax Error.");
277 if(errorCode==2) sprintf(msg,"Left operand must be l-value.");
278 //errorCode==3は予約されています
279 if(errorCode==4) sprintf(msg,"Correlation of %s is wrong.",tempKeyWord);
280 if(errorCode==5) sprintf(msg,"Correlation of double quotes is wrong.");
281 if(errorCode==6) sprintf(msg,"\"%s\" Label not found.",tempKeyWord);
282 if(errorCode==7) lstrcpy(msg,"The DLL name is too long. Must be 16 characters or less.");
283 if(errorCode==8) lstrcpy(msg,"The inaccurate characters are contained.");
284 if(errorCode==9) sprintf(msg,"Type is wrong.");
285 if(errorCode==10) sprintf(msg,"\"%s\" Rule of parameter is wrong.",tempKeyWord);
286 if(errorCode==11) sprintf(msg,"\"%s\" Type is wrong.",tempKeyWord);
287 if(errorCode==12) sprintf(msg,"\"%s\" Not a valid use.",tempKeyWord);
288 if(errorCode==13) sprintf(msg,"Cannot refer to \"%s\".",tempKeyWord);
289 if(errorCode==14) sprintf(msg,"\"%s\" Array argument(s) out of bound.",tempKeyWord);
290 if(errorCode==15) sprintf(msg,"\"%s\" is already defined.",tempKeyWord);
291 if(errorCode==16) sprintf(msg,"\"%s\" Argument(s) following variable which is not pointer or array.",tempKeyWord);
292 if(errorCode==17) sprintf(msg,"Invalid resource data.");
293 if(errorCode==18) sprintf(msg,"\"%s\" Invalid operation on a pointer variable.",tempKeyWord);
294 if(errorCode==19) sprintf(msg,"\"%s\" is already to be passed by value. You cannot use \"ByVal\".",tempKeyWord);
295 if(errorCode==21) sprintf(msg,"Wrong structure of \"If\" block.");
296 if(errorCode==22) sprintf(msg,"No matching \"End %s\" found for \"%s\".",tempKeyWord,tempKeyWord);
297 if(errorCode==23) sprintf(msg,"Cannot read the resource file \"%s\".",tempKeyWord);
298 if(errorCode==24) lstrcpy(msg,"Must not use String type as an argument for exported function. (Use BytePtr type instead.)");
299 if(errorCode==27) sprintf(msg,"\"%s\" Undefined procedure.",tempKeyWord);
300 if(errorCode==28) sprintf(msg,"\"%s\" Structure must not be passed by value. (Use \"ByRef\".)",tempKeyWord);
301 if(errorCode==29) sprintf(msg,"Array must not be passed by value. (Use \"ByRef\".)");
302 //errorCode==30は予約されています
303 if(errorCode==31) sprintf(msg,"\"%s\" is a struct. (Use period \".\" to refer to the members.)",tempKeyWord);
304 if(errorCode==32) sprintf(msg,"\"%s\" is a pointer of struct. (Use arrow \"->\" to refer to the members.)",tempKeyWord);
305 if(errorCode==33) sprintf(msg,"Constant formula has a thing that is not literal value or constant value.");
306 if(errorCode==34) sprintf(msg,"Constant formula must be defined in the module level.");
307 if(errorCode==38) sprintf(msg,"\"%s\" is a procedure without a return value.",tempKeyWord);
308 if(errorCode==39) sprintf(msg,"\"%s\" is not object pointer. \"->\" is invalid.",tempKeyWord);
309 if(errorCode==40) lstrcpy(msg,"Cannot set a object to return value.");
310 if(errorCode==41) lstrcpy(msg,"Init data is wrong.");
311 if(errorCode==42) lstrcpy(msg,"The inaccurate characters are contained after the closing parenthesis \")\".");
312 if(errorCode==43) lstrcpy(msg,"The inaccurate characters are contained after the double quote.");
313
314 //オブジェクト関連
315 if(errorCode==102) sprintf(msg,"\"%s\" The object is not defined.",tempKeyWord);
316 if(errorCode==103) sprintf(msg,"\"%s\" The member is not defined.",tempKeyWord);
317 if(errorCode==104) sprintf(msg,"\"%s\" The reference character is different.",tempKeyWord);
318 if(errorCode==105) sprintf(msg,"\"%s\" An own class is not inheritable.",tempKeyWord);
319 if(errorCode==106) sprintf(msg,"\"%s\" It class is not defined.",tempKeyWord);
320 if(errorCode==107) sprintf(msg,"\"%s\" Cannot access the private member.",tempKeyWord);
321 if(errorCode==108) sprintf(msg,"\"%s\" Cannot access the protected member.",tempKeyWord);
322 if(errorCode==109) sprintf(msg,"\"%s\" Cannot call the private member.",tempKeyWord);
323 if(errorCode==110) sprintf(msg,"\"%s\" Cannot call the protected member.",tempKeyWord);
324 if(errorCode==111) lstrcpy(msg,"The Inherits phrase must be described to the 1st line of class module");
325 if(errorCode==112) sprintf(msg,"\"%s\" is not class object. Therefor you cannot set the parameter for constructor.",tempKeyWord);
326 if(errorCode==113) sprintf(msg,"\"%s\" The parameter for constructor is wrong.",tempKeyWord);
327 if(errorCode==114) lstrcpy(msg,"Destructor cannot have a parameter.");
328 if(errorCode==115) lstrcpy(msg,"Constructor and Destructor cannot have a return value.");
329 if(errorCode==116) lstrcpy(msg,"Constructor and Destructor must be public access.");
330 if(errorCode==117) lstrcpy(msg,"Destructors name must be \"~ClassName\".");
331 if(errorCode==118) lstrcpy(msg,"Super class is not found.");
332 if(errorCode==119) sprintf(msg,"\"%s\" The member is not defined in the super class.",tempKeyWord);
333
334 //Enum関連
335 if(errorCode==150) sprintf(msg,"\"%s\" The value is not set",tempKeyWord);
336 if(errorCode==151) sprintf(msg,"\"%s\" is not found from enum lists.",tempKeyWord);
337
338 //リンカ
339 if(errorCode==200) sprintf(msg,"\"%s\" Unknown error.",tempKeyWord);
340#endif
341
342 return msg;
343}
344
345std::string ErrorInfo::GetFullMessageString() const
346{
347 if( sourceLineNum != -1 )
348 {
349 char temporary[1024];
350 sprintf( temporary, "%s(%d) : %s",
351 sourceFilePath.c_str(),
352 sourceLineNum + 1,
353 GetMessageString().c_str()
354 );
355
356 return temporary;
357 }
358
359 return GetMessageString();
360}
361
362void ErrorMessenger::Output( const ErrorInfo &errorInfo )
363{
364 if( errorInfo.GetErrorCode() == 3 )
365 {
366 if( errorInfo.GetKeyword().size() <= 0 )
367 {
368 // ありえない
369 _ASSERTE( false );
370 }
371
372 if( Jenga::Common::IsExistString( synonymKeyWords, errorInfo.GetKeyword() ) )
373 {
374 // 既にエラーが出力されている場合は無視
375 return;
376 }
377
378 synonymKeyWords.push_back( errorInfo.GetKeyword() );
379 }
380
381 errorInfos.push_back( errorInfo );
382
383 // 文字列を出力
384 Messenger::Output( errorInfo.GetFullMessageString() );
385}
386void ErrorMessenger::Output( int errorCode, const std::string &keyword, int sourceIndex )
387{
388 Output( ErrorInfo( errorCode, keyword, sourceIndex ) );
389}
390void ErrorMessenger::Output( int errorCode, const char *keyword, int sourceIndex )
391{
392 if( !keyword )
393 {
394 keyword = "";
395 }
396 Output( errorCode, std::string( keyword ), sourceIndex );
397}
398void ErrorMessenger::OutputFatalError()
399{
400 Output( 300, "", cp );
401}
402
403void ErrorMessenger::ClearSynonymKeyWords()
404{
405 synonymKeyWords.clear();
406}
407
408int ErrorMessenger::GetErrorCount() const
409{
410 int count = 0;
411 BOOST_FOREACH( const ErrorInfo &errorInfo, errorInfos )
412 {
413 if( !errorInfo.IsWarning() )
414 {
415 count ++;
416 }
417 }
418 return count;
419}
420bool ErrorMessenger::HasError() const
421{
422 return ( GetErrorCount() > 0 );
423}
424int ErrorMessenger::GetWarningCount() const
425{
426 int count = 0;
427 BOOST_FOREACH( const ErrorInfo &errorInfo, errorInfos )
428 {
429 if( errorInfo.IsWarning() )
430 {
431 count ++;
432 }
433 }
434 return count;
435}
436
437void ErrorMessenger::ShowErrorLine( int errorLineNum )
438{
439 const ErrorInfo *pErrorInfo = NULL;
440 BOOST_FOREACH( const ErrorInfo &errorInfo, errorInfos )
441 {
442 if( errorInfo.GetErrorLineNum() == errorLineNum )
443 {
444 pErrorInfo = &errorInfo;
445 break;
446 }
447 }
448
449 if( !pErrorInfo )
450 {
451 // 該当なし
452 return;
453 }
454 if( pErrorInfo->GetSourceLineNum() == -1 )
455 {
456 return;
457 }
458
459 HANDLE hFile;
460 DWORD dw;
461 char FileName[MAX_PATH];
462 char temporary[MAX_PATH];
463
464 lstrcpy( FileName, pErrorInfo->GetSourceFilePath().c_str() );
465
466 if(IsWindow(hOwnerEditor)){
467 if(FileName){
468
469 while( !IsFileExist( FileName ) ){
470 char temp2[MAX_PATH],temp3[MAX_PATH];
471 _splitpath(FileName,NULL,NULL,temp2,temp3);
472 lstrcat(temp2,temp3);
473
474 sprintf(temporary,"\"%s\" が見つかりません。格納されているディレクトリを指定してください。",temp2);
475 if(!GetFolder(hOwnerEditor,temp3,temporary)) return;
476
477 if(temp3[lstrlen(temp3)-1]!='\\') lstrcat(temp3,"\\");
478
479 sprintf(FileName,"%s%s",temp3,temp2);
480 }
481
482 hFile=CreateFile(
483 ( ActiveBasic::Common::Environment::GetUserAppDir() + "\\pgm.tmp" ).c_str(),
484 GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_TEMPORARY,NULL);
485 WriteFile(hFile,FileName,lstrlen(FileName),&dw,NULL);
486 CloseHandle(hFile);
487
488 SendMessage(hOwnerEditor,WM_SHOWERROR,pErrorInfo->GetSourceLineNum(),0);
489 }
490 }
491}
Note: See TracBrowser for help on using the repository browser.