blob: 64b5bd91005c5d6cb64622e96f411f7f6d4b9bb3 (
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
namespace WixToolset.Preprocess
{
using System;
/// <summary>
/// Current state of the if context.
/// </summary>
internal enum IfState
{
/// <summary>Context currently in unknown state.</summary>
Unknown,
/// <summary>Context currently inside if statement.</summary>
If,
/// <summary>Context currently inside elseif statement..</summary>
ElseIf,
/// <summary>Conext currently inside else statement.</summary>
Else,
}
/// <summary>
/// Context for an if statement in the preprocessor.
/// </summary>
internal sealed class IfContext
{
private bool active;
private bool keep;
private bool everKept;
private IfState state;
/// <summary>
/// Creates a default if context object, which are used for if's within an inactive preprocessor block
/// </summary>
public IfContext()
{
this.active = false;
this.keep = false;
this.everKept = true;
this.state = IfState.If;
}
/// <summary>
/// Creates an if context object.
/// </summary>
/// <param name="active">Flag if context is currently active.</param>
/// <param name="keep">Flag if context is currently true.</param>
/// <param name="state">State of context to start in.</param>
public IfContext(bool active, bool keep, IfState state)
{
this.active = active;
this.keep = keep;
this.everKept = keep;
this.state = state;
}
/// <summary>
/// Gets and sets if this if context is currently active.
/// </summary>
/// <value>true if context is active.</value>
public bool Active
{
get { return this.active; }
set { this.active = value; }
}
/// <summary>
/// Gets and sets if context is current true.
/// </summary>
/// <value>true if context is currently true.</value>
public bool IsTrue
{
get
{
return this.keep;
}
set
{
this.keep = value;
if (this.keep)
{
this.everKept = true;
}
}
}
/// <summary>
/// Gets if the context was ever true.
/// </summary>
/// <value>True if context was ever true.</value>
public bool WasEverTrue
{
get { return this.everKept; }
}
/// <summary>
/// Gets the current state of the if context.
/// </summary>
/// <value>Current state of context.</value>
public IfState IfState
{
get { return this.state; }
set { this.state = value; }
}
}
}
|