示例#1
0
 public override void Eval(ExecutionEnvironment env)
 {
     if (condition.Eval(env).As <TurtBool>())
     {
         success.Eval(env);
     }
     else if (failure != null)
     {
         failure.Eval(env);
     }
 }
示例#2
0
        public override void Eval(ExecutionEnvironment env)
        {
            env.Frame.PushScope();
            env.Frame.Scope.Type = ScopeType.LOOP;

            var start = this.start.Eval(env).As <TurtInteger>().Value;
            var end   = this.end.Eval(env).As <TurtInteger>().Value;

            var current = start;
            var running = true;

            while (running)
            {
                if (current == end)
                {
                    running = false;
                }

                env.Frame.Scope[iterator.Ident] = current.Turt();

                if (start < end)
                {
                    current++;
                }
                else
                {
                    current--;
                }

                try {
                    statement.Eval(env);
                } catch (BreakException) {
                    break;
                } catch (ContinueException) {
                }
            }

            env.Frame.PopScope();
        }