source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/common.h@ 484

Last change on this file since 484 was 484, checked in by dai_9181, 16 years ago

プロジェクトのリネーム中

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