public GeneratorExpressionProcessor(CompilerContext context,
								ForeignReferenceCollector collector,
								GeneratorExpression node)
        {
            _collector = collector;
            _generator = node;
            Initialize(context);
        }
		public GeneratorExpressionProcessor(CompilerContext context,
		                                    ForeignReferenceCollector collector,
		                                    GeneratorExpression node)
		{
			_collector = collector;
			_generator = node;
			_skeleton = My<GeneratorSkeletonBuilder>.Instance.SkeletonFor(node, node.GetAncestor<Method>());
			Initialize(context);
		}
Esempio n. 3
0
        public override void LeaveGeneratorExpression(GeneratorExpression node)
        {
            var collector = new ForeignReferenceCollector();
            collector.CurrentType = (IType) AstUtil.GetParentClass(node).Entity;
            collector.Visit(node);

            var processor = new GeneratorExpressionProcessor(Context, collector, node);
            processor.Run();
            ReplaceCurrentNode(processor.CreateEnumerableConstructorInvocation());
        }
		public override void OnGeneratorExpression(GeneratorExpression node)
		{
			if (node.LexicalInfo.Line != resolver.CaretLine)
				return;
			LoggingService.Warn("GeneratorExpression: " + node.EndSourceLocation.Line);
			foreach (Declaration decl in node.Declarations) {
				IterationDeclarationFound(decl.Name, decl.Type, node.Iterator, node.LexicalInfo);
			}
			base.OnGeneratorExpression(node);
		}
