1 | #include "../BasicCompiler_Common/common.h" |
---|
2 | |
---|
3 | BOOL GetErrorMsg(int num,const char *KeyWord,char *msg,int pos){ |
---|
4 | extern HANDLE hHeap; |
---|
5 | int i2; |
---|
6 | char temporary[64]; |
---|
7 | |
---|
8 | char tempKeyWord[1024]; |
---|
9 | if(KeyWord){ |
---|
10 | lstrcpy(tempKeyWord,KeyWord); |
---|
11 | for(i2=0;;i2++){ |
---|
12 | if(tempKeyWord[i2]=='\0') break; |
---|
13 | if(tempKeyWord[i2]==1){ |
---|
14 | GetDefaultNameFromES(tempKeyWord[i2+1],temporary); |
---|
15 | SlideString(tempKeyWord+i2+2,lstrlen(temporary)-2); |
---|
16 | memcpy(tempKeyWord+i2,temporary,lstrlen(temporary)); |
---|
17 | } |
---|
18 | } |
---|
19 | } |
---|
20 | else{ |
---|
21 | lstrcpy(tempKeyWord,""); |
---|
22 | } |
---|
23 | |
---|
24 | if(num==-1||num==-2) lstrcpy(msg,tempKeyWord); //部分エラー |
---|
25 | |
---|
26 | if(num==3){ |
---|
27 | temporary[0]=tempKeyWord[0]; |
---|
28 | for(i2=1;;i2++){ |
---|
29 | if((!IsVariableChar(tempKeyWord[i2]))||i2>=255){ |
---|
30 | temporary[i2]=0; |
---|
31 | break; |
---|
32 | } |
---|
33 | temporary[i2]=tempKeyWord[i2]; |
---|
34 | } |
---|
35 | |
---|
36 | extern char **SynonymErrorWords; |
---|
37 | extern int SynonymErrorNum; |
---|
38 | for(i2=0;i2<SynonymErrorNum;i2++){ |
---|
39 | if(lstrcmp(SynonymErrorWords[i2],temporary)==0) return 0; |
---|
40 | } |
---|
41 | |
---|
42 | #if defined(JPN) |
---|
43 | //日本語 |
---|
44 | sprintf(msg,"\"%s\" 無効な識別子です",temporary); |
---|
45 | #else |
---|
46 | //英語 |
---|
47 | sprintf(msg,"\"%s\" Invalid identifier.",temporary); |
---|
48 | #endif |
---|
49 | |
---|
50 | //重複エラー情報を追加 |
---|
51 | SynonymErrorWords=(char **)HeapReAlloc(hHeap,0,SynonymErrorWords,(SynonymErrorNum+1)*sizeof(char *)); |
---|
52 | SynonymErrorWords[SynonymErrorNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); |
---|
53 | lstrcpy(SynonymErrorWords[SynonymErrorNum],temporary); |
---|
54 | SynonymErrorNum++; |
---|
55 | } |
---|
56 | if(num==30){ |
---|
57 | #if defined(JPN) |
---|
58 | //日本語 |
---|
59 | if(temporary[0]) sprintf(msg,"\"%s\" の使い方が不正です",tempKeyWord); |
---|
60 | else lstrcpy(msg,"文法が間違っています"); |
---|
61 | #else |
---|
62 | //英語 |
---|
63 | if(temporary[0]) sprintf(msg,"How to use the \"%s\" is wrong.",tempKeyWord); |
---|
64 | else lstrcpy(msg,"Syntax Error."); |
---|
65 | #endif |
---|
66 | } |
---|
67 | |
---|
68 | |
---|
69 | ///////////////////// |
---|
70 | // ワーニングエラー |
---|
71 | ///////////////////// |
---|
72 | #if defined(JPN) |
---|
73 | //////////////////// |
---|
74 | //日本語 |
---|
75 | //////////////////// |
---|
76 | if(num==-101) sprintf(msg,"[警告] %sに強制変換されています。データが失われる可能性があります。",tempKeyWord); |
---|
77 | if(num==-102) sprintf(msg,"[警告] %sに強制変換されています。",tempKeyWord); |
---|
78 | if(num==-103) sprintf(msg,"[警告] \"%s\" 型が指定されていません。Double型として扱います。",tempKeyWord); |
---|
79 | if(num==-104) sprintf(msg,"[警告] \"%s\" 戻り値の型が指定されていません。Double型として扱います。",tempKeyWord); |
---|
80 | if(num==-105) sprintf(msg,"[警告] 一時オブジェクトの解放を行えません。キャスト用オブジェクトを用意してください。",tempKeyWord); |
---|
81 | if(num==-106) sprintf(msg,"[警告] DLLファイル \"%s\" が見つかりません。",tempKeyWord); |
---|
82 | if(num==-107) sprintf(msg,"[警告] DLL関数 \"%s\" を参照できません。",tempKeyWord); |
---|
83 | if(num==-120) sprintf(msg,"[警告] VarPtr関数の引数にオブジェクト インスタンスが指定されました。オブジェクトの先頭アドレスを取得したいときはObjPtr関数に切り替えをお願いします。m(__)m(この警告はVarPtr→ObjPtrへの切り替えが完了したら消します(切り替えは \"適材箇所に限り\" ですので、ご注意ください!))",tempKeyWord); |
---|
84 | #else |
---|
85 | #endif |
---|
86 | |
---|
87 | |
---|
88 | /////////////// |
---|
89 | // 一般エラー |
---|
90 | /////////////// |
---|
91 | |
---|
92 | #if defined(JPN) |
---|
93 | //////////////////// |
---|
94 | //日本語 |
---|
95 | //////////////////// |
---|
96 | if(num==1) lstrcpy(msg,"文法が間違っています。"); |
---|
97 | if(num==2) sprintf(msg,"左のオペランドが、左辺値になっていません。"); |
---|
98 | //num==3は予約されています |
---|
99 | if(num==4) sprintf(msg,"%sの相互関係が一致しません。",tempKeyWord); |
---|
100 | if(num==5) sprintf(msg,"ダブルクォートの数が一致しません。"); |
---|
101 | if(num==6) sprintf(msg,"\"%s\" ジャンプ先が不正です。",tempKeyWord); |
---|
102 | if(num==7) lstrcpy(msg,"DLL名が長すぎます(拡張子を含め、16文字以下にして下さい)。"); |
---|
103 | if(num==8) lstrcpy(msg,"コンパイラが認識できない文字コードが含まれています。"); |
---|
104 | if(num==9) sprintf(msg,"型が違います。"); |
---|
105 | if(num==10) sprintf(msg,"\"%s\" のパラメータ指定が間違っています。",tempKeyWord); |
---|
106 | if(num==11) sprintf(msg,"\"%s\" 型が違います。",tempKeyWord); |
---|
107 | if(num==12) sprintf(msg,"\"%s\" の使い方が不正です。",tempKeyWord); |
---|
108 | if(num==13) sprintf(msg,"\"%s\" を参照できません。",tempKeyWord); |
---|
109 | if(num==14) sprintf(msg,"\"%s\" 配列指定が不正です。",tempKeyWord); |
---|
110 | if(num==15) sprintf(msg,"\"%s\" はすでに定義されています。",tempKeyWord); |
---|
111 | if(num==16) sprintf(msg,"\"%s\" 配列、またはポインタ以外の変数に添え字が指定されています。",tempKeyWord); |
---|
112 | if(num==17) sprintf(msg,"リソース データが不正です。"); |
---|
113 | if(num==18) sprintf(msg,"\"%s\"はポインタ変数型です。文字列演算を指定することはできません。",tempKeyWord); |
---|
114 | if(num==19) sprintf(msg,"\"%s\"は値参照型です。ByVal指定することはできません。",tempKeyWord); |
---|
115 | if(num==20) lstrcpy(msg,"全角スペースが含まれています(全角スペースはコンパイラが認識できないので、半角スペースまたはタブ文字にしてください)。"); |
---|
116 | if(num==21) sprintf(msg,"If制御のブロック指定が不正です。"); |
---|
117 | if(num==22) sprintf(msg,"\"%s\" に対する \"End %s\" が見つかりません。",tempKeyWord,tempKeyWord); |
---|
118 | if(num==23) sprintf(msg,"リソース ファイル \"%s\" の読み込みに失敗。",tempKeyWord); |
---|
119 | if(num==24) lstrcpy(msg,"Export指定の関数のパラメータには実体オブジェクトを利用することはできません(BytePtr型などを利用して下さい)。"); |
---|
120 | if(num==25) sprintf(msg,"DLL関数にオブジェクトを引き渡すことはできません(%s)。",tempKeyWord); |
---|
121 | if(num==26) sprintf(msg,"\"%s\" 戻り値の型が指定されていません。",tempKeyWord); |
---|
122 | if(num==27) sprintf(msg,"\"%s\" は定義されていません。",tempKeyWord); |
---|
123 | if(num==28) sprintf(msg,"構造体パラメータは参照渡しにしてください(%s)。",tempKeyWord); |
---|
124 | if(num==29) sprintf(msg,"配列ポインタを要素と同時に引渡すときは、ポインタ参照(ByRef)にしてください。"); |
---|
125 | //num==30は予約されています |
---|
126 | if(num==31) sprintf(msg,"\"%s\" は構造体です(メンバの参照はピリオド \".\" で区切ってください)。",tempKeyWord); |
---|
127 | if(num==32) sprintf(msg,"\"%s\" は構造体ポインタです(メンバの参照は \"->\" で区切ってください)。",tempKeyWord); |
---|
128 | if(num==33) sprintf(msg,"定数式にリテラル値、または定数以外のものが含まれています。"); |
---|
129 | if(num==34) sprintf(msg,"定数はモジュールレベルで宣言して下さい。"); |
---|
130 | if(num==38) sprintf(msg,"\"%s\" 戻り値が存在しないプロシージャです。",tempKeyWord); |
---|
131 | if(num==39) sprintf(msg,"\"%s\" はオブジェクトポインタではありません(\"->\" 参照はできません)。",tempKeyWord); |
---|
132 | if(num==40) lstrcpy(msg,"DLL関数の戻り値としてオブジェクトを受け取ることはできません。"); |
---|
133 | if(num==41) lstrcpy(msg,"初期データが不正です。"); |
---|
134 | if(num==42) lstrcpy(msg,"閉じカッコ \")\" の後に不正な文字が含まれています。"); |
---|
135 | if(num==43) lstrcpy(msg,"ダブルクォートの後に不正な文字が含まれています。"); |
---|
136 | if(num==45) sprintf(msg,"実数に対して \"%s\" 演算子は利用できません。",tempKeyWord); |
---|
137 | if(num==46) lstrcpy(msg,"配列の添え字に整数以外の値が与えられています。"); |
---|
138 | if(num==47) lstrcpy(msg,"As演算子の右辺値に型名以外の識別子が指定されています。"); |
---|
139 | if(num==48) sprintf(msg,"%s演算子に対して型名が指定されています。",tempKeyWord); |
---|
140 | if(num==49) lstrcpy(msg,"添え字に整数以外の型が指定されています。"); |
---|
141 | if(num==50) sprintf(msg,"%sに変換できません。",tempKeyWord); |
---|
142 | if(num==51) lstrcpy(msg,"オブジェクト、構造体のアラインメント値は1,2,4,8,16のいずれかでなければなりません。"); |
---|
143 | if(num==52) sprintf(msg,"\"%s\" オーバーロードを解決できません。",tempKeyWord); |
---|
144 | if(num==53) sprintf(msg,"\"%s\" 出力ファイルの書き込みに失敗しました。実行されている可能性があります。",tempKeyWord); |
---|
145 | if(num==54) sprintf(msg,"対応する%sが存在しません。",tempKeyWord); |
---|
146 | if(num==55) sprintf(msg,"\"%s\" は対応するForステートメントで利用されるカウンタ変数ではありません。",tempKeyWord); |
---|
147 | if(num==56) lstrcpy(msg,"ゼロ割りが行われました。"); |
---|
148 | if(num==57) lstrcpy(msg,"8進数のリテラル表記が不正です。"); |
---|
149 | if(num==58) lstrcpy(msg,"16進数のリテラル表記が不正です。"); |
---|
150 | if(num==59) sprintf(msg,"マニフェスト ファイル \"%s\" の読み込みに失敗。",tempKeyWord); |
---|
151 | if(num==60) lstrcpy(msg,"Staticステートメントはグローバル領域では使用できません。"); |
---|
152 | if(num==61) sprintf(msg,"\"%s\" は定数です。書き込みアクセスはできません。",tempKeyWord); |
---|
153 | if(num==62) sprintf(msg,"グローバル領域でのReturnは禁止されています。",tempKeyWord); |
---|
154 | if(num==63) lstrcpy(msg,"名前空間が正しく閉じられていません。"); |
---|
155 | if(num==64) sprintf(msg,"\"%s\" 無効な名前空間です。",tempKeyWord); |
---|
156 | if(num==65) sprintf(msg,"ローカル領域で%sは使用できません。",tempKeyWord); |
---|
157 | |
---|
158 | |
---|
159 | //オブジェクト関連 |
---|
160 | if(num==102) sprintf(msg,"\"%s\" オブジェクトは定義されていません。",tempKeyWord); |
---|
161 | if(num==103) sprintf(msg,"\"%s\" メンバは定義されていません。",tempKeyWord); |
---|
162 | if(num==104) sprintf(msg,"\"%s\" 参照方法が違います。",tempKeyWord); |
---|
163 | if(num==105) sprintf(msg,"\"%s\" 自身のクラスを継承することはできません。",tempKeyWord); |
---|
164 | if(num==106) sprintf(msg,"\"%s\" クラスは定義されていません。",tempKeyWord); |
---|
165 | if(num==107) sprintf(msg,"Privateメンバ \"%s\" にアクセスすることはできません。",tempKeyWord); |
---|
166 | if(num==108) sprintf(msg,"Protectedメンバ \"%s\" にアクセスすることはできません。",tempKeyWord); |
---|
167 | if(num==109) sprintf(msg,"Privateメンバ関数 \"%s\" を呼び出すことはできません。",tempKeyWord); |
---|
168 | if(num==110) sprintf(msg,"Protectedメンバ関数 \"%s\" を呼び出すことはできません。",tempKeyWord); |
---|
169 | if(num==111) lstrcpy(msg,"InheritsはClass定義内の先頭に記述する必要があります。"); |
---|
170 | if(num==112) sprintf(msg,"\"%s\" はクラス型ではないため、初期パラメータを指定することはできません。",tempKeyWord); |
---|
171 | if(num==113) sprintf(msg,"\"%s\" コンストラクタへ渡すパラメータが不正です。",tempKeyWord); |
---|
172 | if(num==114) lstrcpy(msg,"デストラクタはパラメータを持てません。"); |
---|
173 | if(num==115) lstrcpy(msg,"コンストラクタ及びデストラクタは戻り値を持てません。"); |
---|
174 | //if(num==116) lstrcpy(msg,"コンストラクタ及びデストラクタはパブリックアクセスにしなければなりません。"); |
---|
175 | if(num==117) lstrcpy(msg,"デストラクタの名前が \"~クラス名\" になっていません。"); |
---|
176 | if(num==118) lstrcpy(msg,"参照する基底クラスが存在しません。"); |
---|
177 | if(num==119) sprintf(msg,"\"%s\" メンバは基底クラスで定義されていません。",tempKeyWord); |
---|
178 | if(num==120) lstrcpy(msg,"デストラクトするオブジェクトの型が不明です。"); |
---|
179 | if(num==121) lstrcpy(msg,"New演算子にはクラス以外の型を指定できません。"); |
---|
180 | if(num==122) lstrcpy(msg,"Delete演算子にポインタ以外の型が指定されています。"); |
---|
181 | if(num==123) lstrcpy(msg,"ループ継承が行われました。"); |
---|
182 | if(num==124) lstrcpy(msg,"循環参照が行われました。"); |
---|
183 | if(num==125) sprintf(msg,"\"%s\" は抽象クラスです。インスタンス化することはできません。",tempKeyWord); |
---|
184 | if(num==126) lstrcpy(msg,"オペレータのオーバーロードをクラスの外で行うことはできません。"); |
---|
185 | if(num==127) lstrcpy(msg,"Override修飾子の指定が無い状況でオーバーライドを行うことはできません。"); |
---|
186 | if(num==128) lstrcpy(msg,"オーバーライドを行うときはアクセシビリティを同一にしなければなりません。"); |
---|
187 | if(num==129) sprintf(msg,"静的メンバ \"%s\" は定義されていません。",tempKeyWord); |
---|
188 | if(num==130) sprintf(msg,"\"%s\" はオブジェクト定数です。書き込みアクセスはできません。",tempKeyWord); |
---|
189 | if(num==131) lstrcpy(msg,"Const定義されたメソッド内でクラスメンバへの書き込みアクセスはできません。"); |
---|
190 | if(num==132) lstrcpy(msg,"明示的なコンストラクタ呼び出しと初期値の指定を同時に行うことはできません。"); |
---|
191 | if(num==133) lstrcpy(msg,"Thisに代入はできません。"); |
---|
192 | if(num==134) lstrcpy( msg,"ObjPtr関数にはオブジェクト インスタンス以外を指定できません。" ); |
---|
193 | |
---|
194 | //Enum関連 |
---|
195 | if(num==150) sprintf(msg,"\"%s\" 値が定義されていません。",tempKeyWord); |
---|
196 | if(num==151) sprintf(msg,"\"%s\" 列挙リストに登録されていません。",tempKeyWord); |
---|
197 | |
---|
198 | //リンカ |
---|
199 | if(num==200) sprintf(msg,"\"%s\" 未解決です (リンク エラー)。",tempKeyWord); |
---|
200 | if(num==201) sprintf(msg,"\"%s\" の読み込みに失敗。",tempKeyWord); |
---|
201 | |
---|
202 | //原因不明 |
---|
203 | if(num==300) lstrcpy(msg,"内部エラー"); |
---|
204 | |
---|
205 | #else |
---|
206 | //////////////////// |
---|
207 | //英語 |
---|
208 | //////////////////// |
---|
209 | if(num==1) lstrcpy(msg,"Syntax Error."); |
---|
210 | if(num==2) sprintf(msg,"Left operand must be l-value."); |
---|
211 | //num==3は予約されています |
---|
212 | if(num==4) sprintf(msg,"Correlation of %s is wrong.",tempKeyWord); |
---|
213 | if(num==5) sprintf(msg,"Correlation of double quotes is wrong."); |
---|
214 | if(num==6) sprintf(msg,"\"%s\" Label not found.",tempKeyWord); |
---|
215 | if(num==7) lstrcpy(msg,"The DLL name is too long. Must be 16 characters or less."); |
---|
216 | if(num==8) lstrcpy(msg,"The inaccurate characters are contained."); |
---|
217 | if(num==9) sprintf(msg,"Type is wrong."); |
---|
218 | if(num==10) sprintf(msg,"\"%s\" Rule of parameter is wrong.",tempKeyWord); |
---|
219 | if(num==11) sprintf(msg,"\"%s\" Type is wrong.",tempKeyWord); |
---|
220 | if(num==12) sprintf(msg,"\"%s\" Not a valid use.",tempKeyWord); |
---|
221 | if(num==13) sprintf(msg,"Cannot refer to \"%s\".",tempKeyWord); |
---|
222 | if(num==14) sprintf(msg,"\"%s\" Array argument(s) out of bound.",tempKeyWord); |
---|
223 | if(num==15) sprintf(msg,"\"%s\" is already defined.",tempKeyWord); |
---|
224 | if(num==16) sprintf(msg,"\"%s\" Argument(s) following variable which is not pointer or array.",tempKeyWord); |
---|
225 | if(num==17) sprintf(msg,"Invalid resource data."); |
---|
226 | if(num==18) sprintf(msg,"\"%s\" Invalid operation on a pointer variable.",tempKeyWord); |
---|
227 | if(num==19) sprintf(msg,"\"%s\" is already to be passed by value. You cannot use \"ByVal\".",tempKeyWord); |
---|
228 | if(num==21) sprintf(msg,"Wrong structure of \"If\" block."); |
---|
229 | if(num==22) sprintf(msg,"No matching \"End %s\" found for \"%s\".",tempKeyWord,tempKeyWord); |
---|
230 | if(num==23) sprintf(msg,"Cannot read the resource file \"%s\".",tempKeyWord); |
---|
231 | if(num==24) lstrcpy(msg,"Must not use String type as an argument for exported function. (Use BytePtr type instead.)"); |
---|
232 | if(num==27) sprintf(msg,"\"%s\" Undefined procedure.",tempKeyWord); |
---|
233 | if(num==28) sprintf(msg,"\"%s\" Structure must not be passed by value. (Use \"ByRef\".)",tempKeyWord); |
---|
234 | if(num==29) sprintf(msg,"Array must not be passed by value. (Use \"ByRef\".)"); |
---|
235 | //num==30は予約されています |
---|
236 | if(num==31) sprintf(msg,"\"%s\" is a struct. (Use period \".\" to refer to the members.)",tempKeyWord); |
---|
237 | if(num==32) sprintf(msg,"\"%s\" is a pointer of struct. (Use arrow \"->\" to refer to the members.)",tempKeyWord); |
---|
238 | if(num==33) sprintf(msg,"Constant formula has a thing that is not literal value or constant value."); |
---|
239 | if(num==34) sprintf(msg,"Constant formula must be defined in the module level."); |
---|
240 | if(num==38) sprintf(msg,"\"%s\" is a procedure without a return value.",tempKeyWord); |
---|
241 | if(num==39) sprintf(msg,"\"%s\" is not object pointer. \"->\" is invalid.",tempKeyWord); |
---|
242 | if(num==40) lstrcpy(msg,"Cannot set a object to return value."); |
---|
243 | if(num==41) lstrcpy(msg,"Init data is wrong."); |
---|
244 | if(num==42) lstrcpy(msg,"The inaccurate characters are contained after the closing parenthesis \")\"."); |
---|
245 | if(num==43) lstrcpy(msg,"The inaccurate characters are contained after the double quote."); |
---|
246 | |
---|
247 | //オブジェクト関連 |
---|
248 | if(num==102) sprintf(msg,"\"%s\" The object is not defined.",tempKeyWord); |
---|
249 | if(num==103) sprintf(msg,"\"%s\" The member is not defined.",tempKeyWord); |
---|
250 | if(num==104) sprintf(msg,"\"%s\" The reference character is different.",tempKeyWord); |
---|
251 | if(num==105) sprintf(msg,"\"%s\" An own class is not inheritable.",tempKeyWord); |
---|
252 | if(num==106) sprintf(msg,"\"%s\" It class is not defined.",tempKeyWord); |
---|
253 | if(num==107) sprintf(msg,"\"%s\" Cannot access the private member.",tempKeyWord); |
---|
254 | if(num==108) sprintf(msg,"\"%s\" Cannot access the protected member.",tempKeyWord); |
---|
255 | if(num==109) sprintf(msg,"\"%s\" Cannot call the private member.",tempKeyWord); |
---|
256 | if(num==110) sprintf(msg,"\"%s\" Cannot call the protected member.",tempKeyWord); |
---|
257 | if(num==111) lstrcpy(msg,"The Inherits phrase must be described to the 1st line of class module"); |
---|
258 | if(num==112) sprintf(msg,"\"%s\" is not class object. Therefor you cannot set the parameter for constructor.",tempKeyWord); |
---|
259 | if(num==113) sprintf(msg,"\"%s\" The parameter for constructor is wrong.",tempKeyWord); |
---|
260 | if(num==114) lstrcpy(msg,"Destructor cannot have a parameter."); |
---|
261 | if(num==115) lstrcpy(msg,"Constructor and Destructor cannot have a return value."); |
---|
262 | if(num==116) lstrcpy(msg,"Constructor and Destructor must be public access."); |
---|
263 | if(num==117) lstrcpy(msg,"Destructors name must be \"~ClassName\"."); |
---|
264 | if(num==118) lstrcpy(msg,"Super class is not found."); |
---|
265 | if(num==119) sprintf(msg,"\"%s\" The member is not defined in the super class.",tempKeyWord); |
---|
266 | |
---|
267 | //Enum関連 |
---|
268 | if(num==150) sprintf(msg,"\"%s\" The value is not set",tempKeyWord); |
---|
269 | if(num==151) sprintf(msg,"\"%s\" is not found from enum lists.",tempKeyWord); |
---|
270 | |
---|
271 | //リンカ |
---|
272 | if(num==200) sprintf(msg,"\"%s\" Unknown error.",tempKeyWord); |
---|
273 | #endif |
---|
274 | |
---|
275 | return 1; |
---|
276 | } |
---|
277 | void SetError(int ErrorNum,const string &keyWord,int pos){ |
---|
278 | SetError( ErrorNum, keyWord.c_str(), pos ); |
---|
279 | } |
---|
280 | void SetError(int num,const char *KeyWord,int pos){ |
---|
281 | extern HANDLE hHeap; |
---|
282 | extern HWND hMainDlg; |
---|
283 | extern ERRORINFO *pErrorInfo; |
---|
284 | extern int ErrorNum; |
---|
285 | char temporary[1024],temp2[1024],temp3[32],FileName[MAX_PATH]; |
---|
286 | BOOL bFirst; |
---|
287 | int i2; |
---|
288 | |
---|
289 | extern BOOL bDebugRun; |
---|
290 | if(bDebugRun) return; |
---|
291 | |
---|
292 | if(num!=-2){ |
---|
293 | //一般エラーまたは警告 |
---|
294 | i2=0; //ここにブレークポイントをおく |
---|
295 | |
---|
296 | if(num>-100){ |
---|
297 | //エラーのみ |
---|
298 | i2=0; |
---|
299 | } |
---|
300 | |
---|
301 | } |
---|
302 | |
---|
303 | if(!GetErrorMsg(num,KeyWord,temporary,pos)) return; |
---|
304 | |
---|
305 | if(ErrorNum==0){ |
---|
306 | SetDlgItemText(hMainDlg,IDC_ERRORLIST,""); |
---|
307 | EnableWindow(GetDlgItem(hMainDlg,IDC_ERRORLIST),1); |
---|
308 | bFirst=1; |
---|
309 | } |
---|
310 | else bFirst=0; |
---|
311 | |
---|
312 | |
---|
313 | //////////////////// |
---|
314 | // エラー情報を追加 |
---|
315 | pErrorInfo=(ERRORINFO *)HeapReAlloc(hHeap,0,pErrorInfo,(ErrorNum+1)*sizeof(ERRORINFO)); |
---|
316 | |
---|
317 | if(pos==-1){ |
---|
318 | pErrorInfo[ErrorNum].FileName=0; |
---|
319 | lstrcpy(temp2,temporary); |
---|
320 | } |
---|
321 | else{ |
---|
322 | GetLineNum(pos,&pErrorInfo[ErrorNum].line,FileName); |
---|
323 | |
---|
324 | pErrorInfo[ErrorNum].FileName=(char *)HeapAlloc(hHeap,0,lstrlen(FileName)+1); |
---|
325 | lstrcpy(pErrorInfo[ErrorNum].FileName,FileName); |
---|
326 | |
---|
327 | _splitpath(pErrorInfo[ErrorNum].FileName,0,0,temp2,temp3); |
---|
328 | lstrcat(temp2,temp3); |
---|
329 | |
---|
330 | if(pErrorInfo[ErrorNum].line==-1) |
---|
331 | sprintf(temp2+lstrlen(temp2),"(no area) %s",temporary); |
---|
332 | else |
---|
333 | sprintf(temp2+lstrlen(temp2),"(%d) - %s",pErrorInfo[ErrorNum].line+1,temporary); |
---|
334 | } |
---|
335 | |
---|
336 | i2=GetWindowTextLength(GetDlgItem(hMainDlg,IDC_ERRORLIST)); |
---|
337 | SendDlgItemMessage(hMainDlg,IDC_ERRORLIST,EM_SETSEL,i2,i2); |
---|
338 | if(bFirst==0){ |
---|
339 | SendDlgItemMessage(hMainDlg,IDC_ERRORLIST,EM_REPLACESEL,0,(LPARAM)"\r\n"); |
---|
340 | i2+=2; |
---|
341 | SendDlgItemMessage(hMainDlg,IDC_ERRORLIST,EM_SETSEL,i2,i2); |
---|
342 | } |
---|
343 | SendDlgItemMessage(hMainDlg,IDC_ERRORLIST,EM_REPLACESEL,0,(LPARAM)temp2); |
---|
344 | |
---|
345 | if(num==-2){ |
---|
346 | //コンパイルメッセージ |
---|
347 | //※何もしない |
---|
348 | extern int CompileMsgNum; |
---|
349 | CompileMsgNum++; |
---|
350 | } |
---|
351 | else{ |
---|
352 | if(num>-100){ |
---|
353 | //警告ではなく、エラーの場合はエラーチェックフラグを立てる |
---|
354 | extern BOOL bError; |
---|
355 | bError=1; |
---|
356 | } |
---|
357 | else{ |
---|
358 | extern int WarningNum; |
---|
359 | WarningNum++; |
---|
360 | } |
---|
361 | } |
---|
362 | |
---|
363 | ErrorNum++; |
---|
364 | } |
---|
365 | void SetError(){ |
---|
366 | SetError(300,NULL,cp); |
---|
367 | } |
---|
368 | void CompileMessage(char *buffer){ |
---|
369 | SetError(-2,buffer,-1); |
---|
370 | } |
---|
371 | |
---|
372 | #define STRING_SYSTEM_DECLAREHANDLE "*_System_DeclareHandle_" |
---|
373 | void DifferentTypeError(const int VarType,LONG_PTR VarIndex,const int CalcType,LONG_PTR CalcIndex,const int iWarning,const char *pszFuncName,const int ParmNum){ |
---|
374 | ////////////////////////// |
---|
375 | // キャストに関する警告 |
---|
376 | ////////////////////////// |
---|
377 | char temporary[255],temp2[255],temp3[255]; |
---|
378 | |
---|
379 | if(IS_LITERAL(CalcIndex)) CalcIndex=-1; |
---|
380 | |
---|
381 | if(pszFuncName) |
---|
382 | sprintf(temporary,"\"%s\"の第%dパラメータが、",pszFuncName,ParmNum+1); |
---|
383 | else temporary[0]=0; |
---|
384 | |
---|
385 | if(!GetTypeName(VarType,VarIndex,temp2)) lstrcpy(temp2,"Any"); |
---|
386 | if(memcmp(temp2,STRING_SYSTEM_DECLAREHANDLE,lstrlen(STRING_SYSTEM_DECLAREHANDLE))==0){ |
---|
387 | memmove(temp2, |
---|
388 | temp2+lstrlen(STRING_SYSTEM_DECLAREHANDLE), |
---|
389 | lstrlen(temp2+lstrlen(STRING_SYSTEM_DECLAREHANDLE))+1); |
---|
390 | } |
---|
391 | if(!GetTypeName(CalcType,CalcIndex,temp3)) lstrcpy(temp3,"Any"); |
---|
392 | if(memcmp(temp3,STRING_SYSTEM_DECLAREHANDLE,lstrlen(STRING_SYSTEM_DECLAREHANDLE))==0){ |
---|
393 | memmove(temp3, |
---|
394 | temp3+lstrlen(STRING_SYSTEM_DECLAREHANDLE), |
---|
395 | lstrlen(temp3+lstrlen(STRING_SYSTEM_DECLAREHANDLE))+1); |
---|
396 | } |
---|
397 | sprintf(temporary+lstrlen(temporary),"%sから%s",temp3,temp2); |
---|
398 | |
---|
399 | extern int cp; |
---|
400 | if(iWarning==1) SetError(-101,temporary,cp); |
---|
401 | else if(iWarning==2) SetError(-102,temporary,cp); |
---|
402 | else if(iWarning==3) SetError(50,temporary,cp); |
---|
403 | } |
---|
404 | |
---|
405 | bool CheckDifferentType(const int VarType,const LONG_PTR lpVarIndex,int CalcType,const LONG_PTR lpCalcIndex,const char *pszFuncName,const int ParmNum){ |
---|
406 | |
---|
407 | if(VarType==DEF_STRUCT||CalcType==DEF_STRUCT){ |
---|
408 | //いずれかが構造体場合 |
---|
409 | if( VarType != CalcType || lpVarIndex != lpCalcIndex ){ |
---|
410 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,3,pszFuncName,ParmNum); |
---|
411 | return false; |
---|
412 | } |
---|
413 | } |
---|
414 | |
---|
415 | if(VarType==DEF_OBJECT||CalcType==DEF_OBJECT){ |
---|
416 | //いずれかがオブジェクトインスタンスの場合 |
---|
417 | if( VarType != CalcType ){ |
---|
418 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,3,pszFuncName,ParmNum); |
---|
419 | return false; |
---|
420 | } |
---|
421 | |
---|
422 | CClass *pClass = (CClass *)lpVarIndex; |
---|
423 | if( !pClass->IsEqualsOrSubClass( (CClass *)lpCalcIndex ) ){ |
---|
424 | //等しくなく、派生クラスでもないとき |
---|
425 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,3,pszFuncName,ParmNum); |
---|
426 | return false; |
---|
427 | } |
---|
428 | } |
---|
429 | |
---|
430 | //#strictが指定されていないときは型チェックを行わないようにする |
---|
431 | extern BOOL bStrict; |
---|
432 | if(bStrict==0) return true; |
---|
433 | |
---|
434 | if(CalcType&FLAG_PTR){ |
---|
435 | //配列先頭フラグがたっている場合は、ポインタ型として扱う |
---|
436 | CalcType=MAKE_PTR_TYPE(NATURAL_TYPE(CalcType),PTR_LEVEL(CalcType)+1); |
---|
437 | } |
---|
438 | |
---|
439 | if(IsPtrType(VarType)||IsPtrType(CalcType)){ |
---|
440 | /* 右辺及び左辺のいずれかがポインタ型の場合は、 |
---|
441 | 型チェックを行う。 |
---|
442 | ・同一の種類のポインタ型以外はエラーとする */ |
---|
443 | |
---|
444 | if(IsPtrType(VarType)&&lpCalcIndex==LITERAL_NULL){ |
---|
445 | //リテラルNULL値の場合 |
---|
446 | return true; |
---|
447 | } |
---|
448 | |
---|
449 | if(VarType==DEF_PTR_VOID){ |
---|
450 | //左辺がVoidPtr型の場合は、ポインタ型すべてを受け入れる |
---|
451 | if(IsPtrType(CalcType)) return true; |
---|
452 | } |
---|
453 | |
---|
454 | if(CalcType==DEF_PTR_VOID){ |
---|
455 | //右辺がVoidPtr型の場合は、ポインタ型すべてを受け入れる |
---|
456 | if(IsPtrType(VarType)) return true; |
---|
457 | } |
---|
458 | |
---|
459 | if(VarType!=CalcType){ |
---|
460 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,2,pszFuncName,ParmNum); |
---|
461 | return true; |
---|
462 | } |
---|
463 | |
---|
464 | if(VarType==DEF_PTR_OBJECT){ |
---|
465 | //双方がオブジェクトポインタ型の場合 |
---|
466 | if(lpVarIndex!=lpCalcIndex){ |
---|
467 | const CClass *pobj_tempClass; |
---|
468 | pobj_tempClass=(CClass *)lpCalcIndex; |
---|
469 | while(pobj_tempClass&&(!IS_LITERAL((LONG_PTR)pobj_tempClass))){ |
---|
470 | pobj_tempClass=pobj_tempClass->pobj_InheritsClass; |
---|
471 | |
---|
472 | if(lpVarIndex==(LONG_PTR)pobj_tempClass){ |
---|
473 | //継承先が等しいとき |
---|
474 | return true; |
---|
475 | } |
---|
476 | } |
---|
477 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,2,pszFuncName,ParmNum); |
---|
478 | return true; |
---|
479 | } |
---|
480 | } |
---|
481 | } |
---|
482 | |
---|
483 | if(VarType==DEF_DOUBLE){ |
---|
484 | if(Is64Type(CalcType)){ |
---|
485 | //64ビット整数値の場合は警告を出す |
---|
486 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum); |
---|
487 | } |
---|
488 | } |
---|
489 | else if(VarType==DEF_SINGLE){ |
---|
490 | if(Is64Type(CalcType)||CalcType==DEF_DOUBLE){ |
---|
491 | //64ビット整数値、またはDouble型の場合は警告を出す |
---|
492 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum); |
---|
493 | } |
---|
494 | } |
---|
495 | else if(GetTypeSize(VarType,lpVarIndex)==sizeof(char)){ |
---|
496 | if(GetTypeSize(CalcType,lpCalcIndex)>sizeof(char)&& |
---|
497 | lpCalcIndex!=LITERAL_NULL&& |
---|
498 | lpCalcIndex!=LITERAL_M128_0&& |
---|
499 | lpCalcIndex!=LITERAL_0_255){ |
---|
500 | //8ビット整数値より大きな型で、リテラル値でもない場合は警告を出す |
---|
501 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum); |
---|
502 | } |
---|
503 | } |
---|
504 | else if(GetTypeSize(VarType,lpVarIndex)==sizeof(short)){ |
---|
505 | if(GetTypeSize(CalcType,lpCalcIndex)>sizeof(short)&& |
---|
506 | lpCalcIndex!=LITERAL_NULL&& |
---|
507 | lpCalcIndex!=LITERAL_M128_0&& |
---|
508 | lpCalcIndex!=LITERAL_0_255&& |
---|
509 | lpCalcIndex!=LITERAL_M32768_0&& |
---|
510 | lpCalcIndex!=LITERAL_0_65535){ |
---|
511 | //16ビット整数値より大きな型で、リテラル値でもない場合は警告を出す |
---|
512 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum); |
---|
513 | } |
---|
514 | } |
---|
515 | else if(GetTypeSize(VarType,lpVarIndex)==sizeof(long)){ |
---|
516 | if(IsRealNumberType(CalcType)|| |
---|
517 | (IsWholeNumberType(CalcType)&& |
---|
518 | GetTypeSize(CalcType,lpCalcIndex)>sizeof(long)&& |
---|
519 | lpCalcIndex!=LITERAL_NULL) |
---|
520 | ){ |
---|
521 | /* 32ビット整数値より大きな型、または実数、 |
---|
522 | またはリテラル値でもない場合は警告を出す */ |
---|
523 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum); |
---|
524 | } |
---|
525 | } |
---|
526 | else if(GetTypeSize(VarType,lpVarIndex)==sizeof(_int64)){ |
---|
527 | if(IsRealNumberType(CalcType)){ |
---|
528 | //実数の場合は警告を出す |
---|
529 | DifferentTypeError(VarType,lpVarIndex,CalcType,lpCalcIndex,1,pszFuncName,ParmNum); |
---|
530 | } |
---|
531 | } |
---|
532 | |
---|
533 | return true; |
---|
534 | } |
---|
535 | bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum){ |
---|
536 | return CheckDifferentType( |
---|
537 | varType.GetBasicType(), |
---|
538 | varType.GetIndex(), |
---|
539 | calcType.GetBasicType(), |
---|
540 | calcType.GetIndex(), |
---|
541 | pszFuncName, |
---|
542 | ParmNum ); |
---|
543 | } |
---|