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

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

ab_common.hを追加。
TypeMisc.hを追加。

File size: 11.8 KB
RevLine 
[206]1#pragma once
2
[14]3//#define _CRT_SECURE_NO_DEPRECATE
4#pragma warning(disable : 4996)
[5]5
[165]6#include <option.h>
7
[71]8using namespace std;
9
[4]10#ifdef _AMD64_
[485]11#include "../compiler_x64/resource.h"
12#include "../compiler_x64/CommandValue.h"
13#define OPCODE_H_PATH "../compiler_x64/opcode.h"
[4]14#else
[484]15#include "../compiler_x86/resource.h"
16#include "../compiler_x86/CommandValue.h"
17#define OPCODE_H_PATH "../compiler_x86/opcode.h"
[4]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
[123]35#define OBJECT_HEAD_SIZE PTR_SIZE*4
[4]36
37#define MAX_LEN 65535
38#define DIGIT_SIZE 128
39#define MAX_PARMS 64
40#define MAX_ARRAYDIM 16
41#define MAX_HASH 32761
42
43
44#ifdef _AMD64_
[288]45 #define PLATFORM 64
[4]46#else
47#define PLATFORM 32
[288]48 #ifndef LONG_PTR
49 typedef long LONG_PTR;
50 typedef DWORD ULONG_PTR;
51 #endif
[4]52#endif
53
54
55//未定義の定数情報
[107]56#ifndef IMAGE_FILE_MACHINE_AMD64
57 #define IMAGE_FILE_MACHINE_AMD64 0x8664
58#endif
[4]59
[107]60#ifdef _AMD64_
61 #ifndef IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
62 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
63 #endif
64#else
65 #ifndef IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
66 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
67 #endif
68#endif
[4]69
70
71extern HWND hOwnerEditor;
72extern HANDLE hHeap;
73extern int cp;
[69]74extern int typeOfPtrChar;
[97]75extern int typeOfPtrUChar;
[4]76
77
78
79//////////////////////////////////////////
80// BasicCompiler、ProjectEditor共通の定数
81//////////////////////////////////////////
82
83//サイズ変更枠の太さ
84#define LEVER_THICK 5
85
86#define WM_SHOWERROR WM_USER+70 //エラー表示メッセージ
87
88#define WM_SETCOMPILEVIEW WM_USER+71 //コンパイラウィンドウが表示されたとき
89#define WM_DESTROYCOMPILEVIEW WM_USER+72 //コンパイラウィンドウが破棄されたとき
90
91#define WM_SETDEBUGGERBASE WM_USER+73 //デバッガベースウィンドウが表示されたとき
92#define WM_DESTROYDEBUGGERBASE WM_USER+74 //デバッガベースウィンドウが破棄されたとき
93
94#define WM_SETDEBUGGERVIEW WM_USER+75 //デバッガウィンドウが表示されたとき
95#define WM_DESTROYDEBUGGERVIEW WM_USER+76 //デバッガウィンドウが表示されたとき
96
97///////////////////////////////////////////
98
99
100#define WM_SHOWVARLIST WM_USER+80
101#define WM_VARLIST_CLOSE WM_USER+81 //変数リストの終了メッセージ(破棄のみ、解放なし)
102
103
104
105///////////////////////////////////////////
106// デバッグ コマンド
107
108#define WM_DEBUG_CONTINUE WM_USER+200
109#define WM_STEP_IN WM_USER+201
110#define WM_STEP_OVER WM_USER+202
111#define WM_STEP_CURSOR WM_USER+203
112#define WM_DEBUG_STOP WM_USER+204
113#define WM_DEBUG_PAUSE WM_USER+205
114#define WM_CLOSE_DEBUGGER WM_USER+206
115
116///////////////////////////////////////////
117
118
119
120
121#define FILE_ALIGNMENT 0x1000
122#define MEM_ALIGNMENT 0x1000
123#define EXE_HEADER_SIZE 0x1000
124
125
126
127struct ERRORINFO{
128 char *FileName;
129 int line;
130};
131
132//変数の相対情報
133struct RELATIVE_VAR{
134 DWORD dwKind;
135 LONG_PTR offset;
136 BOOL bOffsetOffset;
137};
138
139
140struct RESOURCEDATAINFO{
141 DWORD dwId;
142 char FileName[MAX_PATH];
143};
144
145
146//////////////////////////////////////////
147// リソース ヘッダ(アイコン、カーソル用)
148typedef struct{
149 WORD idReserved;
150 WORD idType;
151 WORD idCount;
152}ICONDIR,CURSORDIR;
153
154
155/////////////////////////////
156// .curファイルのヘッダ情報
157struct CURSORDIRENTRY{
158 BYTE bWidth;
159 BYTE bHeight;
160 BYTE bColorCount;
161 BYTE bReserved;
162 WORD wXHotspot;
163 WORD wYHotspot;
164 DWORD dwBytesInRes;
165 DWORD dwImageOffset;
166};
167struct CURSORDIRENTRY_RES{
168 WORD wWidth;
169 WORD wHeight;
170 WORD wXHotspot;
171 WORD wYHotspot;
172 DWORD dwBytesInRes;
173 WORD wCursorNum;
174};
175
176
177////////////////////////////
178//.icoファイルのヘッダ情報
179struct ICONDIRENTRY{
180 BYTE bWidth;
181 BYTE bHeight;
182 BYTE bColorCount;
183 BYTE bReserved;
184 WORD wPlanes;
185 WORD wBitCount;
186 DWORD dwBytesInRes;
187 DWORD dwImageOffset;
188};
189struct ICONDIRENTRY_RES{
190 BYTE bWidth;
191 BYTE bHeight;
192 BYTE bColorCount;
193 BYTE bReserved;
194 WORD wPlanes;
195 WORD wBitCount;
196 DWORD dwBytesInRes;
197 WORD wIconNum;
198};
199
200
201
[34]202#include "../BasicCompiler_Common/PESchedule.h"
[400]203#include "../BasicCompiler_Common/StrOperation.h"
[75]204#include "../BasicCompiler_Common/VariableOpe.h"
[4]205
206
207
[75]208bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList=0, bool *pIsMemoryAccessError=NULL);
[4]209
210
211//BasicCompiler.cpp
212void HeapDefaultFree(LPVOID lpMem);
[393]213void ts(int i = 0);
[4]214void ts(int i,int i2);
[322]215void ts(const char *msg);
216void ts(const char *msg,const char *title);
[477]217void ts(const std::string msg);
[4]218void epi_check();
219void GetRelationalPath(char *path,char *dir);
[167]220void GetFullPath( char *path, const string &baseDirPath );
[322]221std::string GetApplicationBaseFullPath( const std::string &relationalPath );
[279]222void ShowErrorLine(int LineNum,const char *FileName);
[4]223BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen);
224void MakeMessageText(char *buffer,char *msg,int flag);
225
226//hash.cpp
[75]227int hash_default(const char *name);
[209]228DllProc *GetDeclareHash(const char *name);
[206]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 );
[4]233
234//Object.cpp
[206]235void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
[75]236bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
[4]237
238//Overload.sbp
[206]239class Parameters;
240const UserProc *OverloadSolutionWithStrParam(
[50]241 const char *name,
[206]242 std::vector<const UserProc *> &subs,
[50]243 const char *Parameter,
[75]244 const char *ObjectName);
[206]245const UserProc *OverloadSolution(
[50]246 const char *name,
[206]247 std::vector<const UserProc *> &subs,
[75]248 const Parameters &params,
[424]249 const Type &returnType,
250 const Type &leftType );
[4]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);
[206]259UserProc *GetSubFromObp(ULONG_PTR pos);
[4]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);
[206]271int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
[4]272
273//MakeExe.cpp
274void StepCompileProgress(void);
[350]275void MakeMiddleCode( char *buffer );
[322]276void AddSourceCode(const char *buffer);
[4]277void OutputExe(void);
[467]278void MainThread(void *dummy);
[4]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
[16]294bool GetConstInfo(void);
[4]295void ChangeCommandToCode(char *buffer);
296
297//preprocessor.cpp
[15]298char *OpenBasicFile(char *FileName);
[4]299
300//Resource.cpp
301void GetResourceData(char *FileName);
302
303//CommandFormat.cpp
[75]304void ComOpen(char *Parameter,char *buffer,int nowLine);
[4]305void ComClose(char *Parameter,char *buffer);
306void ComField(char *Parameter,char *buffer);
[75]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);
[4]311
312// StrOperation.cpp
313void KillSpaces(char *str1,char *str2);
314void KillStringSpaces(char *str);
315BOOL RemoveStringQuotes(char *str);
[387]316bool RemoveStringQuotes( std::string &str );
[4]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);
[313]323int GetSourceCodeIndexFromLine( const char *source, int LineNum );
[4]324char GetEndXXXCommand(char es);
325void GetDefaultNameFromES(char es,char *name);
[206]326const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
[279]327bool IsFileExist(const char *path);
[31]328BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
[4]329BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
[31]330void ShortPathToLongPath(const char *ShortPath,char *LongPath);
[4]331
332//calculation.cpp
[15]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);
[4]339int GetLiteralIndex(_int64 i64data);
340int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
[254]341DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true );
342int IsStrCalculation(const char *Command);
[15]343BYTE GetCalcId(const char *Command,int *pi);
344BOOL GetNumOpeElements(const char *Command,int *pnum,
[4]345 char *values[255],long calc[255],long stack[255]);
346
[75]347//NumOpe_GetType.cpp
[4]348int AutoBigCast(int BaseType,int CalcType);
349BOOL CheckCalcType(int idCalc,int *type,int sp);
[415]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 );
[254]353bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL );
[4]354
355//Subroutine.cpp
356int GetCallProcName(char *buffer,char *name);
357int GetProc(char *name,void **ppInfo);
[290]358void SplitObjectName(const char *name,char *ObjectName, ReferenceKind &referenceFind );
[331]359bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, const Type &baseType, Type &resultType, bool isCallOn = true );
[75]360bool CallPropertyMethod( const char *variable, const char *rightSide, Type &resultType);
361bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
[292]362bool GetReturnTypeOfIndexerGetterProc( const Type &classType, Type &resultType );
[78]363int AddProcPtrInfo( const string &typeExpression, int nowLine );
[94]364bool IsNeedProcCompile();
[316]365void CompileLocal();
[4]366
[76]367//OldStatement.cpp
368void Opcode_Input(const char *Parameter);
369void Opcode_Print(const char *Parameter,BOOL bWrite);
370
[4]371//error.cpp
[75]372bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
[4]373
374//Compile.cpp
[17]375void GetIdentifierToken( char *token, const char *source, int &pos );
[296]376void GetCommandToken( char *token, const char *source, int &pos );
[381]377void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence );
[424]378void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass = false, Jenga::Common::Strings *pTypeParameterBaseClassNames = NULL );
[16]379int JumpStatement(const char *source, int &pos);
[4]380void Compile(void);
381
[91]382//Diagnose.cpp
383void Diagnose();
384
[4]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.