Пример #1
0
        public static DeclarationCollection FromArray(params Boo.Lang.Compiler.Ast.Declaration[] items)
        {
            var collection = new DeclarationCollection();

            collection.AddRange(items);
            return(collection);
        }
        public static DeclarationCollection FromArray(params Boo.Lang.Compiler.Ast.Declaration[] items)
        {
            DeclarationCollection collection = new DeclarationCollection();

            collection.Extend(items);
            return(collection);
        }
Пример #3
0
        protected void ProcessDeclarationsForIterator(DeclarationCollection declarations, IType iteratorType)
        {
            var defaultDeclType = GetEnumeratorItemType(iteratorType);
            if (declarations.Count > 1)
                // will enumerate (unpack) each item
                defaultDeclType = GetEnumeratorItemType(defaultDeclType);

            foreach (var d in declarations)
                ProcessDeclarationForIterator(d, defaultDeclType);
        }
Пример #4
0
	protected void declaration_list(
		DeclarationCollection dc
	) //throws RecognitionException, TokenStreamException
{
		
		
				Declaration d = null;
			
		
		try {      // for error handling
			d=declaration();
			if (0==inputState.guessing)
			{
				dc.Add(d);
			}
			{    // ( ... )*
				for (;;)
				{
					if ((LA(1)==COMMA))
					{
						match(COMMA);
						d=declaration();
						if (0==inputState.guessing)
						{
							dc.Add(d);
						}
					}
					else
					{
						goto _loop421_breakloop;
					}
					
				}
_loop421_breakloop:				;
			}    // ( ... )*
		}
		catch (RecognitionException ex)
		{
			if (0 == inputState.guessing)
			{
				reportError(ex, "declaration_list");
				recover(ex,tokenSet_108_);
			}
			else
			{
				throw ex;
			}
		}
	}
Пример #5
0
 public DeclarationsNamespace(INamespace parent, TypeSystemServices tagManager, Declaration declaration)
 {
     _parent = parent;
     _declarations = new DeclarationCollection();
     _declarations.Add(declaration);
 }
Пример #6
0
 public DeclarationsNamespace(INamespace parent, TypeSystemServices tagManager, DeclarationCollection declarations)
 {
     _parent = parent;
     _declarations = declarations;
 }
Пример #7
0
		public DeclarationsNamespace(INamespace parent, Declaration declaration)
		{
			_parent = parent;
			_declarations = new DeclarationCollection { declaration };
		}
Пример #8
0
		public DeclarationsNamespace(INamespace parent, DeclarationCollection declarations)
		{
			_parent = parent;
			_declarations = declarations;
		}
 public Boo.Lang.Compiler.Ast.DeclarationCollection PopRange(int begin)
 {
     Boo.Lang.Compiler.Ast.DeclarationCollection range = new Boo.Lang.Compiler.Ast.DeclarationCollection(_parent);
     range.InnerList.Extend(InternalPopRange(begin));
     return(range);
 }
Пример #10
0
 /// <summary>
 /// Unpacks an expression onto a list of declarations.
 /// </summary>
 /// <param name="block">Block this takes place in</param>
 /// <param name="expression">expression to explode</param>
 /// <param name="declarations">list of declarations to set</param>
 void UnpackExpression(Block block, Expression expression, DeclarationCollection declarations)
 {
     NormalizeIterationStatements.UnpackExpression(CodeBuilder, _currentMethod, block, expression, declarations);
 }
Пример #11
0
		public static void UnpackArray(BooCodeBuilder codeBuilder, Method method, Block block, Expression expression, DeclarationCollection declarations)
		{
			ILocalEntity local = expression.Entity as ILocalEntity;
			if (null == local)
			{
				local = codeBuilder.DeclareTempLocal(method,
				                                     expression.ExpressionType);
				block.Add(
					codeBuilder.CreateAssignment(
						codeBuilder.CreateReference(local),
						expression));
			}
			for (int i=0; i<declarations.Count; ++i)
			{
				Declaration declaration = declarations[i];
				block.Add(
					codeBuilder.CreateAssignment(
						codeBuilder.CreateReference(
							declaration.Entity),
						codeBuilder.CreateSlicing(
							codeBuilder.CreateReference(local),
							i)));
			}
		}
Пример #12
0
		public static void UnpackEnumerable(BooCodeBuilder codeBuilder, Method method, Block block, Expression expression, DeclarationCollection declarations)
		{
			TypeSystemServices tss = codeBuilder.TypeSystemServices;
			
			InternalLocal local = codeBuilder.DeclareTempLocal(method,
			                                                   tss.IEnumeratorType);
			
			IType expressionType = expression.ExpressionType;
			
			if (expressionType.IsSubclassOf(codeBuilder.TypeSystemServices.IEnumeratorType))
			{
				block.Add(
					codeBuilder.CreateAssignment(
						codeBuilder.CreateReference(local),
						expression));
			}
			else
			{
				if (!expressionType.IsSubclassOf(codeBuilder.TypeSystemServices.IEnumerableType))
				{
					expression = codeBuilder.CreateMethodInvocation(
						RuntimeServices_GetEnumerable, expression);
				}
				
				block.Add(
					codeBuilder.CreateAssignment(
						block.LexicalInfo,
						codeBuilder.CreateReference(local),
						codeBuilder.CreateMethodInvocation(
							expression, IEnumerable_GetEnumerator)));
			}
			
			for (int i=0; i<declarations.Count; ++i)
			{
				Declaration declaration = declarations[i];
				
				block.Add(
					codeBuilder.CreateAssignment(
						codeBuilder.CreateReference(declaration.Entity),
						codeBuilder.CreateMethodInvocation(RuntimeServices_MoveNext,
						                                   codeBuilder.CreateReference(local))));
			}
		}
Пример #13
0
		public static void UnpackExpression(BooCodeBuilder codeBuilder, Method method, Block block, Expression expression, DeclarationCollection declarations)
		{
			if (expression.ExpressionType.IsArray)
			{
				UnpackArray(codeBuilder, method, block, expression, declarations);
			}
			else
			{
				UnpackEnumerable(codeBuilder, method, block, expression, declarations);
			}
		}
Пример #14
0
	    void UnpackExpression(Block block, Expression expression, DeclarationCollection declarations)
		{
			UnpackExpression(CodeBuilder, _current, block, expression, declarations);
		}
Пример #15
0
 /// <summary>
 /// Process a iterator and its declarations and returns a new iterator
 /// expression if necessary.
 /// </summary>
 protected Expression ProcessIterator(Expression iterator, DeclarationCollection declarations)
 {
     iterator = GetCorrectIterator(iterator);
     ProcessDeclarationsForIterator(declarations, GetExpressionType(iterator));
     return iterator;
 }
Пример #16
0
 public UnpackStatement CreateUnpackStatement(DeclarationCollection declarations, Expression expression)
 {
     UnpackStatement unpack = new UnpackStatement(expression.LexicalInfo);
     unpack.Declarations.AddRange(declarations);
     unpack.Expression = expression;
     return unpack;
 }
Пример #17
0
        protected void ProcessDeclarationsForIterator(DeclarationCollection declarations, IType iteratorType)
        {
            IType defaultDeclType = GetEnumeratorItemType(iteratorType);
            if (declarations.Count > 1)
                // will enumerate (unpack) each item
                defaultDeclType = GetEnumeratorItemType(defaultDeclType);
            else if (declarations.Count == 1) //local reuse (BOO-1111)
            {
                var d = declarations[0];
                var local = LocalToReuseFor(d);
                if (local != null)
                {
                    GetDeclarationType(defaultDeclType, d);
                    AssertTypeCompatibility(d, GetType(d.Type), ((InternalLocal) local.Entity).Type);
                    d.Entity = local.Entity;
                    return; //okay we reuse a previously declared local
                }
            }

            foreach (var d in declarations)
                ProcessDeclarationForIterator(d, defaultDeclType);
        }