summaryrefslogtreecommitdiff
path: root/Source/VCExpr/cce.cs
diff options
context:
space:
mode:
authorGravatar tabarbe <unknown>2010-08-27 00:29:15 +0000
committerGravatar tabarbe <unknown>2010-08-27 00:29:15 +0000
commit0faac5618039d3617b676c24e9465f712072adf3 (patch)
treeb68a85cabe8b8e655dfc517dfa8619f652995cfe /Source/VCExpr/cce.cs
parentc8d7f1ce39b5b08ed6b5a5791393b8f25169d568 (diff)
Boogie: Graph port 3/3: Committing changed references; also, adding back cce files, to ease between-project conflict. Will trim these back off after commit of Basetypes port in ~20 min.
Diffstat (limited to 'Source/VCExpr/cce.cs')
-rw-r--r--Source/VCExpr/cce.cs117
1 files changed, 90 insertions, 27 deletions
diff --git a/Source/VCExpr/cce.cs b/Source/VCExpr/cce.cs
index ff619b7c..ef594484 100644
--- a/Source/VCExpr/cce.cs
+++ b/Source/VCExpr/cce.cs
@@ -1,14 +1,19 @@
using System;
+using SA=System.Attribute;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Text;
-using Microsoft.Boogie;
+//using Microsoft.Boogie;
- /// <summary>
- /// A class containing static methods to extend the functionality of Code Contracts
- /// </summary>
+/// <summary>
+/// A class containing static methods to extend the functionality of Code Contracts
+/// </summary>
public static class cce {
+ //[Pure]
+ //public static bool NonNullElements<T>(Microsoft.Dafny.Graph<T> collection) {
+ // return collection != null && cce.NonNullElements(collection.TopologicallySortedComponents());
+ //}
[Pure]
public static T NonNull<T>(T t) {
Contract.Assert(t != null);
@@ -22,20 +27,39 @@ public static class cce {
public static bool NonNullElements<TKey, TValue>(IDictionary<TKey, TValue> collection) {
return collection != null && Contract.ForAll(collection, pair => NonNullElements(pair));
}
- [Pure]
- public static bool NonNullElements(VariableSeq collection) {
- return collection != null && Contract.ForAll(0, collection.Length, i => collection[i] != null);
- }
//[Pure]
- //public static bool NonNullElements<T>(Microsoft.Dafny.Graph<T> collection) {
- // return collection != null && cce.NonNullElements(collection.TopologicallySortedComponents());
+ //public static bool NonNullElements(VariableSeq collection) {
+ // return collection != null && Contract.ForAll(0, collection.Length, i => collection[i] != null);
//}
+ /// <summary>
+ /// For possibly-null lists of non-null elements
+ /// </summary>
+ /// <typeparam name="T"></typeparam>
+ /// <param name="collection"></param>
+ /// <param name="nullability">If true, the collection is treated as an IEnumerable&lt;T!&gt;?, rather than an IEnumerable&lt;T!&gt;!</param>
+ /// <returns></returns>
+ [Pure]
+ public static bool NonNullElements<T>(IEnumerable<T> collection, bool nullability) {
+ return (nullability && collection == null) || cce.NonNullElements(collection);
+ //Should be the same as:
+ /*if(nullability&&collection==null)
+ * return true;
+ * return cce.NonNullElements(collection)
+ */
+ }
[Pure]
public static bool NonNullElements<TKey, TValue>(KeyValuePair<TKey, TValue> kvp) {
return kvp.Key != null && kvp.Value != null;
}
-
+ [Pure]
+ public static bool NonNullElements<T>(IEnumerator<T> iEnumerator) {
+ return iEnumerator != null;
+ }
+ //[Pure]
+ //public static bool NonNullElements<T>(Graphing.Graph<T> graph) {
+ // return cce.NonNullElements(graph.TopologicalSort());
+ //}
[Pure]
public static void BeginExpose(object o) {
}
@@ -58,6 +82,10 @@ public static class cce {
public static bool IsExposed(object o) {
return true;
}
+ [Pure]
+ public static bool IsNew(object o) {
+ return true;
+ }
public static class Owner {
[Pure]
public static bool Same(object o, object p) {
@@ -74,12 +102,19 @@ public static class cce {
public static bool None(object o) {
return true;
}
+ [Pure]
+ public static bool Different(object o, object p) {
+ return true;
+ }
+ [Pure]
+ public static bool New(object o) {
+ return true;
+ }
}
[Pure]
public static void LoopInvariant(bool p) {
Contract.Assert(p);
}
-
public class UnreachableException : Exception {
public UnreachableException() {
}
@@ -88,43 +123,71 @@ public static class cce {
//public static bool IsValid(Microsoft.Dafny.Expression expression) {
// return true;
//}
+ //public static List<T> toList<T>(PureCollections.Sequence s) {
+ // List<T> toRet = new List<T>();
+ // foreach (T t in s.elems)
+ // if(t!=null)
+ // toRet.Add(t);
+ // return toRet;
+ //}
- internal static bool NonNullElements<T>(IEnumerator<T> iEnumerator) {
- return iEnumerator != null;
- }
+ //internal static bool NonNullElements(Set set) {
+ // return set != null && Contract.ForAll(0,set.Count, i => set[i] != null);
+ //}
}
-public class PeerAttribute : System.Attribute {
+public class PeerAttribute : SA {
}
-public class RepAttribute : System.Attribute {
+public class RepAttribute : SA {
}
-public class CapturedAttribute : System.Attribute {
+public class CapturedAttribute : SA {
}
-public class NotDelayedAttribute : System.Attribute {
+public class NotDelayedAttribute : SA {
}
-public class NoDefaultContractAttribute : System.Attribute {
+public class NoDefaultContractAttribute : SA {
}
-public class VerifyAttribute : System.Attribute {
+public class VerifyAttribute : SA {
public VerifyAttribute(bool b) {
}
}
-public class StrictReadonlyAttribute : System.Attribute {
- }
-public class AdditiveAttribute : System.Attribute {
+public class StrictReadonlyAttribute : SA {
+}
+public class AdditiveAttribute : SA {
}
-public class ReadsAttribute : System.Attribute {
+public class ReadsAttribute : SA {
public enum Reads {
Nothing,
+ Everything,
};
public ReadsAttribute(object o) {
}
}
-public class GlobalAccessAttribute : System.Attribute {
+public class GlobalAccessAttribute : SA {
public GlobalAccessAttribute(bool b) {
}
}
-public class EscapesAttribute : System.Attribute {
+public class EscapesAttribute : SA {
public EscapesAttribute(bool b, bool b_2) {
}
+}
+public class NeedsContractsAttribute : SA {
+ public NeedsContractsAttribute() {
+ }
+ public NeedsContractsAttribute(bool ret, bool parameters) {
+ }
+ public NeedsContractsAttribute(bool ret, int[] parameters) {
+ }
+}
+public class ImmutableAttribute : SA {
+}
+public class InsideAttribute : SA {
+}
+public class SpecPublicAttribute : SA {
+}
+public class ElementsPeerAttribute : SA {
+}
+public class ResultNotNewlyAllocatedAttribute : SA {
+}
+public class OnceAttribute : SA {
} \ No newline at end of file