Beispiel #1
0
        internal void Control(LoopControlType controlType, string label)
        {
            AssertNotFinished();

            bool controlled = false;

            var statement = Statement;

            while (statement != null)
            {
                if (statement is LoopStatement)
                {
                    var loop = (LoopStatement)statement;
                    if (!String.IsNullOrEmpty(label) &&
                        String.Equals(label, loop.Label))
                    {
                        loop.Control(controlType);
                        controlled = true;
                    }
                    else if (!controlled)
                    {
                        loop.Control(controlType);
                        controlled = true;
                    }
                }

                statement = statement.Parent;
            }

            if (!controlled)
            {
                throw new StatementException(String.Format("Could not control {0} any loop.",
                                                           controlType.ToString().ToUpperInvariant()));
            }
        }
Beispiel #2
0
 internal void Control(LoopControlType controlType)
 {
     if (controlType == LoopControlType.Continue) {
         Continue = true;
     } else if (controlType == LoopControlType.Exit) {
         Exit = true;
     }
 }
        public void GetControlString(LoopControlType controlType, string label, bool?when, string expected)
        {
            var whenExp   = when == null ? null : SqlExpression.Constant(SqlObject.Boolean(when.Value));
            var statement = new LoopControlStatement(controlType, label, whenExp);

            var sql = statement.ToString();

            Assert.Equal(expected, sql);
        }
Beispiel #4
0
 internal void Control(LoopControlType controlType)
 {
     if (controlType == LoopControlType.Continue)
     {
         Continue = true;
     }
     else if (controlType == LoopControlType.Exit)
     {
         Exit = true;
     }
 }
        public void ControlLoop(LoopControlType controlType, string label)
        {
            ThrowIfTerminated();

            var loop = FindLoopInTree(Statement, label);

            if (loop == null)
            {
                throw new SqlStatementException("Could not find the loop");
            }

            loop.Control(controlType);
        }
Beispiel #6
0
        private static LoopControlStatement Build(LoopControlType controlType, PlSqlParser.LabelNameContext labelContext, PlSqlParser.ConditionContext conditionContext)
        {
            string label = null;
            SqlExpression whenExpression = null;

            if (labelContext != null)
                label = Name.Simple(labelContext);

            if (conditionContext != null)
                whenExpression = Expression.Build(conditionContext.expression());

            return new LoopControlStatement(controlType, label, whenExpression);
        }
Beispiel #7
0
        private static LoopControlStatement Build(LoopControlType controlType, PlSqlParser.LabelNameContext labelContext, PlSqlParser.ConditionContext conditionContext)
        {
            string        label          = null;
            SqlExpression whenExpression = null;

            if (labelContext != null)
            {
                label = Name.Simple(labelContext);
            }

            if (conditionContext != null)
            {
                whenExpression = Expression.Build(conditionContext.expression());
            }

            return(new LoopControlStatement(controlType, label, whenExpression));
        }
 public LoopControlStatement(LoopControlType controlType, string label, SqlExpression whenExpression)
 {
     Label = label;
     WhenExpression = whenExpression;
     ControlType = controlType;
 }
Beispiel #9
0
        internal void Control(LoopControlType controlType, string label)
        {
            AssertNotFinished();

            bool controlled = false;

            var statement = Statement;
            while (statement != null) {
                if (statement is LoopStatement) {
                    var loop = (LoopStatement) statement;
                    if (!String.IsNullOrEmpty(label) &&
                        String.Equals(label, loop.Label)) {
                        loop.Control(controlType);
                        controlled = true;
                    } else if (!controlled) {
                        loop.Control(controlType);
                        controlled = true;
                    }
                }

                statement = statement.Parent;
            }

            if (!controlled)
                throw new StatementException(String.Format("Could not control {0} any loop.",
                    controlType.ToString().ToUpperInvariant()));
        }
Beispiel #10
0
 public LoopControlStatement(LoopControlType controlType, SqlExpression whenExpression)
     : this(controlType, null, whenExpression)
 {
 }
Beispiel #11
0
 public LoopControlStatement(LoopControlType controlType, string label)
     : this(controlType, label, null)
 {
 }
 public LoopControlStatement(LoopControlType controlType)
     : this(controlType, (SqlExpression)null)
 {
 }
Beispiel #13
0
 public LoopControlStatement(LoopControlType controlType)
     : this(controlType, (SqlExpression) null)
 {
 }
Beispiel #14
0
 internal void Control(LoopControlType controlType)
 {
     HasControl  = true;
     ControlType = controlType;
 }
 public LoopControlStatement(LoopControlType controlType, SqlExpression when)
     : this(controlType, null, when)
 {
 }
Beispiel #16
0
 public void ControlLoop(LoopControlType controlType, string label)
 {
     throw new NotImplementedException();
 }
 public LoopControlStatement(LoopControlType controlType, string label, SqlExpression when)
 {
     ControlType = controlType;
     Label       = label;
     When        = when;
 }
 public LoopControlStatement(LoopControlType controlType, string label)
     : this(controlType, label, null)
 {
 }