Esempio n. 5
0
 override public bool Replace(Node existing, Node newNode)
 {
     if (base.Replace(existing, newNode))
     {
         return(true);
     }
     if (_items != null)
     {
         GeneratorExpression item = existing as GeneratorExpression;
         if (null != item)
         {
             GeneratorExpression newItem = (GeneratorExpression)newNode;
             if (_items.Replace(item, newItem))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 6
0
        override public object Clone()
        {
            GeneratorExpression clone = (GeneratorExpression)FormatterServices.GetUninitializedObject(typeof(GeneratorExpression));

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

            clone._expressionType = _expressionType;
            if (null != _expression)
            {
                clone._expression = _expression.Clone() as Expression;
                clone._expression.InitializeParent(clone);
            }
            if (null != _declarations)
            {
                clone._declarations = _declarations.Clone() as DeclarationCollection;
                clone._declarations.InitializeParent(clone);
            }
            if (null != _iterator)
            {
                clone._iterator = _iterator.Clone() as Expression;
                clone._iterator.InitializeParent(clone);
            }
            if (null != _filter)
            {
                clone._filter = _filter.Clone() as StatementModifier;
                clone._filter.InitializeParent(clone);
            }
            return(clone);
        }
Esempio n. 7
0
        public override void OnGeneratorExpression(GeneratorExpression node)
        {
            Visit(node.Iterator);
            node.Iterator = ProcessIterator(node.Iterator, node.Declarations);

            EnterNamespace(new DeclarationsNamespace(CurrentNamespace, node.Declarations));
            Visit(node.Filter);
            Visit(node.Expression);
            LeaveNamespace();

            IType generatorItemType = TypeSystemServices.GetConcreteExpressionType(node.Expression);
            BindExpressionType(node, GeneratorTypeOf(generatorItemType));
        }
Esempio n. 8
0
	public void generator_expression_body(
		GeneratorExpression ge
	) //throws RecognitionException, TokenStreamException
{
		
		
			StatementModifier filter = null;
			Expression iterator = null;
			DeclarationCollection declarations = null == ge ? null : ge.Declarations;
		
		
		try {      // for error handling
			declaration_list(declarations);
			match(IN);
			iterator=boolean_expression();
			if (0==inputState.guessing)
			{
				ge.Iterator = iterator;
			}
			{
				if ((LA(1)==IF||LA(1)==UNLESS||LA(1)==WHILE) && (tokenSet_5_.member(LA(2))))
				{
					filter=stmt_modifier();
					if (0==inputState.guessing)
					{
						ge.Filter = filter;
					}
				}
				else if ((tokenSet_14_.member(LA(1))) && (tokenSet_15_.member(LA(2)))) {
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "generator_expression_body");
				recover(ex,tokenSet_14_);
			}
			else
			{
				throw ex;
			}
		}
	}
Esempio n. 9
0
	protected Expression  expression() //throws RecognitionException, TokenStreamException
{
		Expression e;
		
		IToken  f = null;
		IToken  f2 = null;
		
				e = null;
				
				ExtendedGeneratorExpression mge = null;
				GeneratorExpression ge = null;
			
		
		try {      // for error handling
			e=boolean_expression();
			{
				if ((LA(1)==FOR) && (LA(2)==ID))
				{
					f = LT(1);
					match(FOR);
					if (0==inputState.guessing)
					{
						
									ge = new GeneratorExpression(ToLexicalInfo(f));
									ge.Expression = e;
									e = ge;
								
					}
					generator_expression_body(ge);
					{    // ( ... )*
						for (;;)
						{
							if ((LA(1)==FOR) && (LA(2)==ID))
							{
								f2 = LT(1);
								match(FOR);
								if (0==inputState.guessing)
								{
									
													if (null == mge)
													{
														mge = new ExtendedGeneratorExpression(ToLexicalInfo(f));
														mge.Items.Add(ge);
														e = mge;
													}
													
													ge = new GeneratorExpression(ToLexicalInfo(f2));
													mge.Items.Add(ge);
												
								}
								generator_expression_body(ge);
							}
							else
							{
								goto _loop435_breakloop;
							}
							
						}
_loop435_breakloop:						;
					}    // ( ... )*
				}
				else if ((tokenSet_14_.member(LA(1))) && (tokenSet_15_.member(LA(2)))) {
				}
				else
				{
					throw new NoViableAltException(LT(1), getFilename());
				}
				
			}
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "expression");
				recover(ex,tokenSet_14_);
			}
			else
			{
				throw ex;
			}
		}
		return e;
	}
Esempio n. 10
0
 public override void OnGeneratorExpression(GeneratorExpression node)
 {
     NotImplemented(node, node.ToString());
 }
Esempio n. 11
0
		override public void LeaveGeneratorExpression(GeneratorExpression node)
		{
			var collector = new ForeignReferenceCollector { CurrentType = TypeContaining(node) };
			node.Accept(collector);

			var processor = new GeneratorExpressionProcessor(Context, collector, node);
			processor.Run();

			ReplaceCurrentNode(processor.CreateEnumerableConstructorInvocation());
		}
Esempio n. 12
0
 public override void LeaveGeneratorExpression(GeneratorExpression node)
 {
     Expression newExpression = Convert(
                                 GetConcreteExpressionType(node.Expression),
                                 node.Expression);
     if (null != newExpression)
     {
         node.Expression = newExpression;
     }
 }
Esempio n. 13
0
        //throws RecognitionException, TokenStreamException
        protected Expression expression()
        {
            Expression e;

            IToken  f = null;
            IToken  f2 = null;

                e = null;

                ExtendedGeneratorExpression mge = null;
                GeneratorExpression ge = null;

            try {      // for error handling
            e=boolean_expression();
            {
                switch ( LA(1) )
                {
                case FOR:
                {
                    f = LT(1);
                    match(FOR);
                    if (0==inputState.guessing)
                    {

                                    ge = new GeneratorExpression(SourceLocationFactory.ToLexicalInfo(f));
                                    ge.Expression = e;
                                    e = ge;

                    }
                    generator_expression_body(ge);
                    {    // ( ... )*
                        for (;;)
                        {
                            if ((LA(1)==FOR))
                            {
                                f2 = LT(1);
                                match(FOR);
                                if (0==inputState.guessing)
                                {

                                                    if (null == mge)
                                                    {
                                                        mge = new ExtendedGeneratorExpression(SourceLocationFactory.ToLexicalInfo(f));
                                                        mge.Items.Add(ge);
                                                        e = mge;
                                                    }

                                                    ge = new GeneratorExpression(SourceLocationFactory.ToLexicalInfo(f2));
                                                    mge.Items.Add(ge);

                                }
                                generator_expression_body(ge);
                            }
                            else
                            {
                                goto _loop380_breakloop;
                            }

                        }
            _loop380_breakloop:						;
                    }    // ( ... )*
                    break;
                }
                case EOF:
                case ESEPARATOR:
                case DEF:
                case DO:
                case IF:
                case UNLESS:
                case WHILE:
                case ID:
                case EOS:
                case NEWLINE:
                case RPAREN:
                case RBRACK:
                case COMMA:
                case COLON:
                case RBRACE:
                case QQ_END:
                {
                    break;
                }
                default:
                {
                    throw new NoViableAltException(LT(1), getFilename());
                }
                 }
            }
            }
            catch (RecognitionException ex)
            {
            if (0 == inputState.guessing)
            {
                reportError(ex);
                recover(ex,tokenSet_12_);
            }
            else
            {
                throw ex;
            }
            }
            return e;
        }
Esempio n. 14
0
 void WriteGeneratorExpressionBody(GeneratorExpression node)
 {
     WriteKeyword(" for ");
     WriteCommaSeparatedList(node.Declarations);
     WriteKeyword(" in ");
     Visit(node.Iterator);
     Visit(node.Filter);
 }
Esempio n. 15
0
		public GeneratorSkeleton SkeletonFor(GeneratorExpression generator, Method enclosingMethod)
		{
			return CreateGeneratorSkeleton(generator, enclosingMethod, TypeSystemServices.GetConcreteExpressionType(generator.Expression));
		}
Esempio n. 16
0
		private IType TypeContaining(GeneratorExpression node)
		{
			return (IType) AstUtil.GetParentClass(node).Entity;
		}
Esempio n. 17
0
		public override void OnGeneratorExpression(GeneratorExpression node)
		{
			ClearResult();
			node.Expression.Accept(this);
			
			if (resolveResult != null) {
				IReturnType enumerable = new GetClassReturnType(projectContent, "System.Collections.Generic.IEnumerable", 1);
				MakeResult(new ConstructedReturnType(enumerable, new IReturnType[] { resolveResult.ResolvedType }));
			} else {
				MakeResult(new GetClassReturnType(projectContent, "System.Collections.IEnumerable", 0));
			}
		}
Esempio n. 18
0
 public override void OnGeneratorExpression(GeneratorExpression node)
 {
     Write("(");
     Visit(node.Expression);
     WriteGeneratorExpressionBody(node);
     Write(")");
 }
Esempio n. 19
0
		override public object Clone()
		{
		
			GeneratorExpression clone = new GeneratorExpression();
			clone._lexicalInfo = _lexicalInfo;
			clone._endSourceLocation = _endSourceLocation;
			clone._documentation = _documentation;
			clone._isSynthetic = _isSynthetic;
			clone._entity = _entity;
			if (_annotations != null) clone._annotations = (Hashtable)_annotations.Clone();
			clone._expressionType = _expressionType;
			if (null != _expression)
			{
				clone._expression = _expression.Clone() as Expression;
				clone._expression.InitializeParent(clone);
			}
			if (null != _declarations)
			{
				clone._declarations = _declarations.Clone() as DeclarationCollection;
				clone._declarations.InitializeParent(clone);
			}
			if (null != _iterator)
			{
				clone._iterator = _iterator.Clone() as Expression;
				clone._iterator.InitializeParent(clone);
			}
			if (null != _filter)
			{
				clone._filter = _filter.Clone() as StatementModifier;
				clone._filter.InitializeParent(clone);
			}
			return clone;


		}
Esempio n. 20
0
 BooClassBuilder CreateGeneratorSkeleton(GeneratorExpression node)
 {
     BooClassBuilder builder = CreateGeneratorSkeleton(node, _currentMethod.Method, GetConcreteExpressionType(node.Expression));
     _currentMethod.Method.DeclaringType.Members.Add(builder.ClassDefinition);
     return builder;
 }
Esempio n. 21
0
        public override void OnGeneratorExpression(GeneratorExpression node)
        {
            Visit(node.Iterator);
            node.Iterator = ProcessIterator(node.Iterator, node.Declarations);

            EnterNamespace(new DeclarationsNamespace(CurrentNamespace, TypeSystemServices, node.Declarations));
            Visit(node.Filter);
            Visit(node.Expression);
            LeaveNamespace();

            BooClassBuilder generatorType = CreateGeneratorSkeleton(node);

            BindExpressionType(node, generatorType.Entity);
        }
Esempio n. 22
0
 public override void LeaveGeneratorExpression(GeneratorExpression node)
 {
     CheckExpressionType(node.Expression);
 }