/// <summary>
        /// Adds a Rethrow clause into this block. This should only be used if the
        /// actual block is a catch or is inside one.
        /// </summary>
        public TThis Rethrow()
        {
            _CheckModifiable();

            var rethrowExpression = Expression.Rethrow();
            var statement         = new _Expression(rethrowExpression);

            _statements.Add(statement);
            return(_this);
        }
        /// <summary>
        /// Adds a Throw clause into this block.
        /// </summary>
        public TThis Throw(Expression <Func <Exception> > expression)
        {
            if (expression == null)
            {
                throw new ArgumentNullException("expression");
            }

            _CheckModifiable();

            var throwExpression = Expression.Throw(expression.Body);
            var statement       = new _Expression(throwExpression);

            _statements.Add(statement);
            return(_this);
        }
        /// <summary>
        /// Adds a Break statement to this block, making it exit the actual loop.
        /// This should only be used in loop blocks (Loop, While and For) or in sub-blocks of such blocks.
        /// </summary>
        public TThis Break()
        {
            _CheckModifiable();

            _IBlockBuilder instance = this;

            while (instance != null)
            {
                _ILoop loop = instance as _ILoop;
                if (loop != null)
                {
                    var gotoExpression = Expression.Goto(loop.BreakTarget);
                    var statement      = new _Expression(gotoExpression);
                    _statements.Add(statement);
                    return(_this);
                }

                instance = instance.Parent as _IBlockBuilder;
            }

            throw new InvalidOperationException("You are not inside a breakable block.");
        }
 public Item(Item item)
 {
     context = item.context;
     value   = item.value;
 }
 public Item(ItemType context, _Expression value)
 {
     this.context = context;
     this.value   = value;
 }
 public Item()
 {
     context = ItemType.EMPTY;
     value   = null;
 }
 public _ParseResult(int index, _Expression value)
 {
     Index = index;
     Value = value;
 }