Ignore:
Timestamp:
Nov 2, 2007, 2:53:56 AM (17 years ago)
Author:
dai_9181
Message:

静的領域に初期オブジェクトを配置可能にした

File:
1 edited

Legend:

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

    r279 r355  
    44
    55//DataTable.cpp
    6 class DataTable{
     6class DataTable
     7{
    78    char *buffer;
    89    int size;
    910
    10     void Realloc( int size )
    11     {
    12         this->buffer = (char *)realloc( this->buffer, size + 100 );
    13         this->size = size;
    14     }
     11public:
     12    // リンカで解決しなければならないスケジュール
     13    Schedules schedules;
    1514
    1615    // XMLシリアライズ用
     
    2322        ar & BOOST_SERIALIZATION_NVP( _buffer );
    2423        ar & BOOST_SERIALIZATION_NVP( size );
     24        ar & BOOST_SERIALIZATION_NVP( schedules );
    2525
    2626        // 読み込み後の処理
     
    5252        ar & BOOST_SERIALIZATION_NVP( _buffer );
    5353        ar & BOOST_SERIALIZATION_NVP( size );
     54        ar & BOOST_SERIALIZATION_NVP( schedules );
     55    }
     56
     57
     58    void Realloc( int size )
     59    {
     60        this->buffer = (char *)realloc( this->buffer, size + 100 );
     61        this->size = size;
    5462    }
    5563
     
    92100    void Add( const DataTable &dataTable )
    93101    {
     102        long baseOffset = GetSize();
     103
    94104        AddBinary( dataTable.GetPtr(), dataTable.GetSize() );
     105
     106        // スケジュールを追加
     107        BOOST_FOREACH( const Schedule &schedule, dataTable.schedules )
     108        {
     109            this->schedules.push_back(
     110                Schedule(
     111                    schedule.GetType(),
     112                    baseOffset + schedule.GetOffset(),
     113                    schedule.GetLongPtrValue()
     114                )
     115            );
     116        }
    95117    }
    96118
    97     const void *GetPtr() const;
    98     int GetSize() const;
     119    const void *GetPtr() const
     120    {
     121        return buffer;
     122    }
     123    int GetSize() const
     124    {
     125        return size;
     126    }
     127
     128    long GetLong( int pos ) const
     129    {
     130        return *(long *)( buffer + pos );
     131    }
     132    _int64 GetInt64( int pos ) const
     133    {
     134        return *(_int64 *)( buffer + pos );
     135    }
     136    void Overwrite( int pos, long newLongValue )
     137    {
     138        *(long *)( buffer + pos ) = newLongValue;
     139    }
     140    void OverwriteInt64( int pos, _int64 new64Value )
     141    {
     142        *(_int64 *)( buffer + pos ) = new64Value;
     143    }
     144
     145    bool MakeConstObjectToProcessStaticBuffer( const CClass &objClass, const Jenga::Common::Strings &initMemberValues, int &dataTableOffset );
     146    bool MakeConstObjectToProcessStaticBuffer( const char *expression, Type &resultType, int &dataTableOffset );
     147    int MakeConstStringObjectToProcessStaticBuffer( const char *str );
     148    bool MakeLiteralArrayBuffer( const char *expression, const Type &baseType, int &dataTableOffset );
     149
     150private:
     151    int lastMadeConstObjectDataTableOffset;
     152public:
     153    int GetLastMadeConstObjectDataTableOffset()
     154    {
     155        return lastMadeConstObjectDataTableOffset;
     156    }
     157
     158    void ResetDataSectionBaseOffset( long dataSectionBaseOffset );
    99159};
Note: See TracChangeset for help on using the changeset viewer.