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

Last change on this file since 229 was 223, checked in by dai_9181, 17 years ago
File size: 11.5 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_
11#include "../BasicCompiler64/resource.h"
12#include "../BasicCompiler64/CommandValue.h"
13#include "../BasicCompiler64/FunctionValue.h"
[7]14#define OPCODE_H_PATH "../BasicCompiler64/opcode.h"
[4]15#else
[5]16#include "../BasicCompiler32/resource.h"
17#include "../BasicCompiler32/CommandValue.h"
18#include "../BasicCompiler32/FunctionValue.h"
[7]19#define OPCODE_H_PATH "../BasicCompiler32/opcode.h"
[4]20#endif
21
[206]22#include <jenga/include/smoothie/BasicFixed.h>
[4]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)
[123]39#define OBJECT_HEAD_SIZE PTR_SIZE*4
[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//未定義の定数情報
[107]58#ifndef IMAGE_FILE_MACHINE_AMD64
59 #define IMAGE_FILE_MACHINE_AMD64 0x8664
60#endif
[4]61
[107]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
[4]71
72
73extern HWND hOwnerEditor;
74extern HANDLE hHeap;
75extern int cp;
[69]76extern int typeOfPtrChar;
[97]77extern int typeOfPtrUChar;
[4]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
[34]211#include "../BasicCompiler_Common/PESchedule.h"
[75]212#include "../BasicCompiler_Common/VariableOpe.h"
[4]213
214
215
[75]216bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList=0, bool *pIsMemoryAccessError=NULL);
[4]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);
[167]227void GetFullPath( char *path, const string &baseDirPath );
[4]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
[75]233int hash_default(const char *name);
[209]234DllProc *GetDeclareHash(const char *name);
[206]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 );
[4]239
240//Object.cpp
[206]241void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
[75]242bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
[4]243
244//Overload.sbp
[206]245class Parameters;
246const UserProc *OverloadSolutionWithStrParam(
[50]247 const char *name,
[206]248 std::vector<const UserProc *> &subs,
[50]249 const char *Parameter,
[75]250 const char *ObjectName);
[206]251const UserProc *OverloadSolution(
[50]252 const char *name,
[206]253 std::vector<const UserProc *> &subs,
[75]254 const Parameters &params,
255 const Type &returnType );
[4]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);
[206]264UserProc *GetSubFromObp(ULONG_PTR pos);
[4]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);
[206]276int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
[4]277
278//MakeExe.cpp
279void StepCompileProgress(void);
[15]280void AddSourceCode(char *buffer);
[4]281void OutputExe(void);
282int MainThread(DWORD dummy);
283
284//Intermediate_Step1.cpp
285void ChangeReturnCode(char *buffer);
286void DeleteComment(char *buffer);
287void KillReturnCode(char *buffer);
288void CheckParenthesis(char *buffer);
289BOOL CheckParenthesis2(char *buffer);
290void DirectiveCheck(void);
291void NextCommandFormat(char *buffer);
292void SetEscapeSequenceFormat(char *buffer);
293void DefCommandFormat(char *buffer);
294void IfCommandFormat(char *buffer);
295void CheckPareCommand(void);
296
297//Intermediate_Step2.cpp
[16]298bool GetConstInfo(void);
[4]299void ChangeCommandToCode(char *buffer);
300
301//preprocessor.cpp
[15]302char *OpenBasicFile(char *FileName);
[4]303
304//Resource.cpp
305void GetResourceData(char *FileName);
306
307//CommandFormat.cpp
[75]308void ComOpen(char *Parameter,char *buffer,int nowLine);
[4]309void ComClose(char *Parameter,char *buffer);
310void ComField(char *Parameter,char *buffer);
[75]311void ComLine(char *Parameter,char *buffer,int nowLine);
312void ComCircle(char *Parameter,char *buffer,int nowLine);
313void ComPSet(char *Parameter,char *buffer,int nowLine);
314void ComPaint(char *Parameter,char *buffer,int nowLine);
[4]315
316// StrOperation.cpp
317void KillSpaces(char *str1,char *str2);
318void KillStringSpaces(char *str);
319BOOL RemoveStringQuotes(char *str);
320void RemoveStringPare(char *str);
321void RemoveStringBracket(char *str);
322void SetStringQuotes(char *str);
323int FormatString_EscapeSequence(char *buffer);
324void SlideString(char *str,int slide);
325void SlideBuffer(char *buffer,int length,int slide);
326int GetCpFromLine(int LineNum);
327BOOL GetLineNum(int pos,int *pLine,char *FileName);
328char GetEndXXXCommand(char es);
329void GetDefaultNameFromES(char es,char *name);
[206]330const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
[4]331BOOL IsFile(char *path);
[31]332BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
[4]333BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
[31]334void ShortPathToLongPath(const char *ShortPath,char *LongPath);
[4]335
336//calculation.cpp
[15]337bool IsNumberTopChar(const char *buffer);
338bool IsNumberChar(const char c);
339BOOL IsNumCalcMark(const char *Command,int p);
340BOOL IsNumCalcMark_Back(const char *Command,int p);
341BOOL IsStrCalcMark(const char c);
342BOOL IsExponent(const char *Command,int p);
[4]343int GetLiteralIndex(_int64 i64data);
344int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
345DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType);
346int IsStrCalculation(char *Command);
[15]347BYTE GetCalcId(const char *Command,int *pi);
348BOOL GetNumOpeElements(const char *Command,int *pnum,
[4]349 char *values[255],long calc[255],long stack[255]);
350
[75]351//NumOpe_GetType.cpp
[4]352int AutoBigCast(int BaseType,int CalcType);
353BOOL CheckCalcType(int idCalc,int *type,int sp);
[128]354bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL );
[73]355bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType );
[4]356
357//Subroutine.cpp
358int GetCallProcName(char *buffer,char *name);
359int GetProc(char *name,void **ppInfo);
[46]360void SplitObjectName(const char *name,char *ObjectName,int *pRefType);
[75]361bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, Type &resultType, bool isCallOn = true );
362bool CallPropertyMethod( const char *variable, const char *rightSide, Type &resultType);
363bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
364bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType );
[78]365int AddProcPtrInfo( const string &typeExpression, int nowLine );
[94]366bool IsNeedProcCompile();
[4]367
[76]368//OldStatement.cpp
369void Opcode_Input(const char *Parameter);
370void Opcode_Print(const char *Parameter,BOOL bWrite);
371
[4]372//error.cpp
[40]373void SetError(int ErrorNum,const char *KeyWord,int pos);
[75]374void SetError(int ErrorNum,const string &keyWord,int pos);
[64]375void SetError();
[4]376void CompileMessage(char *buffer);
[46]377bool CheckDifferentType(const int VarType,const LONG_PTR lpVarIndex,const int CalcType,const LONG_PTR lpCalcIndex,const char *pszFuncName,const int ParmNum);
[75]378bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
[4]379
380//Compile.cpp
[17]381void GetIdentifierToken( char *token, const char *source, int &pos );
[16]382int JumpStatement(const char *source, int &pos);
[4]383void DebugVariable(void);
384void Compile(void);
385
[91]386//Diagnose.cpp
387void Diagnose();
388
[4]389//gc.cpp
390void InitGCVariables(void);
391
392
393
394#ifdef _DEBUG
395/*Debug*/
396/*
397#define HeapAlloc CheckHeapAlloc
398#define HeapReAlloc CheckHeapReAlloc
399LPVOID CheckHeapAlloc(HANDLE hHeap,DWORD dwFlags,DWORD dwBytes);
400LPVOID CheckHeapReAlloc(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes);
401*/
402#endif
Note: See TracBrowser for help on using the repository browser.