public override JsStatement VisitYieldStatement(JsYieldStatement statement, object data)
 {
     if (statement.Value != null)
     {
         throw new InvalidOperationException("yield return should have been already taken care of.");
     }
     return(new JsGotoStateStatement(_exitState, _currentState));
 }
 public override JsStatement VisitYieldStatement(JsYieldStatement statement, object data)
 {
     if (statement.Value != null)
     {
         _result |= InterestingConstruct.YieldReturn;
     }
     else
     {
         _result |= InterestingConstruct.YieldBreak;
     }
     return(statement);
 }
        private bool HandleYieldReturnStatement(JsYieldStatement stmt, StackEntry location, ImmutableStack <StackEntry> stack, ImmutableStack <Tuple <string, State> > breakStack, ImmutableStack <Tuple <string, State> > continueStack, State currentState, State returnState, IList <JsStatement> currentBlock)
        {
            var stateAfter = GetStateAfterStatement(location, stack, currentState.FinallyStack, returnState);

            currentBlock.Add(_makeSetCurrent(stmt.Value));
            currentBlock.Add(new JsSetNextStateStatement(stateAfter.Item1.StateValue));
            currentBlock.Add(JsStatement.Return(JsExpression.True));

            if (!stack.IsEmpty || location.Index < location.Block.Statements.Count - 1)
            {
                Enqueue(PushFollowing(stack, location), breakStack, continueStack, stateAfter.Item1, returnState);
            }

            return(false);
        }
Exemplo n.º 4
0
 public object VisitYieldStatement(JsYieldStatement statement, bool addNewline)
 {
     if (!_allowIntermediates)
     {
         throw new NotSupportedException("yield should not occur in the output stage");
     }
     if (statement.Value != null)
     {
         _cb.Append("yield return ");
         VisitExpression(statement.Value, false);
         _cb.Append(";");
     }
     else
     {
         _cb.Append("yield break;");
     }
     if (addNewline)
     {
         _cb.AppendLine();
     }
     return(null);
 }
        private bool HandleYieldReturnStatement(JsYieldStatement stmt, StackEntry location, ImmutableStack<StackEntry> stack, ImmutableStack<Tuple<string, State>> breakStack, ImmutableStack<Tuple<string, State>> continueStack, State currentState, State returnState, IList<JsStatement> currentBlock)
        {
            var stateAfter = GetStateAfterStatement(location, stack, currentState.FinallyStack, returnState);

            currentBlock.Add(new JsExpressionStatement(_makeSetCurrent(stmt.Value)));
            currentBlock.Add(new JsSetNextStateStatement(stateAfter.Item1.StateValue));
            currentBlock.Add(new JsReturnStatement(JsExpression.True));

            if (!stack.IsEmpty || location.Index < location.Block.Statements.Count - 1) {
                Enqueue(PushFollowing(stack, location), breakStack, continueStack, stateAfter.Item1, returnState);
            }

            return false;
        }
        public virtual JsStatement VisitYieldStatement(JsYieldStatement statement, TData data)
        {
            var value = statement.Value != null?VisitExpression(statement.Value, data) : null;

            return(ReferenceEquals(value, statement.Value) ? statement : new JsYieldStatement(value));
        }