Example #1
0
		public override void LeaveYieldStatement(YieldStatement node)
		{
			if (node.Expression == null)
				return;

			TryToReify(node.Expression, GeneratorItemTypeFrom(_currentMethod.ReturnType) ?? TypeSystemServices.ObjectArrayType);
		}
Example #2
0
        override public object Clone()
        {
            YieldStatement clone = (YieldStatement)FormatterServices.GetUninitializedObject(typeof(YieldStatement));

            clone._lexicalInfo       = _lexicalInfo;
            clone._endSourceLocation = _endSourceLocation;
            clone._documentation     = _documentation;
            clone._isSynthetic       = _isSynthetic;
            clone._entity            = _entity;
            if (_annotations != null)
            {
                clone._annotations = (Hashtable)_annotations.Clone();
            }

            if (null != _modifier)
            {
                clone._modifier = _modifier.Clone() as StatementModifier;
                clone._modifier.InitializeParent(clone);
            }
            if (null != _expression)
            {
                clone._expression = _expression.Clone() as Expression;
                clone._expression.InitializeParent(clone);
            }
            return(clone);
        }
Example #3
0
 public override void OnYieldStatement(YieldStatement node)
 {
     _hasYieldStatements = true;
 }
Example #4
0
        public override void LeaveYieldStatement(YieldStatement node)
        {
            if (EntityType.Constructor == _currentMethod.EntityType)
            {
                Error(CompilerErrorFactory.YieldInsideConstructor(node));
                return;
            }

            _currentMethod.AddYieldStatement(node);
        }
Example #5
0
	protected YieldStatement  yield_stmt() //throws RecognitionException, TokenStreamException
{
		YieldStatement s;
		
		IToken  yt = null;
		
				s = null;
				Expression e = null;
			
		
		try {      // for error handling
			yt = LT(1);
			match(YIELD);
			{
				switch ( LA(1) )
				{
				case ESEPARATOR:
				case CAST:
				case CHAR:
				case FALSE:
				case NOT:
				case NULL:
				case SELF:
				case SUPER:
				case THEN:
				case TRUE:
				case TYPEOF:
				case TRIPLE_QUOTED_STRING:
				case LPAREN:
				case DOUBLE_QUOTED_STRING:
				case SINGLE_QUOTED_STRING:
				case ID:
				case MULTIPLY:
				case LBRACK:
				case COMMA:
				case SPLICE_BEGIN:
				case DOT:
				case LBRACE:
				case QQ_BEGIN:
				case SUBTRACT:
				case LONG:
				case INCREMENT:
				case DECREMENT:
				case ONES_COMPLEMENT:
				case INT:
				case BACKTICK_QUOTED_STRING:
				case RE_LITERAL:
				case DOUBLE:
				case FLOAT:
				case TIMESPAN:
				{
					e=array_or_expression();
					break;
				}
				case EOL:
				case IF:
				case UNLESS:
				case WHILE:
				case EOS:
				case RBRACE:
				case QQ_END:
				{
					break;
				}
				default:
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				 }
			}
			if (0==inputState.guessing)
			{
				
						s = new YieldStatement(ToLexicalInfo(yt));
						s.Expression = e;
					
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "yield_stmt");
				recover(ex,tokenSet_90_);
			}
			else
			{
				throw ex;
			}
		}
		return s;
	}
Example #6
0
		override public void LeaveYieldStatement(YieldStatement node)
		{
			TryStatementInfo currentTry = (_tryStatementStack.Count > 0) ? _tryStatementStack.Peek() : null;
			if (currentTry != null) {
				ConvertTryStatement(currentTry);
			}
			Block block = new Block();
			block.Add(
				new ReturnStatement(
					node.LexicalInfo,
					CreateYieldInvocation(node.LexicalInfo, _labels.Count, node.Expression),
					null));
			block.Add(CreateLabel(node));
			// setting the state back to the "running" state not required, as that state has the same ensure blocks
			// as the state we are currently in.
//			if (currentTry != null) {
//				block.Add(SetStateTo(currentTry._stateNumber));
//			}
			ReplaceCurrentNode(block);
		}
