Ignore:
Timestamp:
Mar 15, 2008, 3:33:36 PM (16 years ago)
Author:
dai_9181
Message:

関数の戻り値の構造体など、一時メモリに保持された構造体のメンバに直接アクセスした場合、その一時メモリの解放が正常に行われないバグを修正(64bit版も修正した)。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abdev/BasicCompiler32/CParameter.cpp

    r435 r436  
    6565                //変数ではないとき
    6666                Type calcType;
    67                 BOOL bUseHeap;
    68                 NumOpe( Parms[i2], dummyType, calcType, &bUseHeap );
     67                bool isNeedHeapFreeStructure;
     68                NumOpe( Parms[i2], dummyType, calcType, &isNeedHeapFreeStructure );
    6969                //↑ここでスタックに積む
    7070
     
    8686                    i2);
    8787
    88                 if( result && bUseHeap ){
     88                if( result )
     89                {
    8990                    useTempParameters[i2] = true;
     91                    isNeedFreeStructures[i2] = true;
    9092                    useTempObject = true;
    9193
     
    107109    for(int i2=ParmsNum-1;i2>=0;i2--){
    108110        if( useTempParameters[i2] ){
    109             if( types[i2].IsStruct() ){
     111            if( types[i2].IsStruct() )
     112            {
    110113                // 構造体の一時メモリ
    111114
    112                 //メモリを解放する
    113 
    114                 //call free
    115                 extern const UserProc *pSub_free;
    116                 compiler.codeGenerator.op_call(pSub_free);
    117             }
    118             else{
    119                 if( types[i2].Is64() ){
     115                if( isNeedFreeStructures[i2] )
     116                {
     117                    //メモリを解放する
     118
     119                    //call free
     120                    extern const UserProc *pSub_free;
     121                    compiler.codeGenerator.op_call(pSub_free);
     122                }
     123                else
     124                {
     125                    //pop ... 参照を消す
     126                    compiler.codeGenerator.op_add_esp( PTR_SIZE );
     127                }
     128            }
     129            else
     130            {
     131                if( types[i2].Is64() )
     132                {
    120133                    //pop ... 参照を消す
    121134                    //pop ... 上位32ビット
     
    123136                    compiler.codeGenerator.op_add_esp( PTR_SIZE * 3 );
    124137                }
    125                 else{
     138                else
     139                {
    126140                    //pop ... 参照を消す
    127141                    //pop ... 値を消す
     
    150164
    151165    Type calcType;
    152     BOOL bUseHeap;
     166    bool isNeedHeapFreeStructure;
    153167    NumOpe( expression,
    154168        baseType,
    155169        calcType,
    156         &bUseHeap );
     170        &isNeedHeapFreeStructure );
    157171
    158172    // ※スタックにある二つのデータ(コピー先、コピー元)の値を必要とする
    159     SetStructVariable( baseType, calcType, bUseHeap );
     173    SetStructVariable( baseType, calcType, isNeedHeapFreeStructure );
    160174}
    161175
     
    234248            }
    235249
    236             BOOL bCalcUseHeap;
    237250            Type calcType;
    238             if( !NumOpe( Parms[i2], dummyType, calcType, &bCalcUseHeap ) ){
     251            bool isNeedHeapFreeStructure;
     252            if( !NumOpe( Parms[i2], dummyType, calcType, &isNeedHeapFreeStructure ) )
     253            {
    239254                break;
    240255            }
    241256
    242             if( calcType.IsObject() ){
     257            if( calcType.IsObject() )
     258            {
    243259                if( !dummyType.IsObject()
    244260                    ||
    245261                    dummyType.IsObject() &&
    246                     !dummyType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) ){
     262                    !dummyType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) )
     263                {
    247264                        //キャスト演算子のオーバーロードに対応する
    248                         CallCastOperatorProc( calcType, bCalcUseHeap,dummyType );
     265                        CallCastOperatorProc( calcType, isNeedHeapFreeStructure,dummyType );
    249266                }
    250267            }
Note: See TracChangeset for help on using the changeset viewer.