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

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

_System_Newに対応(32bit版のみ)。

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