summaryrefslogtreecommitdiff
path: root/Source/Core/AbsyExpr.cs
diff options
context:
space:
mode:
authorGravatar Dan Liew <daniel.liew@imperial.ac.uk>2015-01-29 03:47:05 +0000
committerGravatar Dan Liew <daniel.liew@imperial.ac.uk>2015-01-29 03:47:05 +0000
commitcef89809053b0679019491a227ed03c98be44854 (patch)
tree12cb272e3b1f0a56f0bdd7bcee111d2be2d863a9 /Source/Core/AbsyExpr.cs
parent9ecdcd65b9173736a191662072865ec0bb075c04 (diff)
Protect the NAryExpr.Fun field when the NAryExpr is immutable.
Add a unit test for this. We need to protect the Args field too but that is going to be much harder to enforce.
Diffstat (limited to 'Source/Core/AbsyExpr.cs')
-rw-r--r--Source/Core/AbsyExpr.cs17
1 files changed, 14 insertions, 3 deletions
diff --git a/Source/Core/AbsyExpr.cs b/Source/Core/AbsyExpr.cs
index e6c21e1f..75a5741a 100644
--- a/Source/Core/AbsyExpr.cs
+++ b/Source/Core/AbsyExpr.cs
@@ -2230,8 +2230,19 @@ namespace Microsoft.Boogie {
public class NAryExpr : Expr {
[Additive]
[Peer]
- // FIXME: Protect these fields
- public IAppliable/*!*/ Fun;
+ private IAppliable _Fun;
+ public IAppliable/*!*/ Fun {
+ get {
+ return _Fun;
+ }
+ set {
+ if (Immutable)
+ throw new InvalidOperationException("Cannot change Function used by Immutable NAryExpr");
+
+ _Fun = value;
+ }
+ }
+ // FIXME: Protect this field when immutable
public List<Expr> Args;
[ContractInvariantMethod]
@@ -2251,7 +2262,7 @@ namespace Microsoft.Boogie {
Contract.Requires(tok != null);
Contract.Requires(fun != null);
Contract.Requires(args != null);
- Fun = fun;
+ _Fun = fun;
Args = args;
Contract.Assert(Contract.ForAll(0, args.Count, index => args[index] != null));
if (immutable)