diff options
author | Dan Liew <daniel.liew@imperial.ac.uk> | 2015-01-29 02:05:56 +0000 |
---|---|---|
committer | Dan Liew <daniel.liew@imperial.ac.uk> | 2015-01-29 02:05:56 +0000 |
commit | 11b8e8c35f6764b266392b9c0f6086b07a803a33 (patch) | |
tree | dab34ccbe6c453391b5fb2005ab86efa53253ca2 /Source/Core/Parser.cs | |
parent | 3eb0126f32b6214c5df73b50a88b1dd374cf7ed6 (diff) |
Add the ability to declare Expr to be immutable at construction time.
This is currently not enforced (it really should be). So right now it
only amounts to a promise by the client that the Expr will not be modified
after it is constructed. We should actually enforce this by protecting
various fields of the Expr classes so they can't be changed if an Expr
is constructed as Immutable.
The motivation for doing this is it allows the value of GetHashCode()
to be cached. Expr classes now implement ComputeHashCode() to do the
actuall hash code computation.
Diffstat (limited to 'Source/Core/Parser.cs')
-rw-r--r-- | Source/Core/Parser.cs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Source/Core/Parser.cs b/Source/Core/Parser.cs index 25be7f27..9a0bab51 100644 --- a/Source/Core/Parser.cs +++ b/Source/Core/Parser.cs @@ -117,7 +117,7 @@ private class BvBounds : Expr { public BigNum Lower;
public BigNum Upper;
public BvBounds(IToken/*!*/ tok, BigNum lower, BigNum upper)
- : base(tok) {
+ : base(tok, /*immutable=*/ false) {
Contract.Requires(tok != null);
this.Lower = lower;
this.Upper = upper;
@@ -132,6 +132,9 @@ private class BvBounds : Expr { Contract.Assert(false);throw new cce.UnreachableException();
}
public override void ComputeFreeVariables(GSet<object>/*!*/ freeVars) { Contract.Assert(false);throw new cce.UnreachableException(); }
+ public override int ComputeHashCode() {
+ return base.GetHashCode();
+ }
}
/*--------------------------------------------------------------------------*/
|