Changeset 632 in dev for trunk/ab5.0/abdev/ab_common/src


Ignore:
Timestamp:
Jun 5, 2008, 10:04:39 PM (16 years ago)
Author:
dai_9181
Message:

ジェネリッククラスの型パラメータに値型が指定されたときに限り、テンプレート展開を行うようにした。

TODO: libファイルを跨ってテンプレート展開ができていないため、ソースコード管理部分に手を加える必要あり。

Location:
trunk/ab5.0/abdev/ab_common/src/Lexical
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Class.cpp

    r603 r632  
    11#include "stdafx.h"
     2
     3
     4CClass::CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const std::string &name )
     5    : ClassPrototype( namespaceScopes, name )
     6    , importedNamespaces( importedNamespaces )
     7    , classType( Class )
     8    , pSuperClass( NULL )
     9    , blittableType( Type() )
     10    , isReady( false )
     11    , fixedAlignment( 0 )
     12    , ConstructorMemberSubIndex( -1 )
     13    , DestructorMemberSubIndex( -1 )
     14    , vtblNum( 0 )
     15    , vtbl_offset( -1 )
     16    , comVtblOffset( 0 )
     17    , isCompilingConstructor( false )
     18    , isCompilingDestructor( false )
     19    , cacheSize( 0 )
     20{
     21}
     22
     23CClass::CClass( const NamespaceScopes &namespaceScopes,
     24    const NamespaceScopesCollection &importedNamespaces,
     25    const std::string &name,
     26    ClassType classType,
     27    const GenericTypes &formalGenericTypes,
     28    const Types &superClassActualTypeParameters,
     29    int ConstructorMemberSubIndex,
     30    int DestructorMemberSubIndex,
     31    int vtblNum,
     32    int fixedAlignment )
     33    : ClassPrototype( namespaceScopes, name )
     34    , importedNamespaces( importedNamespaces )
     35    , classType( classType )
     36    , formalGenericTypes( formalGenericTypes )
     37    , pSuperClass( NULL )
     38    , superClassActualTypeParameters( superClassActualTypeParameters )
     39    , blittableType( Type() )
     40    , isReady( false )
     41    , ConstructorMemberSubIndex( ConstructorMemberSubIndex )
     42    , DestructorMemberSubIndex( DestructorMemberSubIndex )
     43    , vtblNum( vtblNum )
     44    , fixedAlignment( fixedAlignment )
     45    , vtbl_offset( -1 )
     46    , comVtblOffset( 0 )
     47    , isCompilingConstructor( false )
     48    , isCompilingDestructor( false )
     49    , cacheSize( 0 )
     50{
     51}
     52
     53CClass::CClass()
     54    : ClassPrototype()
     55    , importedNamespaces()
     56    , classType()
     57    , pSuperClass( NULL )
     58    , blittableType( Type() )
     59    , isReady( false )
     60    , fixedAlignment( 0 )
     61    , ConstructorMemberSubIndex( -1 )
     62    , DestructorMemberSubIndex( -1 )
     63    , vtblNum( 0 )
     64    , vtbl_offset( -1 )
     65    , comVtblOffset( 0 )
     66    , isCompilingConstructor( false )
     67    , isCompilingDestructor( false )
     68    , cacheSize( 0 )
     69{
     70}
     71
     72CClass::~CClass()
     73{
     74    // 動的メンバ
     75    BOOST_FOREACH( Member *member, dynamicMembers )
     76    {
     77        delete member;
     78    }
     79
     80    // 静的メンバ
     81    BOOST_FOREACH( Member *member, staticMembers )
     82    {
     83        delete member;
     84    }
     85
     86    // インターフェイス
     87    BOOST_FOREACH( ::Interface *pInterface, interfaces )
     88    {
     89        delete pInterface;
     90    }
     91
     92    // テンプレート展開済みのクラス
     93    BOOST_FOREACH( ExpandedTemplateClass *pExpandedTemplateClass, expandedTemplateClasses )
     94    {
     95        delete pExpandedTemplateClass;
     96    }
     97}
    298
    399void CClass::Using() const
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Meta.cpp

    r603 r632  
    186186
    187187    // TypeDefも見る
    188     int index = this->GetTypeDefs().GetIndex( symbol );
    189     if( index != -1 ){
    190         Type type = this->GetTypeDefs()[index].GetBaseType();
    191         if( type.IsObject() ){
     188    const TypeDef *pTypeDef = this->GetTypeDefs().Find( symbol );
     189    if( pTypeDef )
     190    {
     191        Type type = pTypeDef->GetBaseType();
     192        if( type.IsObject() )
     193        {
    192194            return &type.GetClass();
    193195        }
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Parameter.cpp

    r603 r632  
    11#include "stdafx.h"
     2
     3Parameter::Parameter( const std::string &varName, const Type &type, bool isRef, const std::string initValue )
     4    : Type( type )
     5    , varName( varName )
     6    , isRef( isRef )
     7    , isArray( false )
     8    , initValue( initValue )
     9{
     10}
     11
     12Parameter::Parameter( const Parameter &param, const Type &type )
     13    : Type( type )
     14    , varName( param.varName )
     15    , isRef( param.isRef )
     16    , isArray( param.isArray )
     17    , subscripts( param.subscripts )
     18    , initValue( param.initValue )
     19{
     20}
     21
     22Parameter::Parameter( const Parameter &param )
     23    : Type( param )
     24    , varName( param.varName )
     25    , isRef( param.isRef )
     26    , isArray( param.isArray )
     27    , subscripts( param.subscripts )
     28    , initValue( param.initValue )
     29{
     30}
     31
     32Parameter::Parameter()
     33{
     34}
     35
     36Parameter::~Parameter()
     37{
     38}
    239
    340bool Parameter::Equals( const Parameter &param, bool isContravariant ) const
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Procedure.cpp

    r603 r632  
    11#include "stdafx.h"
     2
     3int id_base = 0;
     4
     5UserProc::UserProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const std::string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport )
     6    : Procedure( namespaceScopes, name, kind, isCdecl )
     7    , importedNamespaces( importedNamespaces )
     8    , pParentClass( NULL )
     9    , pInterface( NULL )
     10    , pMethod( NULL )
     11    , isMacro( isMacro )
     12    , secondParmNum( 0 )
     13    , realSecondParmNum( 1 )
     14    , isExport( isExport )
     15    , isSystem( false )
     16    , isAutoGeneration( false )
     17    , isCompiled( false )
     18    , beginOpAddress( 0 )
     19    , endOpAddress( 0 )
     20    , id( id_base ++ )
     21{
     22}
     23
     24UserProc::UserProc( const UserProc &userProc, const CClass *pParentClass )
     25    : Procedure( userProc )
     26    , _paramStr( userProc._paramStr )
     27    , importedNamespaces( userProc.importedNamespaces )
     28    , pParentClass( pParentClass )
     29    , pInterface( NULL )
     30    , pMethod( NULL )
     31    , isMacro( userProc.isMacro )
     32    , secondParmNum( userProc.secondParmNum )
     33    , realParams( userProc.realParams )
     34    , realSecondParmNum( userProc.realSecondParmNum )
     35    , isExport( userProc.isExport )
     36    , isSystem( userProc.isSystem )
     37    , isAutoGeneration( userProc.isAutoGeneration )
     38    , isCompiled( false )
     39    , beginOpAddress( 0 )
     40    , endOpAddress( 0 )
     41    , localVars( Variables() )
     42    , id( id_base ++ )
     43    , nativeCode( NativeCode() )
     44{
     45}
     46
     47UserProc::UserProc()
     48{
     49}
     50
     51UserProc::~UserProc()
     52{
     53    BOOST_FOREACH( Parameter *pParam, realParams ){
     54        delete pParam;
     55    }
     56}
    257
    358bool UserProc::IsEqualForOverride( const Types &actualTypeParametersForThisProc, const UserProc *pUserProc ) const
     
    54109const NamespaceScopes &UserProc::GetNamespaceScopes() const
    55110{
    56     if( HasParentClass() ){
     111    if( HasParentClass() )
     112    {
    57113        return GetParentClassPtr()->GetNamespaceScopes();
    58114    }
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Symbol.cpp

    r603 r632  
    55const NamespaceSupporter *Symbol::namespaceSupporter = NULL;
    66
    7 char *calcNames[255] = {
     7char *calcNames[256] = {
    88    "xor",
    99};
  • trunk/ab5.0/abdev/ab_common/src/Lexical/Type.cpp

    r603 r632  
    384384    return false;
    385385}
     386
     387bool Type::IsValueType() const
     388{
     389    return ( IsWhole() || IsReal() );
     390}
     391
    386392bool Type::IsProcPtr() const
    387393{
     
    550556}
    551557
     558bool Types::IsEquals( const Types &types ) const
     559{
     560    if( this->size() != types.size() )
     561    {
     562        // アイテム数が違う
     563        return false;
     564    }
     565
     566    const Types &thisTypes = *this;
     567    for( int i=0; i<static_cast<int>(this->size()); i++ )
     568    {
     569        if( !thisTypes[i].Equals( types[i] ) )
     570        {
     571            return false;
     572        }
     573    }
     574
     575    return true;
     576}
    552577
    553578void ResolveFormalGenericTypeParameter( Type &typeParameter, const Type &classType, const UserProc *pUserProc )
  • trunk/ab5.0/abdev/ab_common/src/Lexical/TypeDef.cpp

    r603 r632  
    1717}
    1818
    19 int TypeDefCollection::GetIndex( const Symbol &symbol ) const{
    20     int max = (int)(*this).size();
    21     for( int i=0; i<max; i++ ){
    22         if( (*this)[i].IsEqualSymbol( symbol ) ){
    23             return i;
     19const TypeDef *TypeDefCollection::Find( const Symbol &symbol ) const
     20{
     21    const TypeDefCollection &typeDefs = *this;
     22    BOOST_FOREACH( const TypeDef &typeDef, typeDefs )
     23    {
     24        if( typeDef.IsEqualSymbol( symbol ) )
     25        {
     26            return &typeDef;
    2427        }
    2528    }
    26     return -1;
     29    return NULL;
    2730}
Note: See TracChangeset for help on using the changeset viewer.