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

Last change on this file since 471 was 467, checked in by dai_9181, 17 years ago

いくつかのグローバル変数をProgram/Debuggerクラスにまとめた。

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 "../BasicCompiler32/resource.h"
16#include "../BasicCompiler32/CommandValue.h"
17#define OPCODE_H_PATH "../BasicCompiler32/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 epi_check();
219void GetRelationalPath(char *path,char *dir);
220void GetFullPath( char *path, const string &baseDirPath );
221std::string GetApplicationBaseFullPath( const std::string &relationalPath );
222void ShowErrorLine(int LineNum,const char *FileName);
223BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen);
224void MakeMessageText(char *buffer,char *msg,int flag);
225
226//hash.cpp
227int hash_default(const char *name);
228DllProc *GetDeclareHash(const char *name);
229void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs );
230const UserProc *GetSubHash(const char *name,BOOL bError=0);
231const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);
232const UserProc *GetClassMethod( const char *className, const char *methodName );
233
234//Object.cpp
235void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
236bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
237
238//Overload.sbp
239class Parameters;
240const UserProc *OverloadSolutionWithStrParam(
241 const char *name,
242 std::vector<const UserProc *> &subs,
243 const char *Parameter,
244 const char *ObjectName);
245const UserProc *OverloadSolution(
246 const char *name,
247 std::vector<const UserProc *> &subs,
248 const Parameters &params,
249 const Type &returnType,
250 const Type &leftType );
251
252//Debug.cpp
253void Debugger_StepIn(void);
254void Debugger_StepOver(void);
255void Debugger_StepCursor(void);
256void Debugger_Stop(void);
257void Debugger_Pause(void);
258ULONG_PTR rva_to_real(DWORD p);
259UserProc *GetSubFromObp(ULONG_PTR pos);
260void ReadOpBuffer();
261void DebugProgram(void);
262
263//VarList.cpp
264void InitVarList(DWORD dwThreadId);
265BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
266BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
267
268//WatchList.cpp
269ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar);
270ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip);
271int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
272
273//MakeExe.cpp
274void StepCompileProgress(void);
275void MakeMiddleCode( char *buffer );
276void AddSourceCode(const char *buffer);
277void OutputExe(void);
278void MainThread(void *dummy);
279
280//Intermediate_Step1.cpp
281void ChangeReturnCode(char *buffer);
282void DeleteComment(char *buffer);
283void KillReturnCode(char *buffer);
284void CheckParenthesis(char *buffer);
285BOOL CheckParenthesis2(char *buffer);
286void DirectiveCheck(void);
287void NextCommandFormat(char *buffer);
288void SetEscapeSequenceFormat(char *buffer);
289void DefCommandFormat(char *buffer);
290void IfCommandFormat(char *buffer);
291void CheckPareCommand(void);
292
293//Intermediate_Step2.cpp
294bool GetConstInfo(void);
295void ChangeCommandToCode(char *buffer);
296
297//preprocessor.cpp
298char *OpenBasicFile(char *FileName);
299
300//Resource.cpp
301void GetResourceData(char *FileName);
302
303//CommandFormat.cpp
304void ComOpen(char *Parameter,char *buffer,int nowLine);
305void ComClose(char *Parameter,char *buffer);
306void ComField(char *Parameter,char *buffer);
307void ComLine(char *Parameter,char *buffer,int nowLine);
308void ComCircle(char *Parameter,char *buffer,int nowLine);
309void ComPSet(char *Parameter,char *buffer,int nowLine);
310void ComPaint(char *Parameter,char *buffer,int nowLine);
311
312// StrOperation.cpp
313void KillSpaces(char *str1,char *str2);
314void KillStringSpaces(char *str);
315BOOL RemoveStringQuotes(char *str);
316bool RemoveStringQuotes( std::string &str );
317void RemoveStringPare(char *str);
318void RemoveStringBracket(char *str);
319void SetStringQuotes(char *str);
320int FormatString_EscapeSequence(char *buffer);
321void SlideString(char *str,int slide);
322void SlideBuffer(char *buffer,int length,int slide);
323int GetSourceCodeIndexFromLine( const char *source, int LineNum );
324char GetEndXXXCommand(char es);
325void GetDefaultNameFromES(char es,char *name);
326const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
327bool IsFileExist(const char *path);
328BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
329BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
330void ShortPathToLongPath(const char *ShortPath,char *LongPath);
331
332//calculation.cpp
333bool IsNumberTopChar(const char *buffer);
334bool IsNumberChar(const char c);
335BOOL IsNumCalcMark(const char *Command,int p);
336BOOL IsNumCalcMark_Back(const char *Command,int p);
337BOOL IsStrCalcMark(const char c);
338BOOL IsExponent(const char *Command,int p);
339int GetLiteralIndex(_int64 i64data);
340int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
341DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true );
342int IsStrCalculation(const char *Command);
343BYTE GetCalcId(const char *Command,int *pi);
344BOOL GetNumOpeElements(const char *Command,int *pnum,
345 char *values[255],long calc[255],long stack[255]);
346
347//NumOpe_GetType.cpp
348int AutoBigCast(int BaseType,int CalcType);
349BOOL CheckCalcType(int idCalc,int *type,int sp);
350bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL, bool *pIsVariable = NULL );
351bool GetTermType( const char *term, Type &resultType );
352bool GetTermTypeOnlyVariable( const char *term, Type &resultType );
353bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL );
354
355//Subroutine.cpp
356int GetCallProcName(char *buffer,char *name);
357int GetProc(char *name,void **ppInfo);
358void SplitObjectName(const char *name,char *ObjectName, ReferenceKind &referenceFind );
359bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, const Type &baseType, Type &resultType, bool isCallOn = true );
360bool CallPropertyMethod( const char *variable, const char *rightSide, Type &resultType);
361bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
362bool GetReturnTypeOfIndexerGetterProc( const Type &classType, Type &resultType );
363int AddProcPtrInfo( const string &typeExpression, int nowLine );
364bool IsNeedProcCompile();
365void CompileLocal();
366
367//OldStatement.cpp
368void Opcode_Input(const char *Parameter);
369void Opcode_Print(const char *Parameter,BOOL bWrite);
370
371//error.cpp
372bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
373
374//Compile.cpp
375void GetIdentifierToken( char *token, const char *source, int &pos );
376void GetCommandToken( char *token, const char *source, int &pos );
377void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence );
378void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass = false, Jenga::Common::Strings *pTypeParameterBaseClassNames = NULL );
379int JumpStatement(const char *source, int &pos);
380void Compile(void);
381
382//Diagnose.cpp
383void Diagnose();
384
385//gc.cpp
386void InitGCVariables(void);
387
388
389
390#ifdef _DEBUG
391/*Debug*/
392/*
393#define HeapAlloc CheckHeapAlloc
394#define HeapReAlloc CheckHeapReAlloc
395LPVOID CheckHeapAlloc(HANDLE hHeap,DWORD dwFlags,DWORD dwBytes);
396LPVOID CheckHeapReAlloc(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes);
397*/
398#endif
Note: See TracBrowser for help on using the repository browser.