Changeset 424 in dev for trunk/abdev/BasicCompiler_Common/src
- Timestamp:
- Mar 10, 2008, 5:39:36 PM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler_Common/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler_Common/src/Class_Collect.cpp
r409 r424 332 332 char className[VN_SIZE]; 333 333 Jenga::Common::Strings typeParameters; 334 SplitGenericClassInstance( temporary, className, typeParameters ); 334 Jenga::Common::Strings typeParameterBaseClassNames; 335 SplitGenericClassInstance( temporary, className, typeParameters, true, &typeParameterBaseClassNames ); 335 336 336 337 CClass *pobj_c = const_cast<CClass *>( this->Find(namespaceScopes, className) ); … … 353 354 ///////////////////////////////////////////////////////// 354 355 // ☆★☆ ジェネリクスサポート ☆★☆ 355 BOOST_FOREACH( const std::string &typeParameter, typeParameters ) 356 { 357 pobj_c->AddFormalGenericType( GenericType( typeParameter, Type(DEF_OBJECT,*GetObjectClassPtr()) ) ); 356 for( i2=0; i2<static_cast<int>(typeParameters.size()); i2++ ) 357 { 358 Type baseType( DEF_OBJECT, *GetObjectClassPtr() ); 359 if( typeParameterBaseClassNames[i2].size() ) 360 { 361 if( !compiler.StringToType( typeParameterBaseClassNames[i2], baseType ) ) 362 { 363 SetError(106,typeParameterBaseClassNames[i2],i); 364 } 365 else if( !baseType.IsObject() ) 366 { 367 SetError(106,typeParameterBaseClassNames[i2],i); 368 } 369 } 370 371 pobj_c->AddFormalGenericType( GenericType( typeParameters[i2], baseType ) ); 358 372 } 359 373 ///////////////////////////////////////////////////////// … … 527 541 char className[VN_SIZE]; 528 542 Jenga::Common::Strings typeParameters; 529 SplitGenericClassInstance( temporary, className, typeParameters ); 543 Jenga::Common::Strings typeParameterBaseClassNames; 544 SplitGenericClassInstance( temporary, className, typeParameters, true, &typeParameterBaseClassNames ); 530 545 531 546 CClass *pobj_c = const_cast<CClass *>( this->Find(namespaceScopes, className) ); … … 549 564 ///////////////////////////////////////////////////////// 550 565 // ☆★☆ ジェネリクスサポート ☆★☆ 551 BOOST_FOREACH( const std::string &typeParameter, typeParameters ) 552 { 553 pobj_c->AddFormalGenericType( GenericType( typeParameter, Type(DEF_OBJECT,*GetObjectClassPtr()) ) ); 566 for( i2=0; i2<static_cast<int>(typeParameters.size()); i2++ ) 567 { 568 Type baseType( DEF_OBJECT, *GetObjectClassPtr() ); 569 if( typeParameterBaseClassNames[i2].size() ) 570 { 571 if( !compiler.StringToType( typeParameterBaseClassNames[i2], baseType ) ) 572 { 573 SetError(106,typeParameterBaseClassNames[i2],i); 574 } 575 else if( !baseType.IsObject() ) 576 { 577 SetError(106,typeParameterBaseClassNames[i2],i); 578 } 579 } 580 581 pobj_c->AddFormalGenericType( GenericType( typeParameters[i2], baseType ) ); 554 582 } 555 583 ///////////////////////////////////////////////////////// -
trunk/abdev/BasicCompiler_Common/src/Compiler.cpp
r370 r424 155 155 // コンパイル中クラスにおけるジェネリクス用の型パラメータのとき 156 156 type.SetBasicType( DEF_TYPE_PARAMETER ); 157 type.SetClassPtr( this->GetObjectModule().meta.GetClasses().GetObjectClassPtr() );157 type.SetClassPtr( &this->pCompilingClass->GetFormalGenericTypes()[formalTypeIndex].GetType().GetClass() ); 158 158 type.SetFormalTypeName( typeName ); 159 159 type.SetFormalTypeIndex( formalTypeIndex ); -
trunk/abdev/BasicCompiler_Common/src/Enum.cpp
r407 r424 177 177 sprintf(buffer+length,"Class Enum %s\n",enumInfo.GetName().c_str()); 178 178 length+=lstrlen(buffer+length); 179 lstrcpy(buffer+length,"\tInherits EnumBase\n");179 sprintf(buffer+length,"\tInherits EnumBase<%s>\n",enumInfo.GetName().c_str()); 180 180 length+=lstrlen(buffer+length); 181 181 sprintf(buffer+length,"\tSub %s(value As Long,lpszName As LPSTR)\n",enumInfo.GetName().c_str()); … … 211 211 } 212 212 213 sprintf(buffer+length,"\tFunction Operator or (enumBase As %s) As %s\n",enumInfo.GetName().c_str(),enumInfo.GetName().c_str());214 length+=lstrlen(buffer+length);215 sprintf(buffer+length,"\t\tReturn New %s(This.value or enumBase.value, \"custom\")\n",enumInfo.GetName().c_str());216 length+=lstrlen(buffer+length);217 lstrcpy(buffer+length,"\tEnd Function\n");218 length+=lstrlen(buffer+length);219 220 sprintf(buffer+length,"\tFunction Operator and (enumBase As %s) As %s\n",enumInfo.GetName().c_str(),enumInfo.GetName().c_str());221 length+=lstrlen(buffer+length);222 sprintf(buffer+length,"\t\tReturn New %s(This.value and enumBase.value, \"custom\")\n",enumInfo.GetName().c_str());223 length+=lstrlen(buffer+length);224 lstrcpy(buffer+length,"\tEnd Function\n");225 length+=lstrlen(buffer+length);226 227 /*228 sprintf(buffer+length,"\tOverride Function ToString() As String\n",enumInfo.TypeName);229 length+=lstrlen(buffer+length);230 lstrcpy(buffer+length,"\t\tSelect Case value\n");231 length+=lstrlen(buffer+length);232 for(i2=0;i2<enumInfo.iEnumMemberNum;i2++){233 CEnumMember *member;234 member=enumInfo.ppobj_EnumMember[i2];235 236 sprintf(buffer+length,"\t\t\tCase %d\n",member->m_value);237 length+=lstrlen(buffer+length);238 sprintf(buffer+length,"\t\t\t\tReturn \"%s\"\n",member->m_name);239 length+=lstrlen(buffer+length);240 }241 lstrcpy(buffer+length,"\t\tEnd Select\n");242 length+=lstrlen(buffer+length);243 lstrcpy(buffer+length,"\tEnd Function\n");244 length+=lstrlen(buffer+length);245 246 247 sprintf(buffer+length,"\tSub Operator= (ByRef value As %s)\n",enumInfo.TypeName);248 length+=lstrlen(buffer+length);249 lstrcpy(buffer+length,"\t\tThis.Copy(ByVal VarPtr(value))\n");250 length+=lstrlen(buffer+length);251 lstrcpy(buffer+length,"\tEnd Sub\n");252 length+=lstrlen(buffer+length);253 254 sprintf(buffer+length,"\tSub Operator= (ByRef value As String)\n",enumInfo.TypeName);255 length+=lstrlen(buffer+length);256 lstrcpy(buffer+length,"\t\tSelect Case value\n");257 length+=lstrlen(buffer+length);258 for(i2=0;i2<enumInfo.iEnumMemberNum;i2++){259 CEnumMember *member;260 member=enumInfo.ppobj_EnumMember[i2];261 262 sprintf(buffer+length,"\t\t\tCase \"%s\"\n",member->m_name);263 length+=lstrlen(buffer+length);264 sprintf(buffer+length,"\t\t\t\tThis=%s.%s\n",enumInfo.TypeName,member->m_name);265 length+=lstrlen(buffer+length);266 }267 lstrcpy(buffer+length,"\t\tEnd Select\n");268 length+=lstrlen(buffer+length);269 lstrcpy(buffer+length,"\tEnd Sub\n");270 length+=lstrlen(buffer+length);271 272 sprintf(buffer+length,"\tSub Operator= (value As Long)\n",enumInfo.TypeName);273 length+=lstrlen(buffer+length);274 lstrcpy(buffer+length,"\t\tm_Value=value\n");275 length+=lstrlen(buffer+length);276 lstrcpy(buffer+length,"\tEnd Sub\n");277 length+=lstrlen(buffer+length);*/278 279 213 lstrcpy(buffer+length,"End Class\n"); 280 214 length+=lstrlen(buffer+length); -
trunk/abdev/BasicCompiler_Common/src/Type.cpp
r378 r424 541 541 void ResolveFormalGenericTypeParameter( Type &typeParameter, const Type &classType, const UserProc *pUserProc ) 542 542 { 543 if( !typeParameter.IsTypeParameter() ) 544 { 545 // ジェネリックな型ではなかったとき 546 return; 547 } 548 543 549 ///////////////////////////////////////////////////////// 544 550 // ☆★☆ ジェネリクスサポート ☆★☆ 545 551 552 // ポインタレベルを抽出 553 int ptrLevel = PTR_LEVEL( typeParameter.GetBasicType() ); 554 555 if( pUserProc ) 556 { 557 if( classType.IsObject() ) 558 { 559 // 基底クラスでの自己解決 560 const CClass *pClass = &classType.GetClass(); 561 while( pClass->HasSuperClass() ) 562 { 563 if( pUserProc->GetParentClassPtr() == &pClass->GetSuperClass() ) 564 { 565 if( pClass->GetSuperClassActualTypeParameters().size() ) 566 { 567 // TODO: 適切な形に実装し直す(暫定的にトップの型を持ってきている) 568 typeParameter = pClass->GetSuperClassActualTypeParameters()[0]; 569 } 570 } 571 pClass = &pClass->GetSuperClass(); 572 } 573 } 574 } 575 546 576 if( typeParameter.IsTypeParameter() ) 547 577 { 548 // 型パラメータだったとき 549 550 // ポインタレベルを抽出 551 int ptrLevel = PTR_LEVEL( typeParameter.GetBasicType() ); 552 553 if( pUserProc ) 578 if( classType.HasActualGenericType() ) 554 579 { 555 if( classType.IsObject() ) 556 { 557 // 基底クラスでの自己解決 558 const CClass *pClass = &classType.GetClass(); 559 while( pClass->HasSuperClass() ) 560 { 561 if( pUserProc->GetParentClassPtr() == &pClass->GetSuperClass() ) 562 { 563 if( pClass->GetSuperClassActualTypeParameters().size() ) 564 { 565 // TODO: 適切な形に実装し直す(暫定的にトップの型を持ってきている) 566 typeParameter = pClass->GetSuperClassActualTypeParameters()[0]; 567 } 568 } 569 pClass = &pClass->GetSuperClass(); 570 } 571 } 572 } 573 574 if( typeParameter.IsTypeParameter() ) 580 typeParameter = classType.GetActualGenericType( typeParameter.GetFormalTypeIndex() ); 581 } 582 else 575 583 { 576 if( classType.HasActualGenericType() ) 577 { 578 typeParameter = classType.GetActualGenericType( typeParameter.GetFormalTypeIndex() ); 579 } 580 else 581 { 582 // TODO: ベースオブジェクト(指定されていないときはObjectクラス)にセットする 583 typeParameter.SetBasicType( DEF_OBJECT ); 584 } 585 } 586 587 for( int i=0; i<ptrLevel; i++ ) 588 { 589 typeParameter.PtrLevelUp(); 590 } 584 // 制約クラス(指定されていないときはObjectクラス)にセットする 585 typeParameter.SetBasicType( DEF_OBJECT ); 586 } 587 } 588 589 for( int i=0; i<ptrLevel; i++ ) 590 { 591 typeParameter.PtrLevelUp(); 591 592 } 592 593
Note:
See TracChangeset
for help on using the changeset viewer.