Пример #1
0
        public bool PopStack(out object execution, out ExecutionCallback callback, ExecutionEnvironment e)
        {
            int  current    = (int)e.GetState("current");
            bool testResult = (bool)e.GetState("testResult");

            if (current == 0)
            {
                execution = Test;
                callback  = Callback;
                return(true);
            }
            else if (current == 1)
            {
                if (testResult)
                {
                    execution = Consequent;
                }
                else
                {
                    execution = Alternate;
                }
                callback = Callback;
                return(false);
            }
            execution = null;
            callback  = null;
            return(false);
        }
Пример #2
0
        Nullable <DateTime> Callback(object value, object exception, ExecutionEnvironment e)
        {
            int current       = (int)e.GetState("current");
            int currentNumber = (int)e.GetState("currentNumber");

            if (current == 0)
            {
                e.SetState("loopNumber", int.Parse(value + ""));
            }
            else
            {
                e.SetState("currentNumber", currentNumber + 1);
            }
            e.SetState("current", current + 1);
            current = (int)e.GetState("current");
            e.SetState("result", value);
            return(null);
        }
Пример #3
0
        public bool PopStack(out object execution, out ExecutionCallback callback, ExecutionEnvironment e)
        {
            int current       = (int)e.GetState("current");
            int currentNumber = (int)e.GetState("currentNumber");
            int loopNumber    = (int)e.GetState("loopNumber");

            if (current == 0)
            {
                execution = Loop;
                callback  = Callback;
                return(true);
            }
            else
            {
                execution = Body;
                callback  = Callback;
                return(currentNumber < loopNumber);
            }
        }
Пример #4
0
        Nullable <DateTime> Callback(object value, object exception, ExecutionEnvironment e)
        {
            int current = (int)e.GetState("current");

            current++;
            if (current == Body.Count)
            {
                e.SetState("retVal", value);
            }
            e.SetState("current", current);
            return(null);
        }
Пример #5
0
        public bool PopStack(out object execution, out ExecutionCallback callback, ExecutionEnvironment e)
        {
            int  current     = (int)e.GetState("current");
            bool canContinue = (bool)e.GetState("canContinue");

            if (current % 2 == 0)
            {
                execution = Test;
                callback  = Callback;
                return(true);
            }
            else if (canContinue)
            {
                execution = Body;
                callback  = Callback;
                return(true);
            }
            execution = null;
            callback  = null;
            return(false);
        }
Пример #6
0
        Nullable <DateTime> Callback(object value, object exception, ExecutionEnvironment e)
        {
            int current = (int)e.GetState("current");

            if (current == 0)
            {
                e.SetState("minimum", (int)Math.Ceiling((double)value));
            }
            else
            {
                e.SetState("maximum", (int)Math.Floor((double)value));
            }
            e.SetState("current", current + 1);
            return(null);
        }
Пример #7
0
        Nullable <DateTime> Callback(object value, object exception, ExecutionEnvironment e)
        {
            int current = (int)e.GetState("current");

            if (current == 0)
            {
                e.SetState("testResult", value);
            }
            else
            {
            }
            current++;
            e.SetState("current", current);
            e.SetState("result", value);
            return(null);
        }
Пример #8
0
        public bool PopStack(out object execution, out ExecutionCallback callback, ExecutionEnvironment e)
        {
            int current = (int)e.GetState("current");

            callback = Callback;
            if (current == 0)
            {
                execution = Min;
                return(true);
            }
            else
            {
                execution = Max;
                return(false);
            }
        }
Пример #9
0
        public bool PopStack(out object execution, out ExecutionCallback callback, ExecutionEnvironment e)
        {
            callback = Callback;
            int current = (int)e.GetState("current");

            if (current < Body.Count)
            {
                execution = Body[current];
                if (execution is ReturnStatement)
                {
                    return(false);
                }
            }
            else
            {
                execution = null;
                return(false);
            }
            return((current + 1) != Body.Count);
        }
Пример #10
0
 public Completion EndCall(ExecutionEnvironment e)
 {
     return(new Completion(e.GetState("result")));
 }
Пример #11
0
        public Completion EndCall(ExecutionEnvironment e)
        {
            double r = random.Next((int)e.GetState("minimum"), (int)e.GetState("maximum"));

            return(new Completion(r));
        }