public override IDynamic Next(IEnvironment environment, IArgs args)
 {
     if (Generator.Complete)
         return environment.CreateBoolean(false);
     environment.Context.LexicalEnviroment = Scope;
     environment.Context.VariableEnviroment = Scope;
     if (!Generator.Initialized)
     {
         environment.BindVariableDeclarations(VariableDeclarations, true, true);
         Generator.Initialized = true;
     }
     var step = Generator.Steps.Dequeue();
     var iterated = step(environment, Generator);
     Generator.Complete = !iterated || Generator.Steps.Count == 0;
     return environment.CreateBoolean(iterated);
 }
        public override IDynamic Next(IEnvironment environment, IArgs args)
        {
            if (Generator.Complete)
            {
                return(environment.CreateBoolean(false));
            }
            environment.Context.LexicalEnviroment  = Scope;
            environment.Context.VariableEnviroment = Scope;
            if (!Generator.Initialized)
            {
                environment.BindVariableDeclarations(VariableDeclarations, true, true);
                Generator.Initialized = true;
            }
            var step     = Generator.Steps.Dequeue();
            var iterated = step(environment, Generator);

            Generator.Complete = !iterated || Generator.Steps.Count == 0;
            return(environment.CreateBoolean(iterated));
        }