Beispiel #1
0
 public override void Visit(CaseOp op, Node n)
 {
     using (new AutoXml(this, op))
     {
         var i = 0;
         while (i < n.Children.Count)
         {
             if ((i + 1)
                 < n.Children.Count)
             {
                 using (new AutoXml(this, "when"))
                 {
                     VisitNode(n.Children[i++]);
                 }
                 using (new AutoXml(this, "then"))
                 {
                     VisitNode(n.Children[i++]);
                 }
             }
             else
             {
                 using (new AutoXml(this, "else"))
                 {
                     VisitNode(n.Children[i++]);
                 }
             }
         }
     }
 }
Beispiel #2
0
        public override void Visit(CaseOp op, Node n)
        {
            VisitScalarOpDefault(op, n);
            Assert(
                (n.Children.Count >= 3 && n.Children.Count % 2 == 1),
                "CaseOp: Expected odd number of arguments, and at least 3; found {0}", n.Children.Count);

            // Validate that each when statement is of type Boolean
            for (var i = 0; i < n.Children.Count - 1; i += 2)
            {
                Assert(TypeSemantics.IsBooleanType(n.Children[i].Op.Type), "Encountered a when node with a non-boolean return type");
            }

            // Ensure that the then clauses, the else clause and the result type are all the same
            for (var i = 1; i < n.Children.Count - 1; i += 2)
            {
                AssertEqualTypes(n.Op.Type, n.Children[i].Op.Type);
            }
            AssertEqualTypes(n.Op.Type, n.Children[n.Children.Count - 1].Op.Type);
        }
 public override void Visit(CaseOp op, Node n)
 {
     using (new Dump.AutoXml(this, (Op)op))
     {
         int num = 0;
         while (num < n.Children.Count)
         {
             if (num + 1 < n.Children.Count)
             {
                 using (new Dump.AutoXml(this, "when"))
                     this.VisitNode(n.Children[num++]);
                 using (new Dump.AutoXml(this, "then"))
                     this.VisitNode(n.Children[num++]);
             }
             else
             {
                 using (new Dump.AutoXml(this, "else"))
                     this.VisitNode(n.Children[num++]);
             }
         }
     }
 }
Beispiel #4
0
 // <summary>
 // Copies a CaseOp
 // </summary>
 // <param name="op"> The Op to Copy </param>
 // <param name="n"> The Node that references the Op </param>
 // <returns> A copy of the original Node that references a copy of the original Op </returns>
 public override Node Visit(CaseOp op, Node n)
 {
     return(CopyDefault(m_destCmd.CreateCaseOp(op.Type), n));
 }
 public virtual void Visit(CaseOp op, Node n)
 {
     this.VisitScalarOpDefault((ScalarOp)op, n);
 }
Beispiel #6
0
 /// <summary>
 ///     Visitor pattern method for CaseOp
 /// </summary>
 /// <param name="op"> The CaseOp being visited </param>
 /// <param name="n"> The Node that references the Op </param>
 public virtual void Visit(CaseOp op, Node n)
 {
     VisitScalarOpDefault(op, n);
 }
Beispiel #7
0
 // <summary>
 // CaseOp
 // </summary>
 public virtual TResultType Visit(CaseOp op, Node n)
 {
     return(VisitScalarOpDefault(op, n));
 }