Ignore:
Timestamp:
May 10, 2008, 1:40:33 PM (16 years ago)
Author:
dai_9181
Message:

NativeSectionクラスを追加(64bit版だけ一旦コミット)。

File:
1 edited

Legend:

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

    r532 r585  
    9696void ObjectModule::StaticLink( ObjectModule &objectModule )
    9797{
    98     long dataSectionBaseOffset = dataTable.GetSize();
    99     int sourceIndexBase = (int)sources.size();
     98    long dataSectionBaseOffset = this->nativeSection.dataTable.GetSize();
     99    int sourceIndexBase = (int)nativeSection.GetSources().size();
    100100
    101101    // メタ情報を結合
     
    103103
    104104    // グローバル ネイティブコードを結合
    105     objectModule.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset );
    106     objectModule.globalNativeCode.ResetSourceIndexes( sourceIndexBase );
    107     globalNativeCode.PutEx( objectModule.globalNativeCode );
     105    objectModule.nativeSection.globalNativeCode.ResetDataSectionBaseOffset( dataSectionBaseOffset );
     106    objectModule.nativeSection.globalNativeCode.ResetSourceIndexes( sourceIndexBase );
     107    nativeSection.globalNativeCode.PutEx( objectModule.nativeSection.globalNativeCode );
    108108
    109109    // データテーブルを結合
    110     objectModule.dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset );
    111     dataTable.Add( objectModule.dataTable );
     110    objectModule.nativeSection.dataTable.ResetDataSectionBaseOffset( dataSectionBaseOffset );
     111    this->nativeSection.dataTable.Add( objectModule.nativeSection.dataTable );
    112112
    113113    // ソースコードを結合
    114     BOOST_FOREACH( const BasicSource &source, objectModule.sources )
    115     {
    116         this->sources.push_back( source );
     114    BOOST_FOREACH( const BasicSource &source, objectModule.nativeSection.GetSources() )
     115    {
     116        this->nativeSection.GetSources().push_back( source );
    117117    }
    118118
    119119    // TODO: basbufがいらなくなったら消す
    120120    extern char *basbuf;
    121     basbuf = this->sources[0].GetBuffer();
     121    basbuf = this->nativeSection.GetSources()[0].GetBuffer();
    122122}
    123123
    124124bool ObjectModule::Read( const std::string &filePath )
    125125{
    126     // XMLとして読み込む
     126    Jenga::Common::File file( filePath );
     127
     128    Jenga::Common::Binary binary;
     129    if( !file.ReadBinary( binary ) )
     130    {
     131        return false;
     132    }
     133
     134    return Load( binary );
     135}
     136bool ObjectModule::Write( const std::string &filePath ) const
     137{
     138    Jenga::Common::File file( filePath );
     139
     140    Jenga::Common::Binary binary;
     141    if( !Save( binary ) )
     142    {
     143        return false;
     144    }
     145
     146    return file.WriteBinary( binary );
     147}
     148bool ObjectModule::Load( const Jenga::Common::Binary &binary )
     149{
    127150    bool isSuccessful = false;
    128151
     152    // 入力アーカイブの作成
     153
    129154    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 )
    152     {
    153         return false;
    154     }
    155 
    156     return true;
    157 }
    158 bool ObjectModule::Write( const std::string &filePath ) const
    159 {
    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 )
    185     {
    186         return false;
    187     }
    188 
    189     return true;
    190 }
    191 bool ObjectModule::ReadString( const std::string &str )
    192 {
    193     bool isSuccessful = false;
    194 
    195     // 入力アーカイブの作成
    196 
    197     try{
     155        std::string str( binary.GetBuffer(), binary.GetSize() );
     156
    198157#ifdef OBJECT_MODULE_IS_NOT_BINARY
    199158        std::istringstream iss( str );
     
    224183    return true;
    225184}
    226 bool ObjectModule::WriteString( std::string &str ) const
     185bool ObjectModule::Save( Jenga::Common::Binary &binary ) const
    227186{
    228187    // 出力アーカイブの作成
     
    241200        oa << boost::serialization::make_nvp( RootTagName(), *this );
    242201
    243         str = oss.str();
     202        binary.Put( oss.str().c_str(), static_cast<int>(oss.str().size()) );
    244203
    245204        isSuccessful = true;
Note: See TracChangeset for help on using the changeset viewer.