root/src/VM/cil/cilVMOperatorBeq.cpp

Revision 138, 3.2 kB (checked in by hak, 6 months 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 Branch ops
14  * File     : CCilVmOperatorBeq.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 #include "cilVMBranchMacro.h"
27 namespace cri {
28
29 /***************************************************************************
30  *      Variables
31  ***************************************************************************/
32 #ifdef OP
33         #undef OP
34 #endif
35 #define OP ==
36 #define OP2 ==
37
38
39 /***************************************************************************
40  *      Methods
41  ***************************************************************************/
42
43 /***************************************************************************
44  *      Beq operator
45  *      (1) take value from stack
46  *      (2) take value from stack
47  *      (3) copmare (1) == (2)
48  *      (4) If true, take branch
49  ***************************************************************************/
50 void CCilVm::BeqOperator()
51 {
52         assert( getEvalStackSize() >= 2 );
53         CVariable& rhs = getEvalStackFirstEntry();
54         CVariable& lhs = getEvalStackSecondEntry();
55
56         bool bTrue = false;
57
58 #pragma warning( disable:4311 ) //Suppress warning
59
60         CheckBranch( OP, OP2 );
61
62 #pragma warning( default:4311 ) //Enable warning
63
64         if( bTrue )
65         {
66                 int32_t* pOffset = (int32_t*)m_pCurrentInstruction;
67                 m_pCurrentInstruction += *pOffset + LONGBR_ADJUST;
68         }
69         else
70                 m_pCurrentInstruction += LONGBR_ADJUST;
71
72         popEvalStack();
73         popEvalStack();
74 }
75
76 /***************************************************************************
77  *      BeqS operator
78  *      (1) take value from stack
79  *      (2) take value from stack
80  *      (3) copmare (1) == (2)
81  *      (4) If true, take branch
82  ***************************************************************************/
83 void CCilVm::BeqShortOperator()
84 {
85         assert( getEvalStackSize() >= 2 );
86         CVariable& rhs = getEvalStackFirstEntry();
87         CVariable& lhs = getEvalStackSecondEntry();
88
89         bool bTrue = false;
90
91 #pragma warning( disable:4311 ) //Suppress warning
92
93         CheckBranch( OP, OP2 );
94
95 #pragma warning( default:4311 ) //Enable warning
96
97         if( bTrue )
98         {
99                 int8_t* pOffset = (int8_t*)m_pCurrentInstruction;
100                 m_pCurrentInstruction += *pOffset + SHORTBR_ADJUST;
101         }
102         else
103                 m_pCurrentInstruction += SHORTBR_ADJUST;
104
105         popEvalStack();
106         popEvalStack();
107 }
108
109 /***************************************************************************
110  *      Branch operator Helper
111  ***************************************************************************/
112
113 } //namespace CRI
Note: See TracBrowser for help on using the browser.