From 59fdb656f09cb4f51fc60d30d8c1bef59f5f908d Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 12 Feb 2015 11:51:20 +0000 Subject: Protect Bitvector field of BvExtractExpr when it is immutable. --- Source/Core/AbsyExpr.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'Source/Core/AbsyExpr.cs') diff --git a/Source/Core/AbsyExpr.cs b/Source/Core/AbsyExpr.cs index 2427d856..f3a943b8 100644 --- a/Source/Core/AbsyExpr.cs +++ b/Source/Core/AbsyExpr.cs @@ -2969,11 +2969,21 @@ namespace Microsoft.Boogie { } public class BvExtractExpr : Expr { - // FIXME: Protect these fields - public /*readonly--except in StandardVisitor*/ Expr/*!*/ Bitvector; + private /*readonly--except in StandardVisitor*/ Expr/*!*/ _Bitvector; + public Expr Bitvector { + get { + return _Bitvector; + } + set { + if (Immutable) + throw new InvalidOperationException("Cannot change BitVector field of an immutable BvExtractExpr"); + + _Bitvector = value; + } + } [ContractInvariantMethod] void ObjectInvariant() { - Contract.Invariant(Bitvector != null); + Contract.Invariant(_Bitvector != null); } public readonly int Start, End; @@ -2982,7 +2992,7 @@ namespace Microsoft.Boogie { : base(tok, immutable) { Contract.Requires(tok != null); Contract.Requires(bv != null); - Bitvector = bv; + _Bitvector = bv; Start = start; End = end; if (immutable) -- cgit v1.2.3