Changeset 75 in dev for BasicCompiler32/Compile_Object.cpp


Ignore:
Timestamp:
Mar 20, 2007, 4:36:16 AM (17 years ago)
Author:
dai_9181
Message:

TYPEINFO→Typeへのリファクタリングを実施。64bitはほぼ完了。32bitが全般的に未完成。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/Compile_Object.cpp

    r73 r75  
    22#include "opcode.h"
    33
    4 void _call_constructor(CClass *pobj_c, const char *CreateParameter,int ObjectSize,BOOL bSomeObjects){
     4void _call_constructor( const CClass *pobj_c, const char *CreateParameter,int ObjectSize,BOOL bSomeObjects){
    55    ////////////////////////////
    66    // コンストラクタの呼び出し
     
    3131    ////////////////////////
    3232
    33     std::vector<SubInfo *> subs;
     33    std::vector<UserProc *> subs;
    3434    pobj_c->EnumMethod( pobj_c->name, subs );
    3535
    36     SubInfo *psi;
     36    UserProc *pUserProc;
    3737    if( subs.size() > 0 ){
    3838        //オーバーロードを解決
    39         psi=OverloadSolutionWithStrParam(pobj_c->name,
    40             subs,CreateParameter,"",NULL);
    41 
    42         if(!psi) return;
     39        pUserProc=OverloadSolutionWithStrParam(pobj_c->name,
     40            subs,CreateParameter,"");
     41
     42        if(!pUserProc) return;
    4343    }
    4444
    4545    //コンストラクタを呼び出す
    4646    Opcode_CallProc(CreateParameter,
    47         psi,
     47        pUserProc,
    4848        PROCFLAG_NEW,"",0);
    4949
     
    7474    }
    7575}
    76 void Operator_New( CClass &classObj, const char *objectSizeStr, const char *parameter, const TYPEINFO &baseTypeInfo ){
     76void Operator_New( const CClass &classObj, const char *objectSizeStr, const char *parameter, const Type &baseType ){
    7777    int typeSize = classObj.GetSize();
    7878
     
    8282    }
    8383
     84    BOOL bSomeObjects=0;
    8485    if(objectSizeStr[0]){
    85         int type = NumOpe(objectSizeStr,0,0,0);
    86         ChangeTypeToLong(type);
     86        bSomeObjects=1;
     87
     88        Type tempType;
     89        NumOpe(objectSizeStr,Type(),tempType);
     90        if( !tempType.IsWhole() ) SetError(49,NULL,cp);
     91        ChangeTypeToLong(tempType.GetBasicType());
    8792
    8893        //pop eax
     
    129134    }
    130135
    131     if( baseTypeInfo.type == DEF_OBJECT ){
    132         //DeleteはGCで処理
     136    if( baseType.IsObject() ){
     137        // オブジェクト インスタンス
     138        // ※DeleteはGCで処理
    133139
    134140        //call _System_GC_malloc_ForObject
    135         extern SubInfo *pSub_System_GC_malloc_ForObject;
     141        extern UserProc *pSub_System_GC_malloc_ForObject;
    136142        op_call(pSub_System_GC_malloc_ForObject);
    137143    }
    138144    else{
    139         //明示的なDeleteが必要
     145        // オブジェクトポインタ
     146        // ※明示的なDeleteが必要
    140147
    141148        //call _System_GC_malloc_ForObjectPtr
    142         extern SubInfo *pSub_System_GC_malloc_ForObjectPtr;
     149        extern UserProc *pSub_System_GC_malloc_ForObjectPtr;
    143150        op_call(pSub_System_GC_malloc_ForObjectPtr);
    144151    }
     
    184191    //mov ecx,DestructorProcAddr
    185192    OpBuffer[obp++]=(char)0xB9;
    186     pobj_SubAddrSchedule->add(method->psi,0);
    187     method->psi->bUse=1;
     193    pobj_SubAddrSchedule->add(method->pUserProc,0);
     194    method->pUserProc->Using();
    188195    obp+=sizeof(long);
    189196
     
    209216    ////////////////////////////
    210217
    211     BOOL bSomeObjects;
    212     if(objectSizeStr[0]) bSomeObjects=1;
    213     else bSomeObjects=0;
    214218    _call_constructor(&classObj,parameter,typeSize,bSomeObjects);
    215219}
    216 int Operator_New(const char *Parameter,LONG_PTR *plpIndex,const TYPEINFO &baseTypeInfo ){
    217     char TypeName[VN_SIZE],CreateParameter[VN_SIZE],objectSizeStr[VN_SIZE];
    218     int i,i2;
    219 
    220     i=0;
    221 
    222     if(Parameter[0]=='['){
    223         i=GetStringInBracket(objectSizeStr,Parameter);
    224 
    225         SlideString(objectSizeStr+1,-1);
    226         objectSizeStr[i-2]=0;
    227     }
    228     else objectSizeStr[0]=0;
    229 
    230     for(i2=0;;i++,i2++){
    231         if(Parameter[i]=='('){
    232             TypeName[i2]=0;
    233 
    234             //コンストラクタに渡すパラメータを取得
    235             i2=GetStringInPare(CreateParameter,Parameter+i);
    236             RemoveStringPare(CreateParameter);
    237             i+=i2;
    238             if(Parameter[i]!='\0'){
    239                 SetError(42,NULL,cp);
    240                 return -1;
    241             }
    242             break;
    243         }
    244         TypeName[i2]=Parameter[i];
    245         if(Parameter[i]=='\0'){
    246             CreateParameter[0]=0;
    247             break;
    248         }
    249     }
    250 
    251     int type,TypeSize;
    252     type=GetTypeFixed(TypeName,plpIndex);
    253     if(type==-1){
    254         SetError(3,TypeName,cp);
    255         return -1;
    256     }
    257     TypeSize=GetTypeSize(type,*plpIndex);
    258 
    259     if(type!=DEF_OBJECT){
    260         ////////////////////////
    261         // 通常のデータ型の場合
    262         ////////////////////////
    263 
    264         SetError(121,NULL,cp);
    265         return -1;
    266     }
    267 
    268     CClass *pobj_c;
    269     pobj_c=(CClass *)*plpIndex;
    270 
    271     Operator_New( *pobj_c, objectSizeStr, CreateParameter, baseTypeInfo );
    272 
    273     if( baseTypeInfo.type == DEF_OBJECT ){
    274         return DEF_OBJECT;
    275     }
    276     return DEF_PTR_OBJECT;
    277 }
    278 
    279220void OpcodeDelete(const char *Parameter, bool isSweeping){
    280     int type;
    281 
    282     type=NumOpe(Parameter,0,0,0);
    283     if(type==-1) return;
    284     if(!(type==DEF_PTR_OBJECT||type==DEF_PTR_VOID)) SetError(122,NULL,cp);
     221    Type tempType;
     222    if( !NumOpe(Parameter,Type(),tempType) ){
     223        return;
     224    }
     225    if(!( tempType.IsObjectPtr() || tempType.IsVoidPtr() )) SetError(122,NULL,cp);
    285226
    286227    //pop eax
     
    376317    if( isSweeping ){
    377318        //call _System_GC_free_for_SweepingDelete
    378         extern SubInfo *pSub_System_GC_free_for_SweepingDelete;
     319        extern UserProc *pSub_System_GC_free_for_SweepingDelete;
    379320        op_call(pSub_System_GC_free_for_SweepingDelete);
    380321    }
    381322    else{
    382323        //call free
    383         extern SubInfo *pSub_free;
     324        extern UserProc *pSub_free;
    384325        op_call(pSub_free);
    385326    }
Note: See TracChangeset for help on using the changeset viewer.