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

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

LexicalAnalysis.cppを除去した

File size: 11.8 KB
RevLine 
[206]1#pragma once
2
[14]3//#define _CRT_SECURE_NO_DEPRECATE
4#pragma warning(disable : 4996)
[5]5
[165]6#include <option.h>
7
[71]8using namespace std;
9
[4]10#ifdef _AMD64_
11#include "../BasicCompiler64/resource.h"
12#include "../BasicCompiler64/CommandValue.h"
13#include "../BasicCompiler64/FunctionValue.h"
[7]14#define OPCODE_H_PATH "../BasicCompiler64/opcode.h"
[4]15#else
[5]16#include "../BasicCompiler32/resource.h"
17#include "../BasicCompiler32/CommandValue.h"
18#include "../BasicCompiler32/FunctionValue.h"
[7]19#define OPCODE_H_PATH "../BasicCompiler32/opcode.h"
[4]20#endif
21
[206]22#include <jenga/include/smoothie/BasicFixed.h>
[4]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)
[123]39#define OBJECT_HEAD_SIZE PTR_SIZE*4
[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_
[288]49 #define PLATFORM 64
[4]50#else
51#define PLATFORM 32
[288]52 #ifndef LONG_PTR
53 typedef long LONG_PTR;
54 typedef DWORD ULONG_PTR;
55 #endif
[4]56#endif
57
58
59//未定義の定数情報
[107]60#ifndef IMAGE_FILE_MACHINE_AMD64
61 #define IMAGE_FILE_MACHINE_AMD64 0x8664
62#endif
[4]63
[107]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
[4]73
74
75extern HWND hOwnerEditor;
76extern HANDLE hHeap;
77extern int cp;
[69]78extern int typeOfPtrChar;
[97]79extern int typeOfPtrUChar;
[4]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
[34]206#include "../BasicCompiler_Common/PESchedule.h"
[400]207#include "../BasicCompiler_Common/StrOperation.h"
[75]208#include "../BasicCompiler_Common/VariableOpe.h"
[4]209
210
211
[75]212bool StaticCalculation(bool enableerror, const char *Command,int BaseType,_int64 *pi64data,Type &resultType,BOOL bDebuggingWatchList=0, bool *pIsMemoryAccessError=NULL);
[4]213
214
215//BasicCompiler.cpp
216void HeapDefaultFree(LPVOID lpMem);
[393]217void ts(int i = 0);
[4]218void ts(int i,int i2);
[322]219void ts(const char *msg);
220void ts(const char *msg,const char *title);
[4]221void epi_check();
222void GetRelationalPath(char *path,char *dir);
[167]223void GetFullPath( char *path, const string &baseDirPath );
[322]224std::string GetApplicationBaseFullPath( const std::string &relationalPath );
[279]225void ShowErrorLine(int LineNum,const char *FileName);
[4]226BOOL GetFilePathDialog(HWND hwnd,char *filename,LPSTR Filter,LPSTR Title,BOOL bOpen);
227void MakeMessageText(char *buffer,char *msg,int flag);
228
229//hash.cpp
[75]230int hash_default(const char *name);
[209]231DllProc *GetDeclareHash(const char *name);
[206]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 );
[4]236
237//Object.cpp
[206]238void CallConstructor( const char *ObjectName,const Subscripts &subscripts, const Type &type,const char *Parameter);
[75]239bool Operator_New( const char *expression, const Type &baseType, Type &resultType );
[4]240
241//Overload.sbp
[206]242class Parameters;
243const UserProc *OverloadSolutionWithStrParam(
[50]244 const char *name,
[206]245 std::vector<const UserProc *> &subs,
[50]246 const char *Parameter,
[75]247 const char *ObjectName);
[206]248const UserProc *OverloadSolution(
[50]249 const char *name,
[206]250 std::vector<const UserProc *> &subs,
[75]251 const Parameters &params,
252 const Type &returnType );
[4]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);
[206]261UserProc *GetSubFromObp(ULONG_PTR pos);
[4]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);
[206]273int Debugging_GetVarOffset( char *variable,RELATIVE_VAR *pRelativeVar, Type &resultType, Subscripts *pResultSubscripts = NULL );
[4]274
275//MakeExe.cpp
276void StepCompileProgress(void);
[350]277void MakeMiddleCode( char *buffer );
[322]278void AddSourceCode(const char *buffer);
[4]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
[16]296bool GetConstInfo(void);
[4]297void ChangeCommandToCode(char *buffer);
298
299//preprocessor.cpp
[15]300char *OpenBasicFile(char *FileName);
[4]301
302//Resource.cpp
303void GetResourceData(char *FileName);
304
305//CommandFormat.cpp
[75]306void ComOpen(char *Parameter,char *buffer,int nowLine);
[4]307void ComClose(char *Parameter,char *buffer);
308void ComField(char *Parameter,char *buffer);
[75]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);
[4]313
314// StrOperation.cpp
315void KillSpaces(char *str1,char *str2);
316void KillStringSpaces(char *str);
317BOOL RemoveStringQuotes(char *str);
[387]318bool RemoveStringQuotes( std::string &str );
[4]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);
[313]325int GetSourceCodeIndexFromLine( const char *source, int LineNum );
[4]326char GetEndXXXCommand(char es);
327void GetDefaultNameFromES(char es,char *name);
[206]328const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source );
[279]329bool IsFileExist(const char *path);
[31]330BOOL ShortPathToLongPath(char ShortPath[MAX_PATH],char *LongPath);
[4]331BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle);
[31]332void ShortPathToLongPath(const char *ShortPath,char *LongPath);
[4]333
334//calculation.cpp
[15]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);
[4]341int GetLiteralIndex(_int64 i64data);
342int NeutralizationType(int type1,LONG_PTR index1,int type2,LONG_PTR index2);
[254]343DWORD GetLiteralValue(char *value,_int64 *pi64,int BaseType, bool isNotifyError = true );
344int IsStrCalculation(const char *Command);
[15]345BYTE GetCalcId(const char *Command,int *pi);
346BOOL GetNumOpeElements(const char *Command,int *pnum,
[4]347 char *values[255],long calc[255],long stack[255]);
348
[75]349//NumOpe_GetType.cpp
[4]350int AutoBigCast(int BaseType,int CalcType);
351BOOL CheckCalcType(int idCalc,int *type,int sp);
[331]352bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL );
[254]353bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL );
[4]354
355//Subroutine.cpp
356int GetCallProcName(char *buffer,char *name);
357int GetProc(char *name,void **ppInfo);
[290]358void SplitObjectName(const char *name,char *ObjectName, ReferenceKind &referenceFind );
[331]359bool CallProc( int kind, const void *pProc, const char *fullCallName, const char *lpszParms, const Type &baseType, Type &resultType, bool isCallOn = true );
[75]360bool CallPropertyMethod( const char *variable, const char *rightSide, Type &resultType);
361bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType );
[292]362bool GetReturnTypeOfIndexerGetterProc( const Type &classType, Type &resultType );
[78]363int AddProcPtrInfo( const string &typeExpression, int nowLine );
[94]364bool IsNeedProcCompile();
[316]365void CompileLocal();
[4]366
[76]367//OldStatement.cpp
368void Opcode_Input(const char *Parameter);
369void Opcode_Print(const char *Parameter,BOOL bWrite);
370
[4]371//error.cpp
[40]372void SetError(int ErrorNum,const char *KeyWord,int pos);
[75]373void SetError(int ErrorNum,const string &keyWord,int pos);
[64]374void SetError();
[287]375void CompileMessage(const char *buffer);
[75]376bool CheckDifferentType( const Type &varType,const Type &calcType,const char *pszFuncName,const int ParmNum);
[4]377
378//Compile.cpp
[17]379void GetIdentifierToken( char *token, const char *source, int &pos );
[296]380void GetCommandToken( char *token, const char *source, int &pos );
[381]381void GetCustomToken( char *token, const char *source, int &pos, char delimitation, bool isEscapeSequence );
[299]382void SplitGenericClassInstance( const char *fullName, char *className, Jenga::Common::Strings &typeParameters );
[16]383int JumpStatement(const char *source, int &pos);
[4]384void Compile(void);
385
[91]386//Diagnose.cpp
387void Diagnose();
388
[4]389//gc.cpp
390void InitGCVariables(void);
391
392
393
394#ifdef _DEBUG
395/*Debug*/
396/*
397#define HeapAlloc CheckHeapAlloc
398#define HeapReAlloc CheckHeapReAlloc
399LPVOID CheckHeapAlloc(HANDLE hHeap,DWORD dwFlags,DWORD dwBytes);
400LPVOID CheckHeapReAlloc(HANDLE hHeap,DWORD dwFlags,LPVOID lpMem,DWORD dwBytes);
401*/
402#endif
Note: See TracBrowser for help on using the repository browser.