Changeset 75 in dev for BasicCompiler64/OperatorProc.cpp
- Timestamp:
- Mar 20, 2007, 4:36:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler64/OperatorProc.cpp
r73 r75 2 2 #include "Opcode.h" 3 3 4 void FreeTempObject(int reg, CClass *pobj_c){4 void FreeTempObject(int reg,const CClass *pobj_c){ 5 5 if(!IsSafeReg(reg)) SetError(300,NULL,cp); 6 6 … … 16 16 17 17 //call DestructorProcAddr 18 op_call( method->p si);18 op_call( method->pUserProc ); 19 19 } 20 20 … … 23 23 24 24 //call free 25 extern SubInfo*pSub_free;25 extern UserProc *pSub_free; 26 26 op_call(pSub_free); 27 27 } 28 28 29 int CallOperatorProc(int idCalc, TYPEINFO *pBaseTypeInfo,int *type,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){29 int CallOperatorProc(int idCalc, const Type &baseType, int *type_stack,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){ 30 30 //オーバーロードされたオペレータ関数を呼び出す 31 31 CClass *pobj_c; 32 32 pobj_c=(CClass *)index_stack[sp-2]; 33 33 34 std::vector< SubInfo*> subs;34 std::vector<UserProc *> subs; 35 35 pobj_c->EnumMethod( idCalc, subs ); 36 36 if( subs.size() == 0 ){ … … 45 45 46 46 int i; 47 BOOL bReturnTypeIsObject=1;48 TYPEINFO ReturnType={DEF_OBJECT,subs[0]->u.ReturnIndex};49 for(i=0;i<subs.size();i++){50 if(subs[i]->ReturnType!=DEF_OBJECT)51 bReturnTypeIsObject=0;52 }53 54 if(bReturnTypeIsObject==0){55 if(pBaseTypeInfo){56 if(pBaseTypeInfo->type==DEF_OBJECT){57 ReturnType.u.lpIndex=pBaseTypeInfo->u.lpIndex;58 }59 }60 }61 62 47 63 48 … … 66 51 ///////////////////////////////////////////// 67 52 68 PARAMETER_INFO *ppi = (PARAMETER_INFO *)HeapAlloc(hHeap,0,sizeof(PARAMETER_INFO)*3); 69 int iParmNum=0; 70 71 if(bTwoTerm){ 72 ppi[iParmNum].bArray=0; 73 ppi[iParmNum].bByVal=0; 74 ppi[iParmNum].name=0; 75 ppi[iParmNum].type=type[sp-1]; 76 ppi[iParmNum].u.index=index_stack[sp-1]; 77 ppi[iParmNum].SubScripts[0]=-1; 78 iParmNum++; 79 } 80 53 Parameters params; 54 55 if(bTwoTerm){ 56 params.push_back( new Parameter( "", Type( type_stack[sp-1], index_stack[sp-1] ) ) ); 57 } 81 58 82 59 //オーバーロードを解決 … … 84 61 if(idCalc==CALC_EQUAL) lstrcpy(temporary,"=="); 85 62 else GetCalcName(idCalc,temporary); 86 SubInfo *psi;87 psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo); 88 89 90 if(!psi){91 HeapDefaultFree(ppi);63 UserProc *pUserProc = OverloadSolution( temporary, subs, params, baseType ); 64 65 if(!pUserProc){ 66 if(bTwoTerm){ 67 delete params[0]; 68 } 92 69 return -1; 93 70 } 94 71 else{ 95 72 //オーバーロードされていないが、パラメータ個数が一致しないとき 96 if(iParmNum!=psi->params.size()){ 97 HeapDefaultFree(ppi); 73 if(params.size()!=pUserProc->Params().size()){ 74 if(bTwoTerm){ 75 delete params[0]; 76 } 98 77 return -1; 99 78 } 100 79 } 101 80 102 for(i=0;i< iParmNum;i++){81 for(i=0;i<(int)params.size();i++){ 103 82 CheckDifferentType( 104 p si->params[i]->GetBasicType(),105 p si->params[i]->GetIndex(),106 p pi[i].type,107 p pi[i].u.index,83 pUserProc->Params()[i]->GetBasicType(), 84 pUserProc->Params()[i]->GetIndex(), 85 params[i]->GetBasicType(), 86 params[i]->GetIndex(), 108 87 "", 109 88 i); 110 89 } 111 90 112 HeapDefaultFree(ppi); 113 114 if(bTwoTerm){ 115 if( psi->realParams[1]->IsStruct() && psi->realParams[1]->IsRef() == false ){ 91 if(bTwoTerm){ 92 delete params[0]; 93 } 94 95 int right_side_size = GetTypeSize(type_stack[sp-1],index_stack[sp-1]); 96 97 if(bTwoTerm){ 98 if( pUserProc->RealParams()[1]->IsStruct() &&pUserProc->RealParams()[1]->IsRef() == false ){ 116 99 //一時オブジェクトはメソッド内で破棄される 117 100 bUseHeap[sp-1]=0; … … 119 102 } 120 103 121 if(psi->ReturnType==DEF_STRUCT){ 104 105 if( pUserProc->ReturnType().IsStruct() ){ 122 106 ////////////////////////////////////////////////////// 123 107 // 戻り値に構造体インスタンスを持つ場合 … … 131 115 ////////////////////////////////////////////////////// 132 116 133 int object_size = p si->u.Return_pobj_c->GetSize();117 int object_size = pUserProc->ReturnType().GetClass().GetSize(); 134 118 135 119 //mov rcx,object_size … … 137 121 138 122 //call calloc 139 extern SubInfo*pSub_calloc;123 extern UserProc *pSub_calloc; 140 124 op_call(pSub_calloc); 141 125 … … 152 136 if(bTwoTerm){ 153 137 //右の項(実数の場合が未完成) 154 SetOneTermToReg_Whole64Calc(type [sp-1],®2);138 SetOneTermToReg_Whole64Calc(type_stack[sp-1],®2); 155 139 pobj_reg->UnlockReg(); 156 if( !p si->realParams[1]->IsRef() == false ){140 if( !pUserProc->RealParams()[1]->IsRef() == false ){ 157 141 //一時参照を作成 158 142 pobj_sf->push( reg2 ); … … 190 174 191 175 if(bTwoTerm){ 192 if( psi->ReturnType==DEF_STRUCT){176 if( pUserProc->ReturnType().IsStruct() ){ 193 177 //mov r8,reg2 194 178 op_mov_RR(REG_R8,reg2); … … 200 184 } 201 185 202 if( psi->ReturnType==DEF_STRUCT){186 if( pUserProc->ReturnType().IsStruct() ){ 203 187 //mov rdx,r13 204 188 op_mov_RR(REG_RDX,REG_R13); … … 209 193 210 194 //call operator_proc 211 op_call(p si);212 213 if( psi->ReturnType!=DEF_NON){195 op_call(pUserProc); 196 197 if( !pUserProc->ReturnType().IsNull() ){ 214 198 //戻り値を一時的に退避 215 199 … … 253 237 254 238 if(bTwoTerm){ 255 if( !p si->realParams[1]->IsRef() == false ){239 if( !pUserProc->RealParams()[1]->IsRef() == false ){ 256 240 //一時参照を破棄 257 241 pobj_sf->pop(); … … 259 243 } 260 244 261 if( psi->ReturnType!=DEF_NON){245 if( !pUserProc->ReturnType().IsNull() ){ 262 246 //戻り値をreg1にセット 263 247 reg1=pobj_reg->LockReg(); … … 268 252 269 253 sp--; 270 type [sp-1]=psi->ReturnType;271 index_stack[sp-1]=p si->u.ReturnIndex;272 273 if( psi->ReturnType==DEF_STRUCT){254 type_stack[sp-1]=pUserProc->ReturnType().GetBasicType(); 255 index_stack[sp-1]=pUserProc->ReturnType().GetIndex(); 256 257 if( pUserProc->ReturnType().IsStruct() ){ 274 258 //構造体が戻ったときはヒープ領域にインスタンスが格納されている 275 259 //※後にfreeする必要あり … … 281 265 } 282 266 283 void CallCastOperatorProc(int reg, int &CalcType,LONG_PTR &lpCalcIndex,BOOL bCalcUseHeap,int ToType,LONG_PTR lpToIndex){284 int type [10];267 void CallCastOperatorProc(int reg,Type &calcType,BOOL bCalcUseHeap,const Type &toType){ 268 int type_stack[10]; 285 269 LONG_PTR index_stack[10]; 286 270 BOOL array_bUseHeap[10]; … … 304 288 305 289 //左辺 306 type [0]=CalcType;307 index_stack[0]= lpCalcIndex;290 type_stack[0]=calcType.GetBasicType(); 291 index_stack[0]=calcType.GetIndex(); 308 292 array_bUseHeap[0]=0; 309 type [1]=ToType;310 index_stack[1]= lpToIndex;293 type_stack[1]=toType.GetBasicType(); 294 index_stack[1]=toType.GetIndex(); 311 295 array_bUseHeap[1]=0; 312 296 313 TYPEINFO BaseTypeInfo={ToType,lpToIndex}; 314 315 iRet=CallOperatorProc(CALC_AS,&BaseTypeInfo,type,index_stack,array_bUseHeap,sp); 297 iRet=CallOperatorProc(CALC_AS,toType,type_stack,index_stack,array_bUseHeap,sp); 316 298 317 299 pobj_reg->UnlockReg(); … … 325 307 if(iRet==1){ 326 308 //成功したとき 327 CalcType=type[0]; 328 lpCalcIndex=index_stack[0]; 309 calcType.SetType( type_stack[0], index_stack[0] ); 329 310 return; 330 311 } … … 339 320 340 321 //インデクサ(getter)を呼び出す 341 void CallIndexerGetterProc(int reg, CClass *pobj_Class,char *ObjectName,char *Parameter,TYPEINFO &RetTypeInfo){342 343 std::vector< SubInfo*> subs;322 void CallIndexerGetterProc(int reg,const CClass *pobj_Class,char *ObjectName,char *Parameter,Type &resultType ){ 323 324 std::vector<UserProc *> subs; 344 325 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 345 326 if( subs.size() == 0 ){ … … 353 334 354 335 Opcode_CallProc(Parameter,subs[0],0,ObjectName,DEF_OBJECT); 355 RetTypeInfo.type = subs[0]->ReturnType; 356 RetTypeInfo.u.lpIndex = subs[0]->u.ReturnIndex; 336 resultType = subs[0]->ReturnType(); 357 337 358 338 //mov reg,rax
Note:
See TracChangeset
for help on using the changeset viewer.