diff options
author | Rustan Leino <leino@microsoft.com> | 2012-10-02 17:58:49 -0700 |
---|---|---|
committer | Rustan Leino <leino@microsoft.com> | 2012-10-02 17:58:49 -0700 |
commit | 7b150dbbb8cb50e7ac6085ad2cb0459dca0667ff (patch) | |
tree | 2c1895a7cbe4e638b1a5f5c595cc9864f9fca7db /Source/Dafny/Translator.cs | |
parent | 6489805cff9bc62d1933ca31a0307dbd43cd60e9 (diff) |
Dafny: handle decreases clause for iterators
Diffstat (limited to 'Source/Dafny/Translator.cs')
-rw-r--r-- | Source/Dafny/Translator.cs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Source/Dafny/Translator.cs b/Source/Dafny/Translator.cs index bd000e8b..bb998e1b 100644 --- a/Source/Dafny/Translator.cs +++ b/Source/Dafny/Translator.cs @@ -2973,11 +2973,11 @@ namespace Microsoft.Dafny { /// <summary>
/// Returns true if it is known how to meaningfully compare the type's inhabitants.
/// </summary>
- bool IsOrdered(Type t) {
+ static bool IsOrdered(Type t) {
return !t.IsTypeParameter && !t.IsCoDatatype;
}
- List<Expression> MethodDecreasesWithDefault(Method m, out bool inferredDecreases) {
+ public static List<Expression> MethodDecreasesWithDefault(ICodeContext m, out bool inferredDecreases) {
Contract.Requires(m != null);
inferredDecreases = false;
@@ -2986,12 +2986,14 @@ namespace Microsoft.Dafny { decr = new List<Expression>();
foreach (Formal p in m.Ins) {
if (IsOrdered(p.Type)) {
- IdentifierExpr ie = new IdentifierExpr(p.tok, p.UniqueName);
+ IdentifierExpr ie = new IdentifierExpr(p.tok, p.Name);
ie.Var = p; ie.Type = ie.Var.Type; // resolve it here
decr.Add(ie); // use the method's first parameter instead
}
}
inferredDecreases = true;
+ } else if (m is IteratorDecl) {
+ inferredDecreases = ((IteratorDecl)m).InferredDecreases;
}
return decr;
}
|