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

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

代入演算時の左辺に関数呼び出しの戻り値を評価してメンバを取得するようなコードが存在するとき、エラーになってしまっていたので改修した。(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#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
254//Debug.cpp
255void Debugger_StepIn(void);
256void Debugger_StepOver(void);
257void Debugger_StepCursor(void);
258void Debugger_Stop(void);
259void Debugger_Pause(void);
260ULONG_PTR rva_to_real(DWORD p);
261UserProc *GetSubFromObp(ULONG_PTR pos);
262void ReadOpBuffer();
263void DebugProgram(void);
264
265//VarList.cpp
266void InitVarList(DWORD dwThreadId);
267BOOL CALLBACK DlgDebugger(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
268BOOL CALLBACK DlgVarList(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam);
269
270//WatchList.cpp
271ULONG_PTR Debugging_GetVarPtr(RELATIVE_VAR *pRelativeVar);
272ULONG_PTR Debugging_GetThisPtrOffset(LONG_PTR obp_Rip);
273int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
274
275//MakeExe.cpp
276void StepCompileProgress(void);
277void MakeMiddleCode( char *buffer );
278void AddSourceCode(const char *buffer);
279void OutputExe(void);
280int MainThread(DWORD dummy);
281
282//Intermediate_Step1.cpp
283void ChangeReturnCode(char *buffer);
284void DeleteComment(char *buffer);
285void KillReturnCode(char *buffer);
286void CheckParenthesis(char *buffer);
287BOOL CheckParenthesis2(char *buffer);
288void DirectiveCheck(void);
289void NextCommandFormat(char *buffer);
290void SetEscapeSequenceFormat(char *buffer);
291void DefCommandFormat(char *buffer);
292void IfCommandFormat(char *buffer);
293void CheckPareCommand(void);
294
295//Intermediate_Step2.cpp
296bool GetConstInfo(void);
297void ChangeCommandToCode(char *buffer);
298
299//preprocessor.cpp
300char *OpenBasicFile(char *FileName);
301
302//Resource.cpp
303void GetResourceData(char *FileName);
304
305//CommandFormat.cpp
306void ComOpen(char *Parameter,char *buffer,int nowLine);
307void ComClose(char *Parameter,char *buffer);
308void ComField(char *Parameter,char *buffer);
309void ComLine(char *Parameter,char *buffer,int nowLine);
310void ComCircle(char *Parameter,char *buffer,int nowLine);
311void ComPSet(char *Parameter,char *buffer,int nowLine);
312void ComPaint(char *Parameter,char *buffer,int nowLine);
313
314// StrOperation.cpp
315void KillSpaces(char *str1,char *str2);
316void KillStringSpaces(char *str);
317BOOL RemoveStringQuotes(char *str);
318bool RemoveStringQuotes( std::string &str );
319void RemoveStringPare(char *str);
320void RemoveStringBracket(char *str);
321void SetStringQuotes(char *str);
322int FormatString_EscapeSequence(char *buffer);
323void SlideString(char *str,int slide);
324void SlideBuffer(char *buffer,int length,int slide);
325int GetSourceCodeIndexFromLine( const char *source, int LineNum );
326char GetEndXXXCommand(char es);
327void GetDefaultNameFromES(char es,char *name);
328const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
329bool IsFileExist(const char *path);
330BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
331BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
332void ShortPathToLongPath(const char *ShortPath,char *LongPath);
333
334//calculation.cpp
335bool IsNumberTopChar(const char *buffer);
336bool IsNumberChar(const char c);
337BOOL IsNumCalcMark(const char *Command,int p);
338BOOL IsNumCalcMark_Back(const char *Command,int p);
339BOOL IsStrCalcMark(const char c);
340BOOL IsExponent(const char *Command,int p);
341int GetLiteralIndex(_int64 i64data);
342int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
343DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true );
344int IsStrCalculation(const char *Command);
345BYTE GetCalcId(const char *Command,int *pi);
346BOOL GetNumOpeElements(const char *Command,int *pnum,
347 char *values[255],long calc[255],long stack[255]);
348
349//NumOpe_GetType.cpp
350int AutoBigCast(int BaseType,int CalcType);
351BOOL CheckCalcType(int idCalc,int *type,int sp);
352bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL, bool *pIsVariable = NULL );
353bool GetTermType( const char *term, Type &resultType );
354bool GetTermTypeOnlyVariable( const char *term, Type &resultType );
355bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL );
356
357//Subroutine.cpp
358int GetCallProcName(char *buffer,char *name);
359int GetProc(char *name,void **ppInfo);
360void SplitObjectName(const char *name,char *ObjectName, ReferenceKind &referenceFind );
361bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, const Type &baseType, 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 Type &classType, Type &resultType );
365int AddProcPtrInfo( const string &typeExpression, int nowLine );
366bool IsNeedProcCompile();
367void CompileLocal();
368
369//OldStatement.cpp
370void Opcode_Input(const char *Parameter);
371void Opcode_Print(const char *Parameter,BOOL bWrite);
372
373//error.cpp
374void SetError(int ErrorNum,const char *KeyWord,int pos);
375void SetError(int ErrorNum,const string &keyWord,int pos);
376void SetError();
377void CompileMessage(const char *buffer);
378bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
379
380//Compile.cpp
381void GetIdentifierToken( char *token, const char *source, int &pos );
382void GetCommandToken( char *token, const char *source, int &pos );
383void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence );
384void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters );
385int JumpStatement(const char *source, int &pos);
386void Compile(void);
387
388//Diagnose.cpp
389void Diagnose();
390
391//gc.cpp
392void InitGCVariables(void);
393
394
395
396#ifdef _DEBUG
397/*Debug*/
398/*
399#define HeapAlloc CheckHeapAlloc
400#define HeapReAlloc CheckHeapReAlloc
401LPVOID CheckHeapAlloc(HANDLE hHeap,DWORD dwFlags,DWORD dwBytes);
402LPVOID CheckHeapReAlloc(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes);
403*/
404#endif
Note: See TracBrowser for help on using the repository browser.