Changeset 330 in dev for trunk/abdev
- Timestamp:
- Sep 26, 2007, 3:00:09 AM (17 years ago)
- Location:
- trunk/abdev/BasicCompiler64
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler64/Compile_CallProc.cpp
r325 r330 24 24 } 25 25 26 bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer) {27 26 bool Opcode_CallProcPtr( const char *variable, const char *lpszParms,ProcPointer *pProcPointer) 27 { 28 28 extern BOOL bDebugCompile; 29 29 extern BOOL bDebugSupportProc; … … 475 475 } 476 476 477 void UnsafeCall( const char *methodPtrValueStr, const char *params )477 void Opcode_CallDelegate( const Delegate &dg, const char *methodPtrValueStr, const char *objPtrValueStr, const char *params ) 478 478 { 479 /////////////////////////////////////////////////////////////// 480 // _System_LocalThisのダミーをセット 481 /////////////////////////////////////////////////////////////// 482 483 char temporary[VN_SIZE]={0}; 484 if( objPtrValueStr && objPtrValueStr[0] ){ 485 //_System_LocalThis(第一パラメータ)のダミーを作成 486 lstrcpy(temporary,"0,"); 487 } 488 if( dg.ReturnType().IsStruct() ){ 489 // ※ByRef _System_ReturnValue パラメータのダミーをセット 490 lstrcat(temporary,"0,"); 491 } 492 493 if(params[0]=='\0'&&temporary[0]) 494 temporary[lstrlen(temporary)-1]=0; 495 else lstrcat(temporary,params); 496 497 498 ParamImpl *pobj_parameter = new ParamImpl( params ); 499 500 //スタックフレームに存在する既存のパラメータをバックアップ 501 pobj_parameter->BackupParameter( (int)dg.Params().size() ); 502 503 //一時オブジェクトを生成 504 pobj_parameter->NewTempParameters( dg.GetName(), dg.Params() ); 505 506 //レジスタ、スタックフレームにセット 507 pobj_parameter->SetParameter( dg.GetName(), dg.Params() ); 508 509 510 if( objPtrValueStr && objPtrValueStr[0] ) 511 { 512 RELATIVE_VAR RelativeVar; 513 //Constアクセスが不可能なメソッドの場合 514 if( !GetVarOffsetReadWrite( objPtrValueStr, &RelativeVar, Type() ) ){ 515 Jenga::Throw( "Opcode_CallDelegate関数内で呼ばれるGetVarOffsetReadWrite関数に失敗" ); 516 return; 517 } 518 519 SetVarPtrToReg(REG_RCX,&RelativeVar); 520 521 // 参照を実体ポインタにする 522 //mov rcx,qword ptr[rcx] 523 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_RCX,REG_RCX,0,MOD_BASE); 524 } 525 526 527 { 528 //////////////////////// 529 // call 530 //////////////////////// 531 RELATIVE_VAR RelativeVar; 532 GetVarOffsetReadOnly( methodPtrValueStr, &RelativeVar, Type() ); 533 SetVarPtrToReg(REG_RAX,&RelativeVar); 534 535 //mov rax,qword ptr[rax] 536 compiler.codeGenerator.op_mov_RM(sizeof(_int64),REG_RAX,REG_RAX,0,MOD_BASE); 537 538 //call rax 539 compiler.codeGenerator.PutOld( 540 (char)0xFF, 541 (char)0xD0 542 ); 543 } 544 545 546 //レジスタのブロッキングを解除 ※パラメータセット時にロックされたレジスタ 547 pobj_BlockReg->clear(); 548 549 //一時オブジェクトを破棄 550 pobj_parameter->DeleteTempParameters(); 551 552 //スタックフレームに存在する既存のパラメータを復元 553 pobj_parameter->RestoreParameter( (int)dg.Params().size() ); 554 555 //パラメータオブジェクトを破棄 556 delete pobj_parameter; 479 557 } -
trunk/abdev/BasicCompiler64/Compile_Func.cpp
r325 r330 14 14 if( lstrcmpi( FuncName, "VarPtr" ) == 0 ) return FUNC_VARPTR; 15 15 if( lstrcmpi( FuncName, "ObjPtr" ) == 0 ) return FUNC_OBJPTR; 16 if( lstrcmpi( FuncName, "__unsafe_call" ) == 0 ) return FUNC_UNSAFE_CALL; 16 if( lstrcmpi( FuncName, "__delegate_dynamicmethod_call" ) == 0 ) return FUNC_DELEGATE_DYNAMICMETHOD_CALL; 17 if( lstrcmpi( FuncName, "__delegate_staticmethod_call" ) == 0 ) return FUNC_DELEGATE_STATICMETHOD_CALL; 17 18 if( lstrcmpi( FuncName, "GetDouble" ) == 0 ) return FUNC_GETDOUBLE; 18 19 if( lstrcmpi( FuncName, "GetSingle" ) == 0 ) return FUNC_GETSINGLE; … … 253 254 } 254 255 255 void Opcode_Func_ unsafe_call( const char *paramsStr, Type &resultType, bool isCallOn )256 void Opcode_Func_delegate_call( const char *paramsStr, Type &resultType, bool isDynamicCall, bool isCallOn ) 256 257 { 257 258 if( isCallOn ) 258 259 { 259 260 int i = 0; 260 char methodPtrParamStr[8192]; 261 GetOneParameter( paramsStr, i, methodPtrParamStr ); 262 UnsafeCall( methodPtrParamStr, paramsStr + i ); 261 char methodPtrParamStr[VN_SIZE]; 262 i = GetOneParameter( paramsStr, i, methodPtrParamStr ); 263 264 char objPtrValueStr[VN_SIZE]; 265 if( isDynamicCall ) 266 { 267 i = GetOneParameter( paramsStr, i, objPtrValueStr ); 268 } 269 270 Opcode_CallDelegate( compiler.pCompilingClass->GetDelegate(), methodPtrParamStr, objPtrValueStr, paramsStr + i ); 263 271 } 264 272 … … 311 319 Opcode_Func_ObjPtr( Parameter, resultType, isCallOn ); 312 320 break; 313 case FUNC_UNSAFE_CALL: 314 Opcode_Func_unsafe_call( Parameter, resultType, isCallOn ); 321 case FUNC_DELEGATE_DYNAMICMETHOD_CALL: 322 Opcode_Func_delegate_call( Parameter, resultType, true, isCallOn ); 323 break; 324 case FUNC_DELEGATE_STATICMETHOD_CALL: 325 Opcode_Func_delegate_call( Parameter, resultType, false, isCallOn ); 315 326 break; 316 327 -
trunk/abdev/BasicCompiler64/FunctionValue.h
r325 r330 14 14 #define FUNC_ADDRESSOF 0x0619 15 15 #define FUNC_SIZEOF 0x0620 16 #define FUNC_UNSAFE_CALL 0x0621 16 #define FUNC_DELEGATE_DYNAMICMETHOD_CALL 0x0621 17 #define FUNC_DELEGATE_STATICMETHOD_CALL 0x0622 17 18 18 19 //ポインタ -
trunk/abdev/BasicCompiler64/Opcode.h
r327 r330 327 327 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName); 328 328 bool Opcode_CallDllProc( const char *lpszParms,DllProc *pDllProc); 329 void UnsafeCall( const char *methodPtrValueStr, const char *params );329 void Opcode_CallDelegate( const Delegate &dg, const char *methodPtrValueStr, const char *objPtrValueStr, const char *params ); 330 330 331 331 //Compile_ProcOp.cpp
Note:
See TracChangeset
for help on using the changeset viewer.