コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <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);
        }
コード例 #3
0
        /// <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.");
        }
コード例 #4
0
 public Item(Item item)
 {
     context = item.context;
     value   = item.value;
 }
コード例 #5
0
 public Item(ItemType context, _Expression value)
 {
     this.context = context;
     this.value   = value;
 }
コード例 #6
0
 public Item()
 {
     context = ItemType.EMPTY;
     value   = null;
 }
コード例 #7
0
 public _ParseResult(int index, _Expression value)
 {
     Index = index;
     Value = value;
 }