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

Last change on this file since 350 was 350, checked in by dai_9181, 17 years ago

インターフェイスを実装

File size: 11.6 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/VariableOpe.h"
208
209
210
211bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList=0, bool *pIsMemoryAccessError=NULL);
212
213
214//BasicCompiler.cpp
215void HeapDefaultFree(LPVOID lpMem);
216void ts(int i);
217void ts(int i,int i2);
218void ts(const char *msg);
219void ts(const char *msg,const char *title);
220void epi_check();
221void GetRelationalPath(char *path,char *dir);
222void GetFullPath( char *path, const string &baseDirPath );
223std::string GetApplicationBaseFullPath( const std::string &relationalPath );
224void ShowErrorLine(int LineNum,const char *FileName);
225BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen);
226void MakeMessageText(char *buffer,char *msg,int flag);
227
228//hash.cpp
229int hash_default(const char *name);
230DllProc *GetDeclareHash(const char *name);
231void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs );
232const UserProc *GetSubHash(const char *name,BOOL bError=0);
233const UserProc *GetMethodHash(const char *ObjectName,const char *MethodName,const char *Parameter,BOOL bError=0);
234const UserProc *GetClassMethod( const char *className, const char *methodName );
235
236//Object.cpp
237void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
238bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
239
240//Overload.sbp
241class Parameters;
242const UserProc *OverloadSolutionWithStrParam(
243 const char *name,
244 std::vector<const UserProc *> &subs,
245 const char *Parameter,
246 const char *ObjectName);
247const UserProc *OverloadSolution(
248 const char *name,
249 std::vector<const UserProc *> &subs,
250 const Parameters &params,
251 const Type &returnType );
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);
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);
323int GetSourceCodeIndexFromLine( const char *source, int LineNum );
324char GetEndXXXCommand(char es);
325void GetDefaultNameFromES(char es,char *name);
326const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
327bool IsFileExist(const char *path);
328BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
329BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
330void ShortPathToLongPath(const char *ShortPath,char *LongPath);
331
332//calculation.cpp
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);
339int GetLiteralIndex(_int64 i64data);
340int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
341DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true );
342int IsStrCalculation(const char *Command);
343BYTE GetCalcId(const char *Command,int *pi);
344BOOL GetNumOpeElements(const char *Command,int *pnum,
345 char *values[255],long calc[255],long stack[255]);
346
347//NumOpe_GetType.cpp
348int AutoBigCast(int BaseType,int CalcType);
349BOOL CheckCalcType(int idCalc,int *type,int sp);
350bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL );
351bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL );
352
353//Subroutine.cpp
354int GetCallProcName(char *buffer,char *name);
355int GetProc(char *name,void **ppInfo);
356void SplitObjectName(const char *name,char *ObjectName, ReferenceKind &referenceFind );
357bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, const Type &baseType, Type &resultType, bool isCallOn = true );
358bool CallPropertyMethod( const char *variable, const char *rightSide, Type &resultType);
359bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
360bool GetReturnTypeOfIndexerGetterProc( const Type &classType, Type &resultType );
361int AddProcPtrInfo( const string &typeExpression, int nowLine );
362bool IsNeedProcCompile();
363void CompileLocal();
364
365//OldStatement.cpp
366void Opcode_Input(const char *Parameter);
367void Opcode_Print(const char *Parameter,BOOL bWrite);
368
369//error.cpp
370void SetError(int ErrorNum,const char *KeyWord,int pos);
371void SetError(int ErrorNum,const string &keyWord,int pos);
372void SetError();
373void CompileMessage(const char *buffer);
374bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
375
376//Compile.cpp
377void GetIdentifierToken( char *token, const char *source, int &pos );
378void GetCommandToken( char *token, const char *source, int &pos );
379void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters );
380int JumpStatement(const char *source, int &pos);
381void Compile(void);
382
383//Diagnose.cpp
384void Diagnose();
385
386//gc.cpp
387void InitGCVariables(void);
388
389
390
391#ifdef _DEBUG
392/*Debug*/
393/*
394#define HeapAlloc CheckHeapAlloc
395#define HeapReAlloc CheckHeapReAlloc
396LPVOID CheckHeapAlloc(HANDLE hHeap,DWORD dwFlags,DWORD dwBytes);
397LPVOID CheckHeapReAlloc(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes);
398*/
399#endif
Note: See TracBrowser for help on using the repository browser.