diff options
author | wuestholz <unknown> | 2015-01-09 15:54:00 +0100 |
---|---|---|
committer | wuestholz <unknown> | 2015-01-09 15:54:00 +0100 |
commit | 7a1fdfc03d53699d50fd1cb562364b5a86039e41 (patch) | |
tree | 9cb236c2965cc3e0c342bd87525a67bfdda2752b /Source | |
parent | 62f2f66e8d5fce4e9c80c0eebabd369ee0cc22d9 (diff) |
Made invariant of class 'StmtList' robust by:
- making field private and readonly
- exposing IEnumerable
- adding 'AddLabel' method
(with help from David Rohr)
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Core/AbsyCmd.cs | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/Source/Core/AbsyCmd.cs b/Source/Core/AbsyCmd.cs index 9b73ffa7..8c06cac2 100644 --- a/Source/Core/AbsyCmd.cs +++ b/Source/Core/AbsyCmd.cs @@ -90,12 +90,28 @@ namespace Microsoft.Boogie { public readonly IToken/*!*/ EndCurly;
public StmtList ParentContext;
public BigBlock ParentBigBlock;
- public HashSet<string/*!*/>/*!*/ Labels = new HashSet<string/*!*/>();
+
+ private readonly HashSet<string/*!*/>/*!*/ labels = new HashSet<string/*!*/>();
+
+ public void AddLabel(string label)
+ {
+ labels.Add(label);
+ }
+
+ public IEnumerable<string/*!*/>/*!*/ Labels
+ {
+ get
+ {
+ Contract.Ensures(cce.NonNullElements(Contract.Result<IEnumerable<string/*!*/>/*!*/>()));
+ return this.labels.AsEnumerable<string>();
+ }
+ }
+
[ContractInvariantMethod]
void ObjectInvariant() {
Contract.Invariant(EndCurly != null);
Contract.Invariant(cce.NonNullElements(this.bigBlocks));
- Contract.Invariant(cce.NonNullElements(Labels));
+ Contract.Invariant(cce.NonNullElements(this.labels));
}
public StmtList(IList<BigBlock/*!*/>/*!*/ bigblocks, IToken endCurly) {
@@ -337,7 +353,7 @@ namespace Microsoft.Boogie { prefix += "0";
}
}
- stmtList.Labels.Add(b.LabelName);
+ stmtList.AddLabel(b.LabelName);
}
}
|