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

Last change on this file since 818 was 808, checked in by イグトランス (egtra), 14 years ago

文字列のconst化など

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