Changeset 195

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
  • build/win32/CRIScript

    • Property svn:ignore set to
      debug
  • inc/cilBuiltinObject.h

    r138 r195  
    7070        const wchar_t STRING_INTERNAL_CALLNAME[] = L"call"; 
    7171 
    72  
    73         //RID definitions 
    74         enum RID_BUILTIN_CONSTANT { 
    75                 RID_CONSTANT_UNDEFINED          = MDT_FIELDDEF | 0, 
    76                 RID_CONSTANT_NULL                       = MDT_FIELDDEF | 1, 
    77                 RID_CONSTANT_THIS                       = MDT_FIELDDEF | 2, 
    78                 RID_CONSTANT_BOOL_TRUE          = MDT_FIELDDEF | 3, 
    79                 RID_CONSTANT_BOOL_FALSE         = MDT_FIELDDEF | 4, 
    80                 RID_SWITCHTMP                           = MDT_FIELDDEF | 5, 
    81                 RID_CONSTANT_DELETION           = MDT_FIELDDEF | 6, 
    82                 RID_CONSTANT_NAN                        = MDT_FIELDDEF | 7, 
    83                 RID_CONSTANT_INFINITY           = MDT_FIELDDEF | 8, 
    84                 RID_ARGUMENTS_TMP                       = MDT_FIELDDEF | 9, 
    85         }; 
    86  
    87         /*EN An enum values that defines a number of parameters for a built-in object 
    88         \ingroup MDL_LIB_BUILTINOBJECT 
    89         */ 
    90         enum RID_BUILTIN_PARAM { 
    91                 RID_BUILTINPARAM_NULL                   = 0,                                            /*EN< No parameter */ 
    92                 RID_BUILTINPARAM_DEFAULT_ZERO   = MDT_PARAMDEF| 0xffffff,       /*EN< 0 parameter */ 
    93                 RID_BUILTINPARAM_DEFAULT_ONE    = MDT_PARAMDEF| 0xfffffe,       /*EN< 1 parameter */ 
    94                 RID_BUILTINPARAM_DEFAULT_TWO    = MDT_PARAMDEF| 0xfffffd,       /*EN< 2 parameters */ 
    95                 RID_BUILTINPARAM_DEFAULT_THREE  = MDT_PARAMDEF| 0xfffffc,       /*EN< 3 parameters */ 
    96                 RID_BUILTINPARAM_DEFAULT_FOUR   = MDT_PARAMDEF| 0xfffffb,       /*EN< 4 parameters */ 
    97                 RID_BUILTINPARAM_DEFAULT_FIVE   = MDT_PARAMDEF| 0xfffffa,       /*EN< 5 parameters */ 
    98                 RID_BUILTINPARAM_DEFAULT_SIX    = MDT_PARAMDEF| 0xfffff9,       /*EN< 6 parameters */ 
    99                 RID_BUILTINPARAM_DEFAULT_SEVEN  = MDT_PARAMDEF| 0xfffff8,       /*EN< 7 parameters */ 
    100                 RID_BUILTINPARAM_DEFAULT_EIGHT  = MDT_PARAMDEF| 0xfffff7,       /*EN< 8 parameters */ 
    101                 RID_BUILTINPARAM_DEFAULT_NINE   = MDT_PARAMDEF| 0xfffff6,       /*EN< 9 parameters */ 
    102         }; 
    103  
    10472        const wchar_t STRING_INTERNAL_UNDEFINED[]       = L"undefined"; 
    10573        const wchar_t STRING_INTERNAL_NULL[]            = L"null"; 
     
    11482        const wchar_t STRING_INTERNAL_NAN[]                     = L"NaN"; 
    11583        const wchar_t STRING_INTERNAL_INFINITY[]        = L"Infinity"; 
     84        const wchar_t STRING_INTERNAL_NEGATIVE_INFINITY[]       = L"-Infinity"; 
    11685        const wchar_t STRING_INTERNAL_INFINITY_TOBEREPLACED[] = L"1.#INF"; 
    11786        const wchar_t STRING_INTERNAL_ARGUMENTSTMP[]    = L"argumentsTemporaryField"; 
     
    368337                */ 
    369338                virtual bool InitializeVm( CCilVm& vm ) = 0; 
     339                 
     340                /*EN Ctor*/ 
     341                CBuiltinObject() {}; 
     342                 
     343                /*EN Dtor*/ 
     344                virtual ~CBuiltinObject() {}; 
    370345        }; 
    371346 
     
    463438                                                                        CVariable* pArguments ); 
    464439                static bool CheckArrayIndex( const wstring& str );      /*EN< Check if the string is array index*/  
    465                 static bool Predicater( CVariable& elem1, 
    466                                         CVariable& elem2 );                                           /*EN< Array.sort predicater*/ 
    467                 static bool CilPredicater( CVariable& elem1, 
    468                                         CVariable& elem2 );                                           /*EN< Array.sort predicater with script function given 
     440                static bool Predicater( const CVariable& elem1, 
     441                                        const CVariable& elem2 );                                             /*EN< Array.sort predicater*/ 
     442                static bool CilPredicater( const CVariable& elem1, 
     443                                        const CVariable& elem2 );                                             /*EN< Array.sort predicater with script function given 
    469444                                                                                                                        Note that it's using static member for a function pointer*/ 
    470445                static CCilVm* g_pVm;                                                           /*EN< Static member for Array.sort*/ 
     
    632607        public: 
    633608                //Override it not to initialize keyword map 
    634                 bool init(); 
     609                CNumberparser() {}; 
     610                virtual ~CNumberparser() {}; 
     611                virtual bool init(); 
    635612        protected: 
    636613                //Override tokenFound 
     
    654631                static PROPERTY_INITIALIZATION_PARAM initPropertyParams[]; 
    655632 
    656                 static CNumberparser m_numberparser; 
     633                static CNumberparser* m_pNumberparser; 
    657634 
    658635        public: 
     
    663640                bool InitializeVm( CCilVm& vm ); 
    664641                static bool parseNumber( CVariable& var, const wstring* const pstr ); 
     642                 
     643                CNumberObject() 
     644                { 
     645                        if( m_pNumberparser == NULL ) 
     646                        { 
     647                                m_pNumberparser = new CNumberparser(); 
     648                        } 
     649 
     650                } 
     651                virtual ~CNumberObject() 
     652                { 
     653                } 
    665654        }; 
    666655 
     
    949938                                                                                        const int32_t iNumArguments,  
    950939                                                                                        CVariable* pArguments ); 
    951                 static void typeof( CCilVm* const pVm, 
     940                static void Typeof( CCilVm* const pVm, 
    952941                                                                                        const int32_t iNumArguments,  
    953942                                                                                        CVariable* pArguments ); 
  • inc/cilCodegen.h

    r138 r195  
    458458                //--------------------------------------------------------- 
    459459                CErrorPool*             m_pError; 
    460                 CParser*                m_pparser; 
     460                CParser*                m_pParser; 
    461461                CLexer*                 m_pLex; 
    462462                CStringLexer*   m_pStringLexer; 
  • inc/cilDebugger.h

    r138 r195  
    9191                void setDumpSymbolInfo( bool b ) { m_bDumpSymbolInfo = b;} 
    9292                void setILStream( ILFRAGMENT& ILStream); 
     93                void setILStream( const uint8_t* pStream, const size_t size ); 
    9394 
    9495        private: 
     
    117118                bool m_bDumpByteCodeData; 
    118119                bool m_bDumpSymbolInfo; 
    119                 int8_t m_strBuffer[ SIZE_ERRORSTRING ]; 
     120                char m_strBuffer[ SIZE_ERRORSTRING ]; 
    120121                wchar_t m_wstrBuffer[ SIZE_ERRORSTRING ]; 
    121122 
  • inc/cilErrorDef_English.h

    r110 r195  
    1919#pragma once 
    2020 
     21#include "stdafx.h" 
    2122#include "Error.h" 
    2223 
    2324namespace cri { 
    24  
     25         
    2526const ERROR_DEF g_ErrorTable_English[] = { 
    2627//Tool error code 
    27 { ERROR_FILENOTFOUND,   E_ERROR, true,  L"File %s not found" }, 
     28{ ERROR_FILENOTFOUND,   E_ERROR, true,  L"File " INFO_STRING L" not found" }, 
    2829{ ERROR_INVALIDFILEENCODING,                    E_ERROR, false,  L"Source File format is not in UTF16(BOM)" }, 
    29 { ERROR_INVALIDOPTIONSWITCH,                    E_ERROR, true,  L"Unknown option switch '%s'" }, 
     30{ ERROR_INVALIDOPTIONSWITCH,                    E_ERROR, true,  L"Unknown option switch '" INFO_STRING L"'" }, 
    3031 
    3132//Compiler error code 
     
    5253{ ERROR_EXPECTED_WHILE,                 E_ERROR, false, L"Expected 'while'" }, 
    5354{ ERROR_INVALIDCHARACTER,               E_ERROR, false, L"Invalid character" }, 
    54 { ERROR_LABELNOTFOUND,                  E_ERROR, true,  L"Label \"%s\" not found" }, 
     55{ ERROR_LABELNOTFOUND,                  E_ERROR, true,  L"Label \"" INFO_STRING L"\" not found" }, 
    5556{ ERROR_LABELALREADYDEFINED,    E_ERROR, false, L"Label redefined" }, 
    5657{ ERROR_INVALIDRETURN,                  E_ERROR, false, L"'return' statement outside of function" }, 
     
    6061{ ERROR_INVALIDSTRING,                  E_ERROR, false, L"Unterminated string constant. \" expected." }, 
    6162{ ERROR_INVALIDSTRINGCOLON,             E_ERROR, false, L"Unterminated string constant. ' expected." }, 
    62 { ERROR_RESERVEDWORD,                   E_ERROR, true,  L"Reserved word \"%s\" can not be used." }, 
    63 { ERROR_IDALREADYDEFINED,               E_ERROR, true,  L"identifier \"%s\" already defined" }, 
     63{ ERROR_RESERVEDWORD,                   E_ERROR, true,  L"Reserved word \"" INFO_STRING L"\" can not be used." }, 
     64{ ERROR_IDALREADYDEFINED,               E_ERROR, true,  L"identifier \"" INFO_STRING L"\" already defined" }, 
    6465{ ERROR_STATEMENTNOTALLOWED,    E_ERROR, false, L"Statement is not allowed" }, 
    6566{ ERROR_FOR_INFINITE,                   E_ERROR, false, L"Infinite 'for' loop is not allowed" }, 
    66 { ERROR_INTERNALIDALREADYDEFINED,E_ERROR, true,  L"Internal identifier \"%s\" already defined" }, 
    67 { ERROR_PARAMETERALREADYDEFINED,E_ERROR, true,  L"An argument \"%s\" already defined" }, 
    68 { ERROR_FUNCTIONNAMENOTFOUND,   E_ERROR, true,  L"Could not find a function name \"%s\"" }, 
    69 { ERROR_METHODNAMEASSIGNMENTNOTALLOWED, E_ERROR, true,  L"Assigment to \"%s\" is not allowed by the compile setting" }, 
    70 { ERROR_ILLEGALCALLTYPE,        E_ERROR, true,  L"\"%s\" can not be a function nor a pointer" }, 
     67{ ERROR_INTERNALIDALREADYDEFINED,E_ERROR, true,  L"Internal identifier \"" INFO_STRING L"\" already defined" }, 
     68{ ERROR_PARAMETERALREADYDEFINED,E_ERROR, true,  L"An argument \"" INFO_STRING L"\" already defined" }, 
     69{ ERROR_FUNCTIONNAMENOTFOUND,   E_ERROR, true,  L"Could not find a function name \"" INFO_STRING L"\"" }, 
     70{ ERROR_METHODNAMEASSIGNMENTNOTALLOWED, E_ERROR, true,  L"Assigment to \"" INFO_STRING L"\" is not allowed by the compile setting" }, 
     71{ ERROR_ILLEGALCALLTYPE,        E_ERROR, true,  L"\"" INFO_STRING L"\" can not be a function nor a pointer" }, 
    7172{ ERROR_CANNOTASSIGNCONSTANT,   E_ERROR, false,  L"Can not assign to a constant value" }, 
    72 { ERROR_CANNOTASSIGNREADONLY,   E_ERROR, true,  L"Can not assign to a readonly variable \"%s\"" }, 
     73{ ERROR_CANNOTASSIGNREADONLY,   E_ERROR, true,  L"Can not assign to a readonly variable \"" INFO_STRING L"\"" }, 
    7374{ ERROR_ONLYONEDEFAULTISALLOWED,        E_ERROR, false,  L"Just 1 default clause is allowed inside a switch clause" }, 
    7475{ ERROR_CANNOTHAVECASE,                 E_ERROR, false,  L"Can't have 'case/default' outside of a switch statement" }, 
    75 { ERROR_NOOBJECTCTOR,                   E_ERROR, true,  L"The object \"%s\" does not have a constructor" }, 
     76{ ERROR_NOOBJECTCTOR,                   E_ERROR, true,  L"The object \"" INFO_STRING L"\" does not have a constructor" }, 
    7677{ ERROR_FUNCTIONCTORNOTSUPPORTED,                       E_ERROR, false,  L"The Function constructor with arguments is not supported in this version" }, 
    7778{ ERROR_WITHONLYACCEPTOBJREF,   E_ERROR, false,  L"'with' statement only accepts an object definition as the argument in this version for a performance reason" }, 
    78 { ERROR_OBJECTNAMENOTFOUND,             E_ERROR, true,  L"Can not find an object name \"%s\"" }, 
     79{ ERROR_OBJECTNAMENOTFOUND,             E_ERROR, true,  L"Can not find an object name \"" INFO_STRING L"\"" }, 
    7980{ ERROR_BADREGEXLITERALFORMAT,  E_ERROR, false,  L"Bad RegExp literal format" }, 
    80 { ERROR_ILLEGALTYPESPECIFIER,   E_ERROR, true,  L"Illegal type name \"%s\"" }, 
     81{ ERROR_ILLEGALTYPESPECIFIER,   E_ERROR, true,  L"Illegal type name \"" INFO_STRING L"\"" }, 
    8182{ ERROR_DYNAMICEVALNOTSUPPORTED,        E_ERROR, false,  L"Dynamic eval not supported in this version." }, 
    8283 
     
    8485{ INFO_IF_NOEFFECT,                             E_INFORMATION, false, L"IF statement has no effect" }, 
    8586{ INFO_FOR_NOEFFECT,                    E_INFORMATION, false, L"For statement has no effect" }, 
    86 { INFO_IDNOTREGISTERED,                 E_INFORMATION, true, L"Variable \"%s\" is not registered explicitly" }, 
    87 { INFO_VARIABLENOTASSIGNED,             E_INFORMATION, true, L"Variable \"%s\" is not initialized here" }, 
     87{ INFO_IDNOTREGISTERED,                 E_INFORMATION, true, L"Variable \"" INFO_STRING L"\" is not registered explicitly" }, 
     88{ INFO_VARIABLENOTASSIGNED,             E_INFORMATION, true, L"Variable \"" INFO_STRING L"\" is not initialized here" }, 
    8889{ INFO_DIFFERENTNUMARGS,                E_INFORMATION, false, L"A number of given arguments differs from the function signature" }, 
    89 { INFO_OBJECTINITIALIZORDUPLICATION, E_INFORMATION, true, L"Duplicating object property name \"%s\"." }, 
     90{ INFO_OBJECTINITIALIZORDUPLICATION, E_INFORMATION, true, L"Duplicating object property name \"" INFO_STRING L"\"." }, 
    9091{ INFO_arrayLiteralTOOLARGE,    E_INFORMATION, false, L"Array size could be too large." }, 
    91 { INFO_INVOKINGVARIABLE,                E_INFORMATION, true,  L"Invoking variable \"%s\". Could involve runtime exception if the variable is not a function reference." }, 
     92{ INFO_INVOKINGVARIABLE,                E_INFORMATION, true,  L"Invoking variable \"" INFO_STRING L"\". Could involve runtime exception if the variable is not a function reference." }, 
    9293 
    9394 
  • inc/cilOpcode.h

    r138 r195  
    2323 
    2424namespace cri { 
    25  
    26 // 
    27 // Token tags. 
    28 // 
    29 typedef enum COR_TOKEN_TYPE 
    30 { 
    31     MDT_MODULE               = 0x00000000,       // 
    32     MDT_TYPEREF              = 0x01000000,       // 
    33     MDT_TYPEDEF              = 0x02000000,       // 
    34     MDT_FIELDDEF             = 0x04000000,       // 
    35     MDT_METHODDEF            = 0x06000000,       // 
    36     MDT_PARAMDEF             = 0x08000000,       // 
    37     MDT_INTERFACEIMPL        = 0x09000000,       // 
    38     MDT_MEMBERREF            = 0x0a000000,       // 
    39     MDT_CUSTOMATTRIBUTE      = 0x0c000000,       // 
    40     MDT_PERMISSION           = 0x0e000000,       // 
    41     MDT_SIGNATURE            = 0x11000000,       // 
    42     MDT_EVENT                = 0x14000000,       // 
    43     MDT_PROPERTY             = 0x17000000,       // 
    44     MDT_MODULEREF            = 0x1a000000,       // 
    45     MDT_TYPESPEC             = 0x1b000000,       // 
    46     MDT_ASSEMBLY             = 0x20000000,       // 
    47     MDT_ASSEMBLYREF          = 0x23000000,       // 
    48     MDT_FILE                 = 0x26000000,       // 
    49     MDT_EXPORTEDTYPE         = 0x27000000,       // 
    50     MDT_MANIFESTRESOURCE     = 0x28000000,       // 
    51     MDT_GENERICPARAM         = 0x2a000000,       // 
    52     MDT_METHAODSPEC           = 0x2b000000,       // 
    53     MDT_GENERICPARAMCONSTRAINT = 0x2c000000, 
    54  
    55     MDT_STRING               = 0x70000000,       // 
    56     MDT_NAME                 = 0x71000000,       // 
    57     MDT_BASETYPE             = 0x72000000,       // Leave this on the high end value. This does not correspond to metadata table 
    58 } COR_TOKEN_TYPE; 
    5925 
    6026// 
     
    6430#define TokenFromRid(rid,tktype) ((rid) | (tktype)) 
    6531#define RidFromToken(tk) ((RID) ((tk) & 0x00ffffff)) 
    66 #define TypeFromToken(tk) ((ULONG32)((tk) & 0xff000000)) 
     32#define TypeFromToken(tk) ((uint32_t)((tk) & 0xff000000)) 
    6733#define isNilToken(tk) ((RidFromToken(tk)) == 0) 
    6834#define isBuiltinRid(tk) ((tk) & 0x800000) 
     
    484450struct OPCODE_TABLEENTRY { 
    485451        OP_CODE OpCode; 
    486         int8_t * pName; 
     452        const char * pName; 
    487453        int32_t iPopbehaivor; 
    488454        int32_t iPushbehaivor; 
     
    495461}; 
    496462 
    497 typedef vector< uint8_t > ILFRAGMENT; 
     463typedef std::vector< uint8_t > ILFRAGMENT; 
    498464 
    499465class ILFRAGMENTINFO { 
     
    501467        ILFRAGMENTINFO() : MethodRID( 0 ), iNumEvalStackEntries( 0 ) {} 
    502468        ~ILFRAGMENTINFO() {} 
     469        RID             MethodRID; 
     470        int32_t iNumEvalStackEntries; 
     471        wstring strScopeName; 
    503472        ILFRAGMENT ILPool; 
    504         RID             MethodRID; 
    505         wstring strScopeName; 
    506         int32_t iNumEvalStackEntries; 
    507473}; 
    508474 
     
    517483 
    518484}//namespace cri 
     485 
     486#ifdef __APPLE__ 
     487//Hash function 
     488namespace __gnu_cxx { 
     489        template<> 
     490        struct hash<cri::OP_CODE> 
     491        { 
     492                size_t operator()(const cri::OP_CODE __x) const 
     493                { 
     494                        return size_t(__x); 
     495                } 
     496        };       
     497} 
     498#endif 
     499 
  • 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 
  • inc/criscript.h

    r103 r195  
    3131 
    3232//------------------------------------------------------------- 
     33//enums 
     34//------------------------------------------------------------- 
     35// 
     36// Token tags. 
     37// 
     38typedef enum COR_TOKEN_TYPE 
     39        { 
     40                MDT_MODULE               = 0x00000000,       // 
     41                MDT_TYPEREF              = 0x01000000,       // 
     42                MDT_TYPEDEF              = 0x02000000,       // 
     43                MDT_FIELDDEF             = 0x04000000,       // 
     44                MDT_METHODDEF            = 0x06000000,       // 
     45                MDT_PARAMDEF             = 0x08000000,       // 
     46                MDT_INTERFACEIMPL        = 0x09000000,       // 
     47                MDT_MEMBERREF            = 0x0a000000,       // 
     48                MDT_CUSTOMATTRIBUTE      = 0x0c000000,       // 
     49                MDT_PERMISSION           = 0x0e000000,       // 
     50                MDT_SIGNATURE            = 0x11000000,       // 
     51                MDT_EVENT                = 0x14000000,       // 
     52                MDT_PROPERTY             = 0x17000000,       // 
     53                MDT_MODULEREF            = 0x1a000000,       // 
     54                MDT_TYPESPEC             = 0x1b000000,       // 
     55                MDT_ASSEMBLY             = 0x20000000,       // 
     56                MDT_ASSEMBLYREF          = 0x23000000,       // 
     57                MDT_FILE                 = 0x26000000,       // 
     58                MDT_EXPORTEDTYPE         = 0x27000000,       // 
     59                MDT_MANIFESTRESOURCE     = 0x28000000,       // 
     60                MDT_GENERICPARAM         = 0x2a000000,       // 
     61                MDT_METHAODSPEC           = 0x2b000000,       // 
     62                MDT_GENERICPARAMCONSTRAINT = 0x2c000000, 
     63                 
     64                MDT_STRING               = 0x70000000,       // 
     65                MDT_NAME                 = 0x71000000,       // 
     66                MDT_BASETYPE             = 0x72000000,       // Leave this on the high end value. This does not correspond to metadata table 
     67        } COR_TOKEN_TYPE; 
     68 
     69//RID definitions 
     70enum RID_BUILTIN_CONSTANT { 
     71        RID_CONSTANT_UNDEFINED          = MDT_FIELDDEF | 0, 
     72        RID_CONSTANT_NULL                       = MDT_FIELDDEF | 1, 
     73        RID_CONSTANT_THIS                       = MDT_FIELDDEF | 2, 
     74        RID_CONSTANT_BOOL_TRUE          = MDT_FIELDDEF | 3, 
     75        RID_CONSTANT_BOOL_FALSE         = MDT_FIELDDEF | 4, 
     76        RID_SWITCHTMP                           = MDT_FIELDDEF | 5, 
     77        RID_CONSTANT_DELETION           = MDT_FIELDDEF | 6, 
     78        RID_CONSTANT_NAN                        = MDT_FIELDDEF | 7, 
     79        RID_CONSTANT_INFINITY           = MDT_FIELDDEF | 8, 
     80        RID_ARGUMENTS_TMP                       = MDT_FIELDDEF | 9, 
     81}; 
     82 
     83/*EN An enum values that defines a number of parameters for a built-in object 
     84 \ingroup MDL_LIB_BUILTINOBJECT 
     85 */ 
     86enum RID_BUILTIN_PARAM { 
     87        RID_BUILTINPARAM_NULL                   = 0,                                            /*EN< No parameter */ 
     88        RID_BUILTINPARAM_DEFAULT_ZERO   = MDT_PARAMDEF| 0xffffff,       /*EN< 0 parameter */ 
     89        RID_BUILTINPARAM_DEFAULT_ONE    = MDT_PARAMDEF| 0xfffffe,       /*EN< 1 parameter */ 
     90        RID_BUILTINPARAM_DEFAULT_TWO    = MDT_PARAMDEF| 0xfffffd,       /*EN< 2 parameters */ 
     91        RID_BUILTINPARAM_DEFAULT_THREE  = MDT_PARAMDEF| 0xfffffc,       /*EN< 3 parameters */ 
     92        RID_BUILTINPARAM_DEFAULT_FOUR   = MDT_PARAMDEF| 0xfffffb,       /*EN< 4 parameters */ 
     93        RID_BUILTINPARAM_DEFAULT_FIVE   = MDT_PARAMDEF| 0xfffffa,       /*EN< 5 parameters */ 
     94        RID_BUILTINPARAM_DEFAULT_SIX    = MDT_PARAMDEF| 0xfffff9,       /*EN< 6 parameters */ 
     95        RID_BUILTINPARAM_DEFAULT_SEVEN  = MDT_PARAMDEF| 0xfffff8,       /*EN< 7 parameters */ 
     96        RID_BUILTINPARAM_DEFAULT_EIGHT  = MDT_PARAMDEF| 0xfffff7,       /*EN< 8 parameters */ 
     97        RID_BUILTINPARAM_DEFAULT_NINE   = MDT_PARAMDEF| 0xfffff6,       /*EN< 9 parameters */ 
     98}; 
     99 
     100//------------------------------------------------------------- 
    33101//Includes 
    34102//------------------------------------------------------------- 
    35103#include "stdint.h" 
    36104#include "versions.h" 
    37 #include "Win32/Stopwatch.h" 
    38105#include "lexer.h" 
    39106#include "parser.h" 
     
    95162 
    96163 
    97 #ifndef _XBOX 
     164#ifdef _XBOX 
     165/*************************************************************************** 
     166 * Definitions for Xbox360 
     167 ***************************************************************************/ 
     168#ifdef  NDEBUG 
     169 
     170#define Debug_Fatal(_Message)     ((void)0) 
     171#define Debug_Warning(_Message)     ((void)0) 
     172 
     173#else 
     174 
     175#ifdef  __cplusplus 
     176extern "C" { 
     177#endif 
     178         
     179        _CRTIMP void __cdecl _wassert(__in_z const wchar_t * _Message, 
     180                                                                  __in_z const wchar_t *_File, 
     181                                                                  __in unsigned _Line); 
     182         
     183#ifdef  __cplusplus 
     184
     185#endif 
     186 
     187#define Debug_Fatal(_Message) (void)(_wassert(_CRT_WIDE(#_Message),\ 
     188_CRT_WIDE(__FILE__), __LINE__), 0) 
     189#define Debug_Warning(_Message) (void)(OutputDebugStringW(_CRT_WIDE(_Message))) 
     190#endif 
     191 
     192#else 
     193 
     194#ifdef __APPLE__ 
     195/*************************************************************************** 
     196 * Definitions for OSX 
     197 ***************************************************************************/ 
     198#ifdef  NDEBUG 
     199 
     200#define Debug_Fatal(_Message)     ((void)0) 
     201#define Debug_Warning(_Message)     ((void)0) 
     202 
     203#else 
     204 
     205#ifdef  __cplusplus 
     206extern "C" { 
     207#endif 
     208         
     209//      _CRTIMP void __cdecl _wassert(__in_z const wchar_t * _Message, 
     210//                                                                __in_z const wchar_t *_File, 
     211//                                                                __in unsigned _Line); 
     212         
     213#ifdef  __cplusplus 
     214
     215#endif 
     216 
     217#define Debug_Fatal(_Message) (void)(assert(_Message)) 
     218#define Debug_Warning(_Message) (void)(printf(_Message)) 
     219#endif 
     220 
     221#else 
    98222/*************************************************************************** 
    99223 * Definitions for PC 
    100224 ***************************************************************************/ 
    101        #ifdef  NDEBUG 
    102  
     225#ifdef  NDEBUG 
     226#ifndef Debug_Fatal 
    103227        #define Debug_Fatal(_Message)     ((void)0) 
     228#endif 
     229 
     230#ifndef Debug_Warning 
    104231        #define Debug_Warning(_Message)     ((void)0) 
    105  
    106         #else 
    107  
    108         #ifdef  __cplusplus 
    109         extern "C" { 
    110         #endif 
    111  
     232#endif 
     233 
     234#else 
     235 
     236#ifdef  __cplusplus 
     237extern "C" { 
     238#endif 
     239         
    112240        _CRTIMP void __cdecl _wassert(__in_z const wchar_t * _Message, 
    113                                                                 __in_z const wchar_t *_File, 
    114                                                                 __in unsigned _Line); 
    115  
    116         #ifdef  __cplusplus 
    117         } 
    118         #endif 
    119  
    120         #define Debug_Fatal(_Message) (void)(_wassert(_CRT_WIDE(#_Message),\ 
    121                                                                         _CRT_WIDE(__FILE__), __LINE__), 0) 
    122         #define Debug_Warning(_Message) (void)(OutputDebugString(_CRT_WIDE(_Message))) 
    123         #endif 
    124 #else 
    125 /*************************************************************************** 
    126  * Definitions for Xbox360 
    127  ***************************************************************************/ 
    128         #ifdef  NDEBUG 
    129  
    130         #define Debug_Fatal(_Message)     ((void)0) 
    131         #define Debug_Warning(_Message)     ((void)0) 
    132  
    133         #else 
    134  
    135         #ifdef  __cplusplus 
    136         extern "C" { 
    137         #endif 
    138  
    139         _CRTIMP void __cdecl _wassert(__in_z const wchar_t * _Message, 
    140                                                                 __in_z const wchar_t *_File, 
    141                                                                 __in unsigned _Line); 
    142  
    143         #ifdef  __cplusplus 
    144         } 
    145         #endif 
    146  
    147         #define Debug_Fatal(_Message) (void)(_wassert(_CRT_WIDE(#_Message),\ 
    148                                                                                 _CRT_WIDE(__FILE__), __LINE__), 0) 
    149         #define Debug_Warning(_Message) (void)(OutputDebugStringW(_CRT_WIDE(_Message))) 
    150         #endif 
     241                                                                  __in_z const wchar_t *_File, 
     242                                                                  __in unsigned _Line); 
     243         
     244#ifdef  __cplusplus 
     245
     246#endif 
     247#endif 
     248 
     249#ifndef Debug_Fatal 
     250#define Debug_Fatal(_Message) (void)(_wassert(_CRT_WIDE(#_Message),\ 
     251_CRT_WIDE(__FILE__), __LINE__), 0) 
     252#endif 
     253 
     254#ifndef Debug_Warning 
     255#define Debug_Warning(_Message) (void)(OutputDebugString(_CRT_WIDE(_Message))) 
     256#endif 
     257 
     258#endif 
    151259 
    152260#endif 
  • inc/error.h

    r138 r195  
    1818 ****************************************************************************/ 
    1919#pragma once 
    20  
    21 using namespace std; 
    22  
    2320 
    2421namespace cri { 
     
    222219 
    223220        private: 
     221                const ERROR_DEF* m_pErrorTable; 
     222                int32_t m_iNumErrors[ NUM_ERROR_LEVELS ]; 
     223                bool m_bsuppressErrorLine; 
     224                map< int32_t,const ERROR_DEF * >* m_pmapErrorCode; 
     225 
    224226                map< wstring, int32_t > m_mapFileName; 
    225227                map< wstring, int32_t > m_mapSrcLine; 
    226228                map< wstring, int32_t > m_mapInfo; 
    227229                vector< parserError > m_ErrorList; 
    228                 const ERROR_DEF* m_pErrorTable; 
     230 
    229231                bool getErrorLevel( int32_t iErrorCode ); 
    230  
    231                 int32_t m_iNumErrors[ NUM_ERROR_LEVELS ]; 
    232                 map< int32_t,const ERROR_DEF * > m_mapErrorCode; 
    233                 bool m_bsuppressErrorLine; 
    234232        }; 
    235233 
  • inc/icodegen.h

    r138 r195  
    1919#pragma once 
    2020 
    21 using namespace std; 
    22 using namespace stdext; 
    23  
    2421namespace cri { 
    2522 
     
    9592        union {                                  
    9693                int32_t iILOffset;                                      /*EN< Offset value of IL stream of the method*/ 
    97                 void*  lpFunction;                                    /*EN< Function pointer to the method if the method is native one*/ 
     94                void   (*lpFunction)();                       /*EN< Function pointer to the method if the method is native one*/ 
    9895        }; 
    9996        int32_t iNumArgments;                                   /*EN< Number of arguments*/ 
     
    103100        union { 
    104101                int32_t iNumLocals;                                     /*EN< Number of local variables*/ 
    105                 void*  lpFunctionBody;                        /*EN< Pointer to the function body if the method is a wrapped function*/ 
     102                void   (*lpFunctionBody)();           /*EN< Pointer to the function body if the method is a wrapped function*/ 
    106103        }; 
    107104        uint32_t        iNumberOfReturnPass;            /*EN< Number of return passes in the method*/ 
     
    350347 
    351348class CParser; 
    352 class CVariable; 
    353349class CCilVm; 
    354350class CVmObject; 
    355  
     351
     352 
     353#include "variable.h" 
     354 
     355namespace cri { 
    356356/*EN Object type information structure 
    357357*/ 
     
    450450 
    451451//--------------------------------------------------------------------------- 
    452         // Meta data managing class 
    453         //--------------------------------------------------------------------------- 
    454         //Forward decls 
    455         enum RID_BUILTIN_OBJECT; 
    456         enum RID_BUILTIN_STRING; 
    457         enum RID_BUILTIN_PARAM; 
    458         enum RID_BUILTIN_METHOD; 
     452// Meta data managing class 
     453//--------------------------------------------------------------------------- 
    459454 
    460455        /*EN Metadata information class 
     
    466461                ~CMetaData();                                   /*EN< dtor*/ 
    467462                CMetaData( CMetaData& right );  /*EN< Copy ctor*/ 
    468                 CMetaData& CMetaData::operator=( CMetaData& right ); 
     463                CMetaData& operator=( CMetaData& right ); 
    469464                                                                                /*EN< =Operator*/ 
    470465 
  • inc/lexer.h

    r138 r195  
    2222#include "iCodeGen.h" 
    2323 
    24 using namespace std; 
    25  
    2624//Work around to Doxygen behaivor 
    2725//Somehow Doxygen does not parse the descriptions inside a namespace with #include.. 
     
    4038 
    4139struct LEX_WORD_ITEM { 
    42         wstring sKey; 
    43         int32_t iTokenValue; 
     40        const wstring sKey; 
     41        const int32_t iTokenValue; 
    4442}; 
    4543 
    4644struct LEX_WORD_ITEM_EX { 
    47         wstring sKey; 
    48         int32_t iTokenValue; 
    49         int32_t       iValue; 
     45        const wstring sKey; 
     46        const int32_t iTokenValue; 
     47        const int32_t iValue; 
    5048}; 
    5149const wchar_t CODE_LF = 0xa; 
     
    8785                                m_iCurrentTokenColumn( 1 ), 
    8886                                m_bEnableErrorOutput( false ), 
    89                                 m_bEndOfStream( false ) 
    90                 { 
    91                         m_pError = NULL; 
    92                         m_bDuplicateToken = false; 
    93                 }; 
    94  
    95                 /*EN dtor */ 
    96                 ~CLexer()
     87                                m_bEndOfStream( false ), 
     88                               m_strCurrentLine( L"" ), 
     89                               m_strErrorInfo( L"" ), 
     90                               m_strFileName( L"" ), 
     91                               m_strIdentifier( L"" ), 
     92                                m_pError( NULL ), 
     93                               m_bDuplicateToken( false ) 
     94               
    9795                        m_mapReservedWord.clear(); 
    9896                        m_mapKeyword.clear(); 
     
    10199                }; 
    102100 
     101                /*EN dtor */ 
     102                virtual ~CLexer() { 
     103                        m_mapReservedWord.clear(); 
     104                        m_mapKeyword.clear(); 
     105                        m_mapLiteral.clear(); 
     106                        m_mapOperator.clear(); 
     107                }; 
     108 
    103109                /*EN Processes a token stream 
    104110                \par Token stream need to be attached prior process() call 
     
    210216                virtual wchar_t fetchNextChar( void ) = 0; 
    211217                virtual void ungetChar( const wchar_t c ) = 0; 
    212  
    213218                virtual void tokenFound( const int32_t iToken, const int32_t iLine, const int32_t iColumm); 
    214219 
     
    234239                void updateLine( const int32_t iLine, const int32_t iColumn ); 
    235240 
     241                //--------------------------------------------------------- 
     242                //Automatic semicolon insertion flag 
     243                //--------------------------------------------------------- 
     244                bool m_bAllowAutoSemicolon; 
     245                bool m_bDuplicateToken; 
     246                bool m_bBigEndianSource; 
     247                bool m_AllowRegexLiteral; 
     248 
     249                //--------------------------------------------------------- 
     250                //data members 
     251                //--------------------------------------------------------- 
    236252                static const LEX_WORD_ITEM s_ReservedWordTable[]; 
    237253                static const LEX_WORD_ITEM s_KeywordTable[]; 
    238254                static const LEX_WORD_ITEM_EX s_LiteralTable[]; 
    239255                static const LEX_WORD_ITEM s_OperatorTable[]; 
    240  
    241                 hash_map< wstring, int32_t > m_mapReservedWord; 
    242                 hash_map< wstring, int32_t > m_mapKeyword; 
    243                 hash_map< wstring, int32_t > m_mapLiteral; 
    244                 hash_map< wstring, int32_t > m_mapOperator; 
    245  
    246                 //--------------------------------------------------------- 
    247                 //Get current line information 
    248                 //--------------------------------------------------------- 
    249                 wstring m_strCurrentLine; 
    250                 wstring m_strErrorInfo; 
    251                 wstring m_strFileName; 
    252  
    253                 //--------------------------------------------------------- 
    254                 //Automatic semicolon insertion flag 
    255                 //--------------------------------------------------------- 
    256                 bool m_bAllowAutoSemicolon; 
    257                 bool m_bDuplicateToken; 
    258                 bool m_bBigEndianSource; 
    259  
    260                 bool m_AllowRegexLiteral; 
    261  
    262                 //--------------------------------------------------------- 
    263                 //data members 
    264                 //--------------------------------------------------------- 
     256                 
    265257                bool m_bInitialized; 
    266                 CErrorPool * m_pError
    267                 bool   m_bEnableErrorOutput
     258                bool m_bEnableErrorOutput
     259                bool m_bEndOfStream
    268260                int32_t m_iLineNumber; 
    269261                int32_t m_iColumn; 
     
    273265                int32_t m_iLastTokenColumn; 
    274266                int32_t m_iLastTokenLine; 
    275                 YYSTYPE m_uCurrentValue; 
    276                 wstring m_strIdentifier; 
    277267                int64_t m_iValue; 
    278268                double m_dValue; 
    279                 vector<int32_t> m_arrayColumns; 
    280                 vector<int32_t> m_arrayLineOffsets; 
    281                 bool m_bEndOfStream; 
     269                YYSTYPE m_uCurrentValue; 
     270                CErrorPool * m_pError; 
    282271 
    283272        #ifdef _DEBUG 
     
    286275        #endif 
    287276 
     277                vector<int32_t> m_arrayColumns; 
     278                vector<int32_t> m_arrayLineOffsets; 
     279 
     280                hash_map< wstring, int32_t > m_mapKeyword; 
     281                hash_map< wstring, int32_t > m_mapReservedWord; 
     282                hash_map< wstring, int32_t > m_mapLiteral; 
     283                hash_map< wstring, int32_t > m_mapOperator; 
     284                 
     285                //--------------------------------------------------------- 
     286                //Get current line information 
     287                //--------------------------------------------------------- 
     288                wstring m_strIdentifier; 
     289                wstring m_strCurrentLine; 
     290                wstring m_strErrorInfo; 
     291                wstring m_strFileName; 
    288292        }; 
    289293 
     
    298302                //--------------------------------------------------------- 
    299303                /*EN ctor */ 
    300                 CFileStreamLexer() : m_pistream(NULL) 
    301                 { 
     304                CFileStreamLexer() 
     305                { 
     306                        m_pistream = NULL; 
    302307                }; 
    303308                /*EN dtor */ 
    304                 ~CFileStreamLexer() { 
     309                virtual ~CFileStreamLexer() { 
    305310                }; 
    306311 
     
    348353                }; 
    349354                /*EN dtor */ 
    350                 ~CStringLexer() { 
     355                virtual ~CStringLexer() { 
    351356                }; 
    352357 
  • inc/parser.h

    r138 r195  
    4444                CParser() 
    4545                { 
    46                         if( m_pparser == NULL ) 
     46                        if( m_pParser == NULL ) 
    4747                        { 
    48                                 m_pparser = this; 
     48                                m_pParser = this; 
    4949                                m_pError = NULL; 
    5050                                m_pLex = NULL; 
     
    5555                /*EN dtor */ 
    5656                ~CParser() { 
    57                         m_pparser = NULL; 
     57                        m_pParser = NULL; 
    5858                        terminate(); 
    5959                }; 
     
    124124                /*EN get a singleton instance of the parser */ 
    125125                static CParser* getparser() { 
    126                         assert( m_pparser ); 
    127                         return m_pparser; 
     126                        assert( m_pParser ); 
     127                        return m_pParser; 
    128128                }; 
    129129 
     
    132132                YYSTYPE getTokenValue( void );   
    133133        private: 
    134                 static CParser* m_pparser; 
     134                static CParser* m_pParser; 
    135135                bool m_bInitialized; 
    136136                bool m_bPerformLinkage; 
  • inc/stdafx.h

    r44 r195  
    2020 
    2121#ifdef _XBOX 
     22        //Xbox360 
    2223        #include "xbox360/stdafx_xbox360.h" 
     24        using namespace std; 
     25        using namespace stdext; 
     26 
     27        //sprintf_s cast setting 
     28        #define SPRINTF_CAST(a) (a) 
    2329#else 
     30#ifdef __APPLE__        //OSX 
     31        using namespace std; 
     32        #include "osx/stdafx_osx.h" 
     33        using namespace __gnu_cxx; 
     34 
     35        //sprintf_s cast setting 
     36        #define SPRINTF_CAST(a) ((char*)a) 
     37#else 
     38        //Win32 
    2439        #include "win32/stdafx_win32.h" 
     40        using namespace std; 
     41        using namespace stdext; 
     42 
     43        //sprintf_s cast setting 
     44        #define SPRINTF_CAST(a) (a) 
    2545#endif 
     46 
     47#endif 
  • inc/stdint.h

    r1 r195  
    2121#include <limits.h> 
    2222 
     23#ifdef __APPLE__ 
     24typedef __int8_t                        int8_t; 
     25typedef __int16_t                       int16_t; 
     26typedef __int32_t                       int32_t; 
     27typedef __int64_t                       int64_t; 
     28typedef __uint8_t                       uint8_t; 
     29typedef __uint16_t                      uint16_t; 
     30typedef __uint32_t                      uint32_t; 
     31typedef __uint64_t                      uint64_t; 
     32 
     33/* 7.18.1.2 Minimum-width integer types */ 
     34typedef int8_t           int_least8_t; 
     35typedef int16_t         int_least16_t; 
     36typedef int32_t         int_least32_t; 
     37typedef int64_t         int_least64_t; 
     38typedef uint8_t         uint_least8_t; 
     39typedef uint16_t       uint_least16_t; 
     40typedef uint32_t       uint_least32_t; 
     41typedef uint64_t       uint_least64_t; 
     42 
     43/* 7.18.1.3 Fastest-width integer types */ 
     44typedef int8_t            int_fast8_t; 
     45typedef int16_t          int_fast16_t; 
     46typedef int32_t          int_fast32_t; 
     47typedef int64_t          int_fast64_t; 
     48typedef uint8_t          uint_fast8_t; 
     49typedef uint16_t        uint_fast16_t; 
     50typedef uint32_t        uint_fast32_t; 
     51typedef uint64_t        uint_fast64_t; 
     52 
     53/* 7.18.1.4 Integer types capable of holding object pointers */ 
     54 
     55#ifndef _INTPTR_T 
     56#define _INTPTR_T 
     57typedef long   intptr_t; 
     58#endif /* _INTPTR_T */ 
     59 
     60#ifndef _UINTPTR_T 
     61#define _UINTPTR_T 
     62typedef unsigned long   uintptr_t; 
     63#endif /* _UINTPTR_T */ 
     64 
     65 
     66/* 7.18.1.5 Greatest-width integer types */ 
     67#ifndef _INTMAX_T 
     68#define _INTMAX_T 
     69#ifdef __INTMAX_TYPE__ 
     70typedef __INTMAX_TYPE__             intmax_t; 
     71#else /* __INTMAX_TYPE__ */ 
     72typedef long long                intmax_t; 
     73#endif /* __INTMAX_TYPE__ */ 
     74#endif /* _INTMAX_T */ 
     75 
     76#ifndef _UINTMAX_T 
     77#define _UINTMAX_T 
     78#ifdef __UINTMAX_TYPE__ 
     79typedef __UINTMAX_TYPE__             uintmax_t; 
     80#else /* __UINTMAX_TYPE__ */ 
     81typedef unsigned long long      uintmax_t; 
     82#endif /* __UINTMAX_TYPE__ */ 
     83#endif /* _UINTMAX_T */ 
     84 
     85#else 
     86// 
     87//Win32, Xbox360 
     88// 
    2389typedef __int8            int8_t; 
    2490typedef __int16           int16_t; 
     
    2995typedef unsigned __int32  uint32_t; 
    3096typedef unsigned __int64  uint64_t; 
     97#endif 
  • inc/variable.h

    r138 r195  
    1919#pragma once 
    2020 
    21 using namespace std; 
    22  
    23  
    2421namespace cri { 
     22 
     23/*************************************************************************** 
     24 *      Constants 
     25 ***************************************************************************/ 
     26/*EN 
     27 toString precision for float 
     28*/ 
     29const int32_t TOSTRING_PRECISION_SINGLE = 6; 
     30/*EN 
     31 toString precision for double 
     32*/ 
     33const int32_t TOSTRING_PRECISION_DOUBLE = 12; 
    2534 
    2635/*************************************************************************** 
     
    263272                void convertToString( CCilVm* pVm ); 
    264273 
     274                /*EN Converts the variable to a string and retrieves a result with specified radix. 
     275                 \param pVm VM instance pointer. a string conversion requires VM instances to execute. 
     276                 \param iRadix Radix to be used while conversion 
     277                 \return Pointer to a converted string. The pointer need to be deleted by the caller. 
     278                 */ 
     279                wstring* toString( CCilVm* pVm, const int32_t iRadix ); 
     280                 
     281                /*EN Converts the variable to a string value with specified radix. 
     282                 \param pVm VM instance pointer. a string conversion requires VM instances to execute. 
     283                 \param iRadix Radix to be used while conversion 
     284                 */ 
     285                void convertToString( CCilVm* pVm, const int32_t iRadix ); 
     286 
    265287                /*EN Converts the variable to a integer and retrieves a result. 
    266288                \return Convesion result. 
     
    330352                operator bool()         { return toBoolean(); } /*EN< boolean cast*/ 
    331353                operator int()          { return toInt(); }             /*EN< integer cast*/ 
    332                 operator __int64()    { return toInt64(); }   /*EN< 64bit integer cast*/ 
     354                operator int64_t()    { return toInt64(); }   /*EN< 64bit integer cast*/ 
    333355 
    334356                union { 
  • inc/versions.h

    r194 r195  
    2727#define CRISCRIPT_VER_MINOR             9       /* #MINOR_NUMBER# */ 
    2828#define CRISCRIPT_VER_REVISION  16      /* #REVISION_NUMBER# */ 
    29 #define CRISCRIPT_VER_BUILD             138   /* #BUILD_NUMBER# */ 
     29#define CRISCRIPT_VER_BUILD             137   /* #BUILD_NUMBER# */ 
    3030 
    3131/* Macros for version definition */ 
  • inc/win32/StopWatch.h

    r138 r195  
    1818 ****************************************************************************/ 
    1919#pragma once 
    20 #include "stdafx.h" 
     20//#include "stdafx.h" 
    2121 
    2222using namespace std; 
  • inc/win32/stdafx_win32.h

    r1 r195  
    3232 
    3333#include "../inc/stdint.h" 
     34#include "win32/stopwatch.h" 
    3435 
    35 // TODO: reference additional headers your program requires here 
     36//-------------------------------------------------------------- 
     37//swprintf definition 
     38//-------------------------------------------------------------- 
     39#define INFO_STRING L"%s" 
     40 
     41#define LONG_LONG_MAX LLONG_MAX 
     42#define LONG_LONG_MIN LLONG_MIN 
     43 
  • source-archive-win32.txt

    r142 r195  
    248248 
    249249//Tools 
    250 CriScript\tools\cscl\cscl.sln 
    251 CriScript\tools\cscl\cscl\cscl.cpp 
    252 CriScript\tools\cscl\cscl\cscl.vcproj 
    253 CriScript\tools\cscl\cscl\stdafx.cpp 
    254 CriScript\tools\cscl\cscl\stdafx.h 
     250CriScript\tools\cscl\mkwin32\cscl.sln 
     251CriScript\tools\cscl\cscl.cpp 
     252CriScript\tools\cscl\mkwin32\cscl.vcproj 
     253CriScript\tools\cscl\stdafx.cpp 
     254CriScript\tools\cscl\stdafx.h 
    255255 
    256256 
  • src/BuiltInObject/cil/cilBuiltinArrayObject.cpp

    r138 r195  
    9999{ 
    100100        bool bReturn = true; 
    101         CMetaData& Metadata = CodeGen.getMetaData(); 
    102101 
    103102        RID ridObject = CodeGen.registerBuiltinObject( wstring( NAME_BUILTIN_ARRAY_OBJECT ) ); 
     
    155154 
    156155        //Set true as an object value.. 
    157         pObj->setValue( CVariable( true ) ); 
     156        CVariable var( true ); 
     157        pObj->setValue( var ); 
    158158 
    159159        CG_SYMBOL_INFORMATION info = vm.querySymbolInformation( NAME_BUILTIN_ARRAY_OBJECT ); 
     
    197197        assert( iNumArguments >= 1 ); 
    198198 
    199         CMetaData& Metadata = pVm->getMetaData(); 
    200  
    201199        //Initialize this object 
    202200        CVariable& var = *pArguments; 
     
    261259                //Just set length 
    262260                //Set to ".lengh" 
    263                 var.refObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH
    264                         CVariable( (int32_t)iArrayLength, 
    265                                                OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) ) ); 
     261                CVariable varLength( (int32_t)iArrayLength
     262                                         OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) ); 
     263                var.refObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH, varLength ); 
    266264        } 
    267265        else 
     
    279277 
    280278                //Set to ".lengh" 
    281                 var.refObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH, 
    282                         CVariable( (int32_t)iNumArguments - 1, 
    283                                                 OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) ) 
    284                         ); 
     279                CVariable varLength( (int32_t)iNumArguments - 1, 
     280                                          OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) );  
     281                var.refObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH, varLength ); 
    285282        } 
    286283 
     
    390387 
    391388void CArrayObject::sort( CCilVm* const pVm, 
    392                                                                         const int32_t iNumArguments,  
    393                                                                         CVariable* pArguments ) 
    394  
     389                                                const int32_t iNumArguments,  
     390                                                CVariable* pArguments ) 
    395391{ 
    396392        assert( iNumArguments >= 1 ); 
    397393        CVariable& varThis = *pArguments; 
    398  
     394         
    399395        if( OperandType( pArguments->iOperandType ) != OPERAND_OBJECTREF 
    400396                || pArguments->refObject->getRID() != pVm->getArrayObjectRID() ) 
     
    402398                //Throw TypeError 
    403399                pVm->throwException( &wstring( ERRORSTRING_TYPEERROR_ARRAY_TOSTRING ), 
    404                         &wstring( NAME_BUILTIN_ERROR_OBJECT ), 
    405                         ERROR_TYPEERROR_ARRAY_TOSTRING ); 
    406  
    407                 return; 
    408         } 
    409  
     400                                                        &wstring( NAME_BUILTIN_ERROR_OBJECT ), 
     401                                                        ERROR_TYPEERROR_ARRAY_TOSTRING ); 
     402                                                return; 
     403        } 
     404                 
    410405        hash_map< wstring, CVariable >& map = varThis.refObject->getPropertyMap(); 
    411  
     406                 
    412407        hash_map< wstring, CVariable >::iterator itBegin = map.begin(); 
    413408        hash_map< wstring, CVariable >::iterator itErase; 
    414409        hash_map< wstring, CVariable >::iterator itEnd = map.end(); 
    415  
     410                 
    416411        vector< CVariable >vecArray; 
    417412        vecArray.reserve( map.size() ); 
    418  
     413                 
    419414        //Dup entries to the vector 
    420415        while( itBegin != itEnd ) 
     
    429424                else 
    430425                        ++itBegin; 
    431  
    432         } 
    433  
     426        } 
     427                 
    434428        vector< CVariable >::iterator itVecBegin = vecArray.begin(); 
    435429        vector< CVariable >::iterator itVecEnd = vecArray.end(); 
    436  
     430         
     431        g_pVm = pVm; 
    437432        if( iNumArguments >= 2 ) 
    438433        { 
     
    443438                        //Cmp function is given as 1st argument 
    444439                        g_ridPredicater = pArguments->refObject->getCall(); 
    445                         g_pVm = pVm; 
    446440                        std::sort( itVecBegin, itVecEnd, CilPredicater ); 
    447441                } 
     
    460454        uint32_t iIndexSrc = 0; 
    461455        uint32_t iIndexDest = 0; 
    462  
     456         
    463457        //Restore to the map 
     458        itVecBegin = vecArray.begin(); 
     459        itVecEnd = vecArray.end(); 
    464460        while( itVecBegin != itVecEnd ) 
    465461        { 
     
    473469                swprintf( strIndex, 16, L"%d", iIndexDest ); 
    474470                map[ strIndex ] = vecArray[ iIndexSrc ]; 
    475  
     471                 
    476472                ++iIndexSrc; 
    477473                ++iIndexDest; 
    478474                ++itVecBegin; 
    479475        } 
    480  
     476         
    481477        pVm->pushEvalStack( varThis ); 
    482478        return; 
    483479} 
    484  
    485 bool CArrayObject::CilPredicater( CVariable& elem1, 
    486                                         CVariable& elem2 ) 
     480         
     481bool CArrayObject::CilPredicater( const CVariable& elem1, 
     482                                                                       const CVariable& elem2 ) 
    487483{ 
    488484        assert( g_ridPredicater != RID_NULL ); 
     
    493489        vars[ 1 ] = elem1; 
    494490        vars[ 2 ] = elem2; 
    495  
     491         
    496492        CVariable* pResult = g_pVm->invokeMethod( g_ridPredicater, 
    497                                                                                         3, 
    498                                                                                         vars ); 
     493                                                                                               3, 
     494                                                                                               vars ); 
    499495        bool bReturn = (pResult->toInt() < 0); 
    500496        delete( pResult ); 
    501  
     497         
    502498        return bReturn; 
    503499} 
    504  
    505  
    506 bool CArrayObject::Predicater( CVariable& elem1, 
    507                                         CVariable& elem2 ) 
    508 
    509         if(elem1.iOperandType == elem2.iOperandType ) 
     500         
     501         
     502bool CArrayObject::Predicater( const CVariable& elem1, 
     503                                                                const CVariable& elem2 ) 
     504
     505        assert( g_pVm != NULL ); 
     506        if( elem1.iOperandType == elem2.iOperandType ) 
    510507        { 
    511508                switch( elem1.iOperandType ) 
    512509                { 
    513                 case OPERAND_STRING: 
    514                         return *elem1.pString < *elem2.pString;  
    515                 default: 
    516                         return elem1.i64Value < elem2.i64Value; 
     510                        case OPERAND_STRING: 
     511                                return *elem1.pString < *elem2.pString;  
     512                        case OPERAND_OBJECTREF: 
     513                        case OPERAND_UNDEFINED: 
     514                        case OPERAND_NULL: 
     515                        case OPERAND_NAN: 
     516                                return false; //Those not comparable 
     517                        case OPERAND_INT: 
     518                                return elem1.iValue < elem2.iValue; 
     519                        case OPERAND_INT64: 
     520                                return elem1.i64Value < elem2.i64Value; 
     521                        case OPERAND_FLOAT: 
     522                                return elem1.fValue < elem2.fValue; 
     523                        case OPERAND_DOUBLE: 
     524                                return elem1.dValue < elem2.dValue; 
     525                        case OPERAND_BOOLEAN: 
     526                                return elem1.bValue < elem2.bValue; 
     527                        default: 
     528                                assert( "Illegal parameter" ); 
    517529                } 
    518530        } 
    519531        else 
    520532        { 
    521                 if(elem1.pString < elem2.pString ) 
    522                    return true;  
    523         } 
    524  
    525     return false; //Should return false if both the vaules are same 
    526 
    527  
     533                switch( elem1.iOperandType ) 
     534                { 
     535                        case OPERAND_STRING: 
     536                                switch( elem2.iOperandType ) 
     537                                { 
     538                                        case OPERAND_INT: 
     539                                        case OPERAND_INT64: 
     540                                        case OPERAND_FLOAT: 
     541                                        case OPERAND_DOUBLE: 
     542                                        case OPERAND_BOOLEAN: 
     543                                                return *elem1.pString < *(const_cast<CVariable&>(elem2).toString( g_pVm )); 
     544                                        case OPERAND_OBJECTREF: 
     545                                        case OPERAND_UNDEFINED: 
     546                                        case OPERAND_NULL: 
     547                                        case OPERAND_NAN: 
     548                                                return false; //Those not comparable 
     549                                        default: 
     550                                                assert( "Illegal parameter" ); 
     551                                        } 
     552                                case OPERAND_INT: 
     553                                        switch( elem2.iOperandType ) 
     554                                        { 
     555                                        case OPERAND_STRING: 
     556                                                return *(const_cast<CVariable&>(elem1)).toString( g_pVm ) < *elem2.pString;  
     557                                        case OPERAND_INT64: 
     558                                                return elem1.iValue < elem2.i64Value; 
     559                                        case OPERAND_FLOAT: 
     560                                                return elem1.iValue < elem2.fValue; 
     561                                        case OPERAND_DOUBLE: 
     562                                                return elem1.iValue < elem2.dValue; 
     563                                        case OPERAND_BOOLEAN: 
     564                                                return elem1.iValue < static_cast<int32_t>(elem2.bValue); 
     565                                        case OPERAND_OBJECTREF: 
     566                                        case OPERAND_UNDEFINED: 
     567                                        case OPERAND_NULL: 
     568                                        case OPERAND_NAN: 
     569                                                return false; //Those not comparable 
     570                                        default: 
     571                                                assert( "Illegal parameter" ); 
     572                                        } 
     573                                case OPERAND_INT64: 
     574                                        switch( elem2.iOperandType ) 
     575                                        { 
     576                                        case OPERAND_STRING: 
     577                                                return *(const_cast<CVariable&>(elem1)).toString( g_pVm ) < *elem2.pString;  
     578                                        case OPERAND_INT: 
     579                                                return elem1.i64Value < elem2.iValue; 
     580                                        case OPERAND_FLOAT: 
     581                                                return elem1.i64Value < elem2.fValue; 
     582                                        case OPERAND_DOUBLE: 
     583                                                return elem1.i64Value < elem2.dValue; 
     584                                        case OPERAND_BOOLEAN: 
     585                                                return elem1.i64Value < static_cast<int64_t>(elem2.bValue); 
     586                                        case OPERAND_OBJECTREF: 
     587                                        case OPERAND_UNDEFINED: 
     588                                        case OPERAND_NULL: 
     589                                        case OPERAND_NAN: 
     590                                                return false; //Those not comparable 
     591                                        default: 
     592                                                assert( "Illegal parameter" ); 
     593                                        } 
     594                                case OPERAND_FLOAT: 
     595                                        switch( elem2.iOperandType ) 
     596                                        { 
     597                                        case OPERAND_STRING: 
     598                                                return *(const_cast<CVariable&>(elem1)).toString( g_pVm ) < *elem2.pString;  
     599                                        case OPERAND_INT: 
     600                                                return elem1.fValue < elem2.fValue; 
     601                                        case OPERAND_INT64: 
     602                                                return elem1.fValue < elem2.fValue; 
     603                                        case OPERAND_DOUBLE: 
     604                                                return elem1.fValue < elem2.dValue; 
     605                                        case OPERAND_BOOLEAN: 
     606                                                return elem1.fValue < static_cast<float>(elem2.bValue); 
     607                                        case OPERAND_OBJECTREF: 
     608                                        case OPERAND_UNDEFINED: 
     609                                        case OPERAND_NULL: 
     610                                        case OPERAND_NAN: 
     611                                                return false; //Those not comparable 
     612                                        default: 
     613                                                assert( "Illegal parameter" ); 
     614                                        } 
     615                                case OPERAND_DOUBLE: 
     616                                        switch( elem2.iOperandType ) 
     617                                        { 
     618                                        case OPERAND_STRING: 
     619                                                return *(const_cast<CVariable&>(elem1)).toString( g_pVm ) < *elem2.pString;  
     620                                        case OPERAND_INT: 
     621                                                return elem1.dValue < elem2.iValue; 
     622                                        case OPERAND_INT64: 
     623                                                return elem1.dValue < elem2.i64Value; 
     624                                        case OPERAND_FLOAT: 
     625                                                return elem1.dValue < elem2.fValue; 
     626                                        case OPERAND_BOOLEAN: 
     627                                                return elem1.dValue < static_cast<double>(elem2.bValue); 
     628                                        case OPERAND_OBJECTREF: 
     629                                        case OPERAND_UNDEFINED: 
     630                                        case OPERAND_NULL: 
     631                                        case OPERAND_NAN: 
     632                                                return false; //Those not comparable 
     633                                        default: 
     634                                                assert( "Illegal parameter" ); 
     635                                        } 
     636                                case OPERAND_BOOLEAN: 
     637                                        switch( elem2.iOperandType ) 
     638                                        { 
     639                                        case OPERAND_STRING: 
     640                                                return *(const_cast<CVariable&>(elem1)).toString( g_pVm ) < *elem2.pString;  
     641                                        case OPERAND_INT: 
     642                                                return static_cast<int32_t>(elem1.bValue) < elem2.iValue; 
     643                                        case OPERAND_INT64: 
     644                                                return static_cast<int64_t>(elem1.bValue) < elem2.i64Value; 
     645                                        case OPERAND_FLOAT: 
     646                                                return static_cast<float>(elem1.bValue) < elem2.fValue; 
     647                                        case OPERAND_DOUBLE: 
     648                                                return static_cast<double>(elem1.bValue) < elem2.dValue; 
     649                                        case OPERAND_OBJECTREF: 
     650                                        case OPERAND_UNDEFINED: 
     651                                        case OPERAND_NULL: 
     652                                        case OPERAND_NAN: 
     653                                                return false; //Those not comparable 
     654                                        default: 
     655                                                assert( "Illegal parameter" ); 
     656                                        } 
     657                                case OPERAND_OBJECTREF: 
     658                                case OPERAND_UNDEFINED: 
     659                                case OPERAND_NULL: 
     660                                case OPERAND_NAN: 
     661                                        return false; //Those not comparable 
     662                                default: 
     663                                        assert( "Illegal parameter" ); 
     664                        } 
     665                } 
     666                 
     667        return false; //Should return false if both the vaules are same 
     668
     669         
    528670/*************************************************************************** 
    529671 *      reverse property 
     
    607749 
    608750                //Just expanding the array, nothing to do 
    609                 pObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH
    610                                                                CVariable( iGivenIndex, 
    611                                                                        OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) ) ); 
     751                CVariable var( iGivenIndex
     752                                          OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) ); 
     753                pObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH, var ); 
    612754 
    613755                if( iGivenIndex < iLength ) 
     
    679821                if( iGivenIndex > iLength ) 
    680822                { 
    681                         pObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH, 
    682                                CVariable( iGivenIndex, OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) ) ); 
     823                        CVariable var( iGivenIndex, OPERAND_FLAG( OPERAND_FLAG_DONTDELETE | OPERAND_FLAG_DONTENUM ) );  
     824                        pObject->setProperty( STRING_PROPERTY_INTERNAL_LENGTH, var ); 
    683825                } 
    684826                return NULL; 
  • src/BuiltInObject/cil/cilBuiltinBooleanObject.cpp

    r138 r195  
    7272{ 
    7373        bool bReturn = true; 
    74         CMetaData& Metadata = CodeGen.getMetaData(); 
    75  
     74         
    7675        RID ridObject = CodeGen.registerBuiltinObject( NAME_BUILTIN_BOOLEAN_OBJECT ); 
    7776        if( ridObject == RID_NOTDEFINED ) 
     
    126125 
    127126        //Set true as an object value.. 
    128         pObj->setValue( CVariable( true ) ); 
     127        CVariable var( true ); 
     128        pObj->setValue( var ); 
    129129 
    130130        CG_SYMBOL_INFORMATION info = vm.querySymbolInformation( NAME_BUILTIN_BOOLEAN_OBJECT ); 
     
    194194                case OPERAND_NULL: 
    195195                case OPERAND_OBJECTREF: 
    196                         thisobj.refObject->setValue( CVariable( pArguments->toBoolean() ) ); 
     196                        { 
     197                        CVariable var( pArguments->toBoolean() ); 
     198                        thisobj.refObject->setValue( var ); 
     199                        } 
    197200                        break; 
    198201                default: 
  • src/BuiltInObject/cil/cilBuiltinDateObject.cpp

    r138 r195  
    190190{ 
    191191        bool bReturn = true; 
    192         CMetaData& Metadata = CodeGen.getMetaData(); 
    193192 
    194193        RID ridObject = CodeGen.registerBuiltinObject( NAME_BUILTIN_DATE_OBJECT ); 
     
    244243 
    245244        //Set true as an object value.. 
    246         pObj->setValue( CVariable( true ) ); 
     245        CVariable var( true ); 
     246        pObj->setValue( var ); 
    247247 
    248248        CG_SYMBOL_INFORMATION info = vm.querySymbolInformation( NAME_BUILTIN_DATE_OBJECT ); 
     
    346346 
    347347                        //Set number value to the object 
    348                         thisobj.refObject->setValue( CVariable( 0 ) ); 
     348                        CVariable varInt( 0 ); 
     349                        thisobj.refObject->setValue( varInt ); 
    349350 
    350351                        pVm->popEvalStack(); 
     
    515516        int32_t iWeekDay = CDateObject::WeekDay( iTime ); 
    516517        wchar_t strDate[ 32 ]; 
    517         swprintf( strDate, 32, L"%s %s %d %02d:%02d:%02d %s %d", 
     518/* 
     519 //To keep compatibility between GNU and VS 
     520 swprintf( strDate, 32, L"%s %s %d %02d:%02d:%02d %s %d", 
    518521                                                strWeekday[ iWeekDay ],                                 //Weekday 
    519522                                                strMonth[ CDateObject::MonthFromTime( iTime ) ],        //Month 
     
    525528                                                CDateObject::YearFromTime( iTime )              //Year 
    526529                                                ); 
    527  
    528  
    529         pVm->pushEvalStackString( strDate ); 
    530  
     530*/ 
     531        wstring* pStr = new wstring( strWeekday[ iWeekDay ] ); 
     532        pStr->append( L" " ); 
     533        pStr->append( strMonth[ CDateObject::MonthFromTime( iTime ) ] ); 
     534        pStr->append( L" " ); 
     535        swprintf( strDate, 32, L"%d %02d:%02d:%02d ", 
     536                         CDateObject::DateFromTime( iTime ),            //Date 
     537                         CDateObject::HourFromTime( iTime ),            //Hour 
     538                         CDateObject::MinFromTime( iTime ),             //Min 
     539                         CDateObject::SecFromTime( iTime )              //Sec 
     540                         ); 
     541        pStr->append( strDate ); 
     542        pStr->append( TimeZoneSettings[ pDate->m_currentTimeZoneIndex ].strTimeZone ); 
     543        swprintf( strDate, 32, L" %d", 
     544                         CDateObject::YearFromTime( iTime )             //Year 
     545                         ); 
     546        pStr->append( strDate ); 
     547 
     548        //pVm->pushEvalStackString( strDate ); 
     549        pVm->pushEvalStackStringPointer( pStr ); 
    531550 
    532551        return; 
     
    770789} 
    771790 
    772 //DaysInYear(y) = 365 if (y modulo 4) ‚ 0 
    773 //= 366 if (y modulo 4) = 0 and (y modulo 100) ‚ 0 
    774 //= 365 if (y modulo 100) = 0 and (y modulo 400) ‚ 0 
     791//DaysInYear(y) = 365 if (y modulo 4) à
     792Ç 0 
     793//= 366 if (y modulo 4) = 0 and (y modulo 100) à
     794Ç 0 
     795//= 365 if (y modulo 100) = 0 and (y modulo 400) à
     796Ç 0 
    775797//= 366 if (y modulo 400) = 0 
    776798int32_t CDateObject::DaysInYear( int32_t y ) 
     
    789811} 
    790812 
    791 //TimeFromYear(y) =msPerDay ~ DayFromYear(y) 
     813//TimeFromYear(y) =msPerDay à
     814~ DayFromYear(y) 
    792815int64_t CDateObject::TimeFromYear( int32_t y ) 
    793816{ 
  • src/BuiltInObject/cil/cilBuiltinErrorObject.cpp

    r138 r195  
    5454{ 
    5555        bool bReturn = true; 
    56         CMetaData& Metadata = CodeGen.getMetaData(); 
    5756 
    5857        RID ridObject = CodeGen.registerBuiltinObject( NAME_BUILTIN_ERROR_OBJECT ); 
     
    102101        //--------------------------------------------------------------------------- 
    103102        CVmObject& protoobj = vm.getPrototypeObject( vm.getErrorObjectRID() ); 
    104         protoobj.setProperty( NAME_BUILTIN_ERROR_PROPERTY_NAME, 
    105                                                 CVariable( NAME_BUILTIN_ERROR_OBJECT ) ); 
    106         protoobj.setProperty( NAME_BUILTIN_ERROR_PROPERTY_NUMBER, 
    107                                                 CVariable( -1 ) ); 
     103        CVariable varName( NAME_BUILTIN_ERROR_OBJECT ); 
     104        CVariable var( -1 ); 
     105 
     106        protoobj.setProperty( NAME_BUILTIN_ERROR_PROPERTY_NAME, varName ); 
     107        protoobj.setProperty( NAME_BUILTIN_ERROR_PROPERTY_NUMBER, var ); 
    108108 
    109109        //--------------------------------------------------------------------------- 
     
    116116 
    117117        //Set true as an object value..