Пример #1
0
        protected virtual void DoEach <T> (RCRunner runner,
                                           RCClosure closure,
                                           RCBlock left,
                                           RCVector <T> right)
        {
            if (right.Count == 0)
            {
                runner.Yield(closure, RCBlock.Empty);
                return;
            }
            int i = closure.Index - 2;

            if (i < right.Count)
            {
                RCBlock result = new RCBlock("I", ":", new RCLong(i));
                result = new RCBlock(result,
                                     "R",
                                     ":",
                                     RCVectorBase.FromArray(new RCArray <T> (right[i])));
                left.Eval(runner,
                          new RCClosure(closure, closure.Bot, left, closure.Left, result, 0));
            }
            else
            {
                runner.Yield(closure, closure.Parent.Result);
            }
        }
Пример #2
0
 public void EvalThen(RCRunner runner, RCClosure closure, RCBoolean left, RCBlock right)
 {
     if (left[0])
     {
         int i = closure.Index - 2;
         if (i < left.Count)
         {
             RCClosure child = new RCClosure(closure,
                                             closure.Bot,
                                             right,
                                             closure.Left,
                                             RCBlock.Empty,
                                             0);
             right.Eval(runner, child);
         }
         else
         {
             runner.Yield(closure, closure.Parent.Result);
         }
     }
     else
     {
         runner.Yield(closure, RCBoolean.False);
     }
 }
Пример #3
0
        public void EvalEach(RCRunner runner, RCClosure closure, RCBlock left, RCBlock right)
        {
            if (right.Count == 0)
            {
                runner.Yield(closure, right);
                return;
            }
            long i = closure.Index - 2;

            if (i < right.Count)
            {
                RCBlock name   = right.GetName(i);
                RCBlock result = new RCBlock(closure.Result, "L", ":", new RCString(name.Name));
                result  = new RCBlock(result, "I", ":", new RCLong(i));
                result  = new RCBlock(result, "R", ":", right.Get(i));
                closure = new RCClosure(closure.Parent,
                                        closure.Bot,
                                        closure.Code,
                                        closure.Left,
                                        result,
                                        closure.Index);
                left.Eval(runner,
                          new RCClosure(closure,
                                        closure.Bot,
                                        left,
                                        closure.Left,
                                        RCBlock.Empty,
                                        0));
            }
            else
            {
                runner.Yield(closure, closure.Parent.Result);
            }
        }
Пример #4
0
 public void EvalTry(RCRunner runner, RCClosure closure, RCBlock right)
 {
     right.Eval(runner,
                new RCClosure(closure, closure.Bot, right, closure.Left, RCBlock.Empty, 0));
 }