Changeset 195 for inc/cilVm.h

Show
Ignore:
Timestamp:
09/14/08 01:45:22 (4 months ago)
Author:
hak
Message:

Ver.0.91.0.137
- Added OSX/GCC support!
- Can compile in XCode 3.1/GCC 4.0.1 & Visual Studio 2005.
- Runs in OSX 10.5.4 & Windows XP/Vista
- Number::toString support a radix.
- BRFALSE bug fix
- Minor code clean up

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • inc/cilVm.h

    r138 r195  
    2323#include "iCodeGen.h" 
    2424#include "cilCodeGen.h" 
    25 #include "win32/StopWatch.h" 
    2625#include "variable.h" 
    2726#include "vmRuntimeError.h" 
     
    164163}; 
    165164 
    166  
    167 /*************************************************************************** 
    168  *      VM helper APIs 
    169  ***************************************************************************/ 
    170 #define VMRET_INT int32_t 
    171 #define VMRET_FLOAT float 
    172 #define VMRET_DOUBLE double 
    173  
    174 #define VMARG_INT int32_t 
    175 #define VMARG_FLOAT float 
    176 #define VMARG_DOUBLE double 
    177  
    178 /*EN Wrapper template classes for user specified functions. 
    179 This wrapper is for a function that does not require 'this' value. 
    180 no parameter, with return variable version. 
    181 \param pVm A pointer to the VM 
    182 \param iNumArguments A number of given parameters. 
    183 \param pArguments A pointer to the arguments array. 
    184 \param pMethodBody An API body. 
    185 \ingroup MDL_LIB_VM 
    186 */ 
    187 template< class RET > 
    188 void MakeWrapperStdP0( CCilVm* const pVm, 
    189                         const int32_t iNumArguments, 
    190                         CVariable* pArguments, 
    191                         PMETHOD pMethodBody ) 
    192 { 
    193         RET ret = ((RET (*)( void ) )pMethodBody)(); 
    194         pVm->pushEvalStack( ret ); 
    195  
    196         return; 
    197 } 
    198  
    199 /*EN Wrapper template classes for user specified functions. 
    200 This wrapper is for a function that does not require 'this' value. 
    201 1 parameter, with return variable version. 
    202 \param pVm A pointer to the VM 
    203 \param iNumArguments A number of given parameters. 
    204 \param pArguments A pointer to the arguments array. 
    205 \param pMethodBody An API body. 
    206 \ingroup MDL_LIB_VM 
    207 */ 
    208 template< class RET, class P1 > 
    209 void MakeWrapperStdP1( CCilVm* const pVm, 
    210                         const int32_t iNumArguments, 
    211                         CVariable* pArguments, 
    212                         PMETHOD pMethodBody ) 
    213 { 
    214         //Skip This pointer 
    215         pArguments ++; 
    216  
    217         P1 param1; 
    218         switch( iNumArguments ) 
    219         { 
    220         default: 
    221                 param1 = (P1)*pArguments; 
    222         case 1: 
    223                 break; 
    224         } 
    225  
    226         RET ret = ((RET (*)( P1 ) )pMethodBody)( param1 ); 
    227         pVm->pushEvalStack( ret ); 
    228  
    229         return; 
    230 } 
    231  
    232 /*EN Wrapper template classes for user specified functions. 
    233 This wrapper is for a function that does not require 'this' value. 
    234 2 parameters, with return variable version. 
    235 \param pVm A pointer to the VM 
    236 \param iNumArguments A number of given parameters. 
    237 \param pArguments A pointer to the arguments array. 
    238 \param pMethodBody An API body. 
    239 \ingroup MDL_LIB_VM 
    240 */ 
    241 template< class RET, class P1, class P2 > 
    242 void MakeWrapperStdP2( CCilVm* const pVm, 
    243                         const int32_t iNumArguments, 
    244                         CVariable* pArguments, 
    245                         PMETHOD pMethodBody ) 
    246 { 
    247         //Skip This pointer 
    248         pArguments ++; 
    249  
    250         P1 param1 = (P1)0; 
    251         P2 param2 = (P2)0; 
    252         switch( iNumArguments ) 
    253         { 
    254         default: 
    255                 param2 = (P2)*(pArguments+1); 
    256         case 2: 
    257                 param1 = (P1)*pArguments; 
    258         case 1: 
    259                 break; 
    260         } 
    261  
    262         RET ret = ((RET (*)( P1, P2 ) )pMethodBody)( param1, param2 ); 
    263         pVm->pushEvalStack( ret ); 
    264  
    265         return; 
    266 } 
    267  
    268 /*EN Wrapper template classes for user specified functions. 
    269 This wrapper is for a function that does not require 'this' value. 
    270 3 parameters, with return variable version. 
    271 \param pVm A pointer to the VM 
    272 \param iNumArguments A number of given parameters. 
    273 \param pArguments A pointer to the arguments array. 
    274 \param pMethodBody An API body. 
    275 \ingroup MDL_LIB_VM 
    276 */ 
    277 template< class RET, class P1, class P2, class P3 > 
    278 void MakeWrapperStdP3( CCilVm* const pVm, 
    279                         const int32_t iNumArguments, 
    280                         CVariable* pArguments, 
    281                         PMETHOD pMethodBody ) 
    282 { 
    283         //Skip This pointer 
    284         pArguments ++; 
    285  
    286         P1 param1 = (P1)0; 
    287         P2 param2 = (P2)0; 
    288         P3 param3 = (P3)0; 
    289         switch( iNumArguments ) 
    290         { 
    291         default: 
    292                 param3 = (P3)*(pArguments+2); 
    293         case 3: 
    294                 param2 = (P2)*(pArguments+1); 
    295         case 2: 
    296                 param1 = (P1)*pArguments; 
    297         case 1: 
    298                 break; 
    299         } 
    300  
    301         RET ret = ((RET (*)( P1, P2, P3 ) )pMethodBody)( param1, param2, param3 ); 
    302         pVm->pushEvalStack( ret ); 
    303  
    304         return; 
    305 } 
    306  
    307 /*EN Wrapper template classes for user specified functions. 
    308 This wrapper is for a function that does not require 'this' value. 
    309 4 parameters, with return variable version. 
    310 \param pVm A pointer to the VM 
    311 \param iNumArguments A number of given parameters. 
    312 \param pArguments A pointer to the arguments array. 
    313 \param pMethodBody An API body. 
    314 \ingroup MDL_LIB_VM 
    315 */ 
    316 template< class RET, class P1, class P2, class P3, class P4 > 
    317 void MakeWrapperStdP4( CCilVm* const pVm, 
    318                         const int32_t iNumArguments, 
    319                         CVariable* pArguments, 
    320                         PMETHOD pMethodBody ) 
    321 { 
    322         //Skip This pointer 
    323         pArguments ++; 
    324  
    325         P1 param1 = (P1)0; 
    326         P2 param2 = (P2)0; 
    327         P3 param3 = (P3)0; 
    328         P4 param4 = (P4)0; 
    329         switch( iNumArguments ) 
    330         { 
    331         default: 
    332                 param4 = (P4)*(pArguments+3); 
    333         case 4: 
    334                 param3 = (P3)*(pArguments+2); 
    335         case 3: 
    336                 param2 = (P2)*(pArguments+1); 
    337         case 2: 
    338                 param1 = (P1)*pArguments; 
    339         case 1: 
    340                 break; 
    341         } 
    342  
    343         RET ret = ((RET (*)( P1, P2, P3, P4 ) )pMethodBody)( param1, param2, param3, param4 ); 
    344         pVm->pushEvalStack( ret ); 
    345  
    346         return; 
    347 } 
    348  
    349 /*EN Wrapper template classes for user specified functions. 
    350 This wrapper is for a function that does not require 'this' value. 
    351 5 parameters, with return variable version. 
    352 \param pVm A pointer to the VM 
    353 \param iNumArguments A number of given parameters. 
    354 \param pArguments A pointer to the arguments array. 
    355 \param pMethodBody An API body. 
    356 \ingroup MDL_LIB_VM 
    357 */ 
    358 template< class RET, class P1, class P2, class P3, class P4, class P5 > 
    359 void MakeWrapperStdP5( CCilVm* const pVm, 
    360                         const int32_t iNumArguments, 
    361                         CVariable* pArguments, 
    362                         PMETHOD pMethodBody ) 
    363 { 
    364         //Skip This pointer 
    365         pArguments ++; 
    366  
    367         P1 param1 = (P1)0; 
    368         P2 param2 = (P2)0; 
    369         P3 param3 = (P3)0; 
    370         P4 param4 = (P4)0; 
    371         P5 param5 = (P5)0; 
    372         switch( iNumArguments ) 
    373         { 
    374         default: 
    375                 param5 = (P5)*(pArguments+4); 
    376         case 5: 
    377                 param4 = (P4)*(pArguments+3); 
    378         case 4: 
    379                 param3 = (P3)*(pArguments+2); 
    380         case 3: 
    381                 param2 = (P2)*(pArguments+1); 
    382         case 2: 
    383                 param1 = (P1)*pArguments; 
    384         case 1: 
    385                 break; 
    386         } 
    387  
    388         RET ret = ((RET (*)( P1, P2, P3, P4, P5 ) )pMethodBody)( param1, param2, param3, param4, param5 ); 
    389         pVm->pushEvalStack( ret ); 
    390  
    391         return; 
    392 } 
    393  
    394 //---------------------- 
    395 //Void return version 
    396 //---------------------- 
    397 /*EN Wrapper template classes for user specified functions. 
    398 This wrapper is for a function that does not require 'this' value. 
    399 no parameter, without return variable version. 
    400 \param pVm A pointer to the VM 
    401 \param iNumArguments A number of given parameters. 
    402 \param pArguments A pointer to the arguments array. 
    403 \param pMethodBody An API body. 
    404 \ingroup MDL_LIB_VM 
    405 */ 
    406 void MakeWrapperStdVoidP0( CCilVm* const pVm, 
    407                         const int32_t iNumArguments, 
    408                         CVariable* pArguments, 
    409                         PMETHOD pMethodBody ); 
    410 /* 
    411 { 
    412         ((void (*)( void ) )pMethodBody)(); 
    413         pVm->pushEvalStackUndefined(); 
    414  
    415         return; 
    416 }*/ 
    417  
    418 /*EN Wrapper template classes for user specified functions. 
    419 This wrapper is for a function that does not require 'this' value. 
    420 1 parameter, without return variable version. 
    421 \param pVm A pointer to the VM 
    422 \param iNumArguments A number of given parameters. 
    423 \param pArguments A pointer to the arguments array. 
    424 \param pMethodBody An API body. 
    425 \ingroup MDL_LIB_VM 
    426 */ 
    427 template< class P1 > 
    428 void MakeWrapperStdVoidP1( CCilVm* const pVm, 
    429                         const int32_t iNumArguments, 
    430                         CVariable* pArguments, 
    431                         PMETHOD pMethodBody ) 
    432 { 
    433         //Skip This pointer 
    434         pArguments ++; 
    435  
    436         P1 param1; 
    437         switch( iNumArguments ) 
    438         { 
    439         default: 
    440                 param1 = (P1)*pArguments; 
    441         case 1: 
    442                 break; 
    443         } 
    444  
    445         ((void (*)( P1 ) )pMethodBody)( param1 ); 
    446         pVm->pushEvalStackUndefined(); 
    447  
    448         return; 
    449 } 
    450  
    451 /*EN Wrapper template classes for user specified functions. 
    452 This wrapper is for a function that does not require 'this' value. 
    453 2 parameters, without return variable version. 
    454 \param pVm A pointer to the VM 
    455 \param iNumArguments A number of given parameters. 
    456 \param pArguments A pointer to the arguments array. 
    457 \param pMethodBody An API body. 
    458 \ingroup MDL_LIB_VM 
    459 */ 
    460 template< class P1, class P2 > 
    461 void MakeWrapperStdVoidP2( CCilVm* const pVm, 
    462                         const int32_t iNumArguments, 
    463                         CVariable* pArguments, 
    464                         PMETHOD pMethodBody ) 
    465 { 
    466         //Skip This pointer 
    467         pArguments ++; 
    468  
    469         P1 param1 = (P1)0; 
    470         P2 param2 = (P2)0; 
    471         switch( iNumArguments ) 
    472         { 
    473         default: 
    474                 param2 = (P2)*(pArguments+1); 
    475         case 2: 
    476                 param1 = (P1)*pArguments; 
    477         case 1: 
    478                 break; 
    479         } 
    480  
    481  
    482         ((void (*)( P1, P2 ) )pMethodBody)( param1, param2 ); 
    483         pVm->pushEvalStackUndefined(); 
    484  
    485         return; 
    486 } 
    487  
    488 /*EN Wrapper template classes for user specified functions. 
    489 This wrapper is for a function that does not require 'this' value. 
    490 3 parameters, without return variable version. 
    491 \param pVm A pointer to the VM 
    492 \param iNumArguments A number of given parameters. 
    493 \param pArguments A pointer to the arguments array. 
    494 \param pMethodBody An API body. 
    495 \ingroup MDL_LIB_VM 
    496 */ 
    497 template< class P1, class P2, class P3 > 
    498 void MakeWrapperStdVoidP3( CCilVm* const pVm, 
    499                         const int32_t iNumArguments, 
    500                         CVariable* pArguments, 
    501                         PMETHOD pMethodBody ) 
    502 { 
    503         //Skip This pointer 
    504         pArguments ++; 
    505  
    506         P1 param1 = (P1)0; 
    507         P2 param2 = (P2)0; 
    508         P3 param3 = (P3)0; 
    509         switch( iNumArguments ) 
    510         { 
    511         default: 
    512                 param3 = (P3)*(pArguments+2); 
    513         case 3: 
    514                 param2 = (P2)*(pArguments+1); 
    515         case 2: 
    516                 param1 = (P1)*pArguments; 
    517         case 1: 
    518                 break; 
    519         } 
    520  
    521         ((void (*)( P1, P2, P3 ) )pMethodBody)( param1, param2, param3 ); 
    522         pVm->pushEvalStackUndefined(); 
    523  
    524         return; 
    525 } 
    526  
    527 /*EN Wrapper template classes for user specified functions. 
    528 This wrapper is for a function that does not require 'this' value. 
    529 4 parameters, without return variable version. 
    530 \param pVm A pointer to the VM 
    531 \param iNumArguments A number of given parameters. 
    532 \param pArguments A pointer to the arguments array. 
    533 \param pMethodBody An API body. 
    534 \ingroup MDL_LIB_VM 
    535 */ 
    536 template< class P1, class P2, class P3, class P4 > 
    537 void MakeWrapperStdVoidP4( CCilVm* const pVm, 
    538                         const int32_t iNumArguments, 
    539                         CVariable* pArguments, 
    540                         PMETHOD pMethodBody ) 
    541 { 
    542         //Skip This pointer 
    543         pArguments ++; 
    544  
    545         P1 param1 = (P1)0; 
    546         P2 param2 = (P2)0; 
    547         P3 param3 = (P3)0; 
    548         P4 param4 = (P4)0; 
    549         switch( iNumArguments ) 
    550         { 
    551         default: 
    552                 param4 = (P4)*(pArguments+3); 
    553         case 4: 
    554                 param3 = (P3)*(pArguments+2); 
    555         case 3: 
    556                 param2 = (P2)*(pArguments+1); 
    557         case 2: 
    558                 param1 = (P1)*pArguments; 
    559         case 1: 
    560                 break; 
    561         } 
    562  
    563         ((void (*)( P1, P2, P3, P4 ) )pMethodBody)( param1, param2, param3, param4 ); 
    564         pVm->pushEvalStackUndefined(); 
    565  
    566         return; 
    567 } 
    568  
    569 /*EN Wrapper template classes for user specified functions. 
    570 This wrapper is for a function that does not require 'this' value. 
    571 5 parameters, without return variable version. 
    572 \param pVm A pointer to the VM 
    573 \param iNumArguments A number of given parameters. 
    574 \param pArguments A pointer to the arguments array. 
    575 \param pMethodBody An API body. 
    576 \ingroup MDL_LIB_VM 
    577 */ 
    578 template< class P1, class P2, class P3, class P4, class P5 > 
    579 void MakeWrapperStdVoidP5( CCilVm* const pVm, 
    580                         const int32_t iNumArguments, 
    581                         CVariable* pArguments, 
    582                         PMETHOD pMethodBody ) 
    583 { 
    584         //Skip This pointer 
    585         pArguments ++; 
    586  
    587         P1 param1 = (P1)0; 
    588         P2 param2 = (P2)0; 
    589         P3 param3 = (P3)0; 
    590         P4 param4 = (P4)0; 
    591         P5 param5 = (P5)0; 
    592         switch( iNumArguments ) 
    593         { 
    594         default: 
    595                 param5 = (P5)*(pArguments+4); 
    596         case 5: 
    597                 param4 = (P4)*(pArguments+3); 
    598         case 4: 
    599                 param3 = (P3)*(pArguments+2); 
    600         case 3: 
    601                 param2 = (P2)*(pArguments+1); 
    602         case 2: 
    603                 param1 = (P1)*pArguments; 
    604         case 1: 
    605                 break; 
    606         } 
    607  
    608         ((void (*)( P1, P2, P3, P4, P5 ) )pMethodBody)( param1, param2, param3, param4, param5 ); 
    609         pVm->pushEvalStackUndefined(); 
    610  
    611         return; 
    612 } 
    613 //------------------------------------------- 
    614 //Member version 
    615 //------------------------------------------- 
    616 /*EN Wrapper template classes for user specified functions. 
    617 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    618 No parameter, with a return variable version. 
    619 \param pVm A pointer to the VM 
    620 \param iNumArguments A number of given parameters. 
    621 \param pArguments A pointer to the arguments array. 
    622 \param pMethodBody An API body. 
    623 \ingroup MDL_LIB_VM 
    624 */ 
    625 template< class RET > 
    626 void MakeWrapperMtdP0( CCilVm* const pVm, 
    627                         const int32_t iNumArguments, 
    628                         CVariable* pArguments, 
    629                         PMETHOD pMethodBody ) 
    630 { 
    631         //Keep This pointer 
    632         CVariable* pVar = &*pArguments ++; 
    633  
    634         RET ret = ((RET (*)( CVariable* ) )pMethodBody)( pVar ); 
    635         pVm->pushEvalStack( ret ); 
    636  
    637         return; 
    638 } 
    639  
    640 /*EN Wrapper template classes for user specified functions. 
    641 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    642 1 parameter, with a return variable version. 
    643 \param pVm A pointer to the VM 
    644 \param iNumArguments A number of given parameters. 
    645 \param pArguments A pointer to the arguments array. 
    646 \param pMethodBody An API body. 
    647 \ingroup MDL_LIB_VM 
    648 */ 
    649 template< class RET, class P1 > 
    650 void MakeWrapperMtdP1( CCilVm* const pVm, 
    651                         const int32_t iNumArguments, 
    652                         CVariable* pArguments, 
    653                         PMETHOD pMethodBody ) 
    654 { 
    655         //Keep This pointer 
    656         CVariable* pVar = &*pArguments ++; 
    657  
    658         P1 param1; 
    659         switch( iNumArguments ) 
    660         { 
    661         default: 
    662                 param1 = (P1)*pArguments; 
    663         case 1: 
    664                 break; 
    665         } 
    666  
    667         RET ret = ((RET (*)( CVariable*, P1 ) )pMethodBody)( pVar, param1 ); 
    668         pVm->pushEvalStack( ret ); 
    669  
    670         return; 
    671 } 
    672  
    673 /*EN Wrapper template classes for user specified functions. 
    674 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    675 2 parameters, with a return variable version. 
    676 \param pVm A pointer to the VM 
    677 \param iNumArguments A number of given parameters. 
    678 \param pArguments A pointer to the arguments array. 
    679 \param pMethodBody An API body. 
    680 \ingroup MDL_LIB_VM 
    681 */ 
    682 template< class RET, class P1, class P2 > 
    683 void MakeWrapperMtdP2( CCilVm* const pVm, 
    684                         const int32_t iNumArguments, 
    685                         CVariable* pArguments, 
    686                         PMETHOD pMethodBody ) 
    687 { 
    688         //Keep This pointer 
    689         CVariable* pVar = &*pArguments ++; 
    690  
    691         P1 param1 = (P1)0; 
    692         P2 param2 = (P2)0; 
    693         switch( iNumArguments ) 
    694         { 
    695         default: 
    696                 param2 = (P2)*(pArguments+1); 
    697         case 2: 
    698                 param1 = (P1)*pArguments; 
    699         case 1: 
    700                 break; 
    701         } 
    702  
    703         RET ret = ((RET (*)( CVariable*, P1, P2 ) )pMethodBody)( pVar, param1, param2 ); 
    704         pVm->pushEvalStack( ret ); 
    705  
    706         return; 
    707 } 
    708  
    709 /*EN Wrapper template classes for user specified functions. 
    710 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    711 3 parameters, with a return variable version. 
    712 \param pVm A pointer to the VM 
    713 \param iNumArguments A number of given parameters. 
    714 \param pArguments A pointer to the arguments array. 
    715 \param pMethodBody An API body. 
    716 \ingroup MDL_LIB_VM 
    717 */ 
    718 template< class RET, class P1, class P2, class P3 > 
    719 void MakeWrapperMtdP3( CCilVm* const pVm, 
    720                         const int32_t iNumArguments, 
    721                         CVariable* pArguments, 
    722                         PMETHOD pMethodBody ) 
    723 { 
    724         //Keep This pointer 
    725         CVariable* pVar = &*pArguments ++; 
    726  
    727         P1 param1 = (P1)0; 
    728         P2 param2 = (P2)0; 
    729         P3 param3 = (P3)0; 
    730         switch( iNumArguments ) 
    731         { 
    732         default: 
    733                 param3 = (P3)*(pArguments+2); 
    734         case 3: 
    735                 param2 = (P2)*(pArguments+1); 
    736         case 2: 
    737                 param1 = (P1)*pArguments; 
    738         case 1: 
    739                 break; 
    740         } 
    741  
    742         RET ret = ((RET (*)( CVariable*, P1, P2, P3 ) )pMethodBody)( pVar, param1, param2, param3 ); 
    743         pVm->pushEvalStack( ret ); 
    744  
    745         return; 
    746 } 
    747  
    748 /*EN Wrapper template classes for user specified functions. 
    749 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    750 4 parameters, with a return variable version. 
    751 \param pVm A pointer to the VM 
    752 \param iNumArguments A number of given parameters. 
    753 \param pArguments A pointer to the arguments array. 
    754 \param pMethodBody An API body. 
    755 \ingroup MDL_LIB_VM 
    756 */ 
    757 template< class RET, class P1, class P2, class P3, class P4 > 
    758 void MakeWrapperMtdP4( CCilVm* const pVm, 
    759                         const int32_t iNumArguments, 
    760                         CVariable* pArguments, 
    761                         PMETHOD pMethodBody ) 
    762 { 
    763         //Keep This pointer 
    764         CVariable* pVar = &*pArguments ++; 
    765  
    766         P1 param1 = (P1)0; 
    767         P2 param2 = (P2)0; 
    768         P3 param3 = (P3)0; 
    769         P4 param4 = (P4)0; 
    770         switch( iNumArguments ) 
    771         { 
    772         default: 
    773                 param4 = (P4)*(pArguments+3); 
    774         case 4: 
    775                 param3 = (P3)*(pArguments+2); 
    776         case 3: 
    777                 param2 = (P2)*(pArguments+1); 
    778         case 2: 
    779                 param1 = (P1)*pArguments; 
    780         case 1: 
    781                 break; 
    782         } 
    783  
    784         RET ret = ((RET (*)( CVariable*, P1, P2, P3, P4 ) )pMethodBody)( pVar, param1, param2, param3, param4 ); 
    785         pVm->pushEvalStack( ret ); 
    786  
    787         return; 
    788 } 
    789  
    790 /*EN Wrapper template classes for user specified functions. 
    791 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    792 5 parameters, with a return variable version. 
    793 \param pVm A pointer to the VM 
    794 \param iNumArguments A number of given parameters. 
    795 \param pArguments A pointer to the arguments array. 
    796 \param pMethodBody An API body. 
    797 \ingroup MDL_LIB_VM 
    798 */ 
    799 template< class RET, class P1, class P2, class P3, class P4, class P5 > 
    800 void MakeWrapperMtdP5( CCilVm* const pVm, 
    801                         const int32_t iNumArguments, 
    802                         CVariable* pArguments, 
    803                         PMETHOD pMethodBody ) 
    804 { 
    805         //Keep This pointer 
    806         CVariable* pVar = &*pArguments ++; 
    807  
    808         P1 param1 = (P1)0; 
    809         P2 param2 = (P2)0; 
    810         P3 param3 = (P3)0; 
    811         P4 param4 = (P4)0; 
    812         P5 param5 = (P5)0; 
    813         switch( iNumArguments ) 
    814         { 
    815         default: 
    816                 param5 = (P5)*(pArguments+4); 
    817         case 5: 
    818                 param4 = (P4)*(pArguments+3); 
    819         case 4: 
    820                 param3 = (P3)*(pArguments+2); 
    821         case 3: 
    822                 param2 = (P2)*(pArguments+1); 
    823         case 2: 
    824                 param1 = (P1)*pArguments; 
    825         case 1: 
    826                 break; 
    827         } 
    828  
    829         RET ret = ((RET (*)( CVariable*, P1, P2, P3, P4, P5 ) )pMethodBody)( pVar, param1, param2, param3, param4, param5 ); 
    830         pVm->pushEvalStack( ret ); 
    831  
    832         return; 
    833 } 
    834  
    835 //---------------------- 
    836 //Void return version 
    837 //---------------------- 
    838 /*EN Wrapper template classes for user specified functions. 
    839 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    840 no parameter, without a return variable version. 
    841 \param pVm A pointer to the VM 
    842 \param iNumArguments A number of given parameters. 
    843 \param pArguments A pointer to the arguments array. 
    844 \param pMethodBody An API body. 
    845 \ingroup MDL_LIB_VM 
    846 */ 
    847 void MakeWrapperMtdVoidP0( CCilVm* const pVm, 
    848                         const int32_t iNumArguments, 
    849                         CVariable* pArguments, 
    850                         PMETHOD pMethodBody ); 
    851 /* 
    852 { 
    853         //Keep This pointer 
    854         CVariable* pVar = &*pArguments ++; 
    855  
    856         ((void (*)( CVariable* ) )pMethodBody)( pVar ); 
    857         pVm->pushEvalStackUndefined(); 
    858  
    859         return; 
    860 } 
    861 */ 
    862  
    863 /*EN Wrapper template classes for user specified functions. 
    864 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    865 1 parameter, without a return variable version. 
    866 \param pVm A pointer to the VM 
    867 \param iNumArguments A number of given parameters. 
    868 \param pArguments A pointer to the arguments array. 
    869 \param pMethodBody An API body. 
    870 \ingroup MDL_LIB_VM 
    871 */ 
    872 template< class P1 > 
    873 void MakeWrapperMtdVoidP1( CCilVm* const pVm, 
    874                         const int32_t iNumArguments, 
    875                         CVariable* pArguments, 
    876                         PMETHOD pMethodBody ) 
    877 { 
    878         //Keep This pointer 
    879         CVariable* pVar = &*pArguments ++; 
    880  
    881         P1 param1; 
    882         switch( iNumArguments ) 
    883         { 
    884         default: 
    885                 param1 = (P1)*pArguments; 
    886         case 1: 
    887                 break; 
    888         } 
    889  
    890         ((void (*)( CVariable*, P1 ) )pMethodBody)( pVar, param1 ); 
    891         pVm->pushEvalStackUndefined(); 
    892  
    893         return; 
    894 } 
    895  
    896 /*EN Wrapper template classes for user specified functions. 
    897 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    898 2 parameters, without a return variable version. 
    899 \param pVm A pointer to the VM 
    900 \param iNumArguments A number of given parameters. 
    901 \param pArguments A pointer to the arguments array. 
    902 \param pMethodBody An API body. 
    903 \ingroup MDL_LIB_VM 
    904 */ 
    905 template< class P1, class P2 > 
    906 void MakeWrapperMtdVoidP2( CCilVm* const pVm, 
    907                         const int32_t iNumArguments, 
    908                         CVariable* pArguments, 
    909                         PMETHOD pMethodBody ) 
    910 { 
    911         //Keep This pointer 
    912         CVariable* pVar = &*pArguments ++; 
    913  
    914         P1 param1 = (P1)0; 
    915         P2 param2 = (P2)0; 
    916         switch( iNumArguments ) 
    917         { 
    918         default: 
    919                 param2 = (P2)*(pArguments+1); 
    920         case 2: 
    921                 param1 = (P1)*pArguments; 
    922         case 1: 
    923                 break; 
    924         } 
    925  
    926  
    927         ((void (*)( CVariable*, P1, P2 ) )pMethodBody)( pVar, param1, param2 ); 
    928         pVm->pushEvalStackUndefined(); 
    929  
    930         return; 
    931 } 
    932  
    933 /*EN Wrapper template classes for user specified functions. 
    934 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    935 3 parameters, without a return variable version. 
    936 \param pVm A pointer to the VM 
    937 \param iNumArguments A number of given parameters. 
    938 \param pArguments A pointer to the arguments array. 
    939 \param pMethodBody An API body. 
    940 \ingroup MDL_LIB_VM 
    941 */ 
    942 template< class P1, class P2, class P3 > 
    943 void MakeWrapperMtdVoidP3( CCilVm* const pVm, 
    944                         const int32_t iNumArguments, 
    945                         CVariable* pArguments, 
    946                         PMETHOD pMethodBody ) 
    947 { 
    948         //Keep This pointer 
    949         CVariable* pVar = &*pArguments ++; 
    950  
    951         P1 param1 = (P1)0; 
    952         P2 param2 = (P2)0; 
    953         P3 param3 = (P3)0; 
    954         switch( iNumArguments ) 
    955         { 
    956         default: 
    957                 param3 = (P3)*(pArguments+2); 
    958         case 3: 
    959                 param2 = (P2)*(pArguments+1); 
    960         case 2: 
    961                 param1 = (P1)*pArguments; 
    962         case 1: 
    963                 break; 
    964         } 
    965  
    966         ((void (*)( CVariable*, P1, P2, P3 ) )pMethodBody)( pVar, param1, param2, param3 ); 
    967         pVm->pushEvalStackUndefined(); 
    968  
    969         return; 
    970 } 
    971  
    972 /*EN Wrapper template classes for user specified functions. 
    973 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    974 4 parameters, without a return variable version. 
    975 \param pVm A pointer to the VM 
    976 \param iNumArguments A number of given parameters. 
    977 \param pArguments A pointer to the arguments array. 
    978 \param pMethodBody An API body. 
    979 \ingroup MDL_LIB_VM 
    980 */ 
    981 template< class P1, class P2, class P3, class P4 > 
    982 void MakeWrapperMtdVoidP4( CCilVm* const pVm, 
    983                         const int32_t iNumArguments, 
    984                         CVariable* pArguments, 
    985                         PMETHOD pMethodBody ) 
    986 { 
    987         //Keep This pointer 
    988         CVariable* pVar = &*pArguments ++; 
    989  
    990         P1 param1 = (P1)0; 
    991         P2 param2 = (P2)0; 
    992         P3 param3 = (P3)0; 
    993         P4 param4 = (P4)0; 
    994         switch( iNumArguments ) 
    995         { 
    996         default: 
    997                 param4 = (P4)*(pArguments+3); 
    998         case 4: 
    999                 param3 = (P3)*(pArguments+2); 
    1000         case 3: 
    1001                 param2 = (P2)*(pArguments+1); 
    1002         case 2: 
    1003                 param1 = (P1)*pArguments; 
    1004         case 1: 
    1005                 break; 
    1006         } 
    1007  
    1008         ((void (*)( CVariable*, P1, P2, P3, P4 ) )pMethodBody)( pVar, param1, param2, param3, param4 ); 
    1009         pVm->pushEvalStackUndefined(); 
    1010  
    1011         return; 
    1012 } 
    1013  
    1014 /*EN Wrapper template classes for user specified functions. 
    1015 This wrapper is for a function thatrequires 'this' value as a first parameter. 
    1016 5 parameters, without a return variable version. 
    1017 \param pVm A pointer to the VM 
    1018 \param iNumArguments A number of given parameters. 
    1019 \param pArguments A pointer to the arguments array. 
    1020 \param pMethodBody An API body. 
    1021 \ingroup MDL_LIB_VM 
    1022 */ 
    1023 template< class P1, class P2, class P3, class P4, class P5 > 
    1024 void MakeWrapperMtdVoidP5( CCilVm* const pVm, 
    1025                         const int32_t iNumArguments, 
    1026                         CVariable* pArguments, 
    1027                         PMETHOD pMethodBody ) 
    1028 { 
    1029         //Keep This pointer 
    1030         CVariable* pVar = &*pArguments ++; 
    1031  
    1032         P1 param1 = (P1)0; 
    1033         P2 param2 = (P2)0; 
    1034         P3 param3 = (P3)0; 
    1035         P4 param4 = (P4)0; 
    1036         P5 param5 = (P5)0; 
    1037         switch( iNumArguments ) 
    1038         { 
    1039         default: 
    1040                 param5 = (P5)*(pArguments+4); 
    1041         case 5: 
    1042                 param4 = (P4)*(pArguments+3); 
    1043         case 4: 
    1044                 param3 = (P3)*(pArguments+2); 
    1045         case 3: 
    1046                 param2 = (P2)*(pArguments+1); 
    1047         case 2: 
    1048                 param1 = (P1)*pArguments; 
    1049         case 1: 
    1050                 break; 
    1051         } 
    1052  
    1053         ((void (*)( CVariable*, P1, P2, P3, P4, P5 ) )pMethodBody)( pVar, param1, param2, param3, param4, param5 ); 
    1054         pVm->pushEvalStackUndefined(); 
    1055  
    1056         return; 
    1057 } 
    1058  
    1059165/*************************************************************************** 
    1060166 *      VM object definition 
     
    1279385                return: true when succeeded. 
    1280386                */ 
    1281                 bool setILPool( const vector< uint8_t >& vecIL); 
    1282                  
     387                bool setILPool( const std::vector< uint8_t >& vecIL); 
     388                 
     389                /*EN Attaches an IL(intermediate language) stream to the VM. 
     390                 return: true when succeeded. 
     391                 */ 
     392                bool setILPool( const uint8_t* pILPool, const size_t size_t); 
     393 
    1283394                /*EN Attaches a metadata for corresponding IL(intermediate language) stream to the VM. 
    1284395                \return true when succeeded. 
     
    1354465                \return true when the debugger successfully dettached. false otherwise. 
    1355466                */ 
    1356                 bool detachDebugger() { m_pDebugger = NULL;
     467                bool detachDebugger() { m_pDebugger = NULL; return true;
    1357468                 
    1358469                /*EN Sets a map of symbol information. 
     
    19061017        }; 
    19071018 
     1019        /*************************************************************************** 
     1020         *      VM helper APIs 
     1021         ***************************************************************************/ 
     1022#define VMRET_INT int32_t 
     1023#define VMRET_FLOAT float 
     1024#define VMRET_DOUBLE double 
     1025         
     1026#define VMARG_INT int32_t 
     1027#define VMARG_FLOAT float 
     1028#define VMARG_DOUBLE double 
     1029         
     1030        /*EN Wrapper template classes for user specified functions. 
     1031         This wrapper is for a function that does not require 'this' value. 
     1032         no parameter, with return variable version. 
     1033         \param pVm A pointer to the VM 
     1034         \param iNumArguments A number of given parameters. 
     1035         \param pArguments A pointer to the arguments array. 
     1036         \param pMethodBody An API body. 
     1037         \ingroup MDL_LIB_VM 
     1038         */ 
     1039        template< class RET > 
     1040        void MakeWrapperStdP0( CCilVm* const pVm, 
     1041                                                  const int32_t iNumArguments, 
     1042                                                  CVariable* pArguments, 
     1043                                                  PMETHOD pMethodBody ) 
     1044        { 
     1045                RET ret = ((RET (*)( void ) )pMethodBody)(); 
     1046                pVm->pushEvalStack( ret ); 
     1047                 
     1048                return; 
     1049        } 
     1050         
     1051        /*EN Wrapper template classes for user specified functions. 
     1052         This wrapper is for a function that does not require 'this' value. 
     1053         1 parameter, with return variable version. 
     1054         \param pVm A pointer to the VM 
     1055         \param iNumArguments A number of given parameters. 
     1056         \param pArguments A pointer to the arguments array. 
     1057         \param pMethodBody An API body. 
     1058         \ingroup MDL_LIB_VM 
     1059         */ 
     1060        template< class RET, class P1 > 
     1061        void MakeWrapperStdP1( CCilVm* const pVm, 
     1062                                                  const int32_t iNumArguments, 
     1063                                                  CVariable* pArguments, 
     1064                                                  PMETHOD pMethodBody ) 
     1065        { 
     1066                //Skip This pointer 
     1067                pArguments ++; 
     1068                 
     1069                P1 param1; 
     1070                switch( iNumArguments ) 
     1071                { 
     1072                        default: 
     1073                                param1 = (P1)*pArguments; 
     1074                        case 1: 
     1075                                break; 
     1076                } 
     1077                 
     1078                RET ret = ((RET (*)( P1 ) )pMethodBody)( param1 ); 
     1079                pVm->pushEvalStack( ret ); 
     1080                 
     1081                return; 
     1082        } 
     1083         
     1084        /*EN Wrapper template classes for user specified functions. 
     1085         This wrapper is for a function that does not require 'this' value. 
     1086         2 parameters, with return variable version. 
     1087         \param pVm A pointer to the VM 
     1088         \param iNumArguments A number of given parameters. 
     1089         \param pArguments A pointer to the arguments array. 
     1090         \param pMethodBody An API body. 
     1091         \ingroup MDL_LIB_VM 
     1092         */ 
     1093        template< class RET, class P1, class P2 > 
     1094        void MakeWrapperStdP2( CCilVm* const pVm, 
     1095                                                  const int32_t iNumArguments, 
     1096                                                  CVariable* pArguments, 
     1097                                                  PMETHOD pMethodBody ) 
     1098        { 
     1099                //Skip This pointer 
     1100                pArguments ++; 
     1101                 
     1102                P1 param1 = (P1)0; 
     1103                P2 param2 = (P2)0; 
     1104                switch( iNumArguments ) 
     1105                { 
     1106                        default: 
     1107                                param2 = (P2)*(pArguments+1); 
     1108                        case 2: 
     1109                                param1 = (P1)*pArguments; 
     1110                        case 1: 
     1111                                break; 
     1112                } 
     1113                 
     1114                RET ret = ((RET (*)( P1, P2 ) )pMethodBody)( param1, param2 ); 
     1115                pVm->pushEvalStack( ret ); 
     1116                </