From a1a041f3549cb1665964d30b666c825767d59afb Mon Sep 17 00:00:00 2001 From: Rustan Leino Date: Fri, 5 Oct 2012 17:57:40 -0700 Subject: Support default (which, here, means nameless) class-instance constructors --- Source/Dafny/Printer.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'Source/Dafny/Printer.cs') diff --git a/Source/Dafny/Printer.cs b/Source/Dafny/Printer.cs index 7b5c1d42..e85c5e20 100644 --- a/Source/Dafny/Printer.cs +++ b/Source/Dafny/Printer.cs @@ -338,7 +338,8 @@ namespace Microsoft.Dafny { string k = method is Constructor ? "constructor" : "method"; if (method.IsStatic) { k = "static " + k; } if (method.IsGhost) { k = "ghost " + k; } - PrintClassMethodHelper(k, method.Attributes, method.Name, method.TypeArgs); + string nm = method is Constructor && !((Constructor)method).HasName ? "" : method.Name; + PrintClassMethodHelper(k, method.Attributes, nm, method.TypeArgs); if (method.SignatureIsOmitted) { wr.WriteLine(" ..."); } else { @@ -840,9 +841,14 @@ namespace Microsoft.Dafny { s = ", "; } wr.Write("]"); - } else if (t.InitCall != null) { - wr.Write(".{0}(", t.InitCall.MethodName); - PrintExpressionList(t.InitCall.Args); + } else if (t.Arguments == null) { + // nothing else to print + } else { + if (t.OptionalNameComponent != null) { + wr.Write(".{0}", t.OptionalNameComponent); + } + wr.Write("("); + PrintExpressionList(t.Arguments); wr.Write(")"); } } else { -- cgit v1.2.3