[206] | 1 | #pragma once
|
---|
| 2 |
|
---|
[14] | 3 | //#define _CRT_SECURE_NO_DEPRECATE
|
---|
| 4 | #pragma warning(disable : 4996)
|
---|
[5] | 5 |
|
---|
[165] | 6 | #include <option.h>
|
---|
| 7 |
|
---|
[4] | 8 | #ifdef _AMD64_
|
---|
[485] | 9 | #include "../compiler_x64/resource.h"
|
---|
| 10 | #include "../compiler_x64/CommandValue.h"
|
---|
| 11 | #define OPCODE_H_PATH "../compiler_x64/opcode.h"
|
---|
[4] | 12 | #else
|
---|
[484] | 13 | #include "../compiler_x86/resource.h"
|
---|
| 14 | #include "../compiler_x86/CommandValue.h"
|
---|
| 15 | #define OPCODE_H_PATH "../compiler_x86/opcode.h"
|
---|
[4] | 16 | #endif
|
---|
| 17 |
|
---|
| 18 | #include "../BasicCompiler_Common/NonVolatile.h"
|
---|
| 19 | #include "../BasicCompiler_Common/psapi.h"
|
---|
| 20 | #include "../BasicCompiler_Common/BreakPoint.h"
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | #if defined(JPN)
|
---|
| 25 | //日本語
|
---|
| 26 | #include "common_msg_jpn.h"
|
---|
| 27 | #else
|
---|
| 28 | //英語
|
---|
| 29 | #include "common_msg_eng.h"
|
---|
| 30 | #endif
|
---|
| 31 |
|
---|
| 32 |
|
---|
[123] | 33 | #define OBJECT_HEAD_SIZE PTR_SIZE*4
|
---|
[4] | 34 |
|
---|
| 35 | #define MAX_LEN 65535
|
---|
| 36 | #define DIGIT_SIZE 128
|
---|
| 37 | #define MAX_PARMS 64
|
---|
| 38 | #define MAX_ARRAYDIM 16
|
---|
| 39 | #define MAX_HASH 32761
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | #ifdef _AMD64_
|
---|
[288] | 43 | #define PLATFORM 64
|
---|
[4] | 44 | #else
|
---|
| 45 | #define PLATFORM 32
|
---|
[288] | 46 | #ifndef LONG_PTR
|
---|
| 47 | typedef long LONG_PTR;
|
---|
| 48 | typedef DWORD ULONG_PTR;
|
---|
| 49 | #endif
|
---|
[4] | 50 | #endif
|
---|
| 51 |
|
---|
| 52 |
|
---|
| 53 | //未定義の定数情報
|
---|
[107] | 54 | #ifndef IMAGE_FILE_MACHINE_AMD64
|
---|
| 55 | #define IMAGE_FILE_MACHINE_AMD64 0x8664
|
---|
| 56 | #endif
|
---|
[4] | 57 |
|
---|
[107] | 58 | #ifdef _AMD64_
|
---|
| 59 | #ifndef IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
|
---|
| 60 | #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
|
---|
| 61 | #endif
|
---|
| 62 | #else
|
---|
| 63 | #ifndef IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
|
---|
| 64 | #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
|
---|
| 65 | #endif
|
---|
| 66 | #endif
|
---|
[4] | 67 |
|
---|
| 68 |
|
---|
| 69 | extern HWND hOwnerEditor;
|
---|
| 70 | extern HANDLE hHeap;
|
---|
| 71 | extern int cp;
|
---|
[69] | 72 | extern int typeOfPtrChar;
|
---|
[97] | 73 | extern int typeOfPtrUChar;
|
---|
[4] | 74 |
|
---|
| 75 |
|
---|
| 76 |
|
---|
| 77 | //////////////////////////////////////////
|
---|
| 78 | // BasicCompiler、ProjectEditor共通の定数
|
---|
| 79 | //////////////////////////////////////////
|
---|
| 80 |
|
---|
| 81 | //サイズ変更枠の太さ
|
---|
| 82 | #define LEVER_THICK 5
|
---|
| 83 |
|
---|
| 84 | #define WM_SHOWERROR WM_USER+70 //エラー表示メッセージ
|
---|
| 85 |
|
---|
| 86 | #define WM_SETCOMPILEVIEW WM_USER+71 //コンパイラウィンドウが表示されたとき
|
---|
| 87 | #define WM_DESTROYCOMPILEVIEW WM_USER+72 //コンパイラウィンドウが破棄されたとき
|
---|
| 88 |
|
---|
| 89 | #define WM_SETDEBUGGERBASE WM_USER+73 //デバッガベースウィンドウが表示されたとき
|
---|
| 90 | #define WM_DESTROYDEBUGGERBASE WM_USER+74 //デバッガベースウィンドウが破棄されたとき
|
---|
| 91 |
|
---|
| 92 | #define WM_SETDEBUGGERVIEW WM_USER+75 //デバッガウィンドウが表示されたとき
|
---|
| 93 | #define WM_DESTROYDEBUGGERVIEW WM_USER+76 //デバッガウィンドウが表示されたとき
|
---|
| 94 |
|
---|
| 95 | ///////////////////////////////////////////
|
---|
| 96 |
|
---|
| 97 |
|
---|
| 98 | #define WM_SHOWVARLIST WM_USER+80
|
---|
| 99 | #define WM_VARLIST_CLOSE WM_USER+81 //変数リストの終了メッセージ(破棄のみ、解放なし)
|
---|
| 100 |
|
---|
| 101 |
|
---|
| 102 |
|
---|
| 103 | ///////////////////////////////////////////
|
---|
| 104 | // デバッグ コマンド
|
---|
| 105 |
|
---|
| 106 | #define WM_DEBUG_CONTINUE WM_USER+200
|
---|
| 107 | #define WM_STEP_IN WM_USER+201
|
---|
| 108 | #define WM_STEP_OVER WM_USER+202
|
---|
| 109 | #define WM_STEP_CURSOR WM_USER+203
|
---|
| 110 | #define WM_DEBUG_STOP WM_USER+204
|
---|
| 111 | #define WM_DEBUG_PAUSE WM_USER+205
|
---|
| 112 | #define WM_CLOSE_DEBUGGER WM_USER+206
|
---|
| 113 |
|
---|
| 114 | ///////////////////////////////////////////
|
---|
| 115 |
|
---|
| 116 |
|
---|
| 117 |
|
---|
| 118 |
|
---|
| 119 | #define FILE_ALIGNMENT 0x1000
|
---|
| 120 | #define MEM_ALIGNMENT 0x1000
|
---|
| 121 | #define EXE_HEADER_SIZE 0x1000
|
---|
| 122 |
|
---|
| 123 |
|
---|
| 124 |
|
---|
| 125 | struct ERRORINFO{
|
---|
| 126 | char *FileName;
|
---|
| 127 | int line;
|
---|
| 128 | };
|
---|
| 129 |
|
---|
| 130 | //変数の相対情報
|
---|
| 131 | struct RELATIVE_VAR{
|
---|
| 132 | DWORD dwKind;
|
---|
| 133 | LONG_PTR offset;
|
---|
| 134 | BOOL bOffsetOffset;
|
---|
| 135 | };
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 | struct RESOURCEDATAINFO{
|
---|
| 139 | DWORD dwId;
|
---|
| 140 | char FileName[MAX_PATH];
|
---|
| 141 | };
|
---|
| 142 |
|
---|
| 143 |
|
---|
| 144 | //////////////////////////////////////////
|
---|
| 145 | // リソース ヘッダ(アイコン、カーソル用)
|
---|
| 146 | typedef struct{
|
---|
| 147 | WORD idReserved;
|
---|
| 148 | WORD idType;
|
---|
| 149 | WORD idCount;
|
---|
| 150 | }ICONDIR,CURSORDIR;
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | /////////////////////////////
|
---|
| 154 | // .curファイルのヘッダ情報
|
---|
| 155 | struct CURSORDIRENTRY{
|
---|
| 156 | BYTE bWidth;
|
---|
| 157 | BYTE bHeight;
|
---|
| 158 | BYTE bColorCount;
|
---|
| 159 | BYTE bReserved;
|
---|
| 160 | WORD wXHotspot;
|
---|
| 161 | WORD wYHotspot;
|
---|
| 162 | DWORD dwBytesInRes;
|
---|
| 163 | DWORD dwImageOffset;
|
---|
| 164 | };
|
---|
| 165 | struct CURSORDIRENTRY_RES{
|
---|
| 166 | WORD wWidth;
|
---|
| 167 | WORD wHeight;
|
---|
| 168 | WORD wXHotspot;
|
---|
| 169 | WORD wYHotspot;
|
---|
| 170 | DWORD dwBytesInRes;
|
---|
| 171 | WORD wCursorNum;
|
---|
| 172 | };
|
---|
| 173 |
|
---|
| 174 |
|
---|
| 175 | ////////////////////////////
|
---|
| 176 | //.icoファイルのヘッダ情報
|
---|
| 177 | struct ICONDIRENTRY{
|
---|
| 178 | BYTE bWidth;
|
---|
| 179 | BYTE bHeight;
|
---|
| 180 | BYTE bColorCount;
|
---|
| 181 | BYTE bReserved;
|
---|
| 182 | WORD wPlanes;
|
---|
| 183 | WORD wBitCount;
|
---|
| 184 | DWORD dwBytesInRes;
|
---|
| 185 | DWORD dwImageOffset;
|
---|
| 186 | };
|
---|
| 187 | struct ICONDIRENTRY_RES{
|
---|
| 188 | BYTE bWidth;
|
---|
| 189 | BYTE bHeight;
|
---|
| 190 | BYTE bColorCount;
|
---|
| 191 | BYTE bReserved;
|
---|
| 192 | WORD wPlanes;
|
---|
| 193 | WORD wBitCount;
|
---|
| 194 | DWORD dwBytesInRes;
|
---|
| 195 | WORD wIconNum;
|
---|
| 196 | };
|
---|
| 197 |
|
---|
| 198 |
|
---|
| 199 |
|
---|
[34] | 200 | #include "../BasicCompiler_Common/PESchedule.h"
|
---|
[400] | 201 | #include "../BasicCompiler_Common/StrOperation.h"
|
---|
[75] | 202 | #include "../BasicCompiler_Common/VariableOpe.h"
|
---|
[4] | 203 |
|
---|
| 204 |
|
---|
| 205 |
|
---|
[75] | 206 | bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList=0, bool *pIsMemoryAccessError=NULL);
|
---|
[4] | 207 |
|
---|
| 208 |
|
---|
| 209 | //BasicCompiler.cpp
|
---|
| 210 | void HeapDefaultFree(LPVOID lpMem);
|
---|
[393] | 211 | void ts(int i = 0);
|
---|
[4] | 212 | void ts(int i,int i2);
|
---|
[322] | 213 | void ts(const char *msg);
|
---|
| 214 | void ts(const char *msg,const char *title);
|
---|
[477] | 215 | void ts(const std::string msg);
|
---|
[4] | 216 | void epi_check();
|
---|
| 217 | void GetRelationalPath(char *path,char *dir);
|
---|
[523] | 218 | void GetFullPath( char *path, const std::string &baseDirPath );
|
---|
[322] | 219 | std::string GetApplicationBaseFullPath( const std::string &relationalPath );
|
---|
[279] | 220 | void ShowErrorLine(int LineNum,const char *FileName);
|
---|
[4] | 221 | BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen);
|
---|
| 222 | void MakeMessageText(char *buffer,char *msg,int flag);
|
---|
| 223 |
|
---|
| 224 | //hash.cpp
|
---|
[75] | 225 | int hash_default(const char *name);
|
---|
[209] | 226 | DllProc *GetDeclareHash(const char *name);
|
---|
[206] | 227 | void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs );
|
---|
| 228 | const UserProc *GetSubHash(const char *name,BOOL bError=0);
|
---|
| 229 | const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);
|
---|
| 230 | const UserProc *GetClassMethod( const char *className, const char *methodName );
|
---|
[4] | 231 |
|
---|
| 232 | //Object.cpp
|
---|
[206] | 233 | void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
|
---|
[75] | 234 | bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
|
---|
[4] | 235 |
|
---|
| 236 | //Overload.sbp
|
---|
[206] | 237 | class Parameters;
|
---|
| 238 | const UserProc *OverloadSolutionWithStrParam(
|
---|
[50] | 239 | const char *name,
|
---|
[206] | 240 | std::vector<const UserProc *> &subs,
|
---|
[50] | 241 | const char *Parameter,
|
---|
[75] | 242 | const char *ObjectName);
|
---|
[206] | 243 | const UserProc *OverloadSolution(
|
---|
[50] | 244 | const char *name,
|
---|
[206] | 245 | std::vector<const UserProc *> &subs,
|
---|
[75] | 246 | const Parameters ¶ms,
|
---|
[424] | 247 | const Type &returnType,
|
---|
| 248 | const Type &leftType );
|
---|
[4] | 249 |
|
---|
| 250 | //Debug.cpp
|
---|
| 251 | void Debugger_StepIn(void);
|
---|
| 252 | void Debugger_StepOver(void);
|
---|
| 253 | void Debugger_StepCursor(void);
|
---|
| 254 | void Debugger_Stop(void);
|
---|
| 255 | void Debugger_Pause(void);
|
---|
| 256 | ULONG_PTR rva_to_real(DWORD p);
|
---|
[206] | 257 | UserProc *GetSubFromObp(ULONG_PTR pos);
|
---|
[4] | 258 | void ReadOpBuffer();
|
---|
| 259 | void DebugProgram(void);
|
---|
| 260 |
|
---|
| 261 | //VarList.cpp
|
---|
| 262 | void InitVarList(DWORD dwThreadId);
|
---|
| 263 | BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
|
---|
| 264 | BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
|
---|
| 265 |
|
---|
| 266 | //WatchList.cpp
|
---|
| 267 | ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar);
|
---|
| 268 | ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip);
|
---|
[206] | 269 | int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
|
---|
[4] | 270 |
|
---|
| 271 | //MakeExe.cpp
|
---|
| 272 | void StepCompileProgress(void);
|
---|
[350] | 273 | void MakeMiddleCode( char *buffer );
|
---|
[322] | 274 | void AddSourceCode(const char *buffer);
|
---|
[605] | 275 | void Build();
|
---|
[467] | 276 | void MainThread(void *dummy);
|
---|
[4] | 277 |
|
---|
| 278 | //Intermediate_Step1.cpp
|
---|
| 279 | void ChangeReturnCode(char *buffer);
|
---|
| 280 | void DeleteComment(char *buffer);
|
---|
| 281 | void KillReturnCode(char *buffer);
|
---|
| 282 | void CheckParenthesis(char *buffer);
|
---|
| 283 | BOOL CheckParenthesis2(char *buffer);
|
---|
| 284 | void DirectiveCheck(void);
|
---|
| 285 | void NextCommandFormat(char *buffer);
|
---|
| 286 | void SetEscapeSequenceFormat(char *buffer);
|
---|
| 287 | void DefCommandFormat(char *buffer);
|
---|
| 288 | void IfCommandFormat(char *buffer);
|
---|
| 289 | void CheckPareCommand(void);
|
---|
| 290 |
|
---|
| 291 | //Intermediate_Step2.cpp
|
---|
| 292 | void ChangeCommandToCode(char *buffer);
|
---|
| 293 |
|
---|
| 294 | //preprocessor.cpp
|
---|
[15] | 295 | char *OpenBasicFile(char *FileName);
|
---|
[4] | 296 |
|
---|
| 297 | //Resource.cpp
|
---|
| 298 | void GetResourceData(char *FileName);
|
---|
| 299 |
|
---|
| 300 | //CommandFormat.cpp
|
---|
[75] | 301 | void ComOpen(char *Parameter,char *buffer,int nowLine);
|
---|
[4] | 302 | void ComClose(char *Parameter,char *buffer);
|
---|
| 303 | void ComField(char *Parameter,char *buffer);
|
---|
[75] | 304 | void ComLine(char *Parameter,char *buffer,int nowLine);
|
---|
| 305 | void ComCircle(char *Parameter,char *buffer,int nowLine);
|
---|
| 306 | void ComPSet(char *Parameter,char *buffer,int nowLine);
|
---|
| 307 | void ComPaint(char *Parameter,char *buffer,int nowLine);
|
---|
[4] | 308 |
|
---|
| 309 | // StrOperation.cpp
|
---|
| 310 | void KillSpaces(char *str1,char *str2);
|
---|
| 311 | void KillStringSpaces(char *str);
|
---|
| 312 | BOOL RemoveStringQuotes(char *str);
|
---|
[387] | 313 | bool RemoveStringQuotes( std::string &str );
|
---|
[4] | 314 | void RemoveStringPare(char *str);
|
---|
| 315 | void RemoveStringBracket(char *str);
|
---|
| 316 | void SetStringQuotes(char *str);
|
---|
| 317 | int FormatString_EscapeSequence(char *buffer);
|
---|
| 318 | void SlideString(char *str,int slide);
|
---|
| 319 | void SlideBuffer(char *buffer,int length,int slide);
|
---|
[313] | 320 | int GetSourceCodeIndexFromLine( const char *source, int LineNum );
|
---|
[4] | 321 | char GetEndXXXCommand(char es);
|
---|
| 322 | void GetDefaultNameFromES(char es,char *name);
|
---|
[206] | 323 | const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
|
---|
[279] | 324 | bool IsFileExist(const char *path);
|
---|
[31] | 325 | BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
|
---|
[4] | 326 | BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
|
---|
[31] | 327 | void ShortPathToLongPath(const char *ShortPath,char *LongPath);
|
---|
[4] | 328 |
|
---|
| 329 | //calculation.cpp
|
---|
[15] | 330 | bool IsNumberTopChar(const char *buffer);
|
---|
| 331 | bool IsNumberChar(const char c);
|
---|
| 332 | BOOL IsNumCalcMark(const char *Command,int p);
|
---|
| 333 | BOOL IsNumCalcMark_Back(const char *Command,int p);
|
---|
| 334 | BOOL IsStrCalcMark(const char c);
|
---|
| 335 | BOOL IsExponent(const char *Command,int p);
|
---|
[4] | 336 | int GetLiteralIndex(_int64 i64data);
|
---|
| 337 | int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
|
---|
[254] | 338 | DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true );
|
---|
| 339 | int IsStrCalculation(const char *Command);
|
---|
[15] | 340 | BYTE GetCalcId(const char *Command,int *pi);
|
---|
| 341 | BOOL GetNumOpeElements(const char *Command,int *pnum,
|
---|
[4] | 342 | char *values[255],long calc[255],long stack[255]);
|
---|
| 343 |
|
---|
[75] | 344 | //NumOpe_GetType.cpp
|
---|
[4] | 345 | int AutoBigCast(int BaseType,int CalcType);
|
---|
| 346 | BOOL CheckCalcType(int idCalc,int *type,int sp);
|
---|
[415] | 347 | bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL, bool *pIsVariable = NULL );
|
---|
| 348 | bool GetTermType( const char *term, Type &resultType );
|
---|
| 349 | bool GetTermTypeOnlyVariable( const char *term, Type &resultType );
|
---|
[254] | 350 | bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL );
|
---|
[4] | 351 |
|
---|
| 352 | //Subroutine.cpp
|
---|
| 353 | int GetCallProcName(char *buffer,char *name);
|
---|
| 354 | int GetProc(char *name,void **ppInfo);
|
---|
[290] | 355 | void SplitObjectName(const char *name,char *ObjectName, ReferenceKind &referenceFind );
|
---|
[331] | 356 | bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, const Type &baseType, Type &resultType, bool isCallOn = true );
|
---|
[75] | 357 | bool CallPropertyMethod( const char *variable, const char *rightSide, Type &resultType);
|
---|
| 358 | bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
|
---|
[292] | 359 | bool GetReturnTypeOfIndexerGetterProc( const Type &classType, Type &resultType );
|
---|
[523] | 360 | int AddProcPtrInfo( const std::string &typeExpression, int nowLine );
|
---|
[94] | 361 | bool IsNeedProcCompile();
|
---|
[316] | 362 | void CompileLocal();
|
---|
[4] | 363 |
|
---|
[76] | 364 | //OldStatement.cpp
|
---|
| 365 | void Opcode_Input(const char *Parameter);
|
---|
| 366 | void Opcode_Print(const char *Parameter,BOOL bWrite);
|
---|
| 367 |
|
---|
[4] | 368 | //error.cpp
|
---|
[75] | 369 | bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
|
---|
[4] | 370 |
|
---|
| 371 | //Compile.cpp
|
---|
[17] | 372 | void GetIdentifierToken( char *token, const char *source, int &pos );
|
---|
[296] | 373 | void GetCommandToken( char *token, const char *source, int &pos );
|
---|
[381] | 374 | void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence );
|
---|
[424] | 375 | void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass = false, Jenga::Common::Strings *pTypeParameterBaseClassNames = NULL );
|
---|
[16] | 376 | int JumpStatement(const char *source, int &pos);
|
---|
[605] | 377 | void MakeExe();
|
---|
[4] | 378 |
|
---|
[91] | 379 | //Diagnose.cpp
|
---|
| 380 | void Diagnose();
|
---|
| 381 |
|
---|
[4] | 382 | //gc.cpp
|
---|
| 383 | void InitGCVariables(void);
|
---|
| 384 |
|
---|
| 385 |
|
---|
| 386 |
|
---|
| 387 | #ifdef _DEBUG
|
---|
| 388 | /*Debug*/
|
---|
| 389 | /*
|
---|
| 390 | #define HeapAlloc CheckHeapAlloc
|
---|
| 391 | #define HeapReAlloc CheckHeapReAlloc
|
---|
| 392 | LPVOID CheckHeapAlloc(HANDLE hHeap,DWORD dwFlags,DWORD dwBytes);
|
---|
| 393 | LPVOID CheckHeapReAlloc(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes);
|
---|
| 394 | */
|
---|
| 395 | #endif
|
---|