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