Changeset 436 in dev for trunk/abdev/BasicCompiler64/NumOpe.cpp
- Timestamp:
- Mar 15, 2008, 3:33:36 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/NumOpe.cpp
r430 r436 130 130 return true; 131 131 } 132 bool TermMemberOpe( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member, bool &isVariable, RELATIVE_VAR &relativeVar )132 bool TermMemberOpe( const Type &leftType, bool &isNeedHeapFreeStructure, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member, bool &isVariable, RELATIVE_VAR &relativeVar ) 133 133 { 134 134 const CClass &objClass = leftType.GetClass(); … … 218 218 // メンバが見つかったとき 219 219 220 if( isNeedHeapFreeStructure ) 221 { 222 if( !leftType.IsStruct() ) 223 { 224 SetError(); 225 } 226 227 pobj_reg->LockReg(); 228 229 // 親となる構造体が一時メモリに存在していた場合、後ほど解放する必要がある 230 compiler.codeGenerator.op_AddNeedFreeTempStructure( useReg ); 231 isNeedHeapFreeStructure = false; 232 233 pobj_reg->UnlockReg(); 234 } 235 220 236 //オブジェクトポインタをr11にコピー 221 237 compiler.codeGenerator.op_mov_RR( REG_R11, useReg ); … … 267 283 bool dummyIsVariable; 268 284 RELATIVE_VAR dummyRelativeVar; 269 TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, methodName, dummyIsVariable, dummyRelativeVar );285 TermMemberOpe( leftType, isNeedHeapFreeStructure, baseType, resultType, termFull, termLeft, methodName, dummyIsVariable, dummyRelativeVar ); 270 286 271 287 // 戻り値のオブジェクトインスタンスのインデクサを呼び出す … … 274 290 sprintf( temp2, "%s.%s", termLeft, methodName ); 275 291 Type classType = resultType; 276 return TermMemberOpe( classType, baseType, resultType, termFull, temp2, temporary, isVariable, relativeVar );292 return TermMemberOpe( classType, isNeedHeapFreeStructure, baseType, resultType, termFull, temp2, temporary, isVariable, relativeVar ); 277 293 } 278 294 … … 344 360 return false; 345 361 } 346 bool _TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly, bool &isVariable, RELATIVE_VAR &relativeVar, bool isWriteAccess )362 bool _TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool &isNeedHeapFreeStructure, bool *pIsClassName, bool isProcedureCallOnly, bool &isVariable, RELATIVE_VAR &relativeVar, bool isWriteAccess ) 347 363 { 348 364 char parameter[VN_SIZE]; … … 385 401 } 386 402 387 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){403 if( !TermOpe( termLeft, baseType, leftType, isLiteral, isNeedHeapFreeStructure, &isClassName ) ){ 388 404 goto globalArea; 389 405 } … … 403 419 } 404 420 405 return TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, member, isVariable, relativeVar );421 return TermMemberOpe( leftType, isNeedHeapFreeStructure, baseType, resultType, termFull, termLeft, member, isVariable, relativeVar ); 406 422 } 407 423 globalArea: … … 500 516 }//////////////////////////////////////////// 501 517 502 if(resultType.IsStruct()){ 518 if(resultType.IsStruct()) 519 { 503 520 //構造体が戻ったときはヒープ領域にインスタンスが格納されている 504 521 //※後にfreeする必要あり 505 522 // TODO: 解放はGCに任せる 506 *pbUseHeap = 1;523 isNeedHeapFreeStructure = true; 507 524 } 508 525 … … 628 645 }//////////////////////////////////////////// 629 646 630 if(resultType.IsStruct()){ 647 if(resultType.IsStruct()) 648 { 631 649 //構造体が戻ったときはヒープ領域にインスタンスが格納されている 632 650 //※後にfreeする必要あり 633 651 // TODO: 解放はGCに任せる 634 *pbUseHeap = 1;652 isNeedHeapFreeStructure = true; 635 653 } 636 654 … … 648 666 } 649 667 650 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly, bool isWriteAccess )668 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool &isNeedHeapFreeStructure, bool *pIsClassName, bool isProcedureCallOnly, bool isWriteAccess ) 651 669 { 652 670 bool isInitRegSwitch = false; … … 665 683 RELATIVE_VAR relativeVar; 666 684 bool isVariable = false; 667 bool result = _TermOpe( term, baseType, resultType, isLiteral, pbUseHeap, pIsClassName, isProcedureCallOnly, isVariable, relativeVar, isWriteAccess );685 bool result = _TermOpe( term, baseType, resultType, isLiteral, isNeedHeapFreeStructure, pIsClassName, isProcedureCallOnly, isVariable, relativeVar, isWriteAccess ); 668 686 669 687 if( isVariable ) … … 705 723 pobj_reg = new CRegister( REG_NON ); 706 724 707 bool isLiteral, isVariable = false ;708 bool result = _TermOpe( term, Type(), resultType, isLiteral, NULL, NULL, false, isVariable, relativeVar, isWriteAccess );725 bool isLiteral, isVariable = false, isNeedHeapFreeStructure = false; 726 bool result = _TermOpe( term, Type(), resultType, isLiteral, isNeedHeapFreeStructure, NULL, false, isVariable, relativeVar, isWriteAccess ); 709 727 710 728 if( !isVariable ) … … 731 749 const Type &baseType, 732 750 Type &resultType, 733 BOOL *pbUseHeap)751 bool *pbIsNeedHeapFreeStructure ) 734 752 { 735 753 int i,i2,i3; … … 892 910 LONG_PTR index_stack[255]; 893 911 bool isNothing_stack[255]; 894 BOOL bUseHeap[255];912 bool isNeedHeapFreeStructureStack[255]; 895 913 _int64 i64data; 896 914 int UseReg,XmmReg; … … 916 934 else{ 917 935 //オーバーロードされたオペレータを呼び出す 918 i2=CallOperatorProc(idCalc,baseType,type_stack,index_stack, bUseHeap,sp);936 i2=CallOperatorProc(idCalc,baseType,type_stack,index_stack,isNeedHeapFreeStructureStack,sp); 919 937 if(i2==0){ 920 938 if(idCalc==CALC_EQUAL) lstrcpy(temp2,"=="); … … 938 956 index_stack[sp]=-1; 939 957 isNothing_stack[sp] = false; 940 bUseHeap[sp]=0;958 isNeedHeapFreeStructureStack[sp] = false; 941 959 942 960 UseReg=pobj_reg->GetNextReg(); … … 1041 1059 1042 1060 bool isLiteral; 1043 if( TermOpe( term, baseType, resultType, isLiteral, &bUseHeap[sp] ) ){1061 if( TermOpe( term, baseType, resultType, isLiteral, isNeedHeapFreeStructureStack[sp] ) ){ 1044 1062 if(resultType.IsNull()){ 1045 1063 //戻り値が存在しないとき … … 1346 1364 } 1347 1365 1348 if(pbUseHeap) *pbUseHeap=bUseHeap[0]; 1366 if( pbIsNeedHeapFreeStructure ) 1367 { 1368 *pbIsNeedHeapFreeStructure = isNeedHeapFreeStructureStack[0]; 1369 } 1349 1370 1350 1371 if(IsRealNumberType(type_stack[0])) … … 1386 1407 const Type &baseType, 1387 1408 Type &resultType, 1388 BOOL *pbUseHeap)1409 bool *pbIsNeedHeapFreeStructure ) 1389 1410 { 1390 1411 bool isInitRegSwitch = false; … … 1403 1424 1404 1425 1405 bool result = _numope( pReg, expression, baseType, resultType, pb UseHeap);1426 bool result = _numope( pReg, expression, baseType, resultType, pbIsNeedHeapFreeStructure ); 1406 1427 1407 1428
Note:
See TracChangeset
for help on using the changeset viewer.