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

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

・ジェネリックな型をパラメータに持つメソッドのオーバーロード解決に対応した。
・型パラメータの制約クラス指定に対応した。

File size: 12.1 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
52 #ifndef LONG_PTR
53 typedef long LONG_PTR;
54 typedef DWORD ULONG_PTR;
55 #endif
56#endif
57
58
59//未定義の定数情報
60#ifndef IMAGE_FILE_MACHINE_AMD64
61 #define IMAGE_FILE_MACHINE_AMD64 0x8664
62#endif
63
64#ifdef _AMD64_
65 #ifndef IMAGE_SIZEOF_NT_OPTIONAL64_HEADER
66 #define IMAGE_SIZEOF_NT_OPTIONAL64_HEADER 240
67 #endif
68#else
69 #ifndef IMAGE_SIZEOF_NT_OPTIONAL32_HEADER
70 #define IMAGE_SIZEOF_NT_OPTIONAL32_HEADER 224
71 #endif
72#endif
73
74
75extern HWND hOwnerEditor;
76extern HANDLE hHeap;
77extern int cp;
78extern int typeOfPtrChar;
79extern int typeOfPtrUChar;
80
81
82
83//////////////////////////////////////////
84// BasicCompiler、ProjectEditor共通の定数
85//////////////////////////////////////////
86
87//サイズ変更枠の太さ
88#define LEVER_THICK 5
89
90#define WM_SHOWERROR WM_USER+70 //エラー表示メッセージ
91
92#define WM_SETCOMPILEVIEW WM_USER+71 //コンパイラウィンドウが表示されたとき
93#define WM_DESTROYCOMPILEVIEW WM_USER+72 //コンパイラウィンドウが破棄されたとき
94
95#define WM_SETDEBUGGERBASE WM_USER+73 //デバッガベースウィンドウが表示されたとき
96#define WM_DESTROYDEBUGGERBASE WM_USER+74 //デバッガベースウィンドウが破棄されたとき
97
98#define WM_SETDEBUGGERVIEW WM_USER+75 //デバッガウィンドウが表示されたとき
99#define WM_DESTROYDEBUGGERVIEW WM_USER+76 //デバッガウィンドウが表示されたとき
100
101///////////////////////////////////////////
102
103
104#define WM_SHOWVARLIST WM_USER+80
105#define WM_VARLIST_CLOSE WM_USER+81 //変数リストの終了メッセージ(破棄のみ、解放なし)
106
107
108
109///////////////////////////////////////////
110// デバッグ コマンド
111
112#define WM_DEBUG_CONTINUE WM_USER+200
113#define WM_STEP_IN WM_USER+201
114#define WM_STEP_OVER WM_USER+202
115#define WM_STEP_CURSOR WM_USER+203
116#define WM_DEBUG_STOP WM_USER+204
117#define WM_DEBUG_PAUSE WM_USER+205
118#define WM_CLOSE_DEBUGGER WM_USER+206
119
120///////////////////////////////////////////
121
122
123
124
125#define FILE_ALIGNMENT 0x1000
126#define MEM_ALIGNMENT 0x1000
127#define EXE_HEADER_SIZE 0x1000
128
129
130
131struct ERRORINFO{
132 char *FileName;
133 int line;
134};
135
136//変数の相対情報
137struct RELATIVE_VAR{
138 DWORD dwKind;
139 LONG_PTR offset;
140 BOOL bOffsetOffset;
141};
142
143
144struct RESOURCEDATAINFO{
145 DWORD dwId;
146 char FileName[MAX_PATH];
147};
148
149
150//////////////////////////////////////////
151// リソース ヘッダ(アイコン、カーソル用)
152typedef struct{
153 WORD idReserved;
154 WORD idType;
155 WORD idCount;
156}ICONDIR,CURSORDIR;
157
158
159/////////////////////////////
160// .curファイルのヘッダ情報
161struct CURSORDIRENTRY{
162 BYTE bWidth;
163 BYTE bHeight;
164 BYTE bColorCount;
165 BYTE bReserved;
166 WORD wXHotspot;
167 WORD wYHotspot;
168 DWORD dwBytesInRes;
169 DWORD dwImageOffset;
170};
171struct CURSORDIRENTRY_RES{
172 WORD wWidth;
173 WORD wHeight;
174 WORD wXHotspot;
175 WORD wYHotspot;
176 DWORD dwBytesInRes;
177 WORD wCursorNum;
178};
179
180
181////////////////////////////
182//.icoファイルのヘッダ情報
183struct ICONDIRENTRY{
184 BYTE bWidth;
185 BYTE bHeight;
186 BYTE bColorCount;
187 BYTE bReserved;
188 WORD wPlanes;
189 WORD wBitCount;
190 DWORD dwBytesInRes;
191 DWORD dwImageOffset;
192};
193struct ICONDIRENTRY_RES{
194 BYTE bWidth;
195 BYTE bHeight;
196 BYTE bColorCount;
197 BYTE bReserved;
198 WORD wPlanes;
199 WORD wBitCount;
200 DWORD dwBytesInRes;
201 WORD wIconNum;
202};
203
204
205
206#include "../BasicCompiler_Common/PESchedule.h"
207#include "../BasicCompiler_Common/StrOperation.h"
208#include "../BasicCompiler_Common/VariableOpe.h"
209
210
211
212bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList=0, bool *pIsMemoryAccessError=NULL);
213
214
215//BasicCompiler.cpp
216void HeapDefaultFree(LPVOID lpMem);
217void ts(int i = 0);
218void ts(int i,int i2);
219void ts(const char *msg);
220void ts(const char *msg,const char *title);
221void epi_check();
222void GetRelationalPath(char *path,char *dir);
223void GetFullPath( char *path, const string &baseDirPath );
224std::string GetApplicationBaseFullPath( const std::string &relationalPath );
225void ShowErrorLine(int LineNum,const char *FileName);
226BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen);
227void MakeMessageText(char *buffer,char *msg,int flag);
228
229//hash.cpp
230int hash_default(const char *name);
231DllProc *GetDeclareHash(const char *name);
232void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs );
233const UserProc *GetSubHash(const char *name,BOOL bError=0);
234const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);
235const UserProc *GetClassMethod( const char *className, const char *methodName );
236
237//Object.cpp
238void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
239bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
240
241//Overload.sbp
242class Parameters;
243const UserProc *OverloadSolutionWithStrParam(
244 const char *name,
245 std::vector<const UserProc *> &subs,
246 const char *Parameter,
247 const char *ObjectName);
248const UserProc *OverloadSolution(
249 const char *name,
250 std::vector<const UserProc *> &subs,
251 const Parameters &params,
252 const Type &returnType,
253 const Type &leftType );
254
255//Debug.cpp
256void Debugger_StepIn(void);
257void Debugger_StepOver(void);
258void Debugger_StepCursor(void);
259void Debugger_Stop(void);
260void Debugger_Pause(void);
261ULONG_PTR rva_to_real(DWORD p);
262UserProc *GetSubFromObp(ULONG_PTR pos);
263void ReadOpBuffer();
264void DebugProgram(void);
265
266//VarList.cpp
267void InitVarList(DWORD dwThreadId);
268BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
269BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
270
271//WatchList.cpp
272ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar);
273ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip);
274int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
275
276//MakeExe.cpp
277void StepCompileProgress(void);
278void MakeMiddleCode( char *buffer );
279void AddSourceCode(const char *buffer);
280void OutputExe(void);
281int MainThread(DWORD dummy);
282
283//Intermediate_Step1.cpp
284void ChangeReturnCode(char *buffer);
285void DeleteComment(char *buffer);
286void KillReturnCode(char *buffer);
287void CheckParenthesis(char *buffer);
288BOOL CheckParenthesis2(char *buffer);
289void DirectiveCheck(void);
290void NextCommandFormat(char *buffer);
291void SetEscapeSequenceFormat(char *buffer);
292void DefCommandFormat(char *buffer);
293void IfCommandFormat(char *buffer);
294void CheckPareCommand(void);
295
296//Intermediate_Step2.cpp
297bool GetConstInfo(void);
298void ChangeCommandToCode(char *buffer);
299
300//preprocessor.cpp
301char *OpenBasicFile(char *FileName);
302
303//Resource.cpp
304void GetResourceData(char *FileName);
305
306//CommandFormat.cpp
307void ComOpen(char *Parameter,char *buffer,int nowLine);
308void ComClose(char *Parameter,char *buffer);
309void ComField(char *Parameter,char *buffer);
310void ComLine(char *Parameter,char *buffer,int nowLine);
311void ComCircle(char *Parameter,char *buffer,int nowLine);
312void ComPSet(char *Parameter,char *buffer,int nowLine);
313void ComPaint(char *Parameter,char *buffer,int nowLine);
314
315// StrOperation.cpp
316void KillSpaces(char *str1,char *str2);
317void KillStringSpaces(char *str);
318BOOL RemoveStringQuotes(char *str);
319bool RemoveStringQuotes( std::string &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 GetSourceCodeIndexFromLine( const char *source, int LineNum );
327char GetEndXXXCommand(char es);
328void GetDefaultNameFromES(char es,char *name);
329const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
330bool IsFileExist(const char *path);
331BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
332BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
333void ShortPathToLongPath(const char *ShortPath,char *LongPath);
334
335//calculation.cpp
336bool IsNumberTopChar(const char *buffer);
337bool IsNumberChar(const char c);
338BOOL IsNumCalcMark(const char *Command,int p);
339BOOL IsNumCalcMark_Back(const char *Command,int p);
340BOOL IsStrCalcMark(const char c);
341BOOL IsExponent(const char *Command,int p);
342int GetLiteralIndex(_int64 i64data);
343int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
344DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true );
345int IsStrCalculation(const char *Command);
346BYTE GetCalcId(const char *Command,int *pi);
347BOOL GetNumOpeElements(const char *Command,int *pnum,
348 char *values[255],long calc[255],long stack[255]);
349
350//NumOpe_GetType.cpp
351int AutoBigCast(int BaseType,int CalcType);
352BOOL CheckCalcType(int idCalc,int *type,int sp);
353bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL, bool *pIsVariable = NULL );
354bool GetTermType( const char *term, Type &resultType );
355bool GetTermTypeOnlyVariable( const char *term, Type &resultType );
356bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL );
357
358//Subroutine.cpp
359int GetCallProcName(char *buffer,char *name);
360int GetProc(char *name,void **ppInfo);
361void SplitObjectName(const char *name,char *ObjectName, ReferenceKind &referenceFind );
362bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, const Type &baseType, 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 Type &classType, Type &resultType );
366int AddProcPtrInfo( const string &typeExpression, int nowLine );
367bool IsNeedProcCompile();
368void CompileLocal();
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(const char *buffer);
379bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
380
381//Compile.cpp
382void GetIdentifierToken( char *token, const char *source, int &pos );
383void GetCommandToken( char *token, const char *source, int &pos );
384void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence );
385void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters, bool isDefiningClass = false, Jenga::Common::Strings *pTypeParameterBaseClassNames = NULL );
386int JumpStatement(const char *source, int &pos);
387void Compile(void);
388
389//Diagnose.cpp
390void Diagnose();
391
392//gc.cpp
393void InitGCVariables(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.