Changeset 513 in dev


Ignore:
Timestamp:
Apr 30, 2008, 8:38:09 PM (16 years ago)
Author:
dai_9181
Message:

Interfaceクラスを独自ファイルにした。

Location:
trunk/ab5.0/abdev
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/include/Class.h

    r511 r513  
    33#include <option.h>
    44#include <Program.h>
    5 #include <Type.h>
    6 #include <Method.h>
    75#include <Member.h>
    86#include <Source.h>
    97
    108class UserProc;
    11 class CClass;
    129class Delegate;
    13 
    14 class DynamicMethodsPrototype
    15 {
    16     // 動的メソッド
    17     Methods dynamicMethods;
    18 
    19     // XMLシリアライズ用
    20 private:
    21     friend class boost::serialization::access;
    22     template<class Archive> void serialize(Archive& ar, const unsigned int version)
    23     {
    24         ar & BOOST_SERIALIZATION_NVP( dynamicMethods );
    25     }
    26 
    27 public:
    28     DynamicMethodsPrototype(){}
    29     DynamicMethodsPrototype( const DynamicMethodsPrototype &dynamicMethodsPrototype )
    30         : dynamicMethods( dynamicMethodsPrototype.dynamicMethods )
    31     {
    32     }
    33     ~DynamicMethodsPrototype(){}
    34 
    35     const Methods &GetDynamicMethods() const
    36     {
    37         return dynamicMethods;
    38     }
    39     Methods &GetDynamicMethods()
    40     {
    41         return dynamicMethods;
    42     }
    43 
    44     void AddDynamicMethods( CMethod *pMethod )
    45     {
    46         dynamicMethods.push_back( pMethod );
    47     }
    48 };
    4910
    5011class ClassPrototype : public Prototype, public DynamicMethodsPrototype
     
    7132    }
    7233};
    73 
    74 class Interface : public DynamicMethodsPrototype
    75 {
    76     const CClass *pInterfaceClass;
    77     mutable LONG_PTR vtblOffset;
    78 
    79     // 型パラメータ(実パラメータ)
    80     Types actualTypeParameters;
    81 
    82     // XMLシリアライズ用
    83 private:
    84     friend class boost::serialization::access;
    85     template<class Archive> void serialize(Archive& ar, const unsigned int version)
    86     {
    87         trace_for_serialize( "serializing - Interface" );
    88 
    89         ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( DynamicMethodsPrototype );
    90         ar & boost::serialization::make_nvp("pInterfaceClass", const_cast<CClass *&>(pInterfaceClass) );
    91         ar & BOOST_SERIALIZATION_NVP( vtblOffset );
    92         ar & BOOST_SERIALIZATION_NVP( actualTypeParameters );
    93     }
    94 
    95 public:
    96     Interface( const CClass *pInterfaceClass, const Types &actualTypeParameters );
    97     Interface( const Interface &objInterface )
    98         : DynamicMethodsPrototype( objInterface )
    99         , pInterfaceClass( objInterface.pInterfaceClass )
    100         , vtblOffset( objInterface.vtblOffset )
    101     {
    102     }
    103     Interface()
    104     {
    105     }
    106 
    107     const CClass &GetClass() const{
    108         return *pInterfaceClass;
    109     }
    110     LONG_PTR GetVtblOffset() const
    111     {
    112         return vtblOffset;
    113     }
    114     void SetVtblOffset( LONG_PTR vtblOffset ) const
    115     {
    116         this->vtblOffset = vtblOffset;
    117     }
    118 
    119     const Types &GetActualTypeParameters() const
    120     {
    121         return actualTypeParameters;
    122     }
    123 
    124     std::string GetFullNameWithActualGenericTypeParameters() const;
    125 };
    126 typedef std::vector<Interface *> Interfaces;
    12734
    12835class CClass: public ClassPrototype, public Jenga::Common::ObjectInHashmap<CClass>
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Class.cpp

    r511 r513  
    1414using namespace ActiveBasic::Compiler;
    1515
    16 
    17 Interface::Interface( const CClass *pInterfaceClass, const Types &actualTypeParameters )
    18     : DynamicMethodsPrototype()
    19     , pInterfaceClass( pInterfaceClass )
    20     , vtblOffset( -1 )
    21     , actualTypeParameters( actualTypeParameters )
    22 {
    23     //メソッドをコピー
    24     BOOST_FOREACH( const CMethod *pBaseMethod, pInterfaceClass->GetDynamicMethods() )
    25     {
    26         CMethod *pMethod = new DynamicMethod( *pBaseMethod );
    27 
    28         // アクセシビリティ
    29         if(pBaseMethod->GetAccessibility() == Prototype::Private){
    30             pMethod->SetAccessibility( Prototype::None );
    31         }
    32         else{
    33             pMethod->SetAccessibility( pBaseMethod->GetAccessibility() );
    34         }
    35 
    36         //pobj_Inherits
    37         // ※継承元のClassIndexをセット(入れ子継承を考慮する)
    38         if(pBaseMethod->GetInheritsClassPtr()==0){
    39             pMethod->SetInheritsClassPtr( pInterfaceClass );
    40         }
    41         else{
    42             pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );
    43         }
    44 
    45         AddDynamicMethods( pMethod );
    46     }
    47 }
    48 
    49 std::string Interface::GetFullNameWithActualGenericTypeParameters() const
    50 {
    51     std::string interfaceName = this->GetClass().GetFullName();
    52     if( actualTypeParameters.size() )
    53     {
    54         std::string actualGenericTypesName;
    55         BOOST_FOREACH( const Type &typeParameter, actualTypeParameters )
    56         {
    57             if( actualGenericTypesName.size() )
    58             {
    59                 actualGenericTypesName += ",";
    60             }
    61             actualGenericTypesName += typeParameter.ToString();
    62         }
    63 
    64         interfaceName += "<" + actualGenericTypesName + ">";
    65     }
    66     return interfaceName;
    67 }
    6816
    6917bool CClass::IsClass() const
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp

    r511 r513  
    5252#include <Hashmap.h>
    5353#include <Configuration.h>
     54#include <Type.h>
     55#include <Method.h>
     56#include <Interface.h>
    5457#include <Class.h>
    5558#include <Procedure.h>
  • trunk/ab5.0/abdev/compiler_x86/compiler_x86.vcproj

    r512 r513  
    12921292                    </File>
    12931293                    <File
     1294                        RelativePath="..\BasicCompiler_Common\src\Interface.cpp"
     1295                        >
     1296                    </File>
     1297                    <File
    12941298                        RelativePath="..\BasicCompiler_Common\src\LexicalAnalyzer_Class.cpp"
    12951299                        >
     
    14971501                    </File>
    14981502                    <File
     1503                        RelativePath="..\BasicCompiler_Common\include\Interface.h"
     1504                        >
     1505                    </File>
     1506                    <File
    14991507                        RelativePath="..\BasicCompiler_Common\include\LexicalScope.h"
    15001508                        >
  • trunk/ab5.0/abdev/compiler_x86/stdafx.h

    r511 r513  
    4444#include <Hashmap.h>
    4545#include <Configuration.h>
     46#include <Type.h>
     47#include <Method.h>
     48#include <Interface.h>
    4649#include <Class.h>
    4750#include <Procedure.h>
Note: See TracChangeset for help on using the changeset viewer.