예제 #1
0
        void IOperation.Exec(DataStack stack, IDataAccess extdata)
        {
            var b = (double)stack.Pop();
            var a = (double)stack.Pop();

            stack.Push(a - b);
        }
예제 #2
0
        void IOperation.Exec(DataStack stack, IDataAccess extdata)
        {
            object ob = stack.Pop();
            object oa = stack.Pop();

            bool isTrue = OperationHelpers.EvaluateAsLogicalTrue(oa);

            stack.Push(isTrue ? ob : oa);
        }
예제 #3
0
        /// <summary>
        /// Execute the compiled script
        /// </summary>
        /// <param name="xdata"></param>
        /// <returns></returns>
        public RunResult Execute(IDataAccess xdata)
        {
            var cstream = this.CodeStream;

            var stack = new DataStack();

            while (++stack.InstructionIndex < cstream.InstructList.Count)
            {
                cstream.InstructList[stack.InstructionIndex].Exec(stack, xdata);
            }

            var result = new RunResult();

            switch (stack.DataIndex)
            {
            case -1:
                break;

            case 0:
                result.Result    = stack.Pop();
                result.HasResult = true;
                break;

            default:
                result.Error = new RuntimeException(
                    $"The data stack still contains {stack.DataIndex + 1} items."
                    );
                break;
            }
            return(result);
        }
예제 #4
0
        void IOperation.Exec(DataStack stack, IDataAccess extdata)
        {
            object oa = stack.Pop();

            bool isTrue = OperationHelpers.EvaluateAsLogicalTrue(oa);

            if (isTrue)
            {
                stack.InstructionIndex = this.Position - 1;
            }
        }
예제 #5
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     xdata.SetData(this.VarName1, stack.Pop());
 }
예제 #6
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Registers[this.RegName1] = stack.Pop();
 }