blob: a7c6be8a1090973901703950507c2cf27bec2053 (
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
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 GetIfOfIfThenElseVisitor : StandardVisitor
{
IdentifierExpr result;
internal GetIfOfIfThenElseVisitor()
{
result = null;
}
public override Expr VisitNAryExpr(NAryExpr node)
{
if (node.Fun is IfThenElse)
{
if (node.Args[0] is IdentifierExpr)
{
Debug.Assert(result == null);
result = node.Args[0] as IdentifierExpr;
}
else if (node.Args[0] is NAryExpr)
{
Debug.Assert(result == null);
result = ExtractEnabledArg((NAryExpr)node.Args[0]);
}
}
return base.VisitNAryExpr(node);
}
internal IdentifierExpr getResult()
{
Debug.Assert(result != null);
return result;
}
internal IdentifierExpr ExtractEnabledArg(NAryExpr ne)
{
if (ne.Args[0] is IdentifierExpr)
{
return (IdentifierExpr)ne.Args[0];
}
else if (ne.Args[0] is NAryExpr)
{
return ExtractEnabledArg((NAryExpr)ne.Args[0]);
}
else
{
Debug.Assert(false, "ExtractEnabledArg: not all cases covered");
return null;
}
}
}
}
|