Changeset 591 in dev for trunk


Ignore:
Timestamp:
May 10, 2008, 6:11:29 PM (16 years ago)
Author:
dai_9181
Message:

DataTable::AddWStringメソッドを追加。

Location:
trunk/ab5.0/abdev
Files:
6 edited

Legend:

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

    r589 r591  
    9494    int Add( double dbl );
    9595    int Add( float flt );
    96     int AddString( const char *str, int length );
    9796    int AddString( const char *str );
    9897    int AddString( const std::string &str );
     98    int AddWString( const std::wstring &wstr );
    9999    void Add( const DataTable &dataTable )
    100100    {
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/DataTable.cpp

    r589 r591  
    2929    return retSize;
    3030}
    31 int DataTable::AddString( const char *str, int length ){
    32     int retSize = size;
    33 
    34     if( compiler.IsUnicode() ){
    35         //Shift-JIS → Unicode
    36         int size = MultiByteToWideChar(
    37             CP_ACP,
    38             0,
    39             str, length + 1,
    40             NULL, 0 ) * 2;
    41 
    42         LPWSTR pwstr = (LPWSTR)malloc( size );
    43 
    44         MultiByteToWideChar(
    45             CP_ACP,
    46             0,
    47             str, length + 1,
    48             pwstr, length + 1 );
    49 
    50         AddBinary( pwstr, size );
    51 
    52         free( pwstr );
    53     }
    54     else{
    55         AddBinary( str, length + 1 );
    56     }
    57 
    58     return retSize;
    59 }
    6031int DataTable::AddString( const char *str )
    6132{
    62     return AddString( str, lstrlen( str ) );
     33    return AddBinary( str, lstrlen( str ) + sizeof(char) );
    6334}
    6435int DataTable::AddString( const std::string &str )
    6536{
    66     return AddString( str.c_str(), static_cast<int>(str.length()) );
     37    return AddBinary( str.c_str(), static_cast<int>(str.size()) + sizeof(char) );
     38}
     39int DataTable::AddWString( const std::wstring &wstr )
     40{
     41    return AddBinary( wstr.c_str(), static_cast<int>(wstr.size()) + sizeof(wchar_t) );
    6742}
    6843int DataTable::AddSpace( int size )
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/DataTableGenerator.cpp

    r589 r591  
    178178
    179179    // 文字列バッファをデータ領域へ追加
    180     dataTable.AddString( str );
     180    if( compiler.IsUnicode() )
     181    {
     182        dataTable.AddWString( Jenga::Common::ToWString( str ) );
     183    }
     184    else
     185    {
     186        dataTable.AddString( str );
     187    }
    181188
    182189    return dataTableOffset;
     
    232239            {
    233240                // Charポインタ
    234                 strOffset = dataTable.AddString( tempParamStr );
     241                if( compiler.IsUnicode() )
     242                {
     243                    strOffset = dataTable.AddWString( Jenga::Common::ToWString( tempParamStr ) );
     244                }
     245                else
     246                {
     247                    strOffset = dataTable.AddString( tempParamStr );
     248                }
    235249            }
    236250
  • trunk/ab5.0/abdev/BasicCompiler_Common/src/Exception.cpp

    r587 r591  
    201201                lstrcpy( paramName, catchScope.GetParamType().GetClass().GetFullName().c_str() );
    202202            }
    203             paramNameDataTableOffset = compiler.GetObjectModule().dataTable.AddString( paramName );
     203            if( compiler.IsUnicode() )
     204            {
     205                paramNameDataTableOffset = compiler.GetObjectModule().dataTable.AddWString( Jenga::Common::ToWString( paramName ) );
     206            }
     207            else
     208            {
     209                paramNameDataTableOffset = compiler.GetObjectModule().dataTable.AddString( paramName );
     210            }
    204211            *((LONG_PTR *)(buffer+pos)) = paramNameDataTableOffset;
    205212            pos += sizeof(LONG_PTR);
  • trunk/ab5.0/abdev/compiler_x86/Compile_Var.cpp

    r587 r591  
    876876            char *temp;
    877877            temp=(char *)i64data;
    878             i2=compiler.GetObjectModule().dataTable.AddString(temp,lstrlen(temp));
     878            if( compiler.IsUnicode() )
     879            {
     880                i2 = compiler.GetObjectModule().dataTable.AddWString( Jenga::Common::ToWString( temp ) );
     881            }
     882            else
     883            {
     884                i2 = compiler.GetObjectModule().dataTable.AddString( temp );
     885            }
    879886            HeapDefaultFree(temp);
    880887
     
    10651072            char *temp;
    10661073            temp=(char *)i64data;
    1067             i2=compiler.GetObjectModule().dataTable.AddString(temp,lstrlen(temp));
     1074            if( compiler.IsUnicode() )
     1075            {
     1076                i2 = compiler.GetObjectModule().dataTable.AddWString( Jenga::Common::ToWString( temp ) );
     1077            }
     1078            else
     1079            {
     1080                i2 = compiler.GetObjectModule().dataTable.AddString( temp );
     1081            }
    10681082            HeapDefaultFree(temp);
    10691083
  • trunk/ab5.0/abdev/compiler_x86/NumOpe.cpp

    r589 r591  
    957957                    bLiteralCalculation=0;
    958958
    959                     i2=compiler.GetObjectModule().dataTable.AddString(term,i3);
     959                    if( compiler.IsUnicode() )
     960                    {
     961                        i2 = compiler.GetObjectModule().dataTable.AddWString( Jenga::Common::ToWString( std::string( term, i3 ) ) );
     962                    }
     963                    else
     964                    {
     965                        i2 = compiler.GetObjectModule().dataTable.AddString( std::string( term, i3 ) );
     966                    }
    960967
    961968                    //push DataSize
Note: See TracChangeset for help on using the changeset viewer.