Changeset 435 in dev for trunk/abdev/BasicCompiler32/NumOpe.cpp
- Timestamp:
- Mar 15, 2008, 1:20:13 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/NumOpe.cpp
r429 r435 140 140 return true; 141 141 } 142 bool TermMemberOpe( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member, bool &isVariable, RELATIVE_VAR &relativeVar )142 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 ) 143 143 { 144 144 const CClass &objClass = leftType.GetClass(); … … 222 222 // メンバが見つかったとき 223 223 224 if( isNeedHeapFreeStructure ) 225 { 226 if( !leftType.IsStruct() ) 227 { 228 SetError(); 229 } 230 231 // 親となる構造体が一時メモリに存在していた場合、後ほど解放する必要がある 232 compiler.codeGenerator.op_AddNeedFreeTempStructure( useReg ); 233 isNeedHeapFreeStructure = false; 234 } 235 224 236 //オブジェクトポインタをecxにコピー 225 237 compiler.codeGenerator.op_mov_RR( REG_ECX, useReg ); … … 271 283 bool dummyIsVariable; 272 284 RELATIVE_VAR dummyRelativeVar; 273 TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, methodName, dummyIsVariable, dummyRelativeVar );285 TermMemberOpe( leftType, isNeedHeapFreeStructure, baseType, resultType, termFull, termLeft, methodName, dummyIsVariable, dummyRelativeVar ); 274 286 275 287 // 戻り値のオブジェクトインスタンスのインデクサを呼び出す … … 278 290 sprintf( temp2, "%s.%s", termLeft, methodName ); 279 291 Type classType = resultType; 280 return TermMemberOpe( classType, baseType, resultType, termFull, temp2, temporary, isVariable, relativeVar );292 return TermMemberOpe( classType, isNeedHeapFreeStructure, baseType, resultType, termFull, temp2, temporary, isVariable, relativeVar ); 281 293 } 282 294 … … 336 348 return false; 337 349 } 338 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 )350 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 ) 339 351 { 340 352 char parameter[VN_SIZE]; … … 377 389 } 378 390 379 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){391 if( !TermOpe( termLeft, baseType, leftType, isLiteral, isNeedHeapFreeStructure, &isClassName ) ){ 380 392 goto globalArea; 381 393 } … … 395 407 } 396 408 397 return TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, member, isVariable, relativeVar );409 return TermMemberOpe( leftType, isNeedHeapFreeStructure, baseType, resultType, termFull, termLeft, member, isVariable, relativeVar ); 398 410 } 399 411 globalArea: … … 492 504 493 505 494 if(resultType.IsStruct()){ 506 if(resultType.IsStruct()) 507 { 495 508 //構造体が戻ったときはヒープ領域にインスタンスが格納されている 496 509 //※後にfreeする必要あり 497 510 // TODO: 解放はGCに任せる 498 *pbUseHeap = 1;511 isNeedHeapFreeStructure = true; 499 512 } 500 513 … … 603 616 604 617 605 if(resultType.IsStruct()){ 618 if(resultType.IsStruct()) 619 { 606 620 //構造体が戻ったときはヒープ領域にインスタンスが格納されている 607 621 //※後にfreeする必要あり 608 622 // TODO: 解放はGCに任せる 609 *pbUseHeap = 1;623 isNeedHeapFreeStructure = true; 610 624 } 611 625 … … 623 637 } 624 638 625 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly, bool isWriteAccess )639 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool &isNeedHeapFreeStructure, bool *pIsClassName, bool isProcedureCallOnly, bool isWriteAccess ) 626 640 { 627 641 RELATIVE_VAR relativeVar; 628 642 bool isVariable = false; 629 bool result = _TermOpe( term, baseType, resultType, isLiteral, pbUseHeap, pIsClassName, isProcedureCallOnly, isVariable, relativeVar, isWriteAccess );643 bool result = _TermOpe( term, baseType, resultType, isLiteral, isNeedHeapFreeStructure, pIsClassName, isProcedureCallOnly, isVariable, relativeVar, isWriteAccess ); 630 644 631 645 if( isVariable ) … … 641 655 bool TermOpeOnlyVariable( const char *term, Type &resultType, RELATIVE_VAR &relativeVar, bool isWriteAccess ) 642 656 { 643 bool isLiteral, isVariable = false ;644 bool result = _TermOpe( term, Type(), resultType, isLiteral, NULL, NULL, false, isVariable, relativeVar, isWriteAccess );657 bool isLiteral, isVariable = false, isNeedHeapFreeStructure = false; 658 bool result = _TermOpe( term, Type(), resultType, isLiteral, isNeedHeapFreeStructure, NULL, false, isVariable, relativeVar, isWriteAccess ); 645 659 646 660 if( !isVariable ) … … 823 837 bool isNothing_stack[255]; 824 838 LONG_PTR index_stack[255]; 825 BOOL bUseHeap[255];839 bool isNeedHeapFreeStructureStack[255]; 826 840 _int64 i64data; 827 841 for(i=0,sp=0;i<pnum;i++){ … … 845 859 else{ 846 860 //オーバーロードされたオペレータを呼び出す 847 i2=CallOperatorProc(idCalc,baseType,type_stack,index_stack, bUseHeap,sp);861 i2=CallOperatorProc(idCalc,baseType,type_stack,index_stack,isNeedHeapFreeStructureStack,sp); 848 862 if(i2==0){ 849 863 if(idCalc==CALC_EQUAL) lstrcpy(temp2,"=="); … … 867 881 index_stack[sp]=-1; 868 882 isNothing_stack[sp] = false; 869 bUseHeap[sp]=0;883 isNeedHeapFreeStructureStack[sp] = false; 870 884 871 885 char *term; … … 954 968 955 969 bool isLiteral; 956 if( TermOpe( term, baseType, resultType, isLiteral, &bUseHeap[sp] ) ){970 if( TermOpe( term, baseType, resultType, isLiteral, isNeedHeapFreeStructureStack[sp] ) ){ 957 971 if(resultType.IsNull()){ 958 972 //戻り値が存在しないとき … … 1260 1274 } 1261 1275 1262 if(pbUseHeap) *pbUseHeap =bUseHeap[0];1276 if(pbUseHeap) *pbUseHeap = isNeedHeapFreeStructureStack[0]; 1263 1277 1264 1278 resultType.SetType( type_stack[0], index_stack[0] );
Note:
See TracChangeset
for help on using the changeset viewer.