Ignore:
Timestamp:
May 10, 2008, 3:09:26 PM (16 years ago)
Author:
dai_9181
Message:

[585][586]をリバース。NativeCodeクラスとMetaクラスは依存関係があるので分離しない方針とする。

Location:
trunk/ab5.0/abdev/BasicCompiler_Common/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Exception.cpp

    r585 r587  
    201201                lstrcpy( paramName, catchScope.GetParamType().GetClass().GetFullName().c_str() );
    202202            }
    203             paramNameDataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.AddString( paramName );
     203            paramNameDataTableOffset = compiler.GetObjectModule().dataTable.AddString( paramName );
    204204            *((LONG_PTR *)(buffer+pos)) = paramNameDataTableOffset;
    205205            pos += sizeof(LONG_PTR);
     
    210210        }
    211211
    212         int dataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.AddBinary( buffer, size );
     212        int dataTableOffset = compiler.GetObjectModule().dataTable.AddBinary( buffer, size );
    213213
    214214        free( buffer );
     
    218218        {
    219219            // パラメータのクラス名
    220             compiler.GetObjectModule().nativeSection.dataTable.schedules.push_back( Schedule( Schedule::DataTable, dataTableOffset + pos ) );
     220            compiler.GetObjectModule().dataTable.schedules.push_back( Schedule( Schedule::DataTable, dataTableOffset + pos ) );
    221221            pos += sizeof(LONG_PTR);
    222222
     
    227227                pUserProc = UserProc::pGlobalProc;
    228228            }
    229             compiler.GetObjectModule().nativeSection.dataTable.schedules.push_back(
     229            compiler.GetObjectModule().dataTable.schedules.push_back(
    230230                Schedule( Schedule::CatchAddress, pUserProc, dataTableOffset + pos )
    231231            );
     
    407407
    408408    /*
    409     int dataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.Add( static_cast<LONG_PTR>(0) );
     409    int dataTableOffset = compiler.GetObjectModule().dataTable.Add( static_cast<LONG_PTR>(0) );
    410410
    411411#ifdef _WIN64
     
    438438
    439439    /*
    440     int dataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.Add( static_cast<LONG_PTR>(0) );
     440    int dataTableOffset = compiler.GetObjectModule().dataTable.Add( static_cast<LONG_PTR>(0) );
    441441
    442442#ifdef _WIN64
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Delegate.cpp

    r585 r587  
    221221    Jenga::Common::Strings parameterStrings;
    222222    SplitParameter( dg.GetParamStr(), parameterStrings );
    223     ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( dg.GetParameters(), parameterStrings, dg.GetSourceIndex() );
     223    int sourceIndex;
     224    ActiveBasic::Compiler::LexicalAnalyzer::AnalyzeParameter( dg.GetParameters(), parameterStrings, sourceIndex );
     225    dg.SetSourceIndex( sourceIndex );
    224226
    225227    // 動的パラメータを作る
     
    233235        if( !compiler.StringToType( dg.GetReturnTypeName(), returnType ) )
    234236        {
    235             compiler.errorMessenger.Output(3,dg.GetReturnTypeName(),dg.GetSourceIndex());
     237            compiler.errorMessenger.Output(3,dg.GetReturnTypeName(),sourceIndex);
    236238        }
    237239        else
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Linker.cpp

    r585 r587  
    255255    }
    256256
    257     nativeCode.PutEx( masterObjectModule.nativeSection.globalNativeCode );
     257    nativeCode.PutEx( masterObjectModule.globalNativeCode );
    258258
    259259    masterObjectModule.meta.GetUserProcs().Iterator_Reset();
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Messenger.cpp

    r585 r587  
    4242    if( sourceIndex != -1 )
    4343    {
    44         compiler.GetObjectModule().nativeSection.GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath );
     44        compiler.GetObjectModule().GetCurrentSource().GetLineInfo( sourceIndex, sourceLineNum, sourceFilePath );
    4545    }
    4646
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/ObjectModule.cpp

    r585 r587  
    9696void ObjectModule::StaticLink( ObjectModule &objectModule )
    9797{
    98     long dataSectionBaseOffset = this->nativeSection.dataTable.GetSize();
    99     int sourceIndexBase = (int)nativeSection.GetSources().size();
     98    long dataSectionBaseOffset = dataTable.GetSize();
     99    int sourceIndexBase = (int)sources.size();
    100100
    101101    // メタ情報を結合
     
    103103
    104104    // グローバル ネイティブコードを結合
    105     objectModule.nativeSection.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset );
    106     objectModule.nativeSection.globalNativeCode.ResetSourceIndexes( sourceIndexBase );
    107     nativeSection.globalNativeCode.PutEx( objectModule.nativeSection.globalNativeCode );
     105    objectModule.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset );
     106    objectModule.globalNativeCode.ResetSourceIndexes( sourceIndexBase );
     107    globalNativeCode.PutEx( objectModule.globalNativeCode );
    108108
    109109    // データテーブルを結合
    110     objectModule.nativeSection.dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset );
    111     this->nativeSection.dataTable.Add( objectModule.nativeSection.dataTable );
     110    objectModule.dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset );
     111    dataTable.Add( objectModule.dataTable );
    112112
    113113    // ソースコードを結合
    114     BOOST_FOREACH( const BasicSource &source, objectModule.nativeSection.GetSources() )
    115     {
    116         this->nativeSection.GetSources().push_back( source );
     114    BOOST_FOREACH( const BasicSource &source, objectModule.sources )
     115    {
     116        this->sources.push_back( source );
    117117    }
    118118
    119119    // TODO: basbufがいらなくなったら消す
    120120    extern char *basbuf;
    121     basbuf = this->nativeSection.GetSources()[0].GetBuffer();
     121    basbuf = this->sources[0].GetBuffer();
    122122}
    123123
    124124bool ObjectModule::Read( const std::string &filePath )
    125125{
    126     Jenga::Common::File file( filePath );
    127 
    128     Jenga::Common::Binary binary;
    129     if( !file.ReadBinary( binary ) )
     126    // XMLとして読み込む
     127    bool isSuccessful = false;
     128
     129    try{
     130#ifdef OBJECT_MODULE_IS_NOT_BINARY
     131        std::ifstream ifs( filePath.c_str() );
     132        boost::archive::xml_iarchive ia(ifs);
     133#else
     134        std::ifstream ifs( filePath.c_str(), std::ios::in | std::ios::binary );
     135        boost::archive::binary_iarchive ia(ifs);
     136#endif
     137
     138        // ファイルから読込
     139        ia >> boost::serialization::make_nvp( RootTagName(), *this );
     140
     141        isSuccessful = true;
     142    }
     143    catch( boost::archive::archive_exception e )
     144    {
     145        MessageBox( NULL, e.what(), "XMLシリアライズの例外", MB_OK );
     146    }
     147    catch(...){
     148        MessageBox( NULL, "archive_exception以外の不明な例外", "XMLシリアライズの例外", MB_OK );
     149    }
     150
     151    if( !isSuccessful )
    130152    {
    131153        return false;
    132154    }
    133155
    134     return Load( binary );
     156    return true;
    135157}
    136158bool ObjectModule::Write( const std::string &filePath ) const
    137159{
    138     Jenga::Common::File file( filePath );
    139 
    140     Jenga::Common::Binary binary;
    141     if( !Save( binary ) )
     160    bool isSuccessful = false;
     161
     162    try{
     163#ifdef OBJECT_MODULE_IS_NOT_BINARY
     164        std::ofstream ofs( filePath.c_str() );
     165        boost::archive::xml_oarchive oa(ofs);
     166#else
     167        std::ofstream ofs( filePath.c_str(), std::ios::out | std::ios::binary );
     168        boost::archive::binary_oarchive oa(ofs);
     169#endif
     170
     171        // ファイルに書き出し
     172        oa << boost::serialization::make_nvp( RootTagName(), *this );
     173
     174        isSuccessful = true;
     175    }
     176    catch( boost::archive::archive_exception e )
     177    {
     178        MessageBox( NULL, e.what(), "XMLシリアライズの例外", MB_OK );
     179    }
     180    catch(...){
     181        MessageBox( NULL, "archive_exception以外の不明な例外", "XMLシリアライズの例外", MB_OK );
     182    }
     183
     184    if( !isSuccessful )
    142185    {
    143186        return false;
    144187    }
    145188
    146     return file.WriteBinary( binary );
    147 }
    148 bool ObjectModule::Load( const Jenga::Common::Binary &binary )
     189    return true;
     190}
     191bool ObjectModule::ReadString( const std::string &str )
    149192{
    150193    bool isSuccessful = false;
     
    153196
    154197    try{
    155         std::string str( binary.GetBuffer(), binary.GetSize() );
    156 
    157198#ifdef OBJECT_MODULE_IS_NOT_BINARY
    158199        std::istringstream iss( str );
     
    183224    return true;
    184225}
    185 bool ObjectModule::Save( Jenga::Common::Binary &binary ) const
     226bool ObjectModule::WriteString( std::string &str ) const
    186227{
    187228    // 出力アーカイブの作成
     
    200241        oa << boost::serialization::make_nvp( RootTagName(), *this );
    201242
    202         binary.Put( oss.str().c_str(), static_cast<int>(oss.str().size()) );
     243        str = oss.str();
    203244
    204245        isSuccessful = true;
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/ProcedureGenerator.cpp

    r585 r587  
    113113
    114114        objClass.SetTypeInfoDataTableOffset(
    115             compiler.GetObjectModule().nativeSection.dataTable.GetLastMadeConstObjectDataTableOffset()
     115            compiler.GetObjectModule().dataTable.GetLastMadeConstObjectDataTableOffset()
    116116        );
    117117    }
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/VtblGenerator.cpp

    r585 r587  
    33using namespace ActiveBasic::Compiler;
    44
    5 int VtblGenerator::GenerateVTablePart( const Methods &methods )
     5LONG_PTR VtblGenerator::GenerateVTablePart( const Methods &methods )
    66{
    77    const UserProc **ppsi = (const UserProc **)malloc(methods.GetVtblNum()*sizeof(UserProc *));
     
    2929    }
    3030
    31     int vtableDataTableOffset = compiler.GetObjectModule().nativeSection.dataTable.AddBinary( (void *)ppsi, methods.GetVtblNum()*sizeof(LONG_PTR) );
     31    LONG_PTR vtableDataTableOffset = compiler.GetObjectModule().dataTable.AddBinary( (void *)ppsi, methods.GetVtblNum()*sizeof(LONG_PTR) );
    3232
    3333    for( int i=0; i < methods.GetVtblNum(); i++ )
     
    6161
    6262    // 自身のクラスのvtblを生成
    63     int thisClassVtblOffset = GenerateVTablePart( _class.GetDynamicMethods() );
     63    LONG_PTR thisClassVtblOffset = GenerateVTablePart( _class.GetDynamicMethods() );
    6464    _class.SetVtblOffset( thisClassVtblOffset );
    6565    _class.vtblMasterList.push_back( thisClassVtblOffset );
     
    6868    BOOST_FOREACH( const ::Interface *pInterface, _class.GetInterfaces() )
    6969    {
    70         int tempVtblOffset = GenerateVTablePart( pInterface->GetDynamicMethods() );
     70        LONG_PTR tempVtblOffset = GenerateVTablePart( pInterface->GetDynamicMethods() );
    7171        _class.vtblMasterList.push_back( tempVtblOffset );
    7272
     
    8484
    8585    // vtblマスターリストを生成
    86     int offset = compiler.GetObjectModule().nativeSection.dataTable.AddBinary(
     86    int offset = compiler.GetObjectModule().dataTable.AddBinary(
    8787        (void *)&_class.vtblMasterList[0],
    8888        static_cast<int>(_class.vtblMasterList.size()*sizeof(LONG_PTR))
     
    119119    // 自身のクラスのvtbl
    120120    {
    121         LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().nativeSection.dataTable.GetPtr() + _class.GetVtblOffset());
     121        LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + _class.GetVtblOffset());
    122122
    123123        for( int i=0; i<_class.GetVtblNum(); i++ ){
     
    138138    BOOST_FOREACH( const ::Interface *pInterface, _class.GetInterfaces() )
    139139    {
    140         LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().nativeSection.dataTable.GetPtr() + pInterface->GetVtblOffset());
     140        LONG_PTR *pVtbl = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + pInterface->GetVtblOffset());
    141141
    142142        for( int i=0; i<pInterface->GetClass().GetVtblNum(); i++ ){
     
    155155
    156156    // vtblマスターリスト
    157     LONG_PTR *pVtblMasterList = (LONG_PTR *)((char *)compiler.GetObjectModule().nativeSection.dataTable.GetPtr() + _class.GetVtblMasterListOffset() );
     157    LONG_PTR *pVtblMasterList = (LONG_PTR *)((char *)compiler.GetObjectModule().dataTable.GetPtr() + _class.GetVtblMasterListOffset() );
    158158    for( int i=0; i<static_cast<int>(_class.vtblMasterList.size()); i++ )
    159159    {
Note: See TracChangeset for help on using the changeset viewer.