Changeset 193 in dev for trunk/abdev/BasicCompiler_Common/src
- Timestamp:
- Jun 26, 2007, 5:04:50 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common/src
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/src/ClassImpl.cpp
r185 r193 76 76 77 77 78 bool ClassImpl::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 79 { 80 if( GetName() != name ){ 81 return false; 82 } 83 84 return compiler.IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes ); 85 } 86 78 87 bool ClassImpl::Inherits( const char *inheritNames, int nowLine ){ 79 88 int i = 0; … … 91 100 92 101 //継承元クラスを取得 93 const CClass *pInheritsClass = Smoothie::GetMeta().GetClasses().Find(temporary);102 const CClass *pInheritsClass = compiler.GetMeta().GetClasses().Find(temporary); 94 103 if( !pInheritsClass ){ 95 104 SmoothieException::Throw(106,temporary,nowLine); … … 121 130 if( !isInheritsClass ){ 122 131 // クラスを一つも継承していないとき 123 const CClass *pObjectClass = Smoothie::GetMeta().GetClasses().Find("Object");132 const CClass *pObjectClass = compiler.GetMeta().GetClasses().Find("Object"); 124 133 if( !pObjectClass ){ 125 134 SmoothieException::Throw(106,"Object",i); … … 145 154 146 155 //継承元クラスを取得 147 const CClass *pInheritsClass = Smoothie::GetMeta().GetClasses().Find(temporary);156 const CClass *pInheritsClass = compiler.GetMeta().GetClasses().Find(temporary); 148 157 if( !pInheritsClass ){ 149 158 SmoothieException::Throw(106,temporary,nowLine); … … 184 193 //継承先が読み取られていないとき 185 194 pobj_LoopRefCheck->add(this->GetName().c_str()); 186 Smoothie::GetMeta().GetClasses().GetClass_recur(inheritsClass.GetName().c_str());195 compiler.GetMeta().GetClasses().GetClass_recur(inheritsClass.GetName().c_str()); 187 196 pobj_LoopRefCheck->del(this->GetName().c_str()); 188 197 } … … 246 255 //継承先が読み取られていないとき 247 256 pobj_LoopRefCheck->add(this->GetName().c_str()); 248 Smoothie::GetMeta().GetClasses().GetClass_recur(inheritsInterface.GetName().c_str());257 compiler.GetMeta().GetClasses().GetClass_recur(inheritsInterface.GetName().c_str()); 249 258 pobj_LoopRefCheck->del(this->GetName().c_str()); 250 259 } … … 470 479 } 471 480 472 vtbl_offset= Compiler::GetNativeCode().GetDataTable().AddBinary((void *)ppsi,GetVtblNum()*sizeof(LONG_PTR));481 vtbl_offset=compiler.GetNativeCode().GetDataTable().AddBinary((void *)ppsi,GetVtblNum()*sizeof(LONG_PTR)); 473 482 474 483 for( int i=0; i < GetVtblNum(); i++ ){ … … 484 493 485 494 LONG_PTR *pVtbl; 486 pVtbl=(LONG_PTR *)((char *) Compiler::GetNativeCode().GetDataTable().GetPtr()+vtbl_offset);495 pVtbl=(LONG_PTR *)((char *)compiler.GetNativeCode().GetDataTable().GetPtr()+vtbl_offset); 487 496 488 497 int i; … … 505 514 506 515 // Blittable型管理オブジェクトを初期化 507 Smoothie::GetMeta().blittableTypes.clear();516 compiler.GetMeta().GetBlittableTypes().clear(); 508 517 509 518 // 名前空間管理 … … 512 521 513 522 // Importsされた名前空間の管理 514 NamespaceScopesCollection &importedNamespaces = Smoothie::Temp::importedNamespaces;523 NamespaceScopesCollection &importedNamespaces = compiler.GetImportedNamespaces(); 515 524 importedNamespaces.clear(); 516 525 … … 549 558 temporary[i2]=source[i]; 550 559 } 551 if( ! importedNamespaces.Imports( temporary ) )560 if( !compiler.ImportsNamespace( temporary ) ) 552 561 { 553 562 SmoothieException::Throw(64,temporary,i ); … … 580 589 i+=10; 581 590 i+=GetStringInPare_RemovePare(temporary,source.GetBuffer()+i)+1; 582 Type::StringToType( temporary, blittableType );591 Compiler::StringToType( temporary, blittableType ); 583 592 } 584 593 … … 625 634 626 635 // Blittable型として登録 627 Smoothie::GetMeta().blittableTypes.push_back( BlittableType( blittableType, pClass ) );636 compiler.GetMeta().GetBlittableTypes().push_back( BlittableType( blittableType, pClass ) ); 628 637 } 629 638 } … … 783 792 784 793 //継承元クラスを取得 785 const CClass *pInheritsClass = Find(temporary); 794 const Classes &classes = *this; 795 const CClass *pInheritsClass = classes.Find(temporary); 786 796 if( !pInheritsClass ){ 787 797 SetError(106,temporary,i); … … 1283 1293 }*/ 1284 1294 } 1295 1296 const CClass *ClassesImpl::Find( const NamespaceScopes &namespaceScopes, const string &name ) const 1297 { 1298 int key; 1299 key=GetHashCode(name.c_str()); 1300 1301 if( namespaceScopes.size() == 0 && name == "Object" ){ 1302 return GetObjectClassPtr(); 1303 } 1304 else if( namespaceScopes.size() == 0 && name == "String" ){ 1305 return GetStringClassPtr(); 1306 } 1307 1308 if(pobj_ClassHash[key]){ 1309 CClass *pobj_c; 1310 pobj_c=pobj_ClassHash[key]; 1311 while(1){ 1312 if( pobj_c->IsEqualSymbol( namespaceScopes, name ) ){ 1313 //名前空間とクラス名が一致した 1314 return pobj_c; 1315 } 1316 1317 if(pobj_c->pobj_NextClass==0) break; 1318 pobj_c=pobj_c->pobj_NextClass; 1319 } 1320 } 1321 1322 // TypeDefも見る 1323 int index = compiler.GetMeta().GetTypeDefs().GetIndex( namespaceScopes, name ); 1324 if( index != -1 ){ 1325 Type type = compiler.GetMeta().GetTypeDefs()[index].GetBaseType(); 1326 if( type.IsObject() ){ 1327 return &type.GetClass(); 1328 } 1329 } 1330 1331 return NULL; 1332 } -
trunk/abdev/BasicCompiler_Common/src/Compiler.cpp
r184 r193 1 #include <jenga/include/smoothie/Type.h> 2 #include <jenga/include/smoothie/SmoothieException.h> 3 1 4 #include <Compiler.h> 2 5 3 NativeCode Compiler::nativeCode; 6 7 bool Compiler::StringToType( const string &typeName, Type &type ){ 8 type.SetIndex( -1 ); 9 10 if( typeName[0] == '*' ){ 11 if( typeName.size() >= 3 12 && typeName[1] == 1 && ( typeName[2] == ESC_FUNCTION || typeName[2] == ESC_SUB ) ){ 13 //関数ポインタ(*Function) 14 type.SetBasicType( DEF_PTR_PROC ); 15 type.SetIndex( compiler.GetMeta().GetProcPointers().Add( typeName ) ); 16 return true; 17 } 18 19 const string &nextTypeName = typeName.substr( 1 ); 20 21 if( !StringToType( nextTypeName, type ) ){ 22 return false; 23 } 24 25 type.PtrLevelUp(); 26 27 return true; 28 } 29 30 { 31 int basicType; 32 if( Type::StringToBasicType( typeName, basicType ) ){ 33 // 基本型だったとき 34 type.SetBasicType( basicType ); 35 return true; 36 } 37 } 38 39 // Object型だったとき 40 if( typeName == "Object" ){ 41 type.SetType( DEF_OBJECT, compiler.GetMeta().GetClasses().GetObjectClassPtr() ); 42 return true; 43 } 44 45 // String型だったとき 46 if( typeName == "String" ){ 47 type.SetType( DEF_OBJECT, compiler.GetMeta().GetClasses().GetStringClassPtr() ); 48 return true; 49 } 50 51 52 //////////////////// 53 // TypeDefされた型 54 //////////////////// 55 int i=compiler.GetMeta().GetTypeDefs().GetIndex( typeName ); 56 if(i!=-1){ 57 type = compiler.GetMeta().GetTypeDefs()[i].GetBaseType(); 58 return true; 59 } 60 61 //クラス 62 const CClass *pobj_c = compiler.GetMeta().GetClasses().Find( typeName ); 63 if(pobj_c){ 64 type.SetClassPtr( pobj_c ); 65 66 if( pobj_c->IsStructure() ){ 67 type.SetBasicType( DEF_STRUCT ); 68 } 69 else{ 70 type.SetBasicType( DEF_OBJECT ); 71 } 72 return true; 73 } 74 75 return false; 76 } 77 78 const string Compiler::TypeToString( const Type &type ) 79 { 80 if( PTR_LEVEL( type.GetBasicType() ) ){ 81 //ポインタレベルが1以上の場合 82 Type tempType( type ); 83 tempType.PtrLevelDown(); 84 85 return (string)"*" + TypeToString( type ); 86 } 87 else if( type.IsObject() || type.IsStruct() ){ 88 //オブジェクトまたは構造体 89 90 if( !( type.GetIndex() == 0 || type.GetIndex() == -1 ) ){ 91 if( type.GetClass().GetNamespaceScopes().size() >= 1 ) 92 { 93 return type.GetClass().GetNamespaceScopes().ToString() + "." + type.GetClass().GetName(); 94 } 95 return type.GetClass().GetName(); 96 } 97 } 98 else if( type.IsProcPtr() ){ 99 if( type.GetIndex() == 0 || type.GetIndex() == -1 ){ 100 return "VoidPtr"; 101 } 102 else{ 103 if( compiler.GetMeta().GetProcPointers()[type.GetIndex()]->ReturnType().IsNull() ){ 104 return "*Sub"; 105 } 106 return "*Function"; 107 } 108 } 109 else{ 110 // 基本型 111 const char *lpszTypeName = Type::BasicTypeToCharPtr( type ); 112 if( lpszTypeName ) 113 { 114 return (const string)lpszTypeName; 115 } 116 } 117 118 SmoothieException::Throw( 1 ); 119 120 return (string)"(null)"; 121 } -
trunk/abdev/BasicCompiler_Common/src/ProcedureImpl.cpp
r185 r193 2 2 #include <jenga/include/smoothie/LexicalAnalysis.h> 3 3 4 #include <Compiler.h> 4 5 #include <ProcedureImpl.h> 5 6 … … 104 105 //cp = nowLine; 105 106 106 NumOpe_GetType( initValue, Type::String(), type );107 NumOpe_GetType( initValue, GetStringTypeInfo(), type ); 107 108 } 108 109 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){ … … 129 130 } 130 131 131 Type::StringToType( temporary, type );132 Compiler::StringToType( temporary, type ); 132 133 133 134 if( type.IsNull() ){ … … 257 258 } 258 259 259 Type::StringToType( temporary, type );260 Compiler::StringToType( temporary, type ); 260 261 261 262 if( type.IsNull() ){ … … 326 327 temporary[i3]=sourceOfParams[i2]; 327 328 } 328 Type::StringToType( temporary, this->returnType );329 Compiler::StringToType( temporary, this->returnType ); 329 330 if( this->returnType.IsNull() ) SmoothieException::Throw(3,temporary,nowLine); 330 331 … … 387 388 } 388 389 389 return NamespaceScopes::IsSameArea( GetNamespaceScopes(), namespaceScopes );390 return compiler.IsSameAreaNamespace( GetNamespaceScopes(), namespaceScopes ); 390 391 } 391 392 bool GlobalProc::IsEqualSymbol( const GlobalProc &globalProc ) const … … 402 403 } 403 404 405 bool DllProcImpl::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const 406 { 407 if( GetName() != name ){ 408 return false; 409 } 410 return compiler.IsSameAreaNamespace( this->GetNamespaceScopes(), namespaceScopes ); 411 } 404 412 bool DllProcImpl::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){ 405 413 int i = 0; … … 505 513 } 506 514 507 Type::StringToType( temporary, type );515 Compiler::StringToType( temporary, type ); 508 516 509 517 if( type.IsNull() ){ … … 559 567 temporary[i3]=sourceOfParams[i2]; 560 568 } 561 Type::StringToType( temporary, this->returnType );569 Compiler::StringToType( temporary, this->returnType ); 562 570 if( this->returnType.IsNull() ) SmoothieException::Throw(3,temporary,nowLine); 563 571 … … 676 684 } 677 685 678 Type::StringToType( temporary, type );686 Compiler::StringToType( temporary, type ); 679 687 680 688 if( type.IsNull() ){ … … 730 738 temporary[i3]=sourceOfParams[i2]; 731 739 } 732 Type::StringToType( temporary, this->returnType );740 Compiler::StringToType( temporary, this->returnType ); 733 741 if( this->returnType.IsNull() ) SmoothieException::Throw(3,temporary,nowLine); 734 742 -
trunk/abdev/BasicCompiler_Common/src/SmoothieImpl.cpp
r191 r193 6 6 #include <LexicalScopingImpl.h> 7 7 8 MetaImpl SmoothieImpl::metaImpl(9 new ClassesImpl()10 );11 12 8 CLexicalScopes *Smoothie::Temp::pLexicalScopes = new LexicalScopesImpl(); 13 14 15 Meta &Smoothie::GetMeta()16 {17 return SmoothieImpl::metaImpl;18 }
Note:
See TracChangeset
for help on using the changeset viewer.