Пример #1
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);
        }
        void IOperation.Exec(DataStack stack, IDataAccess xdata)
        {
            var a = (double)stack.Registers[this.RegName1];
            var b = (double)xdata.GetData(this.VarName2);

            stack.Push(a - b);
        }
        void IOperation.Exec(DataStack stack, IDataAccess xdata)
        {
            var a = (double)this.Value1;
            var b = (double)xdata.GetData(this.VarName2);

            stack.Push(a - b);
        }
        void IOperation.Exec(DataStack stack, IDataAccess xdata)
        {
            var a = (double)this.Value1;
            var b = (double)stack.Registers[this.RegName2];

            stack.Push(a - b);
        }
Пример #5
0
        void IOperation.Exec(DataStack stack, IDataAccess extdata)
        {
            var b = (double)stack.Pop();
            var a = (double)stack.Pop();

            stack.Push(a - b);
        }
Пример #6
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);
        }
Пример #7
0
        void IOperation.Exec(DataStack stack, IDataAccess extdata)
        {
            object oa = stack.Pop();

            bool isTrue = OperationHelpers.EvaluateAsLogicalTrue(oa);

            if (isTrue)
            {
                stack.InstructionIndex = this.Position - 1;
            }
        }
Пример #8
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     xdata.SetData(this.VarName1, stack.Pop());
 }
Пример #9
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Registers[this.RegName1] = stack.Pop();
 }
Пример #10
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Push(
         xdata.GetData(this.VarName1)
         );
 }
Пример #11
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     xdata.SetData(this.VarName1, stack.Registers[this.RegName2]);
 }
Пример #12
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     xdata.SetData(this.VarName1, this.Value2);
 }
Пример #13
0
 void IOperation.Exec(DataStack stack, IDataAccess extdata)
 {
     stack.Buffer[stack.DataIndex] = -(double)stack.Buffer[stack.DataIndex];
 }
Пример #14
0
 void IOperation.Exec(DataStack stack, IDataAccess extdata)
 {
     //no op
 }
Пример #15
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Registers[this.RegName1] = this.Value2;
 }
Пример #16
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Registers[this.RegName1] = xdata.GetData(this.VarName2);
 }
Пример #17
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Push(this.Value1);
 }
Пример #18
0
        void IOperation.Exec(DataStack stack, IDataAccess extdata)
        {
            var value = (double)stack.Registers[this.RegName1];

            stack.Registers[this.RegName1] = value - 1;
        }
Пример #19
0
 void IOperation.Exec(DataStack stack, IDataAccess extdata)
 {
     stack.InstructionIndex = this.Position - 1;
 }