diff options
author | 0biha <unknown> | 2014-12-27 19:47:35 +0100 |
---|---|---|
committer | 0biha <unknown> | 2014-12-27 19:47:35 +0100 |
commit | 2d6084d3f5ef73b4ace7366790b3149bc8c60452 (patch) | |
tree | 27e59a34938340563dc208e83c0bb172776a1a51 /Source/Core/Absy.cs | |
parent | d04bdd5809de3d6ab649dc4d87a1ee40082bc496 (diff) |
Made invariant of class 'Program' robust by making the GlobalVariables cache read-only.
Diffstat (limited to 'Source/Core/Absy.cs')
-rw-r--r-- | Source/Core/Absy.cs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Source/Core/Absy.cs b/Source/Core/Absy.cs index b0090c68..56ccfa9e 100644 --- a/Source/Core/Absy.cs +++ b/Source/Core/Absy.cs @@ -681,17 +681,17 @@ namespace Microsoft.Boogie { }
}
- private List<GlobalVariable/*!*/> globalVariablesCache = null;
- public IEnumerable<GlobalVariable/*!*/>/*!*/ GlobalVariables
+ private System.Collections.ObjectModel.ReadOnlyCollection<GlobalVariable/*!*/> globalVariablesCache = null;
+ public IList<GlobalVariable/*!*/>/*!*/ GlobalVariables
{
get
{
- Contract.Ensures(cce.NonNullElements(Contract.Result<IEnumerable<GlobalVariable>>()));
+ Contract.Ensures(cce.NonNullElements(Contract.Result<IList<GlobalVariable>>()));
+ Contract.Ensures(Contract.Result<IList<GlobalVariable>>().IsReadOnly);
if (globalVariablesCache == null)
- {
- globalVariablesCache = TopLevelDeclarations.OfType<GlobalVariable>().ToList();
- }
+ globalVariablesCache = TopLevelDeclarations.OfType<GlobalVariable>().ToList().AsReadOnly();
+
return globalVariablesCache;
}
}
|