Changeset 325 in dev for trunk/abdev
- Timestamp:
- Sep 25, 2007, 8:56:38 AM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/Compile_CallProc.cpp
r320 r325 424 424 return true; 425 425 } 426 427 void Opcode_CallDelegate( const Delegate &dg, const char *methodPtrValueStr, const char *objPtrValueStr, const char *params ) 428 { 429 /////////////////////////////////////////////////////////////// 430 // _System_LocalThisのダミーをセット 431 /////////////////////////////////////////////////////////////// 432 433 char temporary[VN_SIZE]={0}; 434 if( objPtrValueStr && objPtrValueStr[0] ){ 435 //_System_LocalThis(第一パラメータ)のダミーを作成 436 lstrcpy(temporary,"0,"); 437 } 438 if( dg.ReturnType().IsStruct() ){ 439 // ※ByRef _System_ReturnValue パラメータのダミーをセット 440 lstrcat(temporary,"0,"); 441 } 442 443 if(params[0]=='\0'&&temporary[0]) 444 temporary[lstrlen(temporary)-1]=0; 445 else lstrcat(temporary,params); 446 447 448 ParamImpl *pobj_parameter = new ParamImpl( params ); 449 450 //一時オブジェクトを生成 451 pobj_parameter->NewTempParameters( dg.GetName(), dg.Params() ); 452 453 //レジスタ、スタックフレームにセット 454 int ParmSize = pobj_parameter->SetParameter( dg.GetName(), dg.Params() ); 455 456 457 if( objPtrValueStr && objPtrValueStr[0] ) 458 { 459 RELATIVE_VAR RelativeVar; 460 //Constアクセスが不可能なメソッドの場合 461 if( !GetVarOffsetReadWrite( objPtrValueStr, &RelativeVar, Type() ) ){ 462 Jenga::Throw( "Opcode_CallDelegate関数内で呼ばれるGetVarOffsetReadWrite関数に失敗" ); 463 return; 464 } 465 466 SetVarPtrToEax(&RelativeVar); 467 468 // 参照を実体ポインタにする 469 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_ECX, REG_EAX, 0, MOD_BASE ); 470 471 //push ecx 472 compiler.codeGenerator.op_push(REG_ECX); 473 } 474 475 476 { 477 //////////////////////// 478 // call 479 //////////////////////// 480 RELATIVE_VAR RelativeVar; 481 GetVarOffsetReadOnly( methodPtrValueStr, &RelativeVar, Type() ); 482 SetVarPtrToEax( &RelativeVar ); 483 484 //mov eax,dword ptr[eax] 485 compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_EAX, 0, MOD_BASE ); 486 487 //call eax 488 compiler.codeGenerator.op_call_R( REG_EAX ); 489 } 490 491 492 //一時オブジェクトを破棄 493 pobj_parameter->DeleteTempParameters(); 494 495 //パラメータオブジェクトを破棄 496 delete pobj_parameter; 497 } -
trunk/abdev/BasicCompiler32/Compile_Func.cpp
r301 r325 9 9 10 10 int GetFunctionFromName(char *FuncName){ 11 if(lstrcmpi(FuncName,"CUDbl")==0) return FUNC_CUDBL; 12 if(lstrcmpi(FuncName,"Fix")==0) return FUNC_FIX; 13 if(lstrcmpi(FuncName,"Len")==0) return FUNC_LEN; 14 if(lstrcmpi(FuncName,"AddressOf")==0) return FUNC_ADDRESSOF; 15 if(lstrcmpi(FuncName,"SizeOf")==0) return FUNC_SIZEOF; 16 if(lstrcmpi(FuncName,"VarPtr")==0) return FUNC_VARPTR; 17 if(lstrcmpi(FuncName,"ObjPtr")==0) return FUNC_OBJPTR; 18 if(lstrcmpi(FuncName,"GetDouble")==0) return FUNC_GETDOUBLE; 19 if(lstrcmpi(FuncName,"GetSingle")==0) return FUNC_GETSINGLE; 20 if(lstrcmpi(FuncName,"GetQWord")==0) return FUNC_GETQWORD; 21 if(lstrcmpi(FuncName,"GetDWord")==0) return FUNC_GETDWORD; 22 if(lstrcmpi(FuncName,"GetWord")==0) return FUNC_GETWORD; 23 if(lstrcmpi(FuncName,"GetByte")==0) return FUNC_GETBYTE; 11 if( lstrcmpi( FuncName, "CUDbl" ) == 0 ) return FUNC_CUDBL; 12 if( lstrcmpi( FuncName, "Fix" ) == 0 ) return FUNC_FIX; 13 if( lstrcmpi( FuncName, "Len" ) == 0 ) return FUNC_LEN; 14 if( lstrcmpi( FuncName, "AddressOf" ) == 0 ) return FUNC_ADDRESSOF; 15 if( lstrcmpi( FuncName, "SizeOf" ) == 0 ) return FUNC_SIZEOF; 16 if( lstrcmpi( FuncName, "VarPtr" ) == 0 ) return FUNC_VARPTR; 17 if( lstrcmpi( FuncName, "ObjPtr" ) == 0 ) return FUNC_OBJPTR; 18 if( lstrcmpi( FuncName, "__delegate_dynamicmethod_call" ) == 0 ) return FUNC_DELEGATE_DYNAMICMETHOD_CALL; 19 if( lstrcmpi( FuncName, "__delegate_staticmethod_call" ) == 0 ) return FUNC_DELEGATE_STATICMETHOD_CALL; 20 if( lstrcmpi( FuncName, "GetDouble" ) == 0 ) return FUNC_GETDOUBLE; 21 if( lstrcmpi( FuncName, "GetSingle" ) == 0 ) return FUNC_GETSINGLE; 22 if( lstrcmpi( FuncName, "GetQWord" ) == 0 ) return FUNC_GETQWORD; 23 if( lstrcmpi( FuncName, "GetDWord" ) == 0 ) return FUNC_GETDWORD; 24 if( lstrcmpi( FuncName, "GetWord" ) == 0 ) return FUNC_GETWORD; 25 if( lstrcmpi( FuncName, "GetByte" ) == 0 ) return FUNC_GETBYTE; 24 26 return 0; 25 27 } … … 394 396 } 395 397 } 398 399 void Opcode_Func_delegate_call( const char *paramsStr, Type &resultType, bool isDynamicCall, bool isCallOn ) 400 { 401 if( isCallOn ) 402 { 403 int i = 0; 404 char methodPtrParamStr[VN_SIZE]; 405 i = GetOneParameter( paramsStr, i, methodPtrParamStr ); 406 407 char objPtrValueStr[VN_SIZE]; 408 if( isDynamicCall ) 409 { 410 i = GetOneParameter( paramsStr, i, objPtrValueStr ); 411 } 412 413 Opcode_CallDelegate( compiler.pCompilingClass->GetDelegate(), methodPtrParamStr, objPtrValueStr, paramsStr + i ); 414 } 415 416 resultType = UserProc::CompilingUserProc().ReturnType(); 417 } 418 396 419 void Opcode_Func_GetPtrData(const char *Parameter,const int type){ 397 420 Type tempType; … … 482 505 Opcode_Func_ObjPtr( Parameter, resultType, isCallOn ); 483 506 break; 507 case FUNC_DELEGATE_DYNAMICMETHOD_CALL: 508 Opcode_Func_delegate_call( Parameter, resultType, true, isCallOn ); 509 break; 510 case FUNC_DELEGATE_STATICMETHOD_CALL: 511 Opcode_Func_delegate_call( Parameter, resultType, false, isCallOn ); 512 break; 484 513 485 514 case FUNC_GETDOUBLE: -
trunk/abdev/BasicCompiler32/FunctionValue.h
r109 r325 13 13 14 14 //その他 15 #define FUNC_ADDRESSOF 0x0619 16 #define FUNC_SIZEOF 0x0620 15 #define FUNC_ADDRESSOF 0x0619 16 #define FUNC_SIZEOF 0x0620 17 #define FUNC_DELEGATE_DYNAMICMETHOD_CALL 0x0621 18 #define FUNC_DELEGATE_STATICMETHOD_CALL 0x0622 17 19 18 20 //ポインタ 19 #define FUNC_GETDOUBLE 0x063020 #define FUNC_GETSINGLE 0x063121 #define FUNC_GETQWORD 0x063222 #define FUNC_GETDWORD 0x063323 #define FUNC_GETWORD 0x063424 #define FUNC_GETBYTE 0x063521 #define FUNC_GETDOUBLE 0x0630 22 #define FUNC_GETSINGLE 0x0631 23 #define FUNC_GETQWORD 0x0632 24 #define FUNC_GETDWORD 0x0633 25 #define FUNC_GETWORD 0x0634 26 #define FUNC_GETBYTE 0x0635 -
trunk/abdev/BasicCompiler32/Opcode.h
r316 r325 215 215 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName ); 216 216 bool Opcode_CallDllProc( const char *lpszParms, const DllProc *pDllProc ); 217 void Opcode_CallDelegate( const Delegate &dg, const char *methodPtrValueStr, const char *objPtrValueStr, const char *params ); 217 218 218 219 //Compile_ProcOp.cpp -
trunk/abdev/BasicCompiler64/Compile_CallProc.cpp
r320 r325 474 474 return true; 475 475 } 476 477 void UnsafeCall( const char *methodPtrValueStr, const char *params ) 478 { 479 } -
trunk/abdev/BasicCompiler64/Compile_Func.cpp
r308 r325 9 9 10 10 int GetFunctionFromName(char *FuncName){ 11 if(lstrcmpi(FuncName,"Len")==0) return FUNC_LEN; 12 if(lstrcmpi(FuncName,"AddressOf")==0) return FUNC_ADDRESSOF; 13 if(lstrcmpi(FuncName,"SizeOf")==0) return FUNC_SIZEOF; 14 if(lstrcmpi(FuncName,"VarPtr")==0) return FUNC_VARPTR; 15 if(lstrcmpi(FuncName,"ObjPtr")==0) return FUNC_OBJPTR; 16 if(lstrcmpi(FuncName,"GetDouble")==0) return FUNC_GETDOUBLE; 17 if(lstrcmpi(FuncName,"GetSingle")==0) return FUNC_GETSINGLE; 18 if(lstrcmpi(FuncName,"GetQWord")==0) return FUNC_GETQWORD; 19 if(lstrcmpi(FuncName,"GetDWord")==0) return FUNC_GETDWORD; 20 if(lstrcmpi(FuncName,"GetWord")==0) return FUNC_GETWORD; 21 if(lstrcmpi(FuncName,"GetByte")==0) return FUNC_GETBYTE; 11 if( lstrcmpi( FuncName, "Len" ) == 0 ) return FUNC_LEN; 12 if( lstrcmpi( FuncName, "AddressOf" ) == 0 ) return FUNC_ADDRESSOF; 13 if( lstrcmpi( FuncName, "SizeOf" ) == 0 ) return FUNC_SIZEOF; 14 if( lstrcmpi( FuncName, "VarPtr" ) == 0 ) return FUNC_VARPTR; 15 if( lstrcmpi( FuncName, "ObjPtr" ) == 0 ) return FUNC_OBJPTR; 16 if( lstrcmpi( FuncName, "__unsafe_call" ) == 0 ) return FUNC_UNSAFE_CALL; 17 if( lstrcmpi( FuncName, "GetDouble" ) == 0 ) return FUNC_GETDOUBLE; 18 if( lstrcmpi( FuncName, "GetSingle" ) == 0 ) return FUNC_GETSINGLE; 19 if( lstrcmpi( FuncName, "GetQWord" ) == 0 ) return FUNC_GETQWORD; 20 if( lstrcmpi( FuncName, "GetDWord" ) == 0 ) return FUNC_GETDWORD; 21 if( lstrcmpi( FuncName, "GetWord" ) == 0 ) return FUNC_GETWORD; 22 if( lstrcmpi( FuncName, "GetByte" ) == 0 ) return FUNC_GETBYTE; 22 23 return 0; 23 24 } … … 251 252 } 252 253 } 254 255 void Opcode_Func_unsafe_call( const char *paramsStr, Type &resultType, bool isCallOn ) 256 { 257 if( isCallOn ) 258 { 259 int i = 0; 260 char methodPtrParamStr[8192]; 261 GetOneParameter( paramsStr, i, methodPtrParamStr ); 262 UnsafeCall( methodPtrParamStr, paramsStr + i ); 263 } 264 265 resultType = UserProc::CompilingUserProc().ReturnType(); 266 } 267 253 268 void Opcode_Func_GetPtrData( const char *Parameter, const int type ){ 254 269 int reg=REG_RAX; … … 296 311 Opcode_Func_ObjPtr( Parameter, resultType, isCallOn ); 297 312 break; 313 case FUNC_UNSAFE_CALL: 314 Opcode_Func_unsafe_call( Parameter, resultType, isCallOn ); 315 break; 298 316 299 317 case FUNC_GETDOUBLE: -
trunk/abdev/BasicCompiler64/FunctionValue.h
r109 r325 12 12 13 13 //その他 14 #define FUNC_ADDRESSOF 0x0619 15 #define FUNC_SIZEOF 0x0620 14 #define FUNC_ADDRESSOF 0x0619 15 #define FUNC_SIZEOF 0x0620 16 #define FUNC_UNSAFE_CALL 0x0621 16 17 17 18 //ポインタ 18 #define FUNC_GETDOUBLE 0x063019 #define FUNC_GETSINGLE 0x063120 #define FUNC_GETQWORD 0x063221 #define FUNC_GETDWORD 0x063422 #define FUNC_GETWORD 0x063523 #define FUNC_GETBYTE 0x063619 #define FUNC_GETDOUBLE 0x0630 20 #define FUNC_GETSINGLE 0x0631 21 #define FUNC_GETQWORD 0x0632 22 #define FUNC_GETDWORD 0x0634 23 #define FUNC_GETWORD 0x0635 24 #define FUNC_GETBYTE 0x0636 -
trunk/abdev/BasicCompiler64/Opcode.h
r316 r325 333 333 bool Opcode_CallProc(const char *Parameter,const UserProc *pUserProc,DWORD dwFlags,const char *ObjectName); 334 334 bool Opcode_CallDllProc( const char *lpszParms,DllProc *pDllProc); 335 void UnsafeCall( const char *methodPtrValueStr, const char *params ); 335 336 336 337 //Compile_ProcOp.cpp -
trunk/abdev/BasicCompiler_Common/include/Class.h
r299 r325 10 10 class UserProc; 11 11 class CClass; 12 class Delegate; 12 13 13 14 class InheritedInterface … … 366 367 } 367 368 369 // デリゲート情報を取得 370 const ::Delegate &GetDelegate() const; 371 368 372 // vtblに存在する仮想関数の数 369 373 int GetVtblNum() const -
trunk/abdev/BasicCompiler_Common/include/Delegate.h
r322 r325 2 2 3 3 #include <Hashmap.h> 4 #include < Symbol.h>4 #include <Procedure.h> 5 5 6 6 class Delegate : public Procedure, public Jenga::Common::ObjectInHashmap<Delegate> -
trunk/abdev/BasicCompiler_Common/include/Parameter.h
r322 r325 146 146 147 147 bool Analyze( const char *sourceOfParams, int nowLine ); 148 149 std::string GetString() const; 148 150 }; -
trunk/abdev/BasicCompiler_Common/src/Class.cpp
r322 r325 589 589 590 590 return 0; 591 } 592 593 const ::Delegate &CClass::GetDelegate() const 594 { 595 const ::Delegate *dg = compiler.GetObjectModule().meta.GetDelegates().GetHashArrayElement( GetName().c_str() ); 596 while( dg ) 597 { 598 if( dg->IsEqualSymbol( GetNamespaceScopes(), GetName() ) ){ 599 //名前空間とクラス名が一致した 600 return *dg; 601 } 602 dg = dg->GetChainNext(); 603 } 604 605 Jenga::Throw( "CClass::GetDelegateメソッドに失敗" ); 606 static ::Delegate dummy; 607 return dummy; 591 608 } 592 609 -
trunk/abdev/BasicCompiler_Common/src/Delegate.cpp
r322 r325 120 120 121 121 std::map<std::string,std::string> values; 122 values.insert( std::map<std::string,std::string>::value_type( "name", dg.GetName() ) ); 123 values.insert( std::map<std::string,std::string>::value_type( "params", "" ) ); 122 123 if( dg.GetNamespaceScopes().size() ) 124 { 125 std::string namespaceScopesCommandStr = ""; 126 std::string endNamespaceScopesCommandStr = ""; 127 BOOST_FOREACH( const std::string &namespaceStr, dg.GetNamespaceScopes() ) 128 { 129 if( namespaceScopesCommandStr.size() ) 130 { 131 namespaceScopesCommandStr += ":"; 132 endNamespaceScopesCommandStr += ":"; 133 } 134 namespaceScopesCommandStr += "Namespace " + namespaceStr; 135 endNamespaceScopesCommandStr += "End Namespace"; 136 } 137 138 values.insert( std::map<std::string,std::string>::value_type( 139 "#namespace_begin#", 140 namespaceScopesCommandStr 141 ) ); 142 values.insert( std::map<std::string,std::string>::value_type( 143 "#namespace_end#", 144 endNamespaceScopesCommandStr 145 ) ); 146 } 147 else 148 { 149 values.insert( std::map<std::string,std::string>::value_type( "#namespace_begin#", "" ) ); 150 values.insert( std::map<std::string,std::string>::value_type( "#namespace_end#", "" ) ); 151 } 152 153 values.insert( std::map<std::string,std::string>::value_type( "#name#", dg.GetName() ) ); 154 155 std::string paramsStr = dg.Params().GetString(); 156 157 if( dg.IsFunction() ) 158 { 159 values.insert( std::map<std::string,std::string>::value_type( 160 "#call_method_begin#", 161 (string)"Function Call(" + paramsStr + ") As " + compiler.TypeToString( dg.ReturnType() ) 162 ) ); 163 164 values.insert( std::map<std::string,std::string>::value_type( 165 "#call_method_end#", 166 "End Function" 167 ) ); 168 169 values.insert( std::map<std::string,std::string>::value_type( "#result#", "Call=" ) ); 170 } 171 else 172 { 173 values.insert( std::map<std::string,std::string>::value_type( 174 "#call_method_begin#", 175 (string)"Sub Call(" + paramsStr + ")" 176 ) ); 177 178 values.insert( std::map<std::string,std::string>::value_type( 179 "#call_method_end#", 180 "End Sub" 181 ) ); 182 183 values.insert( std::map<std::string,std::string>::value_type( "#result#", "" ) ); 184 } 185 186 values.insert( std::map<std::string,std::string>::value_type( "#params#", paramsStr ) ); 187 124 188 destSource += sourceTemplate.GetResult( values ); 125 189 } 190 191 ts( destSource.c_str() ); 126 192 } -
trunk/abdev/BasicCompiler_Common/src/Parameter.cpp
r322 r325 159 159 return true; 160 160 } 161 162 std::string Parameters::GetString() const 163 { 164 std::string result; 165 166 const Parameters ¶ms = *this; 167 BOOST_FOREACH( const Parameter *pParam, params ) 168 { 169 if( result.size() ) 170 { 171 result += ","; 172 } 173 174 result += pParam->GetVarName() + " As " + compiler.TypeToString( *pParam ); 175 } 176 return result; 177 } -
trunk/abdev/BasicCompiler_Common/src/Source.cpp
r322 r325 1048 1048 while( true ) 1049 1049 { 1050 std::string::size_type index = result.find( "#" + it->first + "#");1050 std::string::size_type index = result.find( it->first ); 1051 1051 if( index == std::string::npos ) 1052 1052 { … … 1054 1054 } 1055 1055 1056 result = result.substr( 0, index ) + it->second + result.substr( index + it->first.length() + 2);1056 result = result.substr( 0, index ) + it->second + result.substr( index + it->first.length() ); 1057 1057 } 1058 1058 it++;
Note:
See TracChangeset
for help on using the changeset viewer.