Changeset 64 in dev for BasicCompiler64/CParameter.cpp


Ignore:
Timestamp:
Mar 8, 2007, 2:49:34 AM (17 years ago)
Author:
dai_9181
Message:

すべてのオブジェクトを参照型に切り替えた。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler64/CParameter.cpp

    r63 r64  
    22#include "opcode.h"
    33
    4 void CParameter::NewTempParameters( const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum ){
     4int CParameter::NewTempParameters( const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum ){
    55    ///////////////////////////////////////////////////////
    66    // 一時オブジェクトをあらかじめスタックに積んでおく
    77    ///////////////////////////////////////////////////////
     8
     9    int stackItemNum = 0;
    810
    911    useTempObject = false;
     
    6062                int type = NumOpe( &reg, Parms[i2], DummyTypeInfo.type, DummyTypeInfo.u.lpIndex, &lpVarIndex );
    6163
     64                if( type == DEF_OBJECT ){
     65                    //一時参照を作成
     66                    pobj_sf->push( reg );
     67                    pobj_sf->mov_sp( reg );
     68
     69                    stackItemNum++;
     70                }
     71
    6272                //スタックフレームへコピー
    6373                StackOffsetOfTempObject[i2] = pobj_sf->push(reg);
     74
     75                stackItemNum++;
    6476
    6577                bool result = CheckDifferentType(
     
    8193        }
    8294    }
     95
     96    return stackItemNum * PTR_SIZE;
    8397}
    8498void CParameter::DeleteTempParameters(){
     
    90104    for(int i2=ParmsNum-1;i2>=0;i2--){
    91105        if( useTempParameters[i2] ){
    92             //スタックフレームから取得
    93             pobj_sf->ref(REG_RCX);
    94 
    95             //デストラクタを呼び出す
    96 
    97             //call destructor
    98             CMethod *method = types[i2].u.pobj_Class->GetDestructorMethod();
    99             if( method ){
    100                 op_call( method->psi );
    101             }
    102 
    103             //メモリを解放する
    104 
    105             pobj_sf->pop(REG_RCX);
    106 
    107             //call free
    108             extern SUBINFO *pSub_free;
    109             op_call(pSub_free);
     106            if( types[i2].type == DEF_STRUCT ){
     107                // 構造体の一時メモリ
     108
     109                //メモリを解放する
     110
     111                pobj_sf->pop( REG_RCX );
     112
     113                //call free
     114                extern SUBINFO *pSub_free;
     115                op_call(pSub_free);
     116            }
     117            else if( types[i2].type == DEF_OBJECT ){
     118                pobj_sf->pop();
     119                pobj_sf->pop();
     120            }
     121            else{
     122                SetError(300,NULL,cp);
     123            }
    110124        }
    111125    }
    112126}
    113127
    114 void CParameter::SetObjectParameter(int reg,CClass *pobj_Class,LPSTR Parameter){
     128void CParameter::SetStructParameter(int reg,CClass *pobj_Class,LPSTR Parameter){
    115129    //////////////////////////////////////////////////////
    116130    /////    レジスタ資源のバックアップ
     
    133147        pobj_sf->push(REG_R11);
    134148
    135         TYPEINFO BaseType={DEF_OBJECT,(LONG_PTR)pobj_Class};
     149        TYPEINFO BaseType={DEF_STRUCT,(LONG_PTR)pobj_Class};
    136150        TYPEINFO CalcType;
    137151        CalcType.type=NumOpe_GetType(Parameter,&BaseType,&CalcType.u.lpIndex);
    138152
     153        /*
     154        TODO: 消す
    139155        if( pobj_Class->GetCopyConstructorMethod()
    140156            && CalcType.type==DEF_OBJECT&&CalcType.u.pobj_Class==pobj_Class){
     
    178194                op_call(pobj_Class->GetConstructorMethod()->psi);
    179195            }
     196            */
    180197
    181198
    182199            BOOL bUseHeap;
    183200            int temp_reg=REG_RAX;
    184             CalcType.type=NumOpe(&temp_reg,Parameter,DEF_OBJECT,(LONG_PTR)pobj_Class,&CalcType.u.lpIndex,&bUseHeap);
     201            CalcType.type=NumOpe(&temp_reg,Parameter,DEF_STRUCT,(LONG_PTR)pobj_Class,&CalcType.u.lpIndex,&bUseHeap);
    185202
    186203
     
    194211            RelativeVar.dwKind=VAR_DIRECTMEM;
    195212
    196             SetObjectVariableFromRax((LONG_PTR)pobj_Class,CalcType.type,CalcType.u.lpIndex,&RelativeVar,bUseHeap);
    197 
    198         }
     213            SetStructVariableFromRax((LONG_PTR)pobj_Class,CalcType.type,CalcType.u.lpIndex,&RelativeVar,bUseHeap);
     214
     215        //}
    199216
    200217        //mov r11,qword ptr[rsp+offset]     ※スタックフレームを利用
     
    209226    op_mov_RR(reg,REG_R11);
    210227}
     228
    211229
    212230void CParameter::SetParameter(const char *FuncName,PARAMETER_INFO *ppi,int pi_num,int SecondParmNum){
     
    298316            }
    299317
    300             if(DummyTypeInfo.type==DEF_OBJECT){
    301                 SetObjectParameter(reg,DummyTypeInfo.u.pobj_Class,Parms[i2]);
     318            if(DummyTypeInfo.type==DEF_STRUCT){
     319                SetStructParameter(reg,DummyTypeInfo.u.pobj_Class,Parms[i2]);
    302320                goto next;
    303321            }
     
    318336
    319337            if(CalcType==DEF_OBJECT){
    320                 //キャスト演算子のオーバーロードに対応する
    321                 CallCastOperatorProc(reg,CalcType,lpCalcIndex,bCalcUseHeap,DummyTypeInfo.type,DummyTypeInfo.u.lpIndex);
     338                if( DummyTypeInfo.type != DEF_OBJECT
     339                    ||
     340                    DummyTypeInfo.type == DEF_OBJECT &&
     341                    !DummyTypeInfo.u.pobj_Class->IsEqualsOrSubClass( (CClass *)lpCalcIndex ) ){
     342                        //キャスト演算子のオーバーロードに対応する
     343                        CallCastOperatorProc(reg,CalcType,lpCalcIndex,bCalcUseHeap,DummyTypeInfo.type,DummyTypeInfo.u.lpIndex);
     344                }
    322345            }
    323346
     
    419442                                    }
    420443                                }
     444                                else if(DummyTypeInfo.type==DEF_STRUCT){
     445                                    if( !DummyTypeInfo.u.pobj_Class->IsEquals( (CClass *)lpVarIndex ) ){
     446                                        SetError(11,Parms[i2],cp);
     447                                    }
     448                                }
    421449                            }
    422450                            else if((VarType&FLAG_PTR)&&((VarType^FLAG_PTR)==DummyTypeInfo.type)){
     
    442470            }
    443471        }
     472
    444473next:
     474
    445475        if(reg==REG_RAX){
    446476            //スタックフレームへコピー
Note: See TracChangeset for help on using the changeset viewer.