summaryrefslogtreecommitdiff
path: root/Source/GPUVerifyBoogieDriver/GetThenOfIfThenElseVisitor.cs
blob: dbecda97b8f00a159dd467af50a3fcb7f1ba6a31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Boogie;
using System.Diagnostics;
using System.Text.RegularExpressions;

namespace Microsoft.Boogie
{
  class GetThenOfIfThenElseVisitor : StandardVisitor
  {
    LiteralExpr result;

    internal GetThenOfIfThenElseVisitor()
    {
      result = null;
    }

    public override Expr VisitNAryExpr(NAryExpr node)
    {
      if (node.Fun is IfThenElse)
      {
        if (node.Args[1] is LiteralExpr)
        {
          Debug.Assert(result == null);
          result = (LiteralExpr)node.Args[1];
        }
      }
      return base.VisitNAryExpr(node);
    }

    internal LiteralExpr getResult()
    {
      Debug.Assert(result != null);
      return result;
    }
  }
}