root/src/VM/cil/cilVMMiscAPI.cpp

Revision 138, 2.6 kB (checked in by hak, 2 years ago)

- Added CCilVm::reset()
- Fixed VM status management (ticket #5)
- Fixed API names not to have upper case as 1st letter.
- Fixed sample build break
- Added new sample, "vm_contol" to demonstrate VM status control API

Line 
1 /****************************************************************************
2  *
3  * CRI Middleware SDK
4  *
5  * Copyright (c) 2008 CRI Middleware, Inc. All rights reserved.
6  *
7  * Use, modification and distribution are subject to the CRI Script Software
8  * License, Version 1.0(see accompanying file "CriScript_License_1_0.txt" or
9  * copy at www.criscript.com/trac/wiki/CRI%20Script%20Software%20License%201.0 ).
10  *
11  *
12  * Library  : CRIScript
13  * Module   : cil Virtual Machine
14  * File     : cilVMMiscAPI.cpp
15  * Date     :
16  * Version  :
17  *
18  ****************************************************************************/
19
20 /***************************************************************************
21  *      Include file
22  ***************************************************************************/
23 #include "stdafx.h"
24 #include "criScript.h"
25 #include "cilVM.h"
26 namespace cri {
27 /***************************************************************************
28  *      Variables
29  ***************************************************************************/
30
31 /***************************************************************************
32  *      Methods
33  ***************************************************************************/
34
35 /***************************************************************************
36  * Retrieve VM exit code
37  ***************************************************************************/   
38 int32_t CCilVm::getExitCode()
39 {
40         if( m_status != VM_EXECUTE_DONE )
41         {
42                 return -1;
43         }
44        
45         VMOBJECTREF objSystem =&getPrototypeObject( getSystemObjectRID() );
46         CVariable* pvarEnvironment = objSystem->lookupProperty( NAME_BUILTIN_SYSTEM_PROPERTY_ENVIRONMENT);
47         CVariable* pvarExitCode = pvarEnvironment->refObject->lookupProperty( NAME_BUILTIN_SYSTEM_PROPERTY_EXITCODE );
48         int32_t iRet = pvarExitCode->toInt();
49         return iRet;
50 }
51
52
53 /***************************************************************************
54  * VM Helper API body
55  ***************************************************************************/   
56 void MakeWrapperStdVoidP0( CCilVm* const pVm,
57                         const int32_t iNumArguments,
58                         vector<CVariable>::iterator pArguments,
59                         PMETHOD pMethodBody )
60 {
61         ((void (*)( void ) )pMethodBody)();
62         pVm->pushEvalStackUndefined();
63
64         return;
65 }
66
67 //----------------------
68 //Void return version
69 //----------------------
70 void MakeWrapperMtdVoidP0( CCilVm* const pVm,
71                         const int32_t iNumArguments,
72                         vector<CVariable>::iterator pArguments,
73                         PMETHOD pMethodBody )
74 {
75         //Keep This pointer
76         CVariable* pVar = &*pArguments ++;
77
78         ((void (*)( CVariable* ) )pMethodBody)( pVar );
79         pVm->pushEvalStackUndefined();
80
81         return;
82 }
83
84 } //namespace CRI
Note: See TracBrowser for help on using the browser.