Exemplo n.º 1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="code"></param>
        /// <param name="instructionIndex"></param>
        /// <param name="mStack"></param>
        /// <returns></returns>
        public override bool Execute( AVM1.AVM1Code code, int instructionIndex, CheckMachine.MachineStack mStack )
        {
            if ( mStack.Count < 1 )
                return false;

            CheckMachine.MachineStackEntry e = mStack.Pop();

            if ( e.Type != CheckMachine.MachineStackType.String )
                return false;

            string testValue = (string)e.Value;

            CheckMachine.MachineStackEntry res = new CheckMachine.MachineStackEntry();
            res.Type = CheckMachine.MachineStackType.Boolean;

            if ( testValue.StartsWith( _Match, ( _CaseSensitive ? StringComparison.InvariantCulture : StringComparison.InvariantCultureIgnoreCase ) ) )
            {
                res.Value = ( bool )true;
            }
            else
            {
                res.Value = ( bool )false;
            }
            mStack.Push( res );

            return true;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="code"></param>
        /// <param name="instructionIndex"></param>
        /// <param name="mStack"></param>
        /// <returns></returns>
        public override bool Execute( AVM1.AVM1Code code, int instructionIndex, CheckMachine.MachineStack mStack )
        {
            if ( mStack.Count < 1 )
                return false;

            CheckMachine.MachineStackEntry e = mStack.Pop();

            if ( e.Type != CheckMachine.MachineStackType.Boolean )
                return false;

            bool condition = ( bool )e.Value;

            CheckMachine.MachineStackEntry res = new CheckMachine.MachineStackEntry();
            res.Value = instructionIndex;

            if ( condition )
            {
                res.Type = CheckMachine.MachineStackType.RemoveInstruction;
            }
            else
            {
                res.Type = CheckMachine.MachineStackType.KeepInstruction;
            }
            mStack.Push( res );

            return true;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="code"></param>
        /// <param name="instructionIndex"></param>
        /// <param name="mStack"></param>
        /// <returns></returns>
        public override bool Execute( AVM1Code code, int instructionIndex, CheckMachine.MachineStack mStack )
        {
            AVM1DataElement e = new AVM1DataElement();
            // check if we can resolve the argument within the basic block of the instruction
            if ( AVM1.Stack.Trace.TraceArgument( code, instructionIndex, null, _ArgumentNumber, out e ) )
            {
                if ( e.DataType != AVM1DataTypes.AVM_String )
                {
                    return false;
                }
                else
                {
                    CheckMachine.MachineStackEntry se = new CheckMachine.MachineStackEntry();
                    se.Type = CheckMachine.MachineStackType.String;
                    se.Value = e.Value;
                    mStack.Push( se );
                    return true;
                }
            }

            return false;
        }