Example #7
0
 public override void OnYieldStatement(YieldStatement node)
 {
     if (_state.TryBlockDepth == _state.ProtectedBlockDepth) {
         // we are currently only in the protected blocks, not in any "except" or "ensure" blocks.
         foreach (TryStatement tryBlock in _state.TryBlocks) {
             // only allow yield in the try part of try-ensure blocks, fail if it is a try-except block
             if (tryBlock.FailureBlock != null || tryBlock.ExceptionHandlers.Count > 0) {
                 Error(CompilerErrorFactory.YieldInsideTryExceptOrEnsureBlock(node));
                 break;
             }
         }
     } else {
         Error(CompilerErrorFactory.YieldInsideTryExceptOrEnsureBlock(node));
     }
 }
Example #8
0
		override public object Clone()
		{
		
			YieldStatement clone = new YieldStatement();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			if (null != _modifier)
			{
				clone._modifier = _modifier.Clone() as StatementModifier;
				clone._modifier.InitializeParent(clone);
			}
			if (null != _expression)
			{
				clone._expression = _expression.Clone() as Expression;
				clone._expression.InitializeParent(clone);
			}
			return clone;


		}
Example #9
0
 public void AddYieldStatement(YieldStatement stmt)
 {
     if (null == _yieldStatements) _yieldStatements = new List();
     _yieldStatements.Add(stmt);
 }
Example #10
0
 public override void LeaveYieldStatement(YieldStatement node)
 {
     if (null == node.Expression) return;
     CheckExpressionType(node.Expression);
 }
 public override void LeaveYieldStatement(YieldStatement node)
 {
     LeaveStatement(node);
 }
			public override void OnYieldStatement(YieldStatement node)
			{
				noReturnStatement = false;
				
				IProjectContent pc = context != null ? context.ProjectContent : ParserService.CurrentProjectContent;
				IReturnType enumerable = new GetClassReturnType(pc, "System.Collections.Generic.IEnumerable", 1);
				
				// Prevent creating an infinite number of InferredReturnTypes in inferring cycles
				parentReturnType.expression = new NullLiteralExpression();
				IReturnType returnType;
				if (node.Expression == null)
					returnType = ConvertVisitor.GetDefaultReturnType(pc);
				else
					returnType = new BooResolver().GetTypeOfExpression(node.Expression, context);
				if (returnType != null) {
					returnType.GetUnderlyingClass(); // force to infer type
				}
				if (parentReturnType.expression == null) {
					// inferrence cycle with parentReturnType
					returnType = new GetClassReturnType(pc, "?", 0);
				}
				parentReturnType.expression = null;
				
				result = new ConstructedReturnType(enumerable, new IReturnType[] { returnType });
			}
Example #13
0
 public override void OnYieldStatement(YieldStatement node)
 {
     WriteIndented();
     WriteKeyword("yield ");
     Visit(node.Expression);
     Visit(node.Modifier);
     WriteLine();
 }
 public void yield_statement(Block b)
 {
     IToken token = null;
     try
     {
         Expression expression;
         token = this.LT(1);
         this.match(0x30);
         if (tokenSet_16_.member(this.LA(1)) && tokenSet_49_.member(this.LA(2)))
         {
             expression = this.expression();
         }
         else if (!tokenSet_15_.member(this.LA(1)) || !tokenSet_20_.member(this.LA(2)))
         {
             throw new NoViableAltException(this.LT(1), this.getFilename());
         }
         if (base.inputState.guessing == 0)
         {
             YieldStatement statement;
             YieldStatement statement1 = statement = new YieldStatement(ToLexicalInfo(token));
             statement.set_Expression(expression);
             b.Add(statement);
         }
     }
     catch (RecognitionException exception)
     {
         if (base.inputState.guessing != 0)
         {
             throw;
         }
         this.reportError(exception);
         this.recover(exception, tokenSet_15_);
     }
 }