Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        void IOperation.Exec(DataStack stack, IDataAccess xdata)
        {
            var a = (double)this.Value1;
            var b = (double)xdata.GetData(this.VarName2);

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

            stack.Push(a - b);
        }
Ejemplo n.º 5
0
        void IOperation.Exec(DataStack stack, IDataAccess extdata)
        {
            var b = (double)stack.Pop();
            var a = (double)stack.Pop();

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

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