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