source: dev/branches/egtra/ab5.0/abdev/BasicCompiler_Common/common.h

Last change on this file was 820, checked in by イグトランス (egtra), 13 years ago

Typeクラスを単体テスト可能な状態へ

File size: 11.4 KB
Line 
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
62extern HWND hOwnerEditor;
63extern HANDLE hHeap;
64extern int cp;
65extern int typeOfPtrChar;
66extern 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
118struct ERRORINFO{
119 char *FileName;
120 int line;
121};
122
123//変数の相対情報
124struct RELATIVE_VAR{
125 DWORD dwKind;
126 LONG_PTR offset;
127 BOOL bOffsetOffset;
128};
129
130
131struct RESOURCEDATAINFO{
132 DWORD dwId;
133 char FileName[MAX_PATH];
134};
135
136
137//////////////////////////////////////////
138// リソース ヘッダ(アイコン、カーソル用)
139typedef struct{
140 WORD idReserved;
141 WORD idType;
142 WORD idCount;
143}ICONDIR,CURSORDIR;
144
145
146/////////////////////////////
147// .curファイルのヘッダ情報
148struct 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};
158struct 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ファイルのヘッダ情報
170struct 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};
180struct 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
199bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList=0, bool *pIsMemoryAccessError=NULL);
200
201
202//BasicCompiler.cpp
203void HeapDefaultFree(LPVOID lpMem);
204void ts(int i = 0);
205void ts(int i,int i2);
206void ts(const char *msg);
207void ts(const char *msg,const char *title);
208void ts(const std::string msg);
209void epi_check();
210void GetRelationalPath(char *path,char *dir);
211void GetFullPath( char *path, const std::string &baseDirPath );
212void ShowErrorLine(int LineNum,const char *FileName);
213BOOL GetFilePathDialog(HWND hwnd,char *filename,LPCSTR Filter,LPCSTR Title,BOOL bOpen);
214void MakeMessageText(char *buffer,char *msg,int flag);
215
216//hash.cpp
217DllProc *GetDeclareHash(const char *name);
218void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs );
219const UserProc *GetSubHash(const char *name,BOOL bError=0);
220const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);
221const UserProc *GetClassMethod( const char *className, const char *methodName );
222
223//Object.cpp
224void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
225bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
226
227//Overload.sbp
228class Parameters;
229const UserProc *OverloadSolutionWithStrParam(
230 const char *name,
231 std::vector<const UserProc *> &subs,
232 const char *Parameter,
233 const char *ObjectName);
234const UserProc *OverloadSolution(
235 const char *name,
236 std::vector<const UserProc *> &subs,
237 const Parameters &params,
238 const Type &returnType,
239 const Type &leftType );
240
241//Debug.cpp
242void Debugger_StepIn(void);
243void Debugger_StepOver(void);
244void Debugger_StepCursor(void);
245void Debugger_Stop(void);
246void Debugger_Pause(void);
247ULONG_PTR rva_to_real(DWORD p);
248UserProc *GetSubFromObp(ULONG_PTR pos);
249void ReadOpBuffer();
250void DebugProgram(void);
251
252//VarList.cpp
253void InitVarList(DWORD dwThreadId);
254INT_PTR CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
255INT_PTR CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
256
257//WatchList.cpp
258ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar);
259ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip);
260int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
261
262//MakeExe.cpp
263void StepCompileProgress(void);
264void MakeMiddleCode( char *buffer );
265void AddSourceCode(const char *buffer);
266void Build();
267void MainThread(void *dummy);
268
269//Intermediate_Step1.cpp
270void ChangeReturnCode(char *buffer);
271void DeleteComment(char *buffer);
272void KillReturnCode(char *buffer);
273void CheckParenthesis(char *buffer);
274BOOL CheckParenthesis2(char *buffer);
275void DirectiveCheck(void);
276void NextCommandFormat(char *buffer);
277void SetEscapeSequenceFormat(char *buffer);
278void DefCommandFormat(char *buffer);
279void IfCommandFormat(char *buffer);
280void CheckPareCommand(void);
281
282//Intermediate_Step2.cpp
283void ChangeCommandToCode(char *buffer);
284
285//preprocessor.cpp
286char *OpenBasicFile(char *FileName);
287
288//CommandFormat.cpp
289void ComOpen(char *Parameter,char *buffer,int nowLine);
290void ComClose(char *Parameter,char *buffer);
291void ComField(char *Parameter,char *buffer);
292void ComLine(char *Parameter,char *buffer,int nowLine);
293void ComCircle(char *Parameter,char *buffer,int nowLine);
294void ComPSet(char *Parameter,char *buffer,int nowLine);
295void ComPaint(char *Parameter,char *buffer,int nowLine);
296
297// StrOperation.cpp
298void KillSpaces(const char *str1,char *str2);
299void KillStringSpaces(char *str);
300BOOL RemoveStringQuotes(char *str);
301bool RemoveStringQuotes( std::string &str );
302void RemoveStringPare(char *str);
303void RemoveStringBracket(char *str);
304void SetStringQuotes(char *str);
305int FormatString_EscapeSequence(char *buffer);
306void SlideString(char *str,int slide);
307void SlideBuffer(char *buffer,int length,int slide);
308int GetSourceCodeIndexFromLine( const char *source, int LineNum );
309char GetEndXXXCommand(char es);
310void GetDefaultNameFromES(char es,char *name);
311std::string FormatEscapeSequenceStringToDefaultString( const std::string &source );
312bool IsFileExist(const char *path);
313BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
314BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
315void ShortPathToLongPath(const char *ShortPath,char *LongPath);
316
317//calculation.cpp
318bool IsNumberTopChar(const char *buffer);
319bool IsNumberChar(const char c);
320BOOL IsNumCalcMark(const char *Command,int p);
321BOOL IsNumCalcMark_Back(const char *Command,int p);
322BOOL IsStrCalcMark(const char c);
323BOOL IsExponent(const char *Command,int p);
324int GetLiteralIndex(_int64 i64data);
325int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
326DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true );
327int IsStrCalculation(const char *Command);
328BYTE GetCalcId(const char *Command,int *pi);
329BOOL GetNumOpeElements(const char *Command,int *pnum,
330 char *values[255],long calc[255],long stack[255]);
331
332//NumOpe_GetType.cpp
333int AutoBigCast(int BaseType,int CalcType);
334BOOL CheckCalcType(int idCalc,int *type,int sp);
335bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL, bool *pIsVariable = NULL );
336bool GetTermType( const char *term, Type &resultType );
337bool GetTermTypeOnlyVariable( const char *term, Type &resultType );
338bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL );
339
340//Subroutine.cpp
341int GetCallProcName(const char *buffer,char *name);
342int GetProc(char *name,void **ppInfo);
343void SplitObjectName(const char *name,char *ObjectName, ReferenceKind &referenceFind );
344bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, const Type &baseType, Type &resultType, bool isCallOn = true, int dwCallProcFlags = 0 );
345bool CallPropertyMethod( const char *variable, const char *rightSide, Type &resultType);
346bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
347bool GetReturnTypeOfIndexerGetterProc( const Type &classType, Type &resultType );
348int AddProcPtrInfo( const std::string &typeExpression, int nowLine );
349bool IsNeedProcCompile();
350void CompileLocal();
351
352//OldStatement.cpp
353void Opcode_Input(const char *Parameter);
354void Opcode_Print(const char *Parameter,BOOL bWrite);
355
356//error.cpp
357bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
358
359//Compile.cpp
360void GetIdentifierToken( char *token, const char *source, int &pos );
361void GetCommandToken( char *token, const char *source, int &pos );
362void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence );
363void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass = false, Jenga::Common::Strings *pTypeParameterBaseClassNames = NULL );
364int JumpStatement(const char *source, int &pos);
365
366//MakePeHdr.cpp
367void MakeExe();
368
369//Diagnose.cpp
370void Diagnose();
371
372//gc.cpp
373void InitGCVariables(void);
374
375
376
377#ifdef _DEBUG
378/*Debug*/
379/*
380#define HeapAlloc CheckHeapAlloc
381#define HeapReAlloc CheckHeapReAlloc
382LPVOID CheckHeapAlloc(HANDLE hHeap,DWORD dwFlags,DWORD dwBytes);
383LPVOID CheckHeapReAlloc(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes);
384*/
385#endif
Note: See TracBrowser for help on using the repository browser.