Changeset 209 in dev for trunk/abdev/BasicCompiler_Common
- Timestamp:
- Jul 13, 2007, 4:22:02 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/BasicCompiler.h
r206 r209 23 23 DWORD ImageBase; 24 24 INCLUDEFILEINFO IncludeFileInfo; 25 DllProc **ppDeclareHash;26 25 27 26 ERRORINFO *pErrorInfo; -
trunk/abdev/BasicCompiler_Common/MakeExe.cpp
r206 r209 164 164 extern LINEINFO *pLineInfo; 165 165 HeapDefaultFree(pLineInfo); 166 167 //Declare(DLL関数)情報のメモリ解放168 DeleteDeclareInfo();169 166 170 167 //コンパイルダイアログのプログレスバーを上げる -
trunk/abdev/BasicCompiler_Common/Subroutine.cpp
r206 r209 277 277 } 278 278 279 280 void AddDeclareData(const NamespaceScopes &namespaceScopes, char *buffer,int nowLine){ 281 extern HANDLE hHeap; 282 int i2; 283 284 int i=0; 285 286 //Sub/Function 287 Procedure::Kind kind = Procedure::Sub; 288 if(buffer[i]==ESC_SUB){ 289 } 290 else if(buffer[i]==ESC_FUNCTION){ 291 kind = Procedure::Function; 292 } 293 else{ 294 SetError(1,NULL,nowLine); 295 return; 296 } 297 i++; 298 299 //プロシージャ名 300 char procName[VN_SIZE]; 301 bool isCdecl = false; 302 for(i2=0;;i++,i2++){ 303 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL){ 304 isCdecl = true; 305 306 i+=2; 307 procName[i2]=0; 308 break; 309 } 310 if(buffer[i]==','){ 311 procName[i2]=0; 312 break; 313 } 314 if(buffer[i]=='\0'){ 315 SetError(1,NULL,nowLine); 316 return; 317 } 318 procName[i2]=buffer[i]; 319 } 320 i++; 321 322 //ユーザー定義関数との重複チェック 323 if(GetSubHash(procName)){ 324 SetError(15,procName,nowLine); 325 return; 326 } 327 328 329 //ライブラリ 330 char dllFileName[MAX_PATH]; 331 i = GetOneParameter( buffer, i, dllFileName ); 332 Type resultType; 333 _int64 i64data; 334 if( !StaticCalculation( true, dllFileName, 0, &i64data, resultType ) ){ 335 return; 336 } 337 if( resultType.GetBasicType() != typeOfPtrChar ){ 338 SetError(1,NULL,nowLine); 339 return; 340 } 341 lstrcpy( dllFileName, (char *)i64data ); 342 CharUpper(dllFileName); 343 if(!strstr(dllFileName,".")){ 344 lstrcat(dllFileName,".DLL"); 345 if(lstrlen(dllFileName)>=16){ 346 SetError(7,NULL,nowLine); 347 return; 348 } 349 } 350 351 //エイリアス 352 char alias[VN_SIZE]; 353 i = GetOneParameter( buffer, i, alias ); 354 if( alias[0] ){ 355 if( !StaticCalculation( true, alias, 0, &i64data, resultType ) ){ 356 return; 357 } 358 if( resultType.GetBasicType() != typeOfPtrChar ){ 359 SetError(1,NULL,nowLine); 360 return; 361 } 362 lstrcpy( alias, (char *)i64data ); 363 } 364 else{ 365 //省略されたときは関数名 366 lstrcpy( alias, procName ); 367 } 368 369 370 // オブジェクトを生成 371 DllProc *pDllProc = new DllProc( namespaceScopes, procName, kind, isCdecl, dllFileName, alias ); 372 373 // パラメータを解析 374 // ※第1パラメータにに指定するデータの例:"( s As String ) As String" 375 pDllProc->SetParamsAndReturnType( buffer + i, nowLine ); 376 377 // パラメータのエラーチェック 378 BOOST_FOREACH( const Parameter *pParam, pDllProc->Params() ){ 379 if( pParam->IsObject() ){ 380 SetError(25,pParam->GetVarName(),nowLine); 381 } 382 if( !pParam->IsRef() ){ 383 if( pParam->IsStruct() ){ 384 SetError(28,pParam->GetVarName(),nowLine); 385 } 386 } 387 } 388 389 //戻り値のエラーチェック 390 if( pDllProc->IsFunction() ){ 391 // Function定義 392 393 if( pDllProc->ReturnType().IsObject() ){ 394 // DLL関数ではオブジェクトを戻り値にできない 395 SetError(40,pDllProc->GetName(),nowLine); 396 } 397 } 398 399 400 ///////////////////////////////// 401 // 格納位置を計算してppDeclareHashにセット 402 ///////////////////////////////// 403 404 //ハッシュ値を取得 405 int key; 406 key=hash_default(procName); 407 408 extern DllProc **ppDeclareHash; 409 if(ppDeclareHash[key]){ 410 DllProc *pTempProc = ppDeclareHash[key]; 411 while(1){ 412 if( pTempProc->IsEqualSymbol( pDllProc->GetNamespaceScopes(), pDllProc->GetName() ) ){ 413 //重複エラー 414 SetError(15,procName,nowLine); 415 return; 416 } 417 418 if(pTempProc->pNextData==0){ 419 pTempProc->pNextData=pDllProc; 420 break; 421 } 422 pTempProc=pTempProc->pNextData; 423 } 424 pTempProc=pTempProc->pNextData; 425 } 426 else{ 427 ppDeclareHash[key]=pDllProc; 428 } 429 } 430 431 void UserProcs::CollectUserProcs( const BasicSource &source, UserProcs &userProcs ) 279 void CollectProcedures( const BasicSource &source, UserProcs &userProcs, DllProcs &dllProcs ) 432 280 { 433 281 extern HANDLE hHeap; … … 435 283 char temporary[8192]; 436 284 437 //Declare(DLL関数)情報を初期化438 extern DllProc **ppDeclareHash;439 ppDeclareHash=(DllProc **)HeapAlloc(hHeap,HEAP_ZERO_MEMORY,MAX_HASH*sizeof(DllProc *));440 441 285 //サブルーチン(ユーザー定義)情報を初期化 442 286 userProcs.Clear(); 287 288 //Declare(DLL関数)情報を初期化 289 dllProcs.Clear(); 443 290 444 291 // 名前空間管理 … … 522 369 if(source[i]=='\0') break; 523 370 } 524 AddDeclareData(namespaceScopes,temporary,i);371 dllProcs.Add(namespaceScopes,temporary,i); 525 372 526 373 continue; … … 600 447 delete pDllProc; 601 448 } 602 void DeleteDeclareInfo(void){603 //DLL情報を解放604 extern DllProc **ppDeclareHash;605 int i;606 for(i=0;i<MAX_HASH;i++){607 if(!ppDeclareHash[i]) continue;608 609 Delete_di(ppDeclareHash[i]);610 }611 HeapDefaultFree(ppDeclareHash);612 }613 449 614 450 bool IsNeedProcCompile(){ -
trunk/abdev/BasicCompiler_Common/common.h
r206 r209 232 232 //hash.cpp 233 233 int hash_default(const char *name); 234 DllProc *GetDeclareHash(c har *name);234 DllProc *GetDeclareHash(const char *name); 235 235 void GetOverloadSubHash( const char *lpszName, std::vector<const UserProc *> &subs ); 236 236 const UserProc *GetSubHash(const char *name,BOOL bError=0); … … 278 278 //MakeExe.cpp 279 279 void StepCompileProgress(void); 280 void DeleteDeclareInfo(void);281 280 void AddSourceCode(char *buffer); 282 281 void OutputExe(void); … … 364 363 bool GetReturnTypeOfPropertyMethod( const char *variable, const char *rightSide, Type &resultType ); 365 364 bool GetReturnTypeOfIndexerGetterProc( const CClass &objClass, Type &resultType ); 366 void DeleteDeclareInfo(void);367 365 int AddProcPtrInfo( const string &typeExpression, int nowLine ); 368 366 bool IsNeedProcCompile(); -
trunk/abdev/BasicCompiler_Common/hash.cpp
r206 r209 23 23 } 24 24 25 DllProc *GetDeclareHash(c har *fullName){26 char ObjName[VN_SIZE]; //オブジェクト変数27 char NestMember[VN_SIZE]; //入れ子メンバ28 bool isObjectMember = SplitMemberName( fullName, ObjName, NestMember);25 DllProc *GetDeclareHash(const char *fullName){ 26 char namespaceStr[VN_SIZE]; //オブジェクト変数 27 char simpleName[VN_SIZE]; //入れ子メンバ 28 bool isObjectMember = SplitMemberName( fullName, namespaceStr, simpleName ); 29 29 30 // ハッシュ値を取得31 int key;32 key=hash_default(NestMember);30 /////////////////////////// 31 // グローバル関数を検索 32 /////////////////////////// 33 33 34 //格納位置を取得 35 extern DllProc **ppDeclareHash; 36 DllProc *pDllProc; 37 pDllProc=ppDeclareHash[key]; 34 // ハッシュ値を取得 35 DllProc *pDllProc = compiler.GetMeta().GetDllProcs().GetHashArrayElement( simpleName ); 38 36 while(pDllProc){ 39 // TODO: Declare名前空間対応40 37 if( pDllProc->IsEqualSymbol( fullName ) ){ 41 break;38 return pDllProc; 42 39 } 43 40 44 pDllProc=pDllProc-> pNextData;41 pDllProc=pDllProc->GetChainNext(); 45 42 } 46 43 47 return pDllProc;44 return NULL; 48 45 } 49 46 -
trunk/abdev/BasicCompiler_Common/include/MetaImpl.h
r206 r209 18 18 // 関数・メソッド 19 19 UserProcs userProcs; 20 21 // DLL関数 22 DllProcs dllProcs; 20 23 21 24 // クラス … … 53 56 ar & BOOST_SERIALIZATION_NVP( namespaceScopesCollection ); 54 57 ar & BOOST_SERIALIZATION_NVP( userProcs ); 58 ar & BOOST_SERIALIZATION_NVP( dllProcs ); 55 59 ar & BOOST_SERIALIZATION_NVP( classesImpl ); 56 60 ar & BOOST_SERIALIZATION_NVP( globalVars ); … … 87 91 { 88 92 return userProcs; 93 } 94 95 const DllProcs &GetDllProcs() const 96 { 97 return dllProcs; 98 } 99 DllProcs &GetDllProcs() 100 { 101 return dllProcs; 89 102 } 90 103 -
trunk/abdev/BasicCompiler_Common/include/Procedure.h
r208 r209 205 205 } 206 206 207 bool IsMacro() const208 {209 return isMacro;210 }211 212 int GetSecondParmNum() const213 {214 return secondParmNum;215 }216 const Parameters &RealParams() const217 {218 return realParams;219 }220 int GetRealSecondParmNum() const221 {222 return realSecondParmNum;223 }224 225 void ExportOff(){226 isExport = false;227 }228 bool IsExport() const229 {230 return isExport;231 }232 void ThisIsSystemProc() const233 {234 isSystem = true;235 }236 bool IsSystem() const237 {238 return isSystem;239 }240 void ThisIsAutoGenerationProc() const241 {242 isAutoGeneration = true;243 }244 bool IsAutoGeneration() const245 {246 return isAutoGeneration;247 }248 void CompleteCompile() const249 {250 isCompiled = true;251 }252 void KillCompileStatus() const253 {254 isCompiled = false;255 }256 bool IsCompiled() const257 {258 return isCompiled;259 }260 bool IsDestructor() const261 {262 return ( GetName()[0] == '~' );263 }264 265 // バイナリコード位置とサイズ266 DWORD GetBeginOpAddress() const267 {268 return beginOpAddress;269 }270 void SetBeginOpAddress( DWORD beginOpAddress ) const271 {272 this->beginOpAddress = beginOpAddress;273 }274 DWORD GetEndOpAddress() const275 {276 return endOpAddress;277 }278 void SetEndOpAddress( DWORD endOpAddress ) const279 {280 this->endOpAddress = endOpAddress;281 }282 int GetCodeSize() const283 {284 return endOpAddress - beginOpAddress;285 }286 287 virtual const NamespaceScopes &GetNamespaceScopes() const;288 const NamespaceScopesCollection &GetImportedNamespaces() const;289 290 Variables &GetLocalVars() const291 {292 return localVars;293 }294 295 int GetId() const296 {297 return id;298 }299 300 std::string GetFullName() const;301 302 207 virtual bool IsDuplication( const UserProc *pUserProc ) const 303 208 { … … 311 216 } 312 217 218 bool IsMacro() const 219 { 220 return isMacro; 221 } 222 223 int GetSecondParmNum() const 224 { 225 return secondParmNum; 226 } 227 const Parameters &RealParams() const 228 { 229 return realParams; 230 } 231 int GetRealSecondParmNum() const 232 { 233 return realSecondParmNum; 234 } 235 236 void ExportOff(){ 237 isExport = false; 238 } 239 bool IsExport() const 240 { 241 return isExport; 242 } 243 void ThisIsSystemProc() const 244 { 245 isSystem = true; 246 } 247 bool IsSystem() const 248 { 249 return isSystem; 250 } 251 void ThisIsAutoGenerationProc() const 252 { 253 isAutoGeneration = true; 254 } 255 bool IsAutoGeneration() const 256 { 257 return isAutoGeneration; 258 } 259 void CompleteCompile() const 260 { 261 isCompiled = true; 262 } 263 void KillCompileStatus() const 264 { 265 isCompiled = false; 266 } 267 bool IsCompiled() const 268 { 269 return isCompiled; 270 } 271 bool IsDestructor() const 272 { 273 return ( GetName()[0] == '~' ); 274 } 275 276 // バイナリコード位置とサイズ 277 DWORD GetBeginOpAddress() const 278 { 279 return beginOpAddress; 280 } 281 void SetBeginOpAddress( DWORD beginOpAddress ) const 282 { 283 this->beginOpAddress = beginOpAddress; 284 } 285 DWORD GetEndOpAddress() const 286 { 287 return endOpAddress; 288 } 289 void SetEndOpAddress( DWORD endOpAddress ) const 290 { 291 this->endOpAddress = endOpAddress; 292 } 293 int GetCodeSize() const 294 { 295 return endOpAddress - beginOpAddress; 296 } 297 298 virtual const NamespaceScopes &GetNamespaceScopes() const; 299 const NamespaceScopesCollection &GetImportedNamespaces() const; 300 301 Variables &GetLocalVars() const 302 { 303 return localVars; 304 } 305 306 int GetId() const 307 { 308 return id; 309 } 310 311 std::string GetFullName() const; 312 313 313 bool IsVirtual() const; 314 314 … … 393 393 394 394 void EnumGlobalProcs( const char *simpleName, const char *localName, std::vector<const UserProc *> &subs ); 395 396 static void CollectUserProcs( const BasicSource &source, UserProcs &userProcs ); 397 }; 398 399 class DllProc : public Procedure 395 }; 396 397 class DllProc : public Procedure, public Jenga::Common::ObjectInHashmap<DllProc> 400 398 { 401 399 string dllFileName; … … 428 426 { 429 427 } 430 ~DllProc(){} 428 ~DllProc() 429 { 430 } 431 432 virtual const std::string &GetKeyName() const 433 { 434 return GetName(); 435 } 436 437 virtual bool IsDuplication( const DllProc *pDllProc ) const 438 { 439 if( pDllProc->IsEqualSymbol( *this ) 440 && this->Params().Equals( pDllProc->Params() ) ) 441 { 442 return true; 443 } 444 return false; 445 } 431 446 432 447 const string &GetDllFileName() const … … 449 464 bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine ); 450 465 }; 466 class DllProcs : public Jenga::Common::Hashmap<DllProc> 467 { 468 // XMLシリアライズ用 469 private: 470 friend class boost::serialization::access; 471 template<class Archive> void serialize(Archive& ar, const unsigned int version) 472 { 473 trace_for_serialize( "serializing - DllProcs" ); 474 475 ar & boost::serialization::make_nvp("Hashmap_DllProc", 476 boost::serialization::base_object<Jenga::Common::Hashmap<DllProc>>(*this)); 477 } 478 479 public: 480 void Add(const NamespaceScopes &namespaceScopes, char *buffer,int nowLine); 481 }; 482 483 void CollectProcedures( const BasicSource &source, UserProcs &userProcs, DllProcs &dllProcs ); 451 484 452 485 class ProcPointer : public Procedure -
trunk/abdev/BasicCompiler_Common/src/Procedure.cpp
r208 r209 759 759 } 760 760 761 void DllProcs::Add(const NamespaceScopes &namespaceScopes, char *buffer,int nowLine){ 762 int i2; 763 764 int i=0; 765 766 //Sub/Function 767 Procedure::Kind kind = Procedure::Sub; 768 if(buffer[i]==ESC_SUB){ 769 } 770 else if(buffer[i]==ESC_FUNCTION){ 771 kind = Procedure::Function; 772 } 773 else{ 774 SetError(1,NULL,nowLine); 775 return; 776 } 777 i++; 778 779 //プロシージャ名 780 char procName[VN_SIZE]; 781 bool isCdecl = false; 782 for(i2=0;;i++,i2++){ 783 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL){ 784 isCdecl = true; 785 786 i+=2; 787 procName[i2]=0; 788 break; 789 } 790 if(buffer[i]==','){ 791 procName[i2]=0; 792 break; 793 } 794 if(buffer[i]=='\0'){ 795 SetError(1,NULL,nowLine); 796 return; 797 } 798 procName[i2]=buffer[i]; 799 } 800 i++; 801 802 //ユーザー定義関数との重複チェック 803 if(GetSubHash(procName)){ 804 SetError(15,procName,nowLine); 805 return; 806 } 807 808 809 //ライブラリ 810 char dllFileName[MAX_PATH]; 811 i = GetOneParameter( buffer, i, dllFileName ); 812 Type resultType; 813 _int64 i64data; 814 if( !StaticCalculation( true, dllFileName, 0, &i64data, resultType ) ){ 815 return; 816 } 817 if( resultType.GetBasicType() != typeOfPtrChar ){ 818 SetError(1,NULL,nowLine); 819 return; 820 } 821 lstrcpy( dllFileName, (char *)i64data ); 822 CharUpper(dllFileName); 823 if(!strstr(dllFileName,".")){ 824 lstrcat(dllFileName,".DLL"); 825 if(lstrlen(dllFileName)>=16){ 826 SetError(7,NULL,nowLine); 827 return; 828 } 829 } 830 831 //エイリアス 832 char alias[VN_SIZE]; 833 i = GetOneParameter( buffer, i, alias ); 834 if( alias[0] ){ 835 if( !StaticCalculation( true, alias, 0, &i64data, resultType ) ){ 836 return; 837 } 838 if( resultType.GetBasicType() != typeOfPtrChar ){ 839 SetError(1,NULL,nowLine); 840 return; 841 } 842 lstrcpy( alias, (char *)i64data ); 843 } 844 else{ 845 //省略されたときは関数名 846 lstrcpy( alias, procName ); 847 } 848 849 850 // オブジェクトを生成 851 DllProc *pDllProc = new DllProc( namespaceScopes, procName, kind, isCdecl, dllFileName, alias ); 852 853 // パラメータを解析 854 // ※第1パラメータにに指定するデータの例:"( s As String ) As String" 855 pDllProc->SetParamsAndReturnType( buffer + i, nowLine ); 856 857 // パラメータのエラーチェック 858 BOOST_FOREACH( const Parameter *pParam, pDllProc->Params() ){ 859 if( pParam->IsObject() ){ 860 SetError(25,pParam->GetVarName(),nowLine); 861 } 862 if( !pParam->IsRef() ){ 863 if( pParam->IsStruct() ){ 864 SetError(28,pParam->GetVarName(),nowLine); 865 } 866 } 867 } 868 869 //戻り値のエラーチェック 870 if( pDllProc->IsFunction() ){ 871 // Function定義 872 873 if( pDllProc->ReturnType().IsObject() ){ 874 // DLL関数ではオブジェクトを戻り値にできない 875 SetError(40,pDllProc->GetName(),nowLine); 876 } 877 } 878 879 // ハッシュマップに追加 880 this->Put( pDllProc ); 881 } 882 761 883 bool ProcPointer::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){ 762 884 int i = 0;
Note:
See TracChangeset
for help on using the changeset viewer.