Changeset 75 in dev for BasicCompiler32/OperatorProc.cpp
- Timestamp:
- Mar 20, 2007, 4:36:16 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler32/OperatorProc.cpp
r73 r75 11 11 12 12 //call DestructorProcAddr 13 op_call( method->p si);13 op_call( method->pUserProc ); 14 14 } 15 15 … … 18 18 19 19 //call free 20 extern SubInfo*pSub_free;20 extern UserProc *pSub_free; 21 21 op_call(pSub_free); 22 22 } 23 23 24 int CallOperatorProc(int idCalc,T YPEINFO*pBaseTypeInfo,int *type,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){24 int CallOperatorProc(int idCalc,Type *pBaseTypeInfo,int *type,LONG_PTR *index_stack,BOOL *bUseHeap,int &sp){ 25 25 //オーバーロードされたオペレータ関数を呼び出す 26 26 CClass *pobj_c; 27 27 pobj_c=(CClass *)index_stack[sp-2]; 28 28 29 std::vector< SubInfo*> subs;29 std::vector<UserProc *> subs; 30 30 pobj_c->EnumMethod( idCalc, subs ); 31 31 if( subs.size() == 0 ){ … … 41 41 int i; 42 42 BOOL bReturnTypeIsObject=1; 43 T YPEINFO ReturnType={DEF_OBJECT,subs[0]->u.ReturnIndex};44 foreach( SubInfo *psi, subs ){45 if(p si->ReturnType!=DEF_OBJECT)43 Type ReturnType={DEF_OBJECT,subs[0]->ReturnType().GetIndex()}; 44 foreach( UserProc *pUserProc, subs ){ 45 if(pUserProc->ReturnType().IsObject()) 46 46 bReturnTypeIsObject=0; 47 47 } … … 61 61 ///////////////////////////////////////////// 62 62 63 PARAMETER_INFO *ppi = (PARAMETER_INFO *)HeapAlloc(hHeap,0,sizeof(PARAMETER_INFO)*3); 64 int iParmNum=0; 65 66 if(bTwoTerm){ 67 ppi[iParmNum].bArray=0; 68 ppi[iParmNum].bByVal=0; 69 ppi[iParmNum].name=0; 70 ppi[iParmNum].type=type[sp-1]; 71 ppi[iParmNum].u.index=index_stack[sp-1]; 72 ppi[iParmNum].SubScripts[0]=-1; 73 iParmNum++; 74 } 75 63 Parameters params; 64 65 if(bTwoTerm){ 66 params.push_back( new Parameter( "", Type( type[sp-1], index_stack[sp-1] ) ) ); 67 } 76 68 77 69 //オーバーロードを解決 … … 79 71 if(idCalc==CALC_EQUAL) lstrcpy(temporary,"=="); 80 72 else GetCalcName(idCalc,temporary); 81 SubInfo *psi; 82 psi=OverloadSolution(temporary,subs,ppi,iParmNum,pBaseTypeInfo); 83 84 if(!psi){ 85 HeapDefaultFree(ppi); 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 ); 79 80 if(!pUserProc){ 81 if(bTwoTerm){ 82 delete params[0]; 83 } 86 84 return -1; 87 85 } 88 86 else{ 89 87 //オーバーロードされていないが、パラメータ個数が一致しないとき 90 if(iParmNum!=psi->params.size()){ 91 HeapDefaultFree(ppi); 88 if(params.size()!=pUserProc->Params().size()){ 89 if(bTwoTerm){ 90 delete params[0]; 91 } 92 92 return -1; 93 93 } 94 94 } 95 95 96 for(i=0;i< iParmNum;i++){96 for(i=0;i<(int)params.size();i++){ 97 97 CheckDifferentType( 98 p si->params[i]->GetBasicType(),99 p si->params[i]->GetIndex(),100 p pi[i].type,101 p pi[i].u.index,98 pUserProc->Params()[i]->GetBasicType(), 99 pUserProc->Params()[i]->GetIndex(), 100 params[i]->GetBasicType(), 101 params[i]->GetIndex(), 102 102 "", 103 103 i); 104 104 } 105 105 106 HeapDefaultFree(ppi); 106 if(bTwoTerm){ 107 delete params[0]; 108 } 107 109 108 110 int right_side_size = GetTypeSize(type[sp-1],index_stack[sp-1]); 109 111 110 112 if(bTwoTerm){ 111 if( p si->realParams[1]->IsStruct() &&psi->realParams[1]->IsRef() == false ){113 if( pUserProc->RealParams()[1]->IsStruct() &&pUserProc->RealParams()[1]->IsRef() == false ){ 112 114 //一時オブジェクトはメソッド内で破棄される 113 115 bUseHeap[sp-1]=0; … … 116 118 117 119 118 if( psi->ReturnType==DEF_STRUCT){120 if( pUserProc->ReturnType().IsStruct() ){ 119 121 ////////////////////////////////////////////////////// 120 122 // 戻り値に構造体インスタンスを持つ場合 … … 122 124 ////////////////////////////////////////////////////// 123 125 124 int object_size = p si->u.Return_pobj_c->GetSize();126 int object_size = pUserProc->ReturnType().GetClass().GetSize(); 125 127 126 128 //push object_size … … 128 130 129 131 //call calloc 130 extern SubInfo*pSub_calloc;132 extern UserProc *pSub_calloc; 131 133 op_call(pSub_calloc); 132 134 … … 180 182 } 181 183 182 if( p si->realParams[1]->IsRef() ){184 if( pUserProc->RealParams()[1]->IsRef() ){ 183 185 //一時参照を作成 184 186 … … 191 193 } 192 194 193 if( psi->ReturnType==DEF_STRUCT){195 if( pUserProc->ReturnType().IsStruct() ){ 194 196 //push ebx 195 197 op_push(REG_EBX); … … 200 202 201 203 //call operator_proc 202 op_call(p si);203 204 if(bTwoTerm){ 205 if( p si->realParams[1]->IsRef() ){204 op_call(pUserProc); 205 206 if(bTwoTerm){ 207 if( pUserProc->RealParams()[1]->IsRef() ){ 206 208 //一時参照を破棄 207 209 op_pop( REG_NON ); … … 209 211 } 210 212 211 if( psi->ReturnType!=DEF_NON){213 if( !pUserProc->ReturnType().IsNull() ){ 212 214 //スタックへプッシュ 213 PushReturnValue(p si->ReturnType);215 PushReturnValue(pUserProc->ReturnType().GetBasicType()); 214 216 } 215 217 … … 222 224 223 225 sp--; 224 type[sp-1]=p si->ReturnType;225 index_stack[sp-1]=p si->u.ReturnIndex;226 227 if( psi->ReturnType==DEF_STRUCT){226 type[sp-1]=pUserProc->ReturnType().GetBasicType(); 227 index_stack[sp-1]=pUserProc->ReturnType().GetIndex(); 228 229 if( pUserProc->ReturnType().IsStruct() ){ 228 230 //構造体が戻ったときはヒープ領域にインスタンスが格納されている 229 231 //※後にfreeする必要あり … … 254 256 array_bUseHeap[1]=0; 255 257 256 T YPEINFOBaseTypeInfo={ToType,lpToIndex};258 Type BaseTypeInfo={ToType,lpToIndex}; 257 259 258 260 int iRet; … … 272 274 SetError(-1,"キャスト演算子がオーバーロードされていません。",cp); 273 275 } 274 void CallIndexerGetterProc(CClass *pobj_Class,char *ObjectName,char *Parameter,T YPEINFO&RetTypeInfo){275 std::vector< SubInfo*> subs;276 void CallIndexerGetterProc(CClass *pobj_Class,char *ObjectName,char *Parameter,Type &RetTypeInfo){ 277 std::vector<UserProc *> subs; 276 278 pobj_Class->EnumMethod( CALC_ARRAY_GET, subs ); 277 279 if( subs.size() == 0 ){ … … 280 282 281 283 Opcode_CallProc(Parameter,subs[0],0,ObjectName,DEF_OBJECT); 282 RetTypeInfo.type = subs[0]->ReturnType ;283 RetTypeInfo.u.lpIndex = subs[0]-> u.ReturnIndex;284 } 284 RetTypeInfo.type = subs[0]->ReturnType().GetBasicType(); 285 RetTypeInfo.u.lpIndex = subs[0]->ReturnType().GetIndex(); 286 }
Note:
See TracChangeset
for help on using the changeset viewer.