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