protected override Expression DoResolve(ResolveContext ec)
        {
            var ctx = CreateBlockContext(ec);

            Block.Resolve(ctx);

            //
            // Explicit return is required for Task<T> state machine
            //
            var task_storey = storey as AsyncTaskStorey;

            if (task_storey == null || (task_storey.ReturnType != null && !task_storey.ReturnType.IsGenericTask))
            {
                ctx.CurrentBranching.CurrentUsageVector.Goto();
            }

            ctx.EndFlowBranching();

            if (!ec.IsInProbingMode)
            {
                var move_next = new StateMachineMethod(storey, this, new TypeExpression(ReturnType, loc), Modifiers.PUBLIC, new MemberName("MoveNext", loc));
                move_next.Block.AddStatement(new MoveNextBodyStatement(this));
                storey.AddEntryMethod(move_next);
            }

            eclass = ExprClass.Value;
            return(this);
        }
        public void AddEntryMethod(StateMachineMethod method)
        {
            if (this.method != null)
            {
                throw new InternalErrorException();
            }

            this.method = method;
            Members.Add(method);
        }
 public GetEnumeratorStatement(IteratorStorey host, StateMachineMethod host_method)
 {
     this.host        = host;
     this.host_method = host_method;
     loc = host_method.Location;
 }