Ignore:
Timestamp:
Aug 1, 2007, 11:19:01 PM (17 years ago)
Author:
dai_9181
Message:

MetaImplを廃止し、Metaにした。
ObjectModuleクラス、Linkerクラスを用意。

File:
1 edited

Legend:

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

    r253 r256  
    3939    template<class Archive> void serialize(Archive& ar, const unsigned int version)
    4040    {
     41        trace_for_serialize( "serializing - Schedule" );
     42
    4143        ar & BOOST_SERIALIZATION_NVP( type );
    4244        ar & BOOST_SERIALIZATION_NVP( offset );
     
    9496    template<class Archive> void load(Archive& ar, const unsigned int version)
    9597    {
     98        trace_for_serialize( "serializing(load) - NativeCode" );
     99
    96100        std::string code;
    97101        ar & BOOST_SERIALIZATION_NVP( code );
     
    103107        for( int i=0; i<size; i++ )
    104108        {
    105             char c;
    106             sscanf( code.c_str() + i*3, "%02x,", &c );
    107             codeBuffer[i] = c;
     109            ULONG_PTR l;
     110            sscanf( code.c_str() + i*3, "%02x,", &l );
     111            codeBuffer[i] = (char)l;
    108112        }
    109113    }
    110114    template<class Archive> void save(Archive& ar, const unsigned int version) const
    111115    {
     116        trace_for_serialize( "serializing(save) - NativeCode" );
     117
    112118        // 保存準備
    113         char *tempCode = (char *)malloc( (size+1) * 3 );
     119        char *tempCode = (char *)calloc( (size+1) * 3, 1 );
    114120        for( int i=0; i<size; i++ )
    115121        {
    116122            char temp[32];
    117             sprintf( temp, "%02x,", codeBuffer[i] );
     123            sprintf( temp, "%02x,", (unsigned char)codeBuffer[i] );
    118124            tempCode[i*3] = temp[0];
    119125            tempCode[i*3+1] = temp[1];
     
    130136
    131137
    132     void Realloc( int additionSize = 0 )
    133     {
    134         if( allocateSize < size + 8192 + additionSize )
    135         {
    136             while( allocateSize < size + 8192 + additionSize )
     138    void Realloc( int newSize )
     139    {
     140        if( allocateSize < newSize + 8192 )
     141        {
     142            while( allocateSize < newSize + 8192 )
    137143            {
    138144                allocateSize += 8192;
     
    149155    {
    150156    }
     157    NativeCode( const NativeCode &nativeCode )
     158        : allocateSize( 8192 )
     159        , codeBuffer( (char *)malloc( allocateSize ) )
     160        , size( 0 )
     161    {
     162        Put( nativeCode );
     163    }
    151164    NativeCode( const char *codeBuffer, int size )
    152165        : allocateSize( 8192 )
     
    165178    }
    166179
     180    void operator =( const NativeCode &nativeCode )
     181    {
     182        Clear();
     183        Put( nativeCode );
     184    }
     185
    167186    int GetSize() const
    168187    {
     
    203222    void Put( const char *codeBuffer, int size )
    204223    {
    205         Realloc( size );
     224        Realloc( this->size + size );
    206225
    207226        memcpy( this->codeBuffer + this->size, codeBuffer, size );
     
    268287    void Put( char c )
    269288    {
     289        Realloc( size + 1 );
    270290        codeBuffer[size++] = c;
    271         Realloc();
    272291
    273292
Note: See TracChangeset for help on using the changeset viewer.