- Timestamp:
- Mar 6, 2008, 11:19:38 PM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_Calc.cpp
r402 r415 545 545 546 546 //型を識別 547 if( !Get VarType(variable,varType,false) ){547 if( !GetTermTypeOnlyVariable(variable,varType) ){ 548 548 549 549 // プロパティ用のメソッドを呼び出す … … 593 593 594 594 //変数アドレスを取得 595 if(!GetVarOffsetReadWrite( 596 variable, 597 &VarRelativeVar, 598 varType)) return; 595 if( !TermOpeOnlyVariable( variable, varType, VarRelativeVar, true ) ) 596 { 597 SetError(); 598 return; 599 } 599 600 600 601 if(varType.GetBasicType()&FLAG_PTR){ -
trunk/abdev/BasicCompiler32/Compile_CallProc.cpp
r370 r415 120 120 //"->"によってオブジェクトを指定する通常のメンバ関数呼び出し 121 121 Type varType; 122 GetVarType( ObjectName, varType, false ); 123 if( NATURAL_TYPE( varType.GetBasicType() ) == DEF_OBJECT ) 122 if( GetTermType( ObjectName, varType ) ) 124 123 { 125 pobj_c = &varType.GetClass(); 126 leftType = varType; 124 if( varType.IsObject() ) 125 { 126 pobj_c = &varType.GetClass(); 127 leftType = varType; 128 } 127 129 } 128 else 130 131 if( !pobj_c ) 129 132 { 130 133 pobj_c=compiler.GetObjectModule().meta.GetClasses().Find(ObjectName); … … 286 289 if(lstrcmpi(ObjectName,"Super")==0) goto InClassMember; 287 290 else{ 288 RELATIVE_VAR RelativeVar; 289 if( pMethod->IsConst() ){ 290 //Constアクセスが可能なメソッドの場合 291 if( !GetVarOffsetReadOnly( ObjectName, &RelativeVar, Type() ) ){ 292 return false; 293 } 291 bool isLiteral; 292 if( !TermOpe( ObjectName, Type(), Type(), isLiteral, NULL, NULL, false, !pMethod->IsConst() ) ) 293 { 294 return false; 294 295 } 295 else{ 296 //Constアクセスが不可能なメソッドの場合 297 if( !GetVarOffsetReadWrite( ObjectName, &RelativeVar, Type() ) ){ 298 return false; 299 } 300 } 301 302 SetVarPtrToEax(&RelativeVar); 303 304 // 参照を実体ポインタにする 305 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_ECX, REG_EAX, 0, MOD_BASE ); 296 297 // 実態ポインタをeaxにコピー 298 compiler.codeGenerator.op_mov_RR( REG_ECX, REG_EAX ); 306 299 } 307 300 } -
trunk/abdev/BasicCompiler32/Compile_Statement.cpp
r408 r415 93 93 bool isLiteral; 94 94 BOOL bUseHeap; 95 bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, false,NULL, true );95 bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, NULL, true ); 96 96 if( result ){ 97 97 -
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r407 r415 1651 1651 //リロケーション情報を解放 1652 1652 delete pobj_Reloc; 1653 1654 //クラスに関するメモリを解放1655 compiler.GetObjectModule().meta.GetClasses().Clear();1656 1653 } -
trunk/abdev/BasicCompiler32/NumOpe.cpp
r412 r415 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 )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 ) 143 143 { 144 144 const CClass &objClass = leftType.GetClass(); … … 179 179 compiler.codeGenerator.op_mov_RR( REG_ECX, useReg ); 180 180 181 RELATIVE_VAR relativeVar;182 relativeVar.dwKind=VAR_DIRECTMEM;181 RELATIVE_VAR tempRelativeVar; 182 tempRelativeVar.dwKind=VAR_DIRECTMEM; 183 183 184 184 if( !_member_offset( … … 186 186 false, //読み込み専用 187 187 leftType, 188 VarName,& relativeVar,classType,0)){188 VarName,&tempRelativeVar,classType,0)){ 189 189 return false; 190 190 } 191 191 192 192 // オブジェクトメンバのポインタをeaxにコピー 193 if( !VarToReg( relativeVar, baseType, resultType ) ){193 if( !VarToReg( tempRelativeVar, baseType, resultType ) ){ 194 194 SetError(11,termFull,cp); 195 195 } … … 225 225 compiler.codeGenerator.op_mov_RR( REG_ECX, useReg ); 226 226 227 RELATIVE_VAR relativeVar;228 227 relativeVar.dwKind=VAR_DIRECTMEM; 229 228 … … 236 235 } 237 236 238 if( !VarToReg( relativeVar, baseType, resultType ) ){ 239 SetError(11,termFull,cp); 240 } 237 // 変数として扱う 238 isVariable = true; 241 239 242 240 return true; … … 271 269 272 270 // まずはプロパティ値を取得 273 TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, methodName ); 271 bool dummyIsVariable; 272 RELATIVE_VAR dummyRelativeVar; 273 TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, methodName, dummyIsVariable, dummyRelativeVar ); 274 274 275 275 // 戻り値のオブジェクトインスタンスのインデクサを呼び出す … … 278 278 sprintf( temp2, "%s.%s", termLeft, methodName ); 279 279 Type classType = resultType; 280 return TermMemberOpe( classType, baseType, resultType, termFull, temp2, temporary );280 return TermMemberOpe( classType, baseType, resultType, termFull, temp2, temporary, isVariable, relativeVar ); 281 281 } 282 282 … … 324 324 return false; 325 325 } 326 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool isWantObject, bool *pIsClassName, bool isProcedureCallOnly ){ 326 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 ) 327 { 327 328 char parameter[VN_SIZE]; 328 329 … … 364 365 } 365 366 366 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, true,&isClassName ) ){367 if( !TermOpe( termLeft, baseType, leftType, isLiteral, pbUseHeap, &isClassName ) ){ 367 368 goto globalArea; 368 369 } … … 382 383 } 383 384 384 return TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, member );385 return TermMemberOpe( leftType, baseType, resultType, termFull, termLeft, member, isVariable, relativeVar ); 385 386 } 386 387 globalArea: … … 545 546 //////////////////////////////// 546 547 547 RELATIVE_VAR relativeVar;548 548 if(GetVarOffset( 549 549 false, //エラー表示なし 550 false, //読み込み専用550 isWriteAccess, 551 551 termFull, 552 552 &relativeVar,resultType)){ … … 555 555 ////////// 556 556 557 if( !VarToReg( relativeVar, baseType, resultType ) ){ 558 SetError(11,termFull,cp); 559 } 557 // 変数として扱う 558 isVariable = true; 560 559 561 560 isLiteral = false; … … 610 609 611 610 return false; 611 } 612 613 bool TermOpe( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, BOOL *pbUseHeap, bool *pIsClassName, bool isProcedureCallOnly, bool isWriteAccess ) 614 { 615 RELATIVE_VAR relativeVar; 616 bool isVariable = false; 617 bool result = _TermOpe( term, baseType, resultType, isLiteral, pbUseHeap, pIsClassName, isProcedureCallOnly, isVariable, relativeVar, isWriteAccess ); 618 619 if( isVariable ) 620 { 621 // 変数の場合はeaxに変数ポインタを格納する 622 if( !VarToReg( relativeVar, baseType, resultType ) ){ 623 SetError(11,term,cp); 624 } 625 } 626 627 return result; 628 } 629 bool TermOpeOnlyVariable( const char *term, Type &resultType, RELATIVE_VAR &relativeVar, bool isWriteAccess ) 630 { 631 bool isLiteral, isVariable = false; 632 bool result = _TermOpe( term, Type(), resultType, isLiteral, NULL, NULL, false, isVariable, relativeVar, isWriteAccess ); 633 634 if( !isVariable ) 635 { 636 SetError(); 637 } 638 639 return result; 612 640 } 613 641 -
trunk/abdev/BasicCompiler32/Opcode.h
r376 r415 59 59 //NumOpe.cpp 60 60 void PushReturnValue(int type); 61 bool TermOpeOnlyVariable( const char *term, Type &resultType, RELATIVE_VAR &relativeVar, bool isWriteAccess ); 61 62 bool TermOpe( 62 63 const char *term, … … 65 66 bool &isLiteral, 66 67 BOOL *pbUseHeap, 67 bool isWantObject = false,68 68 bool *pIsClassName = NULL, 69 bool isProcedureCallOnly = false ); 69 bool isProcedureCallOnly = false, 70 bool isWriteAccess = false ); 70 71 bool NumOpe( int reg, 71 72 const char *expression, -
trunk/abdev/BasicCompiler_Common/NumOpe_GetType.cpp
r412 r415 298 298 } 299 299 300 bool GetMemberTermType( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member )300 bool GetMemberTermType( const Type &leftType, const Type &baseType, Type &resultType, const char *termFull, const char *termLeft, const char *member, bool *pIsVariable ) 301 301 { 302 302 //////////////////////////////// … … 325 325 if( GetMemberType( leftType, member, resultType, 0, false ) ){ 326 326 // メンバが見つかったとき 327 328 if( pIsVariable ) 329 { 330 *pIsVariable = true; 331 } 332 327 333 return true; 328 334 } … … 357 363 } 358 364 359 bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName )365 bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName, bool *pIsVariable ) 360 366 { 361 367 char parameter[VN_SIZE]; … … 415 421 } 416 422 417 return GetMemberTermType( leftType, baseType, resultType, termFull, termLeft, member );423 return GetMemberTermType( leftType, baseType, resultType, termFull, termLeft, member, pIsVariable ); 418 424 } 419 425 … … 551 557 isLiteral = false; 552 558 559 if( pIsVariable ) 560 { 561 // 変数である 562 *pIsVariable = true; 563 } 564 553 565 return true; 554 566 } … … 572 584 573 585 return false; 586 } 587 588 bool GetTermType( const char *term, Type &resultType ) 589 { 590 bool isLiteral; 591 return GetTermType( term, Type(), resultType, isLiteral ); 592 } 593 594 bool GetTermTypeOnlyVariable( const char *term, Type &resultType ) 595 { 596 bool isLiteral, isVariable = false; 597 bool result = GetTermType( term, Type(), resultType, isLiteral, NULL, &isVariable ); 598 return ( result && isVariable ); 574 599 } 575 600 -
trunk/abdev/BasicCompiler_Common/common.h
r400 r415 350 350 int AutoBigCast(int BaseType,int CalcType); 351 351 BOOL CheckCalcType(int idCalc,int *type,int sp); 352 bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL ); 352 bool GetTermType( const char *term, const Type &baseType, Type &resultType, bool &isLiteral, bool *pIsClassName = NULL, bool *pIsVariable = NULL ); 353 bool GetTermType( const char *term, Type &resultType ); 354 bool GetTermTypeOnlyVariable( const char *term, Type &resultType ); 353 355 bool NumOpe_GetType( const char *expression, const Type &baseType, Type &resultType, bool *pIsLiteralCalculation = NULL ); 354 356 -
trunk/abdev/BasicCompiler_Common/hash.cpp
r350 r415 72 72 //"->"によってオブジェクトを指定する通常のメンバ関数呼び出し 73 73 Type type; 74 if( GetVarType(ObjName,type,0) ){ 75 pobj_c = &type.GetClass(); 74 if( GetTermType(ObjName,type) ) 75 { 76 if( type.IsObject() ) 77 { 78 pobj_c = &type.GetClass(); 79 } 76 80 } 77 else{ 81 82 if( !pobj_c ) 83 { 78 84 pobj_c=compiler.GetObjectModule().meta.GetClasses().Find(ObjName); 79 85 if( pobj_c ){
Note:
See TracChangeset
for help on using the changeset viewer.