Changeset 195 for inc/cilVm.h

Show
Ignore:
Timestamp:
09/14/08 01:45:22 (1 year 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                 
     1117                return; 
     1118        } 
     1119         
     1120        /*EN Wrapper template classes for user specified functions. 
     1121         This wrapper is for a function that does not require 'this' value. 
     1122         3 parameters, with return variable version. 
     1123         \param pVm A pointer to the VM 
     1124         \param iNumArguments A number of given parameters. 
     1125         \param pArguments A pointer to the arguments array. 
     1126         \param pMethodBody An API body. 
     1127         \ingroup MDL_LIB_VM 
     1128         */ 
     1129        template< class RET, class P1, class P2, class P3 > 
     1130        void MakeWrapperStdP3( CCilVm* const pVm, 
     1131                                                  const int32_t iNumArguments, 
     1132                                                  CVariable* pArguments, 
     1133                                                  PMETHOD pMethodBody ) 
     1134        { 
     1135                //Skip This pointer 
     1136                pArguments ++; 
     1137                 
     1138                P1 param1 = (P1)0; 
     1139                P2 param2 = (P2)0; 
     1140                P3 param3 = (P3)0; 
     1141                switch( iNumArguments ) 
     1142                { 
     1143                        default: 
     1144                                param3 = (P3)*(pArguments+2); 
     1145                        case 3: 
     1146                                param2 = (P2)*(pArguments+1); 
     1147                        case 2: 
     1148                                param1 = (P1)*pArguments; 
     1149                        case 1: 
     1150                                break; 
     1151                } 
     1152                 
     1153                RET ret = ((RET (*)( P1, P2, P3 ) )pMethodBody)( param1, param2, param3 ); 
     1154                pVm->pushEvalStack( ret ); 
     1155                 
     1156                return; 
     1157        } 
     1158         
     1159        /*EN Wrapper template classes for user specified functions. 
     1160         This wrapper is for a function that does not require 'this' value. 
     1161         4 parameters, with return variable version. 
     1162         \param pVm A pointer to the VM 
     1163         \param iNumArguments A number of given parameters. 
     1164         \param pArguments A pointer to the arguments array. 
     1165         \param pMethodBody An API body. 
     1166         \ingroup MDL_LIB_VM 
     1167         */ 
     1168        template< class RET, class P1, class P2, class P3, class P4 > 
     1169        void MakeWrapperStdP4( CCilVm* const pVm, 
     1170                                                  const int32_t iNumArguments, 
     1171                                                  CVariable* pArguments, 
     1172                                                  PMETHOD pMethodBody ) 
     1173        { 
     1174                //Skip This pointer 
     1175                pArguments ++; 
     1176                 
     1177                P1 param1 = (P1)0; 
     1178                P2 param2 = (P2)0; 
     1179                P3 param3 = (P3)0; 
     1180                P4 param4 = (P4)0; 
     1181                switch( iNumArguments ) 
     1182                { 
     1183                        default: 
     1184                                param4 = (P4)*(pArguments+3); 
     1185                        case 4: 
     1186                                param3 = (P3)*(pArguments+2); 
     1187                        case 3: 
     1188                                param2 = (P2)*(pArguments+1); 
     1189                        case 2: 
     1190                                param1 = (P1)*pArguments; 
     1191                        case 1: 
     1192                                break; 
     1193                } 
     1194                 
     1195                RET ret = ((RET (*)( P1, P2, P3, P4 ) )pMethodBody)( param1, param2, param3, param4 ); 
     1196                pVm->pushEvalStack( ret ); 
     1197                 
     1198                return; 
     1199        } 
     1200         
     1201        /*EN Wrapper template classes for user specified functions. 
     1202         This wrapper is for a function that does not require 'this' value. 
     1203         5 parameters, with return variable version. 
     1204         \param pVm A pointer to the VM 
     1205         \param iNumArguments A number of given parameters. 
     1206         \param pArguments A pointer to the arguments array. 
     1207         \param pMethodBody An API body. 
     1208         \ingroup MDL_LIB_VM 
     1209         */ 
     1210        template< class RET, class P1, class P2, class P3, class P4, class P5 > 
     1211        void MakeWrapperStdP5( CCilVm* const pVm, 
     1212                                                  const int32_t iNumArguments, 
     1213                                                  CVariable* pArguments, 
     1214                                                  PMETHOD pMethodBody ) 
     1215        { 
     1216                //Skip This pointer 
     1217                pArguments ++; 
     1218                 
     1219                P1 param1 = (P1)0; 
     1220                P2 param2 = (P2)0; 
     1221                P3 param3 = (P3)0; 
     1222                P4 param4 = (P4)0; 
     1223                P5 param5 = (P5)0; 
     1224                switch( iNumArguments ) 
     1225                { 
     1226                        default: 
     1227                                param5 = (P5)*(pArguments+4); 
     1228                        case 5: 
     1229                                param4 = (P4)*(pArguments+3); 
     1230                        case 4: 
     1231                                param3 = (P3)*(pArguments+2); 
     1232                        case 3: 
     1233                                param2 = (P2)*(pArguments+1); 
     1234                        case 2: 
     1235                                param1 = (P1)*pArguments; 
     1236                        case 1: 
     1237                                break; 
     1238                } 
     1239                 
     1240                RET ret = ((RET (*)( P1, P2, P3, P4, P5 ) )pMethodBody)( param1, param2, param3, param4, param5 ); 
     1241                pVm->pushEvalStack( ret ); 
     1242                 
     1243                return; 
     1244        } 
     1245         
     1246        //---------------------- 
     1247        //Void return version 
     1248        //---------------------- 
     1249        /*EN Wrapper template classes for user specified functions. 
     1250         This wrapper is for a function that does not require 'this' value. 
     1251         no parameter, without return variable version. 
     1252         \param pVm A pointer to the VM 
     1253         \param iNumArguments A number of given parameters. 
     1254         \param pArguments A pointer to the arguments array. 
     1255         \param pMethodBody An API body. 
     1256         \ingroup MDL_LIB_VM 
     1257         */ 
     1258        void MakeWrapperStdVoidP0( CCilVm* const pVm, 
     1259                                                          const int32_t iNumArguments, 
     1260                                                          CVariable* pArguments, 
     1261                                                          PMETHOD pMethodBody ); 
     1262        /* 
     1263         { 
     1264         ((void (*)( void ) )pMethodBody)(); 
     1265         pVm->pushEvalStackUndefined(); 
     1266          
     1267         return; 
     1268         }*/ 
     1269         
     1270        /*EN Wrapper template classes for user specified functions. 
     1271         This wrapper is for a function that does not require 'this' value. 
     1272         1 parameter, without return variable version. 
     1273         \param pVm A pointer to the VM 
     1274         \param iNumArguments A number of given parameters. 
     1275         \param pArguments A pointer to the arguments array. 
     1276         \param pMethodBody An API body. 
     1277         \ingroup MDL_LIB_VM 
     1278         */ 
     1279        template< class P1 > 
     1280        void MakeWrapperStdVoidP1( CCilVm* const pVm, 
     1281                                                          const int32_t iNumArguments, 
     1282                                                          CVariable* pArguments, 
     1283                                                          PMETHOD pMethodBody ) 
     1284        { 
     1285                //Skip This pointer 
     1286                pArguments ++; 
     1287                 
     1288                P1 param1; 
     1289                switch( iNumArguments ) 
     1290                { 
     1291                        default: 
     1292                                param1 = (P1)*pArguments; 
     1293                        case 1: 
     1294                                break; 
     1295                } 
     1296                 
     1297                ((void (*)( P1 ) )pMethodBody)( param1 ); 
     1298                pVm->pushEvalStackUndefined(); 
     1299                 
     1300                return; 
     1301        } 
     1302         
     1303        /*EN Wrapper template classes for user specified functions. 
     1304         This wrapper is for a function that does not require 'this' value. 
     1305         2 parameters, without return variable version. 
     1306         \param pVm A pointer to the VM 
     1307         \param iNumArguments A number of given parameters. 
     1308         \param pArguments A pointer to the arguments array. 
     1309         \param pMethodBody An API body. 
     1310         \ingroup MDL_LIB_VM 
     1311         */ 
     1312        template< class P1, class P2 > 
     1313        void MakeWrapperStdVoidP2( CCilVm* const pVm, 
     1314                                                          const int32_t iNumArguments, 
     1315                                                          CVariable* pArguments, 
     1316                                                          PMETHOD pMethodBody ) 
     1317        { 
     1318                //Skip This pointer 
     1319                pArguments ++; 
     1320                 
     1321                P1 param1 = (P1)0; 
     1322                P2 param2 = (P2)0; 
     1323                switch( iNumArguments ) 
     1324                { 
     1325                        default: 
     1326                                param2 = (P2)*(pArguments+1); 
     1327                        case 2: 
     1328                                param1 = (P1)*pArguments; 
     1329                        case 1: 
     1330                                break; 
     1331                } 
     1332                 
     1333                 
     1334                ((void (*)( P1, P2 ) )pMethodBody)( param1, param2 ); 
     1335                pVm->pushEvalStackUndefined(); 
     1336                 
     1337                return; 
     1338        } 
     1339         
     1340        /*EN Wrapper template classes for user specified functions. 
     1341         This wrapper is for a function that does not require 'this' value. 
     1342         3 parameters, without return variable version. 
     1343         \param pVm A pointer to the VM 
     1344         \param iNumArguments A number of given parameters. 
     1345         \param pArguments A pointer to the arguments array. 
     1346         \param pMethodBody An API body. 
     1347         \ingroup MDL_LIB_VM 
     1348         */ 
     1349        template< class P1, class P2, class P3 > 
     1350        void MakeWrapperStdVoidP3( CCilVm* const pVm, 
     1351                                                          const int32_t iNumArguments, 
     1352                                                          CVariable* pArguments, 
     1353                                                          PMETHOD pMethodBody ) 
     1354        { 
     1355                //Skip This pointer 
     1356                pArguments ++; 
     1357                 
     1358                P1 param1 = (P1)0; 
     1359                P2 param2 = (P2)0; 
     1360                P3 param3 = (P3)0; 
     1361                switch( iNumArguments ) 
     1362                { 
     1363                        default: 
     1364                                param3 = (P3)*(pArguments+2); 
     1365                        case 3: 
     1366                                param2 = (P2)*(pArguments+1); 
     1367                        case 2: 
     1368                                param1 = (P1)*pArguments; 
     1369                        case 1: 
     1370                                break; 
     1371                } 
     1372                 
     1373                ((void (*)( P1, P2, P3 ) )pMethodBody)( param1, param2, param3 ); 
     1374                pVm->pushEvalStackUndefined(); 
     1375                 
     1376                return; 
     1377        } 
     1378         
     1379        /*EN Wrapper template classes for user specified functions. 
     1380         This wrapper is for a function that does not require 'this' value. 
     1381         4 parameters, without return variable version. 
     1382         \param pVm A pointer to the VM 
     1383         \param iNumArguments A number of given parameters. 
     1384         \param pArguments A pointer to the arguments array. 
     1385         \param pMethodBody An API body. 
     1386         \ingroup MDL_LIB_VM 
     1387         */ 
     1388        template< class P1, class P2, class P3, class P4 > 
     1389        void MakeWrapperStdVoidP4( CCilVm* const pVm, 
     1390                                                          const int32_t iNumArguments, 
     1391                                                          CVariable* pArguments, 
     1392                                                          PMETHOD pMethodBody ) 
     1393        { 
     1394                //Skip This pointer 
     1395                pArguments ++; 
     1396                 
     1397                P1 param1 = (P1)0; 
     1398                P2 param2 = (P2)0; 
     1399                P3 param3 = (P3)0; 
     1400                P4 param4 = (P4)0; 
     1401                switch( iNumArguments ) 
     1402                { 
     1403                        default: 
     1404                                param4 = (P4)*(pArguments+3); 
     1405                        case 4: 
     1406                                param3 = (P3)*(pArguments+2); 
     1407                        case 3: 
     1408                                param2 = (P2)*(pArguments+1); 
     1409                        case 2: 
     1410                                param1 = (P1)*pArguments; 
     1411                        case 1: 
     1412                                break; 
     1413                } 
     1414                 
     1415                ((void (*)( P1, P2, P3, P4 ) )pMethodBody)( param1, param2, param3, param4 ); 
     1416                pVm->pushEvalStackUndefined(); 
     1417                 
     1418                return; 
     1419        } 
     1420         
     1421        /*EN Wrapper template classes for user specified functions. 
     1422         This wrapper is for a function that does not require 'this' value. 
     1423         5 parameters, without return variable version. 
     1424         \param pVm A pointer to the VM 
     1425         \param iNumArguments A number of given parameters. 
     1426         \param pArguments A pointer to the arguments array. 
     1427         \param pMethodBody An API body. 
     1428         \ingroup MDL_LIB_VM 
     1429         */ 
     1430        template< class P1, class P2, class P3, class P4, class P5 > 
     1431        void MakeWrapperStdVoidP5( CCilVm* const pVm, 
     1432                                                          const int32_t iNumArguments, 
     1433                                                          CVariable* pArguments, 
     1434                                                          PMETHOD pMethodBody ) 
     1435        { 
     1436                //Skip This pointer 
     1437                pArguments ++; 
     1438                 
     1439                P1 param1 = (P1)0; 
     1440                P2 param2 = (P2)0; 
     1441                P3 param3 = (P3)0; 
     1442                P4 param4 = (P4)0; 
     1443                P5 param5 = (P5)0; 
     1444                switch( iNumArguments ) 
     1445                { 
     1446                        default: 
     1447                                param5 = (P5)*(pArguments+4); 
     1448                        case 5: 
     1449                                param4 = (P4)*(pArguments+3); 
     1450                        case 4: 
     1451                                param3 = (P3)*(pArguments+2); 
     1452                        case 3: 
     1453                                param2 = (P2)*(pArguments+1); 
     1454                        case 2: 
     1455                                param1 = (P1)*pArguments; 
     1456                        case 1: 
     1457                                break; 
     1458                } 
     1459                 
     1460                ((void (*)( P1, P2, P3, P4, P5 ) )pMethodBody)( param1, param2, param3, param4, param5 ); 
     1461                pVm->pushEvalStackUndefined(); 
     1462                 
     1463                return; 
     1464        } 
     1465        //------------------------------------------- 
     1466        //Member version 
     1467        //------------------------------------------- 
     1468        /*EN Wrapper template classes for user specified functions. 
     1469         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1470         No parameter, with a return variable version. 
     1471         \param pVm A pointer to the VM 
     1472         \param iNumArguments A number of given parameters. 
     1473         \param pArguments A pointer to the arguments array. 
     1474         \param pMethodBody An API body. 
     1475         \ingroup MDL_LIB_VM 
     1476         */ 
     1477        template< class RET > 
     1478        void MakeWrapperMtdP0( CCilVm* const pVm, 
     1479                                                  const int32_t iNumArguments, 
     1480                                                  CVariable* pArguments, 
     1481                                                  PMETHOD pMethodBody ) 
     1482        { 
     1483                //Keep This pointer 
     1484                CVariable* pVar = &*pArguments ++; 
     1485                 
     1486                RET ret = ((RET (*)( CVariable* ) )pMethodBody)( pVar ); 
     1487                pVm->pushEvalStack( ret ); 
     1488                 
     1489                return; 
     1490        } 
     1491         
     1492        /*EN Wrapper template classes for user specified functions. 
     1493         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1494         1 parameter, with a return variable version. 
     1495         \param pVm A pointer to the VM 
     1496         \param iNumArguments A number of given parameters. 
     1497         \param pArguments A pointer to the arguments array. 
     1498         \param pMethodBody An API body. 
     1499         \ingroup MDL_LIB_VM 
     1500         */ 
     1501        template< class RET, class P1 > 
     1502        void MakeWrapperMtdP1( CCilVm* const pVm, 
     1503                                                  const int32_t iNumArguments, 
     1504                                                  CVariable* pArguments, 
     1505                                                  PMETHOD pMethodBody ) 
     1506        { 
     1507                //Keep This pointer 
     1508                CVariable* pVar = &*pArguments ++; 
     1509                 
     1510                P1 param1; 
     1511                switch( iNumArguments ) 
     1512                { 
     1513                        default: 
     1514                                param1 = (P1)*pArguments; 
     1515                        case 1: 
     1516                                break; 
     1517                } 
     1518                 
     1519                RET ret = ((RET (*)( CVariable*, P1 ) )pMethodBody)( pVar, param1 ); 
     1520                pVm->pushEvalStack( ret ); 
     1521                 
     1522                return; 
     1523        } 
     1524         
     1525        /*EN Wrapper template classes for user specified functions. 
     1526         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1527         2 parameters, with a return variable version. 
     1528         \param pVm A pointer to the VM 
     1529         \param iNumArguments A number of given parameters. 
     1530         \param pArguments A pointer to the arguments array. 
     1531         \param pMethodBody An API body. 
     1532         \ingroup MDL_LIB_VM 
     1533         */ 
     1534        template< class RET, class P1, class P2 > 
     1535        void MakeWrapperMtdP2( CCilVm* const pVm, 
     1536                                                  const int32_t iNumArguments, 
     1537                                                  CVariable* pArguments, 
     1538                                                  PMETHOD pMethodBody ) 
     1539        { 
     1540                //Keep This pointer 
     1541                CVariable* pVar = &*pArguments ++; 
     1542                 
     1543                P1 param1 = (P1)0; 
     1544                P2 param2 = (P2)0; 
     1545                switch( iNumArguments ) 
     1546                { 
     1547                        default: 
     1548                                param2 = (P2)*(pArguments+1); 
     1549                        case 2: 
     1550                                param1 = (P1)*pArguments; 
     1551                        case 1: 
     1552                                break; 
     1553                } 
     1554                 
     1555                RET ret = ((RET (*)( CVariable*, P1, P2 ) )pMethodBody)( pVar, param1, param2 ); 
     1556                pVm->pushEvalStack( ret ); 
     1557                 
     1558                return; 
     1559        } 
     1560         
     1561        /*EN Wrapper template classes for user specified functions. 
     1562         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1563         3 parameters, with a return variable version. 
     1564         \param pVm A pointer to the VM 
     1565         \param iNumArguments A number of given parameters. 
     1566         \param pArguments A pointer to the arguments array. 
     1567         \param pMethodBody An API body. 
     1568         \ingroup MDL_LIB_VM 
     1569         */ 
     1570        template< class RET, class P1, class P2, class P3 > 
     1571        void MakeWrapperMtdP3( CCilVm* const pVm, 
     1572                                                  const int32_t iNumArguments, 
     1573                                                  CVariable* pArguments, 
     1574                                                  PMETHOD pMethodBody ) 
     1575        { 
     1576                //Keep This pointer 
     1577                CVariable* pVar = &*pArguments ++; 
     1578                 
     1579                P1 param1 = (P1)0; 
     1580                P2 param2 = (P2)0; 
     1581                P3 param3 = (P3)0; 
     1582                switch( iNumArguments ) 
     1583                { 
     1584                        default: 
     1585                                param3 = (P3)*(pArguments+2); 
     1586                        case 3: 
     1587                                param2 = (P2)*(pArguments+1); 
     1588                        case 2: 
     1589                                param1 = (P1)*pArguments; 
     1590                        case 1: 
     1591                                break; 
     1592                } 
     1593                 
     1594                RET ret = ((RET (*)( CVariable*, P1, P2, P3 ) )pMethodBody)( pVar, param1, param2, param3 ); 
     1595                pVm->pushEvalStack( ret ); 
     1596                 
     1597                return; 
     1598        } 
     1599         
     1600        /*EN Wrapper template classes for user specified functions. 
     1601         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1602         4 parameters, with a return variable version. 
     1603         \param pVm A pointer to the VM 
     1604         \param iNumArguments A number of given parameters. 
     1605         \param pArguments A pointer to the arguments array. 
     1606         \param pMethodBody An API body. 
     1607         \ingroup MDL_LIB_VM 
     1608         */ 
     1609        template< class RET, class P1, class P2, class P3, class P4 > 
     1610        void MakeWrapperMtdP4( CCilVm* const pVm, 
     1611                                                  const int32_t iNumArguments, 
     1612                                                  CVariable* pArguments, 
     1613                                                  PMETHOD pMethodBody ) 
     1614        { 
     1615                //Keep This pointer 
     1616                CVariable* pVar = &*pArguments ++; 
     1617                 
     1618                P1 param1 = (P1)0; 
     1619                P2 param2 = (P2)0; 
     1620                P3 param3 = (P3)0; 
     1621                P4 param4 = (P4)0; 
     1622                switch( iNumArguments ) 
     1623                { 
     1624                        default: 
     1625                                param4 = (P4)*(pArguments+3); 
     1626                        case 4: 
     1627                                param3 = (P3)*(pArguments+2); 
     1628                        case 3: 
     1629                                param2 = (P2)*(pArguments+1); 
     1630                        case 2: 
     1631                                param1 = (P1)*pArguments; 
     1632                        case 1: 
     1633                                break; 
     1634                } 
     1635                 
     1636                RET ret = ((RET (*)( CVariable*, P1, P2, P3, P4 ) )pMethodBody)( pVar, param1, param2, param3, param4 ); 
     1637                pVm->pushEvalStack( ret ); 
     1638                 
     1639                return; 
     1640        } 
     1641         
     1642        /*EN Wrapper template classes for user specified functions. 
     1643         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1644         5 parameters, with a return variable version. 
     1645         \param pVm A pointer to the VM 
     1646         \param iNumArguments A number of given parameters. 
     1647         \param pArguments A pointer to the arguments array. 
     1648         \param pMethodBody An API body. 
     1649         \ingroup MDL_LIB_VM 
     1650         */ 
     1651        template< class RET, class P1, class P2, class P3, class P4, class P5 > 
     1652        void MakeWrapperMtdP5( CCilVm* const pVm, 
     1653                                                  const int32_t iNumArguments, 
     1654                                                  CVariable* pArguments, 
     1655                                                  PMETHOD pMethodBody ) 
     1656        { 
     1657                //Keep This pointer 
     1658                CVariable* pVar = &*pArguments ++; 
     1659                 
     1660                P1 param1 = (P1)0; 
     1661                P2 param2 = (P2)0; 
     1662                P3 param3 = (P3)0; 
     1663                P4 param4 = (P4)0; 
     1664                P5 param5 = (P5)0; 
     1665                switch( iNumArguments ) 
     1666                { 
     1667                        default: 
     1668                                param5 = (P5)*(pArguments+4); 
     1669                        case 5: 
     1670                                param4 = (P4)*(pArguments+3); 
     1671                        case 4: 
     1672                                param3 = (P3)*(pArguments+2); 
     1673                        case 3: 
     1674                                param2 = (P2)*(pArguments+1); 
     1675                        case 2: 
     1676                                param1 = (P1)*pArguments; 
     1677                        case 1: 
     1678                                break; 
     1679                } 
     1680                 
     1681                RET ret = ((RET (*)( CVariable*, P1, P2, P3, P4, P5 ) )pMethodBody)( pVar, param1, param2, param3, param4, param5 ); 
     1682                pVm->pushEvalStack( ret ); 
     1683                 
     1684                return; 
     1685        } 
     1686         
     1687        //---------------------- 
     1688        //Void return version 
     1689        //---------------------- 
     1690        /*EN Wrapper template classes for user specified functions. 
     1691         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1692         no parameter, without a return variable version. 
     1693         \param pVm A pointer to the VM 
     1694         \param iNumArguments A number of given parameters. 
     1695         \param pArguments A pointer to the arguments array. 
     1696         \param pMethodBody An API body. 
     1697         \ingroup MDL_LIB_VM 
     1698         */ 
     1699        void MakeWrapperMtdVoidP0( CCilVm* const pVm, 
     1700                                                          const int32_t iNumArguments, 
     1701                                                          CVariable* pArguments, 
     1702                                                          PMETHOD pMethodBody ); 
     1703        /* 
     1704         { 
     1705         //Keep This pointer 
     1706         CVariable* pVar = &*pArguments ++; 
     1707          
     1708         ((void (*)( CVariable* ) )pMethodBody)( pVar ); 
     1709         pVm->pushEvalStackUndefined(); 
     1710          
     1711         return; 
     1712         } 
     1713         */ 
     1714         
     1715        /*EN Wrapper template classes for user specified functions. 
     1716         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1717         1 parameter, without a return variable version. 
     1718         \param pVm A pointer to the VM 
     1719         \param iNumArguments A number of given parameters. 
     1720         \param pArguments A pointer to the arguments array. 
     1721         \param pMethodBody An API body. 
     1722         \ingroup MDL_LIB_VM 
     1723         */ 
     1724        template< class P1 > 
     1725        void MakeWrapperMtdVoidP1( CCilVm* const pVm, 
     1726                                                          const int32_t iNumArguments, 
     1727                                                          CVariable* pArguments, 
     1728                                                          PMETHOD pMethodBody ) 
     1729        { 
     1730                //Keep This pointer 
     1731                CVariable* pVar = &*pArguments ++; 
     1732                 
     1733                P1 param1; 
     1734                switch( iNumArguments ) 
     1735                { 
     1736                        default: 
     1737                                param1 = (P1)*pArguments; 
     1738                        case 1: 
     1739                                break; 
     1740                } 
     1741                 
     1742                ((void (*)( CVariable*, P1 ) )pMethodBody)( pVar, param1 ); 
     1743                pVm->pushEvalStackUndefined(); 
     1744                 
     1745                return; 
     1746        } 
     1747         
     1748        /*EN Wrapper template classes for user specified functions. 
     1749         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1750         2 parameters, without a return variable version. 
     1751         \param pVm A pointer to the VM 
     1752         \param iNumArguments A number of given parameters. 
     1753         \param pArguments A pointer to the arguments array. 
     1754         \param pMethodBody An API body. 
     1755         \ingroup MDL_LIB_VM 
     1756         */ 
     1757        template< class P1, class P2 > 
     1758        void MakeWrapperMtdVoidP2( CCilVm* const pVm, 
     1759                                                          const int32_t iNumArguments, 
     1760                                                          CVariable* pArguments, 
     1761                                                          PMETHOD pMethodBody ) 
     1762        { 
     1763                //Keep This pointer 
     1764                CVariable* pVar = &*pArguments ++; 
     1765                 
     1766                P1 param1 = (P1)0; 
     1767                P2 param2 = (P2)0; 
     1768                switch( iNumArguments ) 
     1769                { 
     1770                        default: 
     1771                                param2 = (P2)*(pArguments+1); 
     1772                        case 2: 
     1773                                param1 = (P1)*pArguments; 
     1774                        case 1: 
     1775                                break; 
     1776                } 
     1777                 
     1778                 
     1779                ((void (*)( CVariable*, P1, P2 ) )pMethodBody)( pVar, param1, param2 ); 
     1780                pVm->pushEvalStackUndefined(); 
     1781                 
     1782                return; 
     1783        } 
     1784         
     1785        /*EN Wrapper template classes for user specified functions. 
     1786         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1787         3 parameters, without a return variable version. 
     1788         \param pVm A pointer to the VM 
     1789         \param iNumArguments A number of given parameters. 
     1790         \param pArguments A pointer to the arguments array. 
     1791         \param pMethodBody An API body. 
     1792         \ingroup MDL_LIB_VM 
     1793         */ 
     1794        template< class P1, class P2, class P3 > 
     1795        void MakeWrapperMtdVoidP3( CCilVm* const pVm, 
     1796                                                          const int32_t iNumArguments, 
     1797                                                          CVariable* pArguments, 
     1798                                                          PMETHOD pMethodBody ) 
     1799        { 
     1800                //Keep This pointer 
     1801                CVariable* pVar = &*pArguments ++; 
     1802                 
     1803                P1 param1 = (P1)0; 
     1804                P2 param2 = (P2)0; 
     1805                P3 param3 = (P3)0; 
     1806                switch( iNumArguments ) 
     1807                { 
     1808                        default: 
     1809                                param3 = (P3)*(pArguments+2); 
     1810                        case 3: 
     1811                                param2 = (P2)*(pArguments+1); 
     1812                        case 2: 
     1813                                param1 = (P1)*pArguments; 
     1814                        case 1: 
     1815                                break; 
     1816                } 
     1817                 
     1818                ((void (*)( CVariable*, P1, P2, P3 ) )pMethodBody)( pVar, param1, param2, param3 ); 
     1819                pVm->pushEvalStackUndefined(); 
     1820                 
     1821                return; 
     1822        } 
     1823         
     1824        /*EN Wrapper template classes for user specified functions. 
     1825         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1826         4 parameters, without a return variable version. 
     1827         \param pVm A pointer to the VM 
     1828         \param iNumArguments A number of given parameters. 
     1829         \param pArguments A pointer to the arguments array. 
     1830         \param pMethodBody An API body. 
     1831         \ingroup MDL_LIB_VM 
     1832         */ 
     1833        template< class P1, class P2, class P3, class P4 > 
     1834        void MakeWrapperMtdVoidP4( CCilVm* const pVm, 
     1835                                                          const int32_t iNumArguments, 
     1836                                                          CVariable* pArguments, 
     1837                                                          PMETHOD pMethodBody ) 
     1838        { 
     1839                //Keep This pointer 
     1840                CVariable* pVar = &*pArguments ++; 
     1841                 
     1842                P1 param1 = (P1)0; 
     1843                P2 param2 = (P2)0; 
     1844                P3 param3 = (P3)0; 
     1845                P4 param4 = (P4)0; 
     1846                switch( iNumArguments ) 
     1847                { 
     1848                        default: 
     1849                                param4 = (P4)*(pArguments+3); 
     1850                        case 4: 
     1851                                param3 = (P3)*(pArguments+2); 
     1852                        case 3: 
     1853                                param2 = (P2)*(pArguments+1); 
     1854                        case 2: 
     1855                                param1 = (P1)*pArguments; 
     1856                        case 1: 
     1857                                break; 
     1858                } 
     1859                 
     1860                ((void (*)( CVariable*, P1, P2, P3, P4 ) )pMethodBody)( pVar, param1, param2, param3, param4 ); 
     1861                pVm->pushEvalStackUndefined(); 
     1862                 
     1863                return; 
     1864        } 
     1865         
     1866        /*EN Wrapper template classes for user specified functions. 
     1867         This wrapper is for a function thatrequires 'this' value as a first parameter. 
     1868         5 parameters, without a return variable version. 
     1869         \param pVm A pointer to the VM 
     1870         \param iNumArguments A number of given parameters. 
     1871         \param pArguments A pointer to the arguments array. 
     1872         \param pMethodBody An API body. 
     1873         \ingroup MDL_LIB_VM 
     1874         */ 
     1875        template< class P1, class P2, class P3, class P4, class P5 > 
     1876        void MakeWrapperMtdVoidP5( CCilVm* const pVm, 
     1877                                                          const int32_t iNumArguments, 
     1878                                                          CVariable* pArguments, 
     1879                                                          PMETHOD pMethodBody ) 
     1880        { 
     1881                //Keep This pointer 
     1882                CVariable* pVar = &*pArguments ++; 
     1883                 
     1884                P1 param1 = (P1)0; 
     1885                P2 param2 = (P2)0; 
     1886                P3 param3 = (P3)0; 
     1887                P4 param4 = (P4)0; 
     1888                P5 param5 = (P5)0; 
     1889                switch( iNumArguments ) 
     1890                { 
     1891                        default: 
     1892                                param5 = (P5)*(pArguments+4); 
     1893                        case 5: 
     1894                                param4 = (P4)*(pArguments+3); 
     1895                        case 4: 
     1896                                param3 = (P3)*(pArguments+2); 
     1897                        case 3: 
     1898                                param2 = (P2)*(pArguments+1); 
     1899                        case 2: 
     1900                                param1 = (P1)*pArguments; 
     1901                        case 1: 
     1902                                break; 
     1903                } 
     1904                 
     1905                ((void (*)( CVariable*, P1, P2, P3, P4, P5 ) )pMethodBody)( pVar, param1, param2, param3, param4, param5 ); 
     1906                pVm->pushEvalStackUndefined(); 
     1907                 
     1908                return; 
     1909        } 
     1910         
    19081911}//namespace cri