source: dev/trunk/abdev/BasicCompiler_Common/common.h@ 206

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

コード全体のリファクタリングを実施

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