Changeset 76 in dev for BasicCompiler32/OperatorProc.cpp


Ignore:
Timestamp:
Mar 21, 2007, 9:26:56 PM (17 years ago)
Author:
dai_9181
Message:

TYPEINFO→Typeへのリファクタリングを実施。32bitが未完成。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/OperatorProc.cpp

    r75 r76  
    22#include "Opcode.h"
    33
    4 void FreeTempObject(int reg,CClass *pobj_c){
     4void FreeTempObject(int reg,const CClass *pobj_c){
    55    if(!IsSafeReg(reg)) SetError(300,NULL,cp);
    66
     
    2222}
    2323
    24 int CallOperatorProc(int idCalc,Type *pBaseTypeInfo,int *type,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){
     24int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){
    2525    //オーバーロードされたオペレータ関数を呼び出す
    2626    CClass *pobj_c;
     
    3939
    4040
    41     int i;
    42     BOOL bReturnTypeIsObject=1;
    43     Type ReturnType={DEF_OBJECT,subs[0]->ReturnType().GetIndex()};
    44     foreach( UserProc *pUserProc, subs ){
    45         if(pUserProc->ReturnType().IsObject())
    46             bReturnTypeIsObject=0;
    47     }
    48 
    49     if(bReturnTypeIsObject==0){
    50         if(pBaseTypeInfo){
    51             if(pBaseTypeInfo->type==DEF_OBJECT){
    52                 ReturnType.u.lpIndex=pBaseTypeInfo->u.lpIndex;
    53             }
    54         }
    55     }
    56 
    57 
    58 
    5941    /////////////////////////////////////////////
    6042    // オーバーロード解決用のパラメータを設定
     
    6446
    6547    if(bTwoTerm){
    66         params.push_back( new Parameter( "", Type( type[sp-1], index_stack[sp-1] ) ) );
     48        params.push_back( new Parameter( "", Type( type_stack[sp-1], index_stack[sp-1] ) ) );
    6749    }
    6850
     
    7153    if(idCalc==CALC_EQUAL) lstrcpy(temporary,"==");
    7254    else GetCalcName(idCalc,temporary);
    73     Type returnType;
    74     if( pBaseTypeInfo ){
    75         returnType.SetBasicType( pBaseTypeInfo->type );
    76         returnType.SetIndex( pBaseTypeInfo->u.lpIndex );
    77     }
    78     UserProc *pUserProc = OverloadSolution( temporary, subs, params, returnType );
     55    UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType );
    7956
    8057    if(!pUserProc){
     
    9471    }
    9572
    96     for(i=0;i<(int)params.size();i++){
     73    for(int i=0;i<(int)params.size();i++){
    9774        CheckDifferentType(
    9875            pUserProc->Params()[i]->GetBasicType(),
     
    10885    }
    10986
    110     int right_side_size = GetTypeSize(type[sp-1],index_stack[sp-1]);
     87    int right_side_size = GetTypeSize(type_stack[sp-1],index_stack[sp-1]);
    11188
    11289    if(bTwoTerm){
     
    224201
    225202    sp--;
    226     type[sp-1]=pUserProc->ReturnType().GetBasicType();
     203    type_stack[sp-1]=pUserProc->ReturnType().GetBasicType();
    227204    index_stack[sp-1]=pUserProc->ReturnType().GetIndex();
    228205
     
    237214}
    238215
    239 void CallCastOperatorProc(int &CalcType,LONG_PTR &lpCalcIndex,BOOL bCalcUseHeap,int ToType,LONG_PTR lpToIndex){
    240     int type[10];
     216void CallCastOperatorProc(Type &calcType,BOOL bCalcUseHeap,const Type &toType){
     217    int type_stack[10];
    241218    LONG_PTR index_stack[10];
    242219    BOOL array_bUseHeap[10];
     
    249226
    250227    //左辺
    251     type[0]=CalcType;
    252     index_stack[0]=lpCalcIndex;
     228    type_stack[0]=calcType.GetBasicType();
     229    index_stack[0]=calcType.GetIndex();
    253230    array_bUseHeap[0]=0;
    254     type[1]=ToType;
    255     index_stack[1]=lpToIndex;
     231    type_stack[1]=toType.GetBasicType();
     232    index_stack[1]=toType.GetIndex();
    256233    array_bUseHeap[1]=0;
    257234
    258     Type BaseTypeInfo={ToType,lpToIndex};
    259 
    260     int iRet;
    261     iRet=CallOperatorProc(CALC_AS,&BaseTypeInfo,type,index_stack,array_bUseHeap,sp);
     235    int iRet = CallOperatorProc(CALC_AS,toType,type_stack,index_stack,array_bUseHeap,sp);
     236
    262237    if(iRet==1){
    263238        //成功したとき
    264         CalcType=type[0];
    265         lpCalcIndex=index_stack[0];
     239        calcType.SetType( type_stack[0], index_stack[0] );
    266240        return;
    267241    }
     
    274248    SetError(-1,"キャスト演算子がオーバーロードされていません。",cp);
    275249}
    276 void CallIndexerGetterProc(CClass *pobj_Class,char *ObjectName,char *Parameter,Type &RetTypeInfo){
     250void CallIndexerGetterProc(const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType){
    277251    std::vector<UserProc *> subs;
    278252    pobj_Class->EnumMethod( CALC_ARRAY_GET, subs );
     
    282256
    283257    Opcode_CallProc(Parameter,subs[0],0,ObjectName,DEF_OBJECT);
    284     RetTypeInfo.type = subs[0]->ReturnType().GetBasicType();
    285     RetTypeInfo.u.lpIndex = subs[0]->ReturnType().GetIndex();
    286 }
     258    resultType = subs[0]->ReturnType();
     259}
Note: See TracChangeset for help on using the changeset viewer.