summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorGravatar Rustan Leino <leino@microsoft.com>2011-05-31 12:03:45 -0700
committerGravatar Rustan Leino <leino@microsoft.com>2011-05-31 12:03:45 -0700
commit8a72a5ba49b582562b8ad9cd5943277b07317470 (patch)
tree45e4ef6bebcd89894355a0a6f9460009f1b1faf5 /Source
parent98fddc738fdccab662f453abd8e9a846775dd10a (diff)
Dafny: compiler fixes
Diffstat (limited to 'Source')
-rw-r--r--Source/Dafny/Compiler.cs14
1 files changed, 8 insertions, 6 deletions
diff --git a/Source/Dafny/Compiler.cs b/Source/Dafny/Compiler.cs
index 75651006..70a2bdfa 100644
--- a/Source/Dafny/Compiler.cs
+++ b/Source/Dafny/Compiler.cs
@@ -297,7 +297,7 @@ namespace Microsoft.Dafny {
wr.WriteLine("}");
}
- void WriteFormals(string sep, List<Formal/*!*/>/*!*/ formals)
+ int WriteFormals(string sep, List<Formal/*!*/>/*!*/ formals)
{
Contract.Requires(sep != null);
Contract.Requires(cce.NonNullElements(formals));
@@ -310,6 +310,7 @@ namespace Microsoft.Dafny {
i++;
}
}
+ return i; // the number of formals written
}
string FormalName(Formal formal, int i) {
@@ -364,8 +365,8 @@ namespace Microsoft.Dafny {
wr.Write("<{0}>", TypeParameters(m.TypeArgs));
}
wr.Write("(");
- WriteFormals("", m.Ins);
- WriteFormals(", ", m.Outs);
+ int nIns = WriteFormals("", m.Ins);
+ WriteFormals(nIns == 0 ? "" : ", ", m.Outs);
wr.WriteLine(")");
Indent(indent); wr.WriteLine("{");
foreach (Formal p in m.Outs) {
@@ -976,7 +977,7 @@ namespace Microsoft.Dafny {
tmpVarCount++;
outTmps.Add(target);
Indent(indent);
- wr.WriteLine("{0} {1};", TypeName(p.Type), target);
+ wr.WriteLine("{0} {1};", TypeName(s.Lhs[i].Type), target);
}
}
@@ -1008,12 +1009,13 @@ namespace Microsoft.Dafny {
// assign to the actual LHSs
int j = 0;
- for (int i = 0; i < s.Method.Outs.Count; i++, j++) {
+ for (int i = 0; i < s.Method.Outs.Count; i++) {
Formal p = s.Method.Outs[i];
if (!p.IsGhost) {
Indent(indent);
TrExpr(s.Lhs[i]);
- wr.Write(" = {0};", outTmps[j]);
+ wr.WriteLine(" = {0};", outTmps[j]);
+ j++;
}
}
Contract.Assert(j == outTmps.Count);