root/src/VM/cil/cilVMOperatorBlt.cpp
| Revision 138, 3.2 kB (checked in by hak, 6 months ago) |
|---|
| 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 : CCilVmOperatorBlt.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 | * Blt operator |
| 45 | * (1) take value from stack |
| 46 | * (2) take value from stack |
| 47 | * (3) copmare (1) OP (2) |
| 48 | * (4) If true, take branch |
| 49 | ***************************************************************************/ |
| 50 | void CCilVm::BnltOperator() |
| 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 | if( !bTrue ) |
| 64 | { |
| 65 | int32_t* pOffset = (int32_t*)m_pCurrentInstruction; |
| 66 | m_pCurrentInstruction += *pOffset + LONGBR_ADJUST; |
| 67 | } |
| 68 | else |
| 69 | m_pCurrentInstruction += LONGBR_ADJUST; |
| 70 | |
| 71 | popEvalStack(); |
| 72 | popEvalStack(); |
| 73 | } |
| 74 | |
| 75 | /*************************************************************************** |
| 76 | * BltS operator |
| 77 | * (1) take value from stack |
| 78 | * (2) take value from stack |
| 79 | * (3) copmare (1) OP (2) |
| 80 | * (4) If true, take branch |
| 81 | ***************************************************************************/ |
| 82 | void CCilVm::BnltShortOperator() |
| 83 | { |
| 84 | assert( getEvalStackSize() >= 2 ); |
| 85 | CVariable& rhs = getEvalStackFirstEntry(); |
| 86 | CVariable& lhs = getEvalStackSecondEntry(); |
| 87 | |
| 88 | bool bTrue = false; |
| 89 | |
| 90 | #pragma warning( disable:4311 ) //Suppress warning |
| 91 | |
| 92 | CheckBranch( OP, OP2 ); |
| 93 | |
| 94 | #pragma warning( default:4311 ) //Enable warning |
| 95 | if( !bTrue ) |
| 96 | { |
| 97 | int8_t* pOffset = (int8_t*)m_pCurrentInstruction; |
| 98 | m_pCurrentInstruction += *pOffset + SHORTBR_ADJUST; |
| 99 | } |
| 100 | else |
| 101 | m_pCurrentInstruction += SHORTBR_ADJUST; |
| 102 | |
| 103 | popEvalStack(); |
| 104 | popEvalStack(); |
| 105 | } |
| 106 | |
| 107 | /*************************************************************************** |
| 108 | * Branch operator Helper |
| 109 | ***************************************************************************/ |
| 110 | |
| 111 | } //namespace CRI |
Note: See TracBrowser for help on using the browser.
