Example #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);
        }
        void IOperation.Exec(DataStack stack, IDataAccess extdata)
        {
            var b = (double)stack.Pop();
            var a = (double)stack.Pop();

            stack.Push(a - b);
        }
Example #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);
        }
Example #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;
            }
        }
Example #8
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     xdata.SetData(this.VarName1, stack.Pop());
 }
Example #9
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Registers[this.RegName1] = stack.Pop();
 }
Example #10
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Push(
         xdata.GetData(this.VarName1)
         );
 }
Example #11
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     xdata.SetData(this.VarName1, stack.Registers[this.RegName2]);
 }
Example #12
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     xdata.SetData(this.VarName1, this.Value2);
 }
 void IOperation.Exec(DataStack stack, IDataAccess extdata)
 {
     stack.Buffer[stack.DataIndex] = -(double)stack.Buffer[stack.DataIndex];
 }
Example #14
0
 void IOperation.Exec(DataStack stack, IDataAccess extdata)
 {
     //no op
 }
Example #15
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Registers[this.RegName1] = this.Value2;
 }
Example #16
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Registers[this.RegName1] = xdata.GetData(this.VarName2);
 }
Example #17
0
 void IOperation.Exec(DataStack stack, IDataAccess xdata)
 {
     stack.Push(this.Value1);
 }
        void IOperation.Exec(DataStack stack, IDataAccess extdata)
        {
            var value = (double)stack.Registers[this.RegName1];

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