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

Last change on this file since 275 was 263, checked in by dai_9181, 17 years ago
File size: 11.4 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
142struct RESOURCEDATAINFO{
143 DWORD dwId;
144 char FileName[MAX_PATH];
145};
146
147
148//////////////////////////////////////////
149// リソース ヘッダ(アイコン、カーソル用)
150typedef struct{
151 WORD idReserved;
152 WORD idType;
153 WORD idCount;
154}ICONDIR,CURSORDIR;
155
156
157/////////////////////////////
158// .curファイルのヘッダ情報
159struct CURSORDIRENTRY{
160 BYTE bWidth;
161 BYTE bHeight;
162 BYTE bColorCount;
163 BYTE bReserved;
164 WORD wXHotspot;
165 WORD wYHotspot;
166 DWORD dwBytesInRes;
167 DWORD dwImageOffset;
168};
169struct CURSORDIRENTRY_RES{
170 WORD wWidth;
171 WORD wHeight;
172 WORD wXHotspot;
173 WORD wYHotspot;
174 DWORD dwBytesInRes;
175 WORD wCursorNum;
176};
177
178
179////////////////////////////
180//.icoファイルのヘッダ情報
181struct ICONDIRENTRY{
182 BYTE bWidth;
183 BYTE bHeight;
184 BYTE bColorCount;
185 BYTE bReserved;
186 WORD wPlanes;
187 WORD wBitCount;
188 DWORD dwBytesInRes;
189 DWORD dwImageOffset;
190};
191struct ICONDIRENTRY_RES{
192 BYTE bWidth;
193 BYTE bHeight;
194 BYTE bColorCount;
195 BYTE bReserved;
196 WORD wPlanes;
197 WORD wBitCount;
198 DWORD dwBytesInRes;
199 WORD wIconNum;
200};
201
202
203
204#include "../BasicCompiler_Common/PESchedule.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);
215void ts(int i,int i2);
216void ts(char *msg);
217void ts(char *msg,char *title);
218void epi_check();
219void GetRelationalPath(char *path,char *dir);
220void GetFullPath( char *path, const string &baseDirPath );
221void ShowErrorLine(int LineNum,char *FileName);
222BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen);
223void MakeMessageText(char *buffer,char *msg,int flag);
224
225//hash.cpp
226int hash_default(const char *name);
227DllProc *GetDeclareHash(const char *name);
228void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs );
229const UserProc *GetSubHash(const char *name,BOOL bError=0);
230const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);
231const UserProc *GetClassMethod( const char *className, const char *methodName );
232
233//Object.cpp
234void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
235bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
236
237//Overload.sbp
238class Parameters;
239const UserProc *OverloadSolutionWithStrParam(
240 const char *name,
241 std::vector<const UserProc *> &subs,
242 const char *Parameter,
243 const char *ObjectName);
244const UserProc *OverloadSolution(
245 const char *name,
246 std::vector<const UserProc *> &subs,
247 const Parameters &params,
248 const Type &returnType );
249
250//Debug.cpp
251void Debugger_StepIn(void);
252void Debugger_StepOver(void);
253void Debugger_StepCursor(void);
254void Debugger_Stop(void);
255void Debugger_Pause(void);
256ULONG_PTR rva_to_real(DWORD p);
257UserProc *GetSubFromObp(ULONG_PTR pos);
258void ReadOpBuffer();
259void DebugProgram(void);
260
261//VarList.cpp
262void InitVarList(DWORD dwThreadId);
263BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
264BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
265
266//WatchList.cpp
267ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar);
268ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip);
269int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
270
271//MakeExe.cpp
272void StepCompileProgress(void);
273void AddSourceCode(char *buffer);
274void OutputExe(void);
275int MainThread(DWORD dummy);
276
277//Intermediate_Step1.cpp
278void ChangeReturnCode(char *buffer);
279void DeleteComment(char *buffer);
280void KillReturnCode(char *buffer);
281void CheckParenthesis(char *buffer);
282BOOL CheckParenthesis2(char *buffer);
283void DirectiveCheck(void);
284void NextCommandFormat(char *buffer);
285void SetEscapeSequenceFormat(char *buffer);
286void DefCommandFormat(char *buffer);
287void IfCommandFormat(char *buffer);
288void CheckPareCommand(void);
289
290//Intermediate_Step2.cpp
291bool GetConstInfo(void);
292void ChangeCommandToCode(char *buffer);
293
294//preprocessor.cpp
295char *OpenBasicFile(char *FileName);
296
297//Resource.cpp
298void GetResourceData(char *FileName);
299
300//CommandFormat.cpp
301void ComOpen(char *Parameter,char *buffer,int nowLine);
302void ComClose(char *Parameter,char *buffer);
303void ComField(char *Parameter,char *buffer);
304void ComLine(char *Parameter,char *buffer,int nowLine);
305void ComCircle(char *Parameter,char *buffer,int nowLine);
306void ComPSet(char *Parameter,char *buffer,int nowLine);
307void ComPaint(char *Parameter,char *buffer,int nowLine);
308
309// StrOperation.cpp
310void KillSpaces(char *str1,char *str2);
311void KillStringSpaces(char *str);
312BOOL RemoveStringQuotes(char *str);
313void RemoveStringPare(char *str);
314void RemoveStringBracket(char *str);
315void SetStringQuotes(char *str);
316int FormatString_EscapeSequence(char *buffer);
317void SlideString(char *str,int slide);
318void SlideBuffer(char *buffer,int length,int slide);
319int GetCpFromLine(int LineNum);
320BOOL GetLineNum(int pos,int *pLine,char *FileName);
321char GetEndXXXCommand(char es);
322void GetDefaultNameFromES(char es,char *name);
323const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
324BOOL IsFile(char *path);
325BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
326BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
327void ShortPathToLongPath(const char *ShortPath,char *LongPath);
328
329//calculation.cpp
330bool IsNumberTopChar(const char *buffer);
331bool IsNumberChar(const char c);
332BOOL IsNumCalcMark(const char *Command,int p);
333BOOL IsNumCalcMark_Back(const char *Command,int p);
334BOOL IsStrCalcMark(const char c);
335BOOL IsExponent(const char *Command,int p);
336int GetLiteralIndex(_int64 i64data);
337int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
338DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true );
339int IsStrCalculation(const char *Command);
340BYTE GetCalcId(const char *Command,int *pi);
341BOOL GetNumOpeElements(const char *Command,int *pnum,
342 char *values[255],long calc[255],long stack[255]);
343
344//NumOpe_GetType.cpp
345int AutoBigCast(int BaseType,int CalcType);
346BOOL CheckCalcType(int idCalc,int *type,int sp);
347bool GetTermType( const char *term, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL );
348bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL );
349
350//Subroutine.cpp
351int GetCallProcName(char *buffer,char *name);
352int GetProc(char *name,void **ppInfo);
353void SplitObjectName(const char *name,char *ObjectName,int *pRefType);
354bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, Type &resultType, bool isCallOn = true );
355bool CallPropertyMethod( const char *variable, const char *rightSide, Type &resultType);
356bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
357bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType );
358int AddProcPtrInfo( const string &typeExpression, int nowLine );
359bool IsNeedProcCompile();
360
361//OldStatement.cpp
362void Opcode_Input(const char *Parameter);
363void Opcode_Print(const char *Parameter,BOOL bWrite);
364
365//error.cpp
366void SetError(int ErrorNum,const char *KeyWord,int pos);
367void SetError(int ErrorNum,const string &keyWord,int pos);
368void SetError();
369void CompileMessage(char *buffer);
370bool CheckDifferentType(const int VarType,const LONG_PTR lpVarIndex,const int CalcType,const LONG_PTR lpCalcIndex,const char *pszFuncName,const int ParmNum);
371bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
372
373//Compile.cpp
374void GetIdentifierToken( char *token, const char *source, int &pos );
375int JumpStatement(const char *source, int &pos);
376void DebugVariable(void);
377void Compile(void);
378
379//Diagnose.cpp
380void Diagnose();
381
382//gc.cpp
383void InitGCVariables(void);
384
385
386
387#ifdef _DEBUG
388/*Debug*/
389/*
390#define HeapAlloc CheckHeapAlloc
391#define HeapReAlloc CheckHeapReAlloc
392LPVOID CheckHeapAlloc(HANDLE hHeap,DWORD dwFlags,DWORD dwBytes);
393LPVOID CheckHeapReAlloc(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes);
394*/
395#endif
Note: See TracBrowser for help on using the repository browser.