public Operand ForEach(Type elementType, Operand expression)
        {
            ForeachBlock fb = new ForeachBlock(elementType, expression);

            Begin(fb);
            return(fb.Element);
        }
Esempio n. 2
0
        public ContextualOperand ForEach(Type elementType, Operand expression)
        {
            ForeachBlock fb = new ForeachBlock(elementType, expression, TypeMapper);

            Begin(fb);
            return(new ContextualOperand(fb.Element, TypeMapper));
        }
Esempio n. 3
0
        public ForeachBlock Build()
        {
            var foreachBlock = new ForeachBlock(_block);

            /*
             *  resolve header
             *
             */

            throwErrorIfHasNoNextOrNext("incompleted foreach block;");

            throwErrorIfOperatorTypeNotMatch(OperatorType.LeftParenthesis);//(

            throwErrorIfHasNoNextOrNext("incompleted foreach block;");

            throwErrorIfOperatorTypeNotMatch(OperatorType.Declare);//(var

            throwErrorIfHasNoNextOrNext("incompleted foreach block;");

            throwIf(x => !x.IsIdentifier());//(var item

            var name = _reader.Current().Value;

            throwErrorIfHasNoNextOrNext("incompleted foreach block;");

            throwIf(x => x.Value != Keywords.IN);//(var item in

            foreachBlock.DeclareExpression = new DeclareExpression(_block)
            {
                Root = new DeclareOperator(_block)
            };

            foreachBlock.DeclareExpression.Root.Operands.Add(new OperandNode(new JString(name)));//(var item in

            foreachBlock.GetCollectionExpression = new Expression(_block);

            foreachBlock.GetCollectionExpression.Root = new AstNodeBuilder(_reader, _block, _interceptChars).Build();

            /*
             * Resolve body
             *
             */

            if (!_reader.HasNext())
            {
                throwErrorIfHasNoNextOrNext("incompleted foreach block;");
            }

            foreachBlock.Body = new OrderedBlockBuilder(_reader, "foreach", foreachBlock).Build();

            return(foreachBlock);
        }
		public Operand ForEach(Type elementType, Operand expression)
		{
			ForeachBlock fb = new ForeachBlock(elementType, expression);
			Begin(fb);
			return fb.Element;
		}