Ignore:
Timestamp:
Aug 21, 2007, 11:00:25 PM (17 years ago)
Author:
dai_9181
Message:

ジェネリクスのベースを実装

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler_Common/include/Type.h

    r271 r290  
    1616
    1717class CClass;
     18
     19class GenericType;
     20typedef std::vector<GenericType> GenericTypes;
    1821
    1922class Type{
     
    2326        const CClass *pClass;
    2427    };
     28    GenericTypes actualGenericTypes;
    2529
    2630    // XMLシリアライズ用
     
    5256      index( -1 ){}
    5357
    54     Type( int basicType, LONG_PTR index ):
    55       basicType( basicType ),
    56       index( index ){}
     58    Type( int basicType, LONG_PTR index )
     59        : basicType( basicType )
     60        , index( index )
     61    {
     62    }
    5763
    5864    Type( int basicType, const CClass &objClass ):
     
    6066      index( (LONG_PTR)&objClass ){}
    6167
    62     Type( const Type &type ):
    63       basicType( type.basicType ),
    64       index( type.index ){}
     68    Type( const Type &type )
     69        : basicType( type.basicType )
     70        , index( type.index )
     71        , actualGenericTypes( type.actualGenericTypes )
     72    {
     73    }
     74
     75    ~Type();
     76
     77    void operator= ( const Type &type )
     78    {
     79        basicType = type.basicType;
     80        index = type.index;
     81        actualGenericTypes = type.actualGenericTypes;
     82    }
    6583
    6684    __inline int GetBasicType() const
     
    7290        return index;
    7391    }
    74     const CClass &GetClass() const
    75     {
    76         return *pClass;
    77     }
     92    const CClass &GetClass() const;
    7893
    7994    void SetBasicType( int basicType ){
     
    85100    void SetClassPtr( const CClass *pClass )
    86101    {
     102        int naturalBasicType = NATURAL_TYPE( basicType );
     103        if( !HasMember() )
     104        {
     105            Jenga::Throw( "クラスまたは構造体でない型に対してSetClassPtrを呼び出した" );
     106        }
    87107        this->pClass = pClass;
    88108    }
     
    98118        SetBasicType( basicType );
    99119        this->pClass = pClass;
     120    }
     121    void SetActualGenericTypes( const GenericTypes &genericTypes )
     122    {
     123        this->actualGenericTypes = genericTypes;
    100124    }
    101125
     
    142166    bool IsObject() const;
    143167    bool IsObjectPtr() const;
     168    bool IsTypeParameter() const;
    144169    bool IsObjectClass() const;
    145170    bool IsStringClass() const;
     
    150175    bool HasMember() const;
    151176
    152     void operator= ( const Type &type ){
    153         basicType = type.basicType;
    154         index = type.index;
    155     }
     177    // 未完成
     178    const Type &GetDummyActualGenericType() const;
     179    bool HasActualGenericType() const;
    156180
    157181
     
    163187    static const char *Type::BasicTypeToCharPtr( const Type &type );
    164188    static int GetBasicTypeFromSimpleName( const char *variable );
     189};
     190
     191class GenericType
     192{
     193    std::string name;
     194    Type type;
     195public:
     196    GenericType( const std::string &name, const Type &type )
     197        : name( name )
     198        , type( type )
     199    {
     200    }
     201    GenericType()
     202    {
     203    }
     204    ~GenericType()
     205    {
     206    }
     207
     208    const std::string &GetName() const
     209    {
     210        return name;
     211    }
     212    const Type &GetType() const
     213    {
     214        return type;
     215    }
    165216};
    166217
Note: See TracChangeset for help on using the changeset viewer.