diff --git a/Source/DafnyCore.Test/GeneratedFromDafny/DefsCoverage.cs b/Source/DafnyCore.Test/GeneratedFromDafny/DefsCoverage.cs index 10677a61959..b46418fee58 100644 --- a/Source/DafnyCore.Test/GeneratedFromDafny/DefsCoverage.cs +++ b/Source/DafnyCore.Test/GeneratedFromDafny/DefsCoverage.cs @@ -18,7 +18,7 @@ public partial class __default { public static void Expect(bool x) { if (!(x)) { - throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-definitions.dfy(789,4): " + Dafny.Sequence.UnicodeFromString("expectation violation").ToVerbatimString(false));} + throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-definitions-coverage.dfy(17,4): " + Dafny.Sequence.UnicodeFromString("expectation violation").ToVerbatimString(false));} } public static void Tests() { diff --git a/Source/DafnyCore.Test/GeneratedFromDafny/FactorPathsOptimizationTest.cs b/Source/DafnyCore.Test/GeneratedFromDafny/FactorPathsOptimizationTest.cs index 749438a6e07..7b3f9367309 100644 --- a/Source/DafnyCore.Test/GeneratedFromDafny/FactorPathsOptimizationTest.cs +++ b/Source/DafnyCore.Test/GeneratedFromDafny/FactorPathsOptimizationTest.cs @@ -40,10 +40,10 @@ public static void TestApply() _3_std__any__Any = (((RAST.__default.@global).MSel(Dafny.Sequence.UnicodeFromString("std"))).MSel(Dafny.Sequence.UnicodeFromString("any"))).MSel(Dafny.Sequence.UnicodeFromString("Any")); RAST._IType _4_Any; _4_Any = RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Any")); - FactorPathsOptimizationTest.__default.ShouldBeEqual(Dafny.Helpers.Id>(FactorPathsOptimization.__default.apply(RAST.__default.crate))(RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements(RAST.ModDecl.create_StructDecl(RAST.Struct.create(Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("test"), Dafny.Sequence.FromElements(_0_T__Decl), RAST.Fields.create_NamedFields(Dafny.Sequence.FromElements(RAST.Field.create(RAST.Visibility.create_PUB(), RAST.Formal.create(Dafny.Sequence.UnicodeFromString("a"), (_3_std__any__Any).AsType())))))), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(Dafny.Sequence.FromElements(_0_T__Decl), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements())), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(Dafny.Sequence.FromElements(_0_T__Decl), (_3_std__any__Any).AsType(), ((((RAST.__default.crate).MSel(Dafny.Sequence.UnicodeFromString("onemodule"))).MSel(Dafny.Sequence.UnicodeFromString("test"))).AsType()).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements()))))), RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements(RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyType")))), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), _3_std__any__Any)), RAST.ModDecl.create_StructDecl(RAST.Struct.create(Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("test"), Dafny.Sequence.FromElements(_1_T__Decl__simp), RAST.Fields.create_NamedFields(Dafny.Sequence.FromElements(RAST.Field.create(RAST.Visibility.create_PUB(), RAST.Formal.create(Dafny.Sequence.UnicodeFromString("a"), _4_Any)))))), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(Dafny.Sequence.FromElements(_1_T__Decl__simp), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements())), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(Dafny.Sequence.FromElements(_1_T__Decl__simp), _4_Any, (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements()))))); - FactorPathsOptimizationTest.__default.ShouldBeEqual(Dafny.Helpers.Id>(FactorPathsOptimization.__default.apply(RAST.__default.crate))(RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(Dafny.Sequence.FromElements(_0_T__Decl), (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("UpcastObject"))).AsType()).Apply(Dafny.Sequence.FromElements(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("x")))), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements()))))), RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements(RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyType")))), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("UpcastObject")))), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(Dafny.Sequence.FromElements(_1_T__Decl__simp), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("UpcastObject"))).Apply(Dafny.Sequence.FromElements(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("x")))), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements()))))); - FactorPathsOptimizationTest.__default.ShouldBeEqual(Dafny.Helpers.Id>(FactorPathsOptimization.__default.apply(RAST.__default.crate))(RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements(RAST.ModDecl.create_ConstDecl(RAST.Constant.create(Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("dummy"), (_3_std__any__Any).AsType(), RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("doit"), Std.Wrappers.Option.create_Some(((RAST.__default.std__rc__Rc).AsType()).Apply1(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("unknown")))), Std.Wrappers.Option.create_Some(((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("something"))).ApplyType(Dafny.Sequence.FromElements(RAST.Type.create_DynType((RAST.__default.std__default__Default).AsType())))).Apply(Dafny.Sequence.FromElements(RAST.__default.std__default__Default__default, (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("rd!"))).AsExpr()).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("obj"))))))), RAST.Expr.create_TypeAscription(RAST.Expr.create_ExprFromType(((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyString"))).AsType()), ((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyType"))).AsType()))))))), RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements(RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), _3_std__any__Any)), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), RAST.__default.std__rc__Rc)), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), RAST.__default.std__default__Default)), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("rd")))), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyString")))), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyType")))), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("dummy"), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Any")), RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("doit"), Std.Wrappers.Option.create_Some((RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Rc"))).Apply1(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("unknown")))), Std.Wrappers.Option.create_Some(((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("something"))).ApplyType(Dafny.Sequence.FromElements(RAST.Type.create_DynType(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Default")))))).Apply(Dafny.Sequence.FromElements(((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("Default"))).FSel(Dafny.Sequence.UnicodeFromString("default"))).Apply(Dafny.Sequence.FromElements()), (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("rd!"))).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("obj"))))))), RAST.Expr.create_TypeAscription(RAST.Expr.create_ExprFromType(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("DafnyString"))), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("DafnyType"))))))))); - FactorPathsOptimizationTest.__default.ShouldBeEqual(Dafny.Helpers.Id>(FactorPathsOptimization.__default.apply(RAST.__default.crate))(RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements(RAST.ModDecl.create_TraitDecl(RAST.Trait.create(Dafny.Sequence.FromElements(), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Something")), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements())), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("dummyExtern"), (((RAST.__default.crate).MSel(Dafny.Sequence.UnicodeFromString("anothermodule"))).MSel(Dafny.Sequence.UnicodeFromString("Something"))).AsType(), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("nothing")))), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("dummyIntern"), (((RAST.__default.crate).MSel(Dafny.Sequence.UnicodeFromString("onemodule"))).MSel(Dafny.Sequence.UnicodeFromString("Something"))).AsType(), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("nothing"))))))), RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements(RAST.ModDecl.create_TraitDecl(RAST.Trait.create(Dafny.Sequence.FromElements(), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Something")), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements())), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("dummyExtern"), (((RAST.__default.crate).MSel(Dafny.Sequence.UnicodeFromString("anothermodule"))).MSel(Dafny.Sequence.UnicodeFromString("Something"))).AsType(), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("nothing")))), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("dummyIntern"), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Something")), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("nothing"))))))); + FactorPathsOptimizationTest.__default.ShouldBeEqual(Dafny.Helpers.Id>(FactorPathsOptimization.__default.apply(RAST.__default.crate))(RAST.Mod.create_Mod(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence.FromElements(RAST.ModDecl.create_StructDecl(RAST.Struct.create(RAST.__default.NoDoc, Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("test"), Dafny.Sequence.FromElements(_0_T__Decl), RAST.Fields.create_NamedFields(Dafny.Sequence.FromElements(RAST.Field.create(RAST.Visibility.create_PUB(), RAST.Formal.create(Dafny.Sequence.UnicodeFromString("a"), (_3_std__any__Any).AsType())))))), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(Dafny.Sequence.FromElements(_0_T__Decl), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements())), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(Dafny.Sequence.FromElements(_0_T__Decl), (_3_std__any__Any).AsType(), ((((RAST.__default.crate).MSel(Dafny.Sequence.UnicodeFromString("onemodule"))).MSel(Dafny.Sequence.UnicodeFromString("test"))).AsType()).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements()))))), RAST.Mod.create_Mod(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence.FromElements(RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyType")))), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), _3_std__any__Any)), RAST.ModDecl.create_StructDecl(RAST.Struct.create(RAST.__default.NoDoc, Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("test"), Dafny.Sequence.FromElements(_1_T__Decl__simp), RAST.Fields.create_NamedFields(Dafny.Sequence.FromElements(RAST.Field.create(RAST.Visibility.create_PUB(), RAST.Formal.create(Dafny.Sequence.UnicodeFromString("a"), _4_Any)))))), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(Dafny.Sequence.FromElements(_1_T__Decl__simp), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements())), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(Dafny.Sequence.FromElements(_1_T__Decl__simp), _4_Any, (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements()))))); + FactorPathsOptimizationTest.__default.ShouldBeEqual(Dafny.Helpers.Id>(FactorPathsOptimization.__default.apply(RAST.__default.crate))(RAST.Mod.create_Mod(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(Dafny.Sequence.FromElements(_0_T__Decl), (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("UpcastObject"))).AsType()).Apply(Dafny.Sequence.FromElements(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("x")))), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements()))))), RAST.Mod.create_Mod(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence.FromElements(RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyType")))), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("UpcastObject")))), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(Dafny.Sequence.FromElements(_1_T__Decl__simp), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("UpcastObject"))).Apply(Dafny.Sequence.FromElements(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("x")))), (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("test"))).Apply(Dafny.Sequence.FromElements(_2_T)), Dafny.Sequence.FromElements()))))); + FactorPathsOptimizationTest.__default.ShouldBeEqual(Dafny.Helpers.Id>(FactorPathsOptimization.__default.apply(RAST.__default.crate))(RAST.Mod.create_Mod(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence.FromElements(RAST.ModDecl.create_ConstDecl(RAST.Constant.create(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("dummy"), (_3_std__any__Any).AsType(), RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("doit"), Std.Wrappers.Option.create_Some(((RAST.__default.std__rc__Rc).AsType()).Apply1(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("unknown")))), Std.Wrappers.Option.create_Some(((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("something"))).ApplyType(Dafny.Sequence.FromElements(RAST.Type.create_DynType((RAST.__default.std__default__Default).AsType())))).Apply(Dafny.Sequence.FromElements(RAST.__default.std__default__Default__default, (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("rd!"))).AsExpr()).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("obj"))))))), RAST.Expr.create_TypeAscription(RAST.Expr.create_ExprFromType(((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyString"))).AsType()), ((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyType"))).AsType()))))))), RAST.Mod.create_Mod(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence.FromElements(RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), _3_std__any__Any)), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), RAST.__default.std__rc__Rc)), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), RAST.__default.std__default__Default)), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("rd")))), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyString")))), RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyType")))), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("dummy"), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Any")), RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("doit"), Std.Wrappers.Option.create_Some((RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Rc"))).Apply1(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("unknown")))), Std.Wrappers.Option.create_Some(((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("something"))).ApplyType(Dafny.Sequence.FromElements(RAST.Type.create_DynType(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Default")))))).Apply(Dafny.Sequence.FromElements(((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("Default"))).FSel(Dafny.Sequence.UnicodeFromString("default"))).Apply(Dafny.Sequence.FromElements()), (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("rd!"))).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("obj"))))))), RAST.Expr.create_TypeAscription(RAST.Expr.create_ExprFromType(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("DafnyString"))), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("DafnyType"))))))))); + FactorPathsOptimizationTest.__default.ShouldBeEqual(Dafny.Helpers.Id>(FactorPathsOptimization.__default.apply(RAST.__default.crate))(RAST.Mod.create_Mod(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence.FromElements(RAST.ModDecl.create_TraitDecl(RAST.Trait.create(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.FromElements(), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Something")), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements())), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("dummyExtern"), (((RAST.__default.crate).MSel(Dafny.Sequence.UnicodeFromString("anothermodule"))).MSel(Dafny.Sequence.UnicodeFromString("Something"))).AsType(), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("nothing")))), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("dummyIntern"), (((RAST.__default.crate).MSel(Dafny.Sequence.UnicodeFromString("onemodule"))).MSel(Dafny.Sequence.UnicodeFromString("Something"))).AsType(), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("nothing"))))))), RAST.Mod.create_Mod(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("onemodule"), Dafny.Sequence.FromElements(RAST.ModDecl.create_TraitDecl(RAST.Trait.create(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.FromElements(), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Something")), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements())), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("dummyExtern"), (((RAST.__default.crate).MSel(Dafny.Sequence.UnicodeFromString("anothermodule"))).MSel(Dafny.Sequence.UnicodeFromString("Something"))).AsType(), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("nothing")))), RAST.ModDecl.create_ConstDecl(RAST.Constant.create(RAST.__default.NoDoc, RAST.__default.NoAttr, Dafny.Sequence.UnicodeFromString("dummyIntern"), RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("Something")), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("nothing"))))))); } } } // end of namespace FactorPathsOptimizationTest \ No newline at end of file diff --git a/Source/DafnyCore/AST/Members/Field.cs b/Source/DafnyCore/AST/Members/Field.cs index 24f27c5b3e0..ab302a10208 100644 --- a/Source/DafnyCore/AST/Members/Field.cs +++ b/Source/DafnyCore/AST/Members/Field.cs @@ -91,11 +91,21 @@ public bool SetIndent(int indentBefore, TokenNewIndentCollector formatter) { } public string GetTriviaContainingDocstring() { - if (EndToken.TrailingTrivia.Trim() != "") { - return EndToken.TrailingTrivia; + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; + } + foreach (var token in OwnedTokens) { + if (token.val == ":=") { + if ((token.Prev.TrailingTrivia + (token.LeadingTrivia ?? "")).Trim() is { } tentativeTrivia and not "") { + return tentativeTrivia; + } + } + } + if (EndToken.TrailingTrivia.Trim() is { } tentativeTrivia2 and not "") { + return tentativeTrivia2; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + return null; } public override SymbolKind? Kind => SymbolKind.Field; diff --git a/Source/DafnyCore/AST/Members/Function.cs b/Source/DafnyCore/AST/Members/Function.cs index 55a88ba8b8a..dcf4ba2a92a 100644 --- a/Source/DafnyCore/AST/Members/Function.cs +++ b/Source/DafnyCore/AST/Members/Function.cs @@ -483,17 +483,30 @@ public override void Resolve(ModuleResolver resolver) { } public string GetTriviaContainingDocstring() { + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; + } var endTokenDefinition = - OwnedTokens.LastOrDefault(token => token.val == ")" || token.pos == ResultType.EndToken.pos) - ?? EndToken; - if (endTokenDefinition.TrailingTrivia.Trim() != "") { - return endTokenDefinition.TrailingTrivia; + OwnedTokens.LastOrDefault(token => token.val == ")" || token.pos == ResultType.EndToken.pos); + var tentativeTrivia = ""; + if (endTokenDefinition != null) { + if (endTokenDefinition.pos < this.EndToken.pos) { // All comments are docstring + tentativeTrivia = (endTokenDefinition.TrailingTrivia + endTokenDefinition.Next.LeadingTrivia).Trim(); + } else { + // Comments at the end of bodiless functions + tentativeTrivia = endTokenDefinition.TrailingTrivia.Trim(); + } + if (tentativeTrivia != "") { + return tentativeTrivia; + } } - if (StartToken.LeadingTrivia.Trim() != "") { - return StartToken.LeadingTrivia; + tentativeTrivia = EndToken.TrailingTrivia.Trim(); + if (tentativeTrivia != "") { + return tentativeTrivia; } + return null; } diff --git a/Source/DafnyCore/AST/Members/Method.cs b/Source/DafnyCore/AST/Members/Method.cs index 93ac3fafe67..75704e519ba 100644 --- a/Source/DafnyCore/AST/Members/Method.cs +++ b/Source/DafnyCore/AST/Members/Method.cs @@ -386,6 +386,10 @@ public override void Resolve(ModuleResolver resolver) { } public string GetTriviaContainingDocstring() { + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; + } + IOrigin lastClosingParenthesis = null; foreach (var token in OwnedTokens) { if (token.val == ")") { @@ -393,11 +397,25 @@ public string GetTriviaContainingDocstring() { } } - if (lastClosingParenthesis != null && lastClosingParenthesis.TrailingTrivia.Trim() != "") { - return lastClosingParenthesis.TrailingTrivia; + var tentativeTrivia = ""; + if (lastClosingParenthesis != null) { + if (lastClosingParenthesis.pos < EndToken.pos) { + tentativeTrivia = (lastClosingParenthesis.TrailingTrivia + lastClosingParenthesis.Next.LeadingTrivia).Trim(); + } else { + tentativeTrivia = lastClosingParenthesis.TrailingTrivia.Trim(); + } + + if (tentativeTrivia != "") { + return tentativeTrivia; + } + } + + tentativeTrivia = EndToken.TrailingTrivia.Trim(); + if (tentativeTrivia != "") { + return tentativeTrivia; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + return null; } public override SymbolKind? Kind => SymbolKind.Method; diff --git a/Source/DafnyCore/AST/Modules/LiteralModuleDecl.cs b/Source/DafnyCore/AST/Modules/LiteralModuleDecl.cs index 15f96dce8fa..35f0fa4f20b 100644 --- a/Source/DafnyCore/AST/Modules/LiteralModuleDecl.cs +++ b/Source/DafnyCore/AST/Modules/LiteralModuleDecl.cs @@ -42,14 +42,13 @@ public LiteralModuleDecl(Cloner cloner, LiteralModuleDecl original, ModuleDefini ModuleDef = newModuleDefinition; DefaultExport = original.DefaultExport; BodyStartTok = ModuleDef.BodyStartTok; - TokenWithTrailingDocString = ModuleDef.TokenWithTrailingDocString; } public LiteralModuleDecl(DafnyOptions options, ModuleDefinition module, ModuleDefinition parent, Guid cloneId) : base(options, module.RangeToken, module.NameNode, parent, false, false, cloneId) { ModuleDef = module; BodyStartTok = module.BodyStartTok; - TokenWithTrailingDocString = module.TokenWithTrailingDocString; + module.EnclosingLiteralModuleDecl = this; } public override object Dereference() { return ModuleDef; } diff --git a/Source/DafnyCore/AST/Modules/ModuleDecl.cs b/Source/DafnyCore/AST/Modules/ModuleDecl.cs index 6c3bcfa6697..0b6d878369d 100644 --- a/Source/DafnyCore/AST/Modules/ModuleDecl.cs +++ b/Source/DafnyCore/AST/Modules/ModuleDecl.cs @@ -61,24 +61,24 @@ public override bool IsEssentiallyEmpty() { } public virtual string GetTriviaContainingDocstring() { - IOrigin candidate = null; + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; + } var tokens = OwnedTokens.Any() ? OwnedTokens : PreResolveChildren.Any() ? PreResolveChildren.First().OwnedTokens : Enumerable.Empty(); foreach (var token in tokens) { if (token.val == "{") { - candidate = token.Prev; - if (candidate.TrailingTrivia.Trim() != "") { - return candidate.TrailingTrivia; + if ((token.Prev.TrailingTrivia + token.LeadingTrivia).Trim() is { } tentativeTrivia and not "") { + return tentativeTrivia; } } } - - if (candidate == null && EndToken.TrailingTrivia.Trim() != "") { - return EndToken.TrailingTrivia; + if (EndToken.TrailingTrivia.Trim() is { } tentativeTrivia2 and not "") { + return tentativeTrivia2; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + return null; } public override SymbolKind? Kind => SymbolKind.Namespace; diff --git a/Source/DafnyCore/AST/Modules/ModuleDefinition.cs b/Source/DafnyCore/AST/Modules/ModuleDefinition.cs index 8033349048a..cdcb28efdd8 100644 --- a/Source/DafnyCore/AST/Modules/ModuleDefinition.cs +++ b/Source/DafnyCore/AST/Modules/ModuleDefinition.cs @@ -41,7 +41,6 @@ static ModuleDefinition() { } public IOrigin BodyStartTok = Token.NoToken; - public IOrigin TokenWithTrailingDocString = Token.NoToken; public string DafnyName => NameNode.StartToken.val; // The (not-qualified) name as seen in Dafny source code public Name NameNode; // (Last segment of the) module name @@ -1078,6 +1077,8 @@ bool InheritsFromObject(TraitDecl traitDecl) { }); public SymbolKind? Kind => SymbolKind.Namespace; + public LiteralModuleDecl EnclosingLiteralModuleDecl { get; set; } + public string GetDescription(DafnyOptions options) { return $"module {Name}"; } diff --git a/Source/DafnyCore/AST/Modules/ModuleExportDecl.cs b/Source/DafnyCore/AST/Modules/ModuleExportDecl.cs index 16e01626ed3..893289c643b 100644 --- a/Source/DafnyCore/AST/Modules/ModuleExportDecl.cs +++ b/Source/DafnyCore/AST/Modules/ModuleExportDecl.cs @@ -98,10 +98,25 @@ public bool SetIndent(int indentBefore, TokenNewIndentCollector formatter) { } public override string GetTriviaContainingDocstring() { - if (Tok.TrailingTrivia.Trim() != "") { - return Tok.TrailingTrivia; + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + var tentativeTrivia = ""; + if (Tok.pos < EndToken.pos) { + tentativeTrivia = (Tok.TrailingTrivia + Tok.Next.LeadingTrivia).Trim(); + } else { + tentativeTrivia = Tok.TrailingTrivia.Trim(); + } + if (tentativeTrivia != "") { + return tentativeTrivia; + } + + tentativeTrivia = EndToken.TrailingTrivia.Trim(); + if (tentativeTrivia != "") { + return tentativeTrivia; + } + + return null; } } \ No newline at end of file diff --git a/Source/DafnyCore/AST/TypeDeclarations/AbstractTypeDecl.cs b/Source/DafnyCore/AST/TypeDeclarations/AbstractTypeDecl.cs index 0c9920a180e..8e1cc55648e 100644 --- a/Source/DafnyCore/AST/TypeDeclarations/AbstractTypeDecl.cs +++ b/Source/DafnyCore/AST/TypeDeclarations/AbstractTypeDecl.cs @@ -88,6 +88,9 @@ public bool SetIndent(int indentBefore, TokenNewIndentCollector formatter) { } public string GetTriviaContainingDocstring() { + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; + } IOrigin openingBlock = null; foreach (var token in OwnedTokens) { if (token.val == "{") { @@ -95,14 +98,19 @@ public string GetTriviaContainingDocstring() { } } - if (openingBlock != null && openingBlock.Prev.TrailingTrivia.Trim() != "") { - return openingBlock.Prev.TrailingTrivia; + var tentativeTrivia = ""; + if (openingBlock != null) { + tentativeTrivia = (openingBlock.Prev.TrailingTrivia + openingBlock.LeadingTrivia).Trim(); + if (tentativeTrivia != "") { + return tentativeTrivia; + } } - if (openingBlock == null && EndToken.TrailingTrivia.Trim() != "") { - return EndToken.TrailingTrivia; + tentativeTrivia = EndToken.TrailingTrivia.Trim(); + if (tentativeTrivia != "") { + return tentativeTrivia; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + return null; } } \ No newline at end of file diff --git a/Source/DafnyCore/AST/TypeDeclarations/ClassLikeDecl.cs b/Source/DafnyCore/AST/TypeDeclarations/ClassLikeDecl.cs index bef96881fcd..ec287a98579 100644 --- a/Source/DafnyCore/AST/TypeDeclarations/ClassLikeDecl.cs +++ b/Source/DafnyCore/AST/TypeDeclarations/ClassLikeDecl.cs @@ -78,20 +78,22 @@ public virtual bool SetIndent(int indentBefore, TokenNewIndentCollector formatte } public virtual string GetTriviaContainingDocstring() { - IOrigin candidate = null; + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; + } + foreach (var token in OwnedTokens) { if (token.val == "{") { - candidate = token.Prev; - if (candidate.TrailingTrivia.Trim() != "") { - return candidate.TrailingTrivia; + if ((token.Prev.TrailingTrivia + token.LeadingTrivia).Trim() is { } tentativeTrivia and not "") { + return tentativeTrivia; } } } - if (candidate == null && EndToken.TrailingTrivia.Trim() != "") { - return EndToken.TrailingTrivia; + if (EndToken.TrailingTrivia.Trim() is { } tentativeTrivia2 and not "") { + return tentativeTrivia2; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + return null; } } \ No newline at end of file diff --git a/Source/DafnyCore/AST/TypeDeclarations/DatatypeCtor.cs b/Source/DafnyCore/AST/TypeDeclarations/DatatypeCtor.cs index 5335cea98e1..03439bd52b4 100644 --- a/Source/DafnyCore/AST/TypeDeclarations/DatatypeCtor.cs +++ b/Source/DafnyCore/AST/TypeDeclarations/DatatypeCtor.cs @@ -43,11 +43,16 @@ public string FullName { } public string GetTriviaContainingDocstring() { - if (EndToken.TrailingTrivia.Trim() != "") { - return EndToken.TrailingTrivia; + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + var tentativeTrivia = EndToken.TrailingTrivia.Trim(); + if (tentativeTrivia != "") { + return tentativeTrivia; + } + + return null; } public override SymbolKind? Kind => SymbolKind.EnumMember; diff --git a/Source/DafnyCore/AST/TypeDeclarations/DatatypeDecl.cs b/Source/DafnyCore/AST/TypeDeclarations/DatatypeDecl.cs index e133546bfdd..3cfbb646c25 100644 --- a/Source/DafnyCore/AST/TypeDeclarations/DatatypeDecl.cs +++ b/Source/DafnyCore/AST/TypeDeclarations/DatatypeDecl.cs @@ -180,13 +180,18 @@ public bool SetIndent(int indent, TokenNewIndentCollector formatter) { } public string GetTriviaContainingDocstring() { + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; + } foreach (var token in OwnedTokens) { - if (token.val == "=" && token.TrailingTrivia.Trim() != "") { - return token.TrailingTrivia; + if (token.val == "=") { + if ((token.Prev.TrailingTrivia + (token.LeadingTrivia ?? "")).Trim() is { } tentativeTrivia and not "") { + return tentativeTrivia; + } } } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + return null; } public void AutoRevealDependencies(AutoRevealFunctionDependencies Rewriter, DafnyOptions Options, ErrorReporter Reporter) { diff --git a/Source/DafnyCore/AST/TypeDeclarations/Declaration.cs b/Source/DafnyCore/AST/TypeDeclarations/Declaration.cs index 2cae59449a8..42e64f7bf1b 100644 --- a/Source/DafnyCore/AST/TypeDeclarations/Declaration.cs +++ b/Source/DafnyCore/AST/TypeDeclarations/Declaration.cs @@ -13,7 +13,6 @@ void ObjectInvariant() { } public IOrigin BodyStartTok = Token.NoToken; - public IOrigin TokenWithTrailingDocString = Token.NoToken; public Name NameNode; public override IOrigin Tok => NameNode.StartToken; diff --git a/Source/DafnyCore/AST/TypeDeclarations/IteratorDecl.cs b/Source/DafnyCore/AST/TypeDeclarations/IteratorDecl.cs index 2cf1d6bbdf9..b723d9d89b2 100644 --- a/Source/DafnyCore/AST/TypeDeclarations/IteratorDecl.cs +++ b/Source/DafnyCore/AST/TypeDeclarations/IteratorDecl.cs @@ -501,6 +501,10 @@ public void Resolve(ModuleResolver resolver) { } public override string GetTriviaContainingDocstring() { + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; + } + IOrigin lastClosingParenthesis = null; foreach (var token in OwnedTokens) { if (token.val == ")") { @@ -508,11 +512,25 @@ public override string GetTriviaContainingDocstring() { } } - if (lastClosingParenthesis != null && lastClosingParenthesis.TrailingTrivia.Trim() != "") { - return lastClosingParenthesis.TrailingTrivia; + var tentativeTrivia = ""; + if (lastClosingParenthesis != null) { + if (lastClosingParenthesis.pos < EndToken.pos) { + tentativeTrivia = (lastClosingParenthesis.TrailingTrivia + lastClosingParenthesis.Next.LeadingTrivia).Trim(); + } else { + tentativeTrivia = lastClosingParenthesis.TrailingTrivia.Trim(); + } + + if (tentativeTrivia != "") { + return tentativeTrivia; + } + } + + tentativeTrivia = EndToken.TrailingTrivia.Trim(); + if (tentativeTrivia != "") { + return tentativeTrivia; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + return null; } public bool ShouldVerify => true; // This could be made more accurate public ModuleDefinition ContainingModule => EnclosingModuleDefinition; diff --git a/Source/DafnyCore/AST/TypeDeclarations/NewtypeDecl.cs b/Source/DafnyCore/AST/TypeDeclarations/NewtypeDecl.cs index a73eb8fff76..f58836510a8 100644 --- a/Source/DafnyCore/AST/TypeDeclarations/NewtypeDecl.cs +++ b/Source/DafnyCore/AST/TypeDeclarations/NewtypeDecl.cs @@ -151,21 +151,23 @@ public override bool IsEssentiallyEmpty() { } public string GetTriviaContainingDocstring() { - IOrigin candidate = null; + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; + } + foreach (var token in OwnedTokens) { - if (token.val == "{") { - candidate = token.Prev; - if (candidate.TrailingTrivia.Trim() != "") { - return candidate.TrailingTrivia; + if (token.val == "=") { + if ((token.Prev.TrailingTrivia + token.LeadingTrivia).Trim() is { } tentativeTrivia1 and not "") { + return tentativeTrivia1; } } } - if (candidate == null && EndToken.TrailingTrivia.Trim() != "") { - return EndToken.TrailingTrivia; + if (EndToken.TrailingTrivia.Trim() is { } tentativeTrivia and not "") { + return tentativeTrivia; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + return null; } public ModuleDefinition ContainingModule => EnclosingModuleDefinition; diff --git a/Source/DafnyCore/AST/TypeDeclarations/TypeSynonymDeclBase.cs b/Source/DafnyCore/AST/TypeDeclarations/TypeSynonymDeclBase.cs index 074a2f1ce2c..ef5b9f637e3 100644 --- a/Source/DafnyCore/AST/TypeDeclarations/TypeSynonymDeclBase.cs +++ b/Source/DafnyCore/AST/TypeDeclarations/TypeSynonymDeclBase.cs @@ -108,22 +108,23 @@ public override bool IsEssentiallyEmpty() { } public string GetTriviaContainingDocstring() { - IOrigin openingBlock = null; - foreach (var token in OwnedTokens) { - if (token.val == "{") { - openingBlock = token; - } + if (GetStartTriviaDocstring(out var triviaFound)) { + return triviaFound; } - if (openingBlock != null && openingBlock.Prev.TrailingTrivia.Trim() != "") { - return openingBlock.Prev.TrailingTrivia; + foreach (var token in OwnedTokens) { + if (token.val == "=") { + if ((token.Prev.TrailingTrivia + token.LeadingTrivia).Trim() is { } tentativeTrivia and not "") { + return tentativeTrivia; + } + } } - if (openingBlock == null && EndToken.TrailingTrivia.Trim() != "") { - return EndToken.TrailingTrivia; + if (EndToken.TrailingTrivia.Trim() is { } tentativeTrivia2 and not "") { + return tentativeTrivia2; } - return GetTriviaContainingDocstringFromStartTokenOrNull(); + return null; } public abstract override SymbolKind? Kind { get; } diff --git a/Source/DafnyCore/Backends/Dafny/AST.dfy b/Source/DafnyCore/Backends/Dafny/AST.dfy index 8fae0e88c7b..abf6b485f67 100644 --- a/Source/DafnyCore/Backends/Dafny/AST.dfy +++ b/Source/DafnyCore/Backends/Dafny/AST.dfy @@ -1,6 +1,6 @@ module {:extern "DAST.Format"} DAST.Format - /* Cues about how to format different AST elements if necessary, - e.g. to generate idiomatic code when needed. */ +/* Cues about how to format different AST elements if necessary, + e.g. to generate idiomatic code when needed. */ { // Dafny AST compilation tenets: // - The Compiled Dafny AST should be minimal @@ -40,7 +40,12 @@ module {:extern "DAST"} DAST { // For example, the identifier 'None' needs to be escaped in Rust, but not as a constructor. datatype VarName = VarName(dafny_name: string) - datatype Module = Module(name: Name, attributes: seq, requiresExterns: bool, body: Option>) + datatype Module = Module( + name: Name, + docString: string, + attributes: seq, + requiresExterns: bool, + body: Option>) datatype ModuleItem = | Module(Module) @@ -219,25 +224,51 @@ module {:extern "DAST"} DAST { datatype Ident = Ident(id: Name) - datatype Class = Class(name: Name, enclosingModule: Ident, typeParams: seq, superTraitTypes: seq, fields: seq, body: seq, attributes: seq) + datatype Class = Class( + name: Name, + docString: string, + enclosingModule: Ident, + typeParams: seq, + superTraitTypes: seq, + fields: seq, + body: seq, + attributes: seq) datatype Trait = Trait( name: Name, + docString: string, typeParams: seq, traitType: TraitType, parents: seq, body: seq, attributes: seq) - datatype Datatype = Datatype(name: Name, enclosingModule: Ident, typeParams: seq, ctors: seq, body: seq, isCo: bool, attributes: seq, superTraitTypes: seq) + datatype Datatype = Datatype( + name: Name, + docString: string, + enclosingModule: Ident, + typeParams: seq, + ctors: seq, + body: seq, + isCo: bool, + attributes: seq, + superTraitTypes: seq) - datatype DatatypeDtor = DatatypeDtor(formal: Formal, callName: Option) + datatype DatatypeDtor = DatatypeDtor( + formal: Formal, + callName: Option) - datatype DatatypeCtor = DatatypeCtor(name: Name, args: seq, hasAnyArgs: bool /* includes ghost */) + datatype DatatypeCtor = DatatypeCtor( + name: Name, + docString: string, + args: seq, + hasAnyArgs: bool /* includes ghost */) datatype Newtype = Newtype( - name: Name, typeParams: seq, base: Type, + name: Name, + docString: string, + typeParams: seq, base: Type, range: NewtypeRange, constraint: Option, witnessStmts: seq, witnessExpr: Option, attributes: seq, classItems: seq) @@ -246,7 +277,14 @@ module {:extern "DAST"} DAST { // At this point, constraints have been entirely removed, // but synonym types might have different witnesses to use for by the compiler - datatype SynonymType = SynonymType(name: Name, typeParams: seq, base: Type, witnessStmts: seq, witnessExpr: Option, attributes: seq) + datatype SynonymType = SynonymType( + name: Name, + docString: string, + typeParams: seq, + base: Type, + witnessStmts: seq, + witnessExpr: Option, + attributes: seq) datatype ClassItem = Method(Method) @@ -255,6 +293,7 @@ module {:extern "DAST"} DAST { datatype Formal = Formal(name: VarName, typ: Type, attributes: seq) datatype Method = Method( + docString: string, attributes: seq, isStatic: bool, hasBody: bool, diff --git a/Source/DafnyCore/Backends/Dafny/ASTBuilder.cs b/Source/DafnyCore/Backends/Dafny/ASTBuilder.cs index 63455990df6..788f3ba7b36 100644 --- a/Source/DafnyCore/Backends/Dafny/ASTBuilder.cs +++ b/Source/DafnyCore/Backends/Dafny/ASTBuilder.cs @@ -35,18 +35,19 @@ public void AddUnsupported(string why) { interface ModuleContainer : Container { void AddModule(Module item); - public ModuleBuilder Module(string name, Sequence attributes, bool requiresExterns) { - return new ModuleBuilder(this, name, attributes, requiresExterns); + public ModuleBuilder Module(string name, string docString, Sequence attributes, bool requiresExterns) { + return new ModuleBuilder(this, name, docString, attributes, requiresExterns); } public static Module UnsupportedToModule(string why) { return new Module( Sequence.UnicodeFromString($"uncompilable/*{why.Replace(".", ",")}*/"), + Sequence.UnicodeFromString(""), Sequence.FromElements( (Attribute)Attribute.create_Attribute( Sequence.UnicodeFromString("extern"), - Sequence>.FromElements( - (Sequence)Sequence.UnicodeFromString($"uncompilable/*{why}*/")))), false, + Sequence>.FromElements( + (Sequence)Sequence.UnicodeFromString($"uncompilable/*{why}*/")))), false, Std.Wrappers.Option>.create_None()); } } @@ -57,12 +58,14 @@ class ModuleBuilder : ClassContainer, TraitContainer, NewtypeContainer, Datatype readonly Sequence attributes; readonly List body = new(); private readonly bool requiresExterns; + private string docString; - public ModuleBuilder(ModuleContainer parent, string name, Sequence attributes, bool requiresExterns) { + public ModuleBuilder(ModuleContainer parent, string name, string docString, Sequence attributes, bool requiresExterns) { this.parent = parent; this.name = name; this.attributes = attributes; this.requiresExterns = requiresExterns; + this.docString = docString; } public void AddModule(Module item) { @@ -88,6 +91,7 @@ public void AddDatatype(Datatype item) { public object Finish() { parent.AddModule((Module)Module.create( Sequence.UnicodeFromString(this.name), + Sequence.UnicodeFromString(this.docString), attributes, requiresExterns, Std.Wrappers.Option>.create_Some((Sequence)Sequence.FromArray(body.ToArray())) @@ -108,8 +112,8 @@ public void AddUnsupported(string why) { interface ClassContainer : Container { void AddClass(Class item); - public ClassBuilder Class(string name, string enclosingModule, List typeParams, List superClasses, ISequence<_IAttribute> attributes) { - return new ClassBuilder(this, name, enclosingModule, typeParams, superClasses, attributes); + public ClassBuilder Class(string name, string enclosingModule, List typeParams, List superClasses, ISequence<_IAttribute> attributes, string docString) { + return new ClassBuilder(this, name, docString, enclosingModule, typeParams, superClasses, attributes); } } @@ -124,14 +128,16 @@ class ClassBuilder : ClassLike { readonly List fields = new(); readonly List body = new(); readonly ISequence<_IAttribute> attributes; + private string docString; - public ClassBuilder(ClassContainer parent, string name, string enclosingModule, List typeParams, List superClasses, ISequence<_IAttribute> attributes) { + public ClassBuilder(ClassContainer parent, string name, string docString, string enclosingModule, List typeParams, List superClasses, ISequence<_IAttribute> attributes) { this.parent = parent; this.name = name; this.enclosingModule = enclosingModule; this.typeParams = typeParams; this.superClasses = superClasses; this.attributes = attributes; + this.docString = docString; } public void AddMethod(DAST.Method item) { @@ -145,6 +151,7 @@ public void AddField(DAST.Formal item, bool isConstant, _IOption.UnicodeFromString(this.name), + Sequence.UnicodeFromString(this.docString), Sequence.UnicodeFromString(this.enclosingModule), Sequence.FromArray(this.typeParams.ToArray()), Sequence.FromArray(this.superClasses.ToArray()), @@ -159,9 +166,9 @@ public object Finish() { interface TraitContainer : Container { void AddTrait(Trait item); - public TraitBuilder Trait(string name, List typeParams, List parents, - ISequence<_IAttribute> attributes, _ITraitType traitType) { - return new TraitBuilder(this, name, typeParams, parents, attributes, traitType); + public TraitBuilder Trait(string name, List typeParams, List parents, + ISequence<_IAttribute> attributes, string docString, _ITraitType traitType) { + return new TraitBuilder(this, name, docString, typeParams, parents, attributes, traitType); } } @@ -172,13 +179,15 @@ class TraitBuilder : ClassLike { private readonly List parents; readonly List body = new(); private ISequence<_IAttribute> attributes; + private string docString; private _ITraitType traitType; - public TraitBuilder(TraitContainer parent, string name, List typeParams, List parents, ISequence<_IAttribute> attributes, _ITraitType traitType) { + public TraitBuilder(TraitContainer parent, string name, string docString, List typeParams, List parents, ISequence<_IAttribute> attributes, _ITraitType traitType) { this.parent = parent; this.name = name; this.typeParams = typeParams; this.attributes = attributes; + this.docString = docString; this.traitType = traitType; this.parents = parents; } @@ -202,6 +211,7 @@ public void AddField(DAST.Formal item, bool isConstant, _IOption.UnicodeFromString(this.name), + Sequence.UnicodeFromString(this.docString), Sequence.FromArray(typeParams.ToArray()), traitType, Sequence.FromArray(parents.ToArray()), @@ -217,8 +227,8 @@ interface NewtypeContainer : Container { public NewtypeBuilder Newtype(string name, List typeParams, DAST.Type baseType, NewtypeRange newtypeRange, Option constraint, List witnessStmts, DAST.Expression witness, - ISequence<_IAttribute> attributes) { - return new NewtypeBuilder(this, name, typeParams, newtypeRange, baseType, constraint, witnessStmts, witness, attributes); + ISequence<_IAttribute> attributes, string docString) { + return new NewtypeBuilder(this, name, typeParams, newtypeRange, baseType, constraint, witnessStmts, witness, attributes, docString); } } @@ -233,11 +243,12 @@ class NewtypeBuilder : ClassLike { readonly DAST.Expression witness; private ISequence<_IAttribute> attributes; private readonly List methods; + private string docString; public NewtypeBuilder(NewtypeContainer parent, string name, List typeParams, NewtypeRange newtypeRange, DAST.Type baseType, Option constraint, List statements, DAST.Expression witness, - ISequence<_IAttribute> attributes) { + ISequence<_IAttribute> attributes, string docString) { this.parent = parent; this.name = name; this.typeParams = typeParams; @@ -247,6 +258,7 @@ public NewtypeBuilder(NewtypeContainer parent, string name, List ty this.witnessStmts = statements; this.witness = witness; this.attributes = attributes; + this.docString = docString; this.methods = new(); } @@ -261,6 +273,7 @@ public void AddField(DAST.Formal item, bool isConstant, _IOption.UnicodeFromString(this.name), + Sequence.UnicodeFromString(this.docString), Sequence.FromArray(this.typeParams.ToArray()), this.baseType, newtypeRange, @@ -281,8 +294,8 @@ interface SynonymTypeContainer : Container { public SynonymTypeBuilder SynonymType(string name, List typeParams, DAST.Type rhsType, List witnessStmts, DAST.Expression witness, - ISequence<_IAttribute> attributes) { - return new SynonymTypeBuilder(this, name, typeParams, rhsType, witnessStmts, witness, attributes); + ISequence<_IAttribute> attributes, string docString) { + return new SynonymTypeBuilder(this, name, typeParams, rhsType, witnessStmts, witness, attributes, docString); } } @@ -294,10 +307,11 @@ class SynonymTypeBuilder { readonly List witnessStmts; readonly DAST.Expression witness; private ISequence<_IAttribute> attributes; + private string docString; public SynonymTypeBuilder(SynonymTypeContainer parent, string name, List typeParams, DAST.Type rhsType, List statements, DAST.Expression witness, - ISequence<_IAttribute> attributes) { + ISequence<_IAttribute> attributes, string docString) { this.parent = parent; this.name = name; this.typeParams = typeParams; @@ -305,11 +319,13 @@ public SynonymTypeBuilder(SynonymTypeContainer parent, string name, List.UnicodeFromString(this.name), + Sequence.UnicodeFromString(this.docString), Sequence.FromArray(this.typeParams.ToArray()), this.rhsType, Sequence.FromArray(this.witnessStmts.ToArray()), @@ -325,9 +341,9 @@ public object Finish() { interface DatatypeContainer : Container { void AddDatatype(Datatype item); - public DatatypeBuilder Datatype(string name, string enclosingModule, List typeParams, - List ctors, bool isCo, ISequence<_IAttribute> attributes, List superTraitTypes) { - return new DatatypeBuilder(this, name, enclosingModule, typeParams, ctors, isCo, attributes, superTraitTypes); + public DatatypeBuilder Datatype(string name, string enclosingModule, List typeParams, + List ctors, bool isCo, ISequence<_IAttribute> attributes, string docString, List superTraitTypes) { + return new DatatypeBuilder(this, name, docString, enclosingModule, typeParams, ctors, isCo, attributes, superTraitTypes); } } @@ -340,11 +356,13 @@ class DatatypeBuilder : ClassLike { readonly bool isCo; readonly List body = new(); private ISequence<_IAttribute> attributes; + private string docString; private List superTraitTypes; - public DatatypeBuilder(DatatypeContainer parent, string name, string enclosingModule, List typeParams, List ctors, bool isCo, ISequence<_IAttribute> attributes, List superTraitTypes) { + public DatatypeBuilder(DatatypeContainer parent, string name, string docString, string enclosingModule, List typeParams, List ctors, bool isCo, ISequence<_IAttribute> attributes, List superTraitTypes) { this.parent = parent; this.name = name; + this.docString = docString; this.typeParams = typeParams; this.enclosingModule = enclosingModule; this.ctors = ctors; @@ -364,6 +382,7 @@ public void AddField(DAST.Formal item, bool isConstant, _IOption.UnicodeFromString(this.name), + Sequence.UnicodeFromString(this.docString), Sequence.UnicodeFromString(this.enclosingModule), Sequence.FromArray(typeParams.ToArray()), Sequence.FromArray(ctors.ToArray()), @@ -382,12 +401,13 @@ interface ClassLike { public MethodBuilder Method(bool isStatic, bool hasBody, bool outVarsAreUninitFieldsToAssign, bool wasFunction, ISequence> overridingPath, + string docString, ISequence<_IAttribute> attributes, string name, List typeArgs, Sequence params_, List outTypes, List> outVars) { - return new MethodBuilder(this, isStatic, hasBody, outVarsAreUninitFieldsToAssign, wasFunction, overridingPath, attributes, name, typeArgs, params_, outTypes, outVars); + return new MethodBuilder(this, isStatic, hasBody, outVarsAreUninitFieldsToAssign, wasFunction, overridingPath, docString, attributes, name, typeArgs, params_, outTypes, outVars); } public object Finish(); @@ -407,11 +427,13 @@ class MethodBuilder : StatementContainer { readonly List> outVars; readonly List body = new(); private ISequence<_IAttribute> attributes; + private ISequence docString; public MethodBuilder( ClassLike parent, bool isStatic, bool hasBody, bool outVarsAreUninitFieldsToAssign, bool wasFunction, ISequence> overridingPath, + string docString, ISequence<_IAttribute> attributes, string name, List typeArgs, @@ -424,6 +446,7 @@ public MethodBuilder( this.outVarsAreUninitFieldsToAssign = outVarsAreUninitFieldsToAssign; this.wasFunction = wasFunction; this.overridingPath = overridingPath; + this.docString = Sequence.UnicodeFromString(docString); this.attributes = attributes; this.name = name; this.typeArgs = typeArgs; @@ -449,8 +472,8 @@ public void AddBuildable(BuildableStatement item) { public DAST.Method Build() { List builtStatements = new(); StatementContainer.RecursivelyBuild(body, builtStatements); - return (DAST.Method)DAST.Method.create( + docString, attributes, isStatic, hasBody, diff --git a/Source/DafnyCore/Backends/Dafny/DafnyCodeGenerator.cs b/Source/DafnyCore/Backends/Dafny/DafnyCodeGenerator.cs index ea5062cac95..8110529b66c 100644 --- a/Source/DafnyCore/Backends/Dafny/DafnyCodeGenerator.cs +++ b/Source/DafnyCore/Backends/Dafny/DafnyCodeGenerator.cs @@ -55,7 +55,10 @@ protected override string GetCompileNameNotProtected(IVariable v) { } public string TokenToString(IOrigin tok) { - return $"{tok.Uri}({tok.line},{tok.col})"; + var absolutePath = tok.Uri; + var localPath = absolutePath.LocalPath; + var relativePath = System.IO.Path.GetRelativePath(".", localPath).Replace("\\", "/"); // Normalize paths + return $"{relativePath}({tok.line},{tok.col})"; } public void AddUnsupported(IOrigin tok, string why) { @@ -145,7 +148,8 @@ protected override ConcreteSyntaxTree CreateModule(ModuleDefinition module, stri GetIsExternAndIncluded(classLikeDecl) is (ClassIsExtern: true, _)) || (decl is AbstractTypeDecl) ); - currentBuilder = moduleBuilder.Module(moduleName, attributes, requiresExternImport); + var docString = GetDocString(module.EnclosingLiteralModuleDecl is { } node ? node : module); + currentBuilder = moduleBuilder.Module(moduleName, docString, attributes, requiresExternImport); } else { throw new InvalidOperationException(); } @@ -153,6 +157,11 @@ protected override ConcreteSyntaxTree CreateModule(ModuleDefinition module, stri return wr; } + private string GetDocString(INode node) { + return ((node is IHasDocstring iHasDocstring ? iHasDocstring?.GetDocstring(Options) : "") + + "\n" + (node.StartToken.line != 0 && node is not DatatypeCtor ? TokenToString(node.StartToken) : "")).Trim(); + } + protected override void FinishModule() { if (currentBuilder is ModuleBuilder builder) { currentBuilder = builder.Finish(); @@ -191,7 +200,7 @@ protected override IClassWriter CreateClass(string moduleName, string name, bool return new ClassWriter(this, typeParams.Count > 0, builder.Class( name, moduleName, typeParams, superClasses.Select(t => GenType(t)).ToList(), - ParseAttributes(cls.Attributes)) + ParseAttributes(cls.Attributes), GetDocString(cls)) ); } else { throw new InvalidOperationException(); @@ -253,7 +262,7 @@ protected override IClassWriter CreateTrait(string name, bool isExtern, List.FromArray(allDtors.ToArray()) select (DAST.DatatypeCtor)DAST.DatatypeCtor.create_DatatypeCtor( Sequence.UnicodeFromString(ctor.GetCompileName(Options)), + Sequence.UnicodeFromString(GetDocString(ctor)), args, ctor.Formals.Count > 0); var superClasses = dt.ParentTypeInformation.UniqueParentTraits(); var superTraitTypes = superClasses.Select(GenType).ToList(); @@ -308,6 +318,7 @@ from arg in ctor.Formals ctors.ToList(), dt is CoDatatypeDecl, ParseAttributes(dt.Attributes), + GetDocString(dt), superTraitTypes )); } else { @@ -351,7 +362,7 @@ protected override IClassWriter DeclareNewtype(NewtypeDecl nt, ConcreteSyntaxTre return new ClassWriter(this, false, builder.Newtype( nt.GetCompileName(Options), new(), GenType(nt.BaseType), NativeTypeToNewtypeRange(nt, false), - constraint, witnessStmts, witness, ParseAttributes(nt.Attributes))); + constraint, witnessStmts, witness, ParseAttributes(nt.Attributes), GetDocString(nt))); } else { throw new InvalidOperationException(); } @@ -459,7 +470,7 @@ protected override void DeclareSubsetType(SubsetTypeDecl sst, ConcreteSyntaxTree builder.SynonymType(sst.GetCompileName(Options), typeParams, GenType(erasedType), witnessStmts, witness, - ParseAttributes(sst.Attributes)).Finish(); + ParseAttributes(sst.Attributes), GetDocString(sst)).Finish(); } protected override void GetNativeInfo(NativeType.Selection sel, out string name, out string literalSuffix, out bool needsCastAfterArithmetic) { @@ -569,6 +580,7 @@ public ConcreteSyntaxTree CreateMethod(Method m, List var builder = this.builder.Method( m.IsStatic, createBody, m is Constructor, false, overridingTrait != null ? compiler.PathFromTopLevel(overridingTrait) : null, + compiler.GetDocString(m), attributes, m.GetCompileName(compiler.Options), astTypeArgs, params_, @@ -606,6 +618,7 @@ public ConcreteSyntaxTree CreateFunction(string name, List)Sequence.Empty, diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-definitions-coverage.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-definitions-coverage.dfy new file mode 100644 index 00000000000..9f7fd18d1d9 --- /dev/null +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-definitions-coverage.dfy @@ -0,0 +1,74 @@ +// Tests +module {:extern "DefsCoverage"} DafnyToRustCompilerDefinitionsCoverage { + import opened DafnyToRustCompilerDefinitions + import opened DAST + import Strings = Std.Strings + import Std + import opened Std.Wrappers + import R = RAST + import opened DafnyCompilerRustUtils + + const IND := R.IND + type Type = DAST.Type + type Formal = DAST.Formal + + method Expect(x: bool) + { + expect x; // Avoids having too little coverage + } + + method Tests() { + Expect(SurelyAssigned.Join(SurelyAssigned) == SurelyAssigned); + Expect(NotAssigned.Join(NotAssigned) == NotAssigned); + Expect(NotAssigned.Join(SurelyAssigned) == Unknown); + Expect(SurelyAssigned.Join(NotAssigned) == Unknown); + Expect(Unknown.Join(NotAssigned) == NotAssigned.Join(Unknown) == Unknown); + Expect(Unknown.Join(SurelyAssigned) == SurelyAssigned.Join(Unknown) == Unknown); + Expect(Unknown.Join(Unknown) == Unknown); + + Expect(SurelyAssigned.Then(Unknown) + == SurelyAssigned.Then(NotAssigned) + == SurelyAssigned.Then(SurelyAssigned) + == NotAssigned.Then(SurelyAssigned) + == SurelyAssigned); + Expect(Unknown.Then(NotAssigned) + == Unknown.Then(SurelyAssigned) + == Unknown.Then(Unknown) + == NotAssigned.Then(Unknown) + == Unknown); + Expect(NotAssigned.Then(NotAssigned) + == NotAssigned); + + var x := VarName("x"); + var y := VarName("y"); + var z := Expression.Ident(VarName("z")); + var assigns_x := [Assign(AssignLhs.Ident(x), Expression.Ident(y))]; + var assigns_y := [Assign(AssignLhs.Ident(y), Expression.Ident(x))]; + var cond := Expression.Ident(VarName("cond")); + var unknown_x := [If(cond, assigns_x, assigns_y)]; + var surely_double_x := [If(cond, assigns_x, assigns_x)]; + var call_to_x := [Statement.Call(z, SetBuilderAdd, [], [], Some([x]))]; + var declare_x_again := [DeclareVar(x, Type.Tuple([]), None)]; + Expect(DetectAssignmentStatus(assigns_y, x) == NotAssigned); + Expect(DetectAssignmentStatus(assigns_x, x) == SurelyAssigned); + Expect(DetectAssignmentStatus(assigns_x, y) == NotAssigned); + Expect(DetectAssignmentStatus(assigns_x + assigns_y, y) == SurelyAssigned); + Expect(DetectAssignmentStatus(unknown_x, x) == Unknown); + Expect(DetectAssignmentStatus(surely_double_x, x) == SurelyAssigned); + Expect(DetectAssignmentStatus(surely_double_x, y) == NotAssigned); + Expect(DetectAssignmentStatus(call_to_x, x) == SurelyAssigned); + Expect(DetectAssignmentStatus(call_to_x, y) == NotAssigned); + Expect(DetectAssignmentStatus(call_to_x + assigns_y, y) == SurelyAssigned); + Expect(DetectAssignmentStatus([Labeled("l", assigns_y)] + assigns_x, y) == SurelyAssigned); + Expect(DetectAssignmentStatus([Labeled("l", assigns_x)] + assigns_y, x) == SurelyAssigned); + Expect(DetectAssignmentStatus([Labeled("l", assigns_x)] + assigns_y, x) == SurelyAssigned); + Expect(DetectAssignmentStatus(declare_x_again + assigns_x, x) == NotAssigned); + Expect(DetectAssignmentStatus(declare_x_again + assigns_y, y) == SurelyAssigned); + Expect(DetectAssignmentStatus([Return(z)] + assigns_x, x) == NotAssigned); + Expect(DetectAssignmentStatus([EarlyReturn()] + assigns_x, x) == NotAssigned); + Expect(DetectAssignmentStatus([JumpTailCallStart()] + assigns_x, x) == NotAssigned); + Expect(DetectAssignmentStatus([Print(z)] + assigns_x, x) == SurelyAssigned); + Expect(DetectAssignmentStatus([Print(z)] + assigns_x, x) == SurelyAssigned); + Expect(DetectAssignmentStatus([While(z, [])] + assigns_x, x) == Unknown); + } +} \ No newline at end of file diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-definitions.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-definitions.dfy index c3b97acc2c5..8ffdc9a03dc 100644 --- a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-definitions.dfy +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-definitions.dfy @@ -499,6 +499,49 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { R.Identifier("panic!").Apply1(R.LiteralString(optText, binary := false, verbatim := false)) } + function DefaultDatatypeImpl( + rTypeParamsDecls: seq, + datatypeType: R.Type, + datatypeName: R.Expr, + structAssignments: seq + ): R.ModDecl { + var defaultConstrainedTypeParams := R.TypeParamDecl.AddConstraintsMultiple( + rTypeParamsDecls, [R.DefaultTrait] + ); + R.ImplDecl( + R.ImplFor( + defaultConstrainedTypeParams, + R.DefaultTrait, + datatypeType, + [R.FnDecl( + R.NoDoc, R.NoAttr, + R.PRIV, + R.Fn( + "default", [], [], Some(datatypeType), + Some( + R.StructBuild( + datatypeName, + structAssignments + ))) + )] + )) + } + + function AsRefDatatypeImpl(rTypeParamsDecls: seq, datatypeType: R.Type): R.ModDecl { + R.ImplDecl( + R.ImplFor( + rTypeParamsDecls, + R.std.MSel("convert").MSel("AsRef").AsType().Apply1(datatypeType), + datatypeType, + [R.FnDecl( + R.NoDoc, R.NoAttr, + R.PRIV, + R.Fn("as_ref", [], [R.Formal.selfBorrowed], Some(R.SelfBorrowed), + Some(R.self)) + )] + )) + } + function DebugImpl(rTypeParamsDecls: seq, datatypeType: R.Type, rTypeParams: seq): R.ModDecl { R.ImplDecl( R.ImplFor( @@ -507,13 +550,13 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { datatypeType, [ R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( "fmt", [], [R.Formal.selfBorrowed, R.Formal("f", R.BorrowedMut(R.std.MSel("fmt").MSel("Formatter").AsType()))], Some(R.std.MSel("fmt").MSel("Result").AsType()), - "", Some(R.dafny_runtime .MSel("DafnyPrint") .AsExpr() @@ -535,6 +578,7 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { R.DafnyPrint, datatypeType, [R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( "fmt_print", [], @@ -542,7 +586,6 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { R.Formal("_formatter", R.BorrowedMut(R.std.MSel("fmt").MSel("Formatter").AsType())), R.Formal("_in_seq", R.Type.Bool)], Some(R.RawType("std::fmt::Result")), - "", Some(printImplBody)))] )) } @@ -562,6 +605,7 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { rTypeParamsDecls, datatypeType, [R.FnDecl( + "Given type parameter conversions, returns a lambda to convert this structure", R.NoAttr, R.PUB, R.Fn( "coerce", rCoerceTypeParams, @@ -572,7 +616,6 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { R.FnType( [datatypeType], R.TypeApp(R.TIdentifier(datatypeName), coerceTypes))))), - "", Some( R.RcNew(R.Lambda([R.Formal("this", R.SelfOwned)], Some(R.TypeApp(R.TIdentifier(datatypeName), coerceTypes)), @@ -590,12 +633,12 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { rTypeParamsDecls, datatypeType, [R.FnDecl( + "Enumerates all possible values of " + datatypeType.ToString(""), [], R.PUB, R.Fn( "_AllSingletonConstructors", [], [], Some(R.dafny_runtime.MSel("SequenceIter").AsType().Apply([instantiationType])), - "", Some(R.dafny_runtime.MSel("seq!").AsExpr().Apply(singletonConstructors).Sel("iter").Apply0()) ) )])) @@ -613,13 +656,13 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { R.Hash, datatypeOrNewtypeType, [R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( "hash", [R.TypeParamDecl("_H", [R.std.MSel("hash").MSel("Hasher").AsType()])], [R.Formal.selfBorrowed, R.Formal("_state", R.BorrowedMut(R.TIdentifier("_H")))], None, - "", Some(hashImplBody)))] )) } @@ -642,12 +685,12 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { newtypeType, [ R.TypeDeclMember("Output", newtypeType), R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( methodName, [], [R.Formal.selfOwned], Some(R.SelfOwned), - "", Some(R.Identifier(newtypeConstructor).Apply1( R.UnaryOp( [op], @@ -678,13 +721,13 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { newtypeType, [ R.TypeDeclMember("Output", newtypeType), R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( methodName, [], [R.Formal.selfOwned, R.Formal("other", R.SelfOwned)], Some(R.SelfOwned), - "", Some(R.Identifier(newtypeConstructor).Apply1( R.BinaryOp( [op], @@ -707,13 +750,13 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { R.std.MSel("cmp").MSel("PartialOrd").AsType(), newtypeType, [ R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( "partial_cmp", [], [R.Formal.selfBorrowed, R.Formal("other", R.SelfBorrowed)], Some(R.std.MSel("option").MSel("Option").AsType().Apply1(R.std.MSel("cmp").MSel("Ordering").AsType())), - "", Some( R.std.MSel("cmp").MSel("PartialOrd").AsExpr().FSel("partial_cmp").Apply([ R.Borrow(R.self.Sel("0")), @@ -735,7 +778,7 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { if SurelyAssigned? then SurelyAssigned else if NotAssigned? then other else Unknown // It's not as simple. If there are are two paths leading to one being assigned, the other not, - // Rust won't be albe to figure out the rules + // Rust won't be albe to figure out the rules } } @@ -769,78 +812,3 @@ module {:extern "Defs"} DafnyToRustCompilerDefinitions { } } } - -// Tests -module {:extern "DefsCoverage"} DafnyToRustCompilerDefinitionsCoverage { - import opened DafnyToRustCompilerDefinitions - import opened DAST - import Strings = Std.Strings - import Std - import opened Std.Wrappers - import R = RAST - import opened DafnyCompilerRustUtils - - const IND := R.IND - type Type = DAST.Type - type Formal = DAST.Formal - - method Expect(x: bool) - { - expect x; // Avoids having too little coverage - } - - method Tests() { - Expect(SurelyAssigned.Join(SurelyAssigned) == SurelyAssigned); - Expect(NotAssigned.Join(NotAssigned) == NotAssigned); - Expect(NotAssigned.Join(SurelyAssigned) == Unknown); - Expect(SurelyAssigned.Join(NotAssigned) == Unknown); - Expect(Unknown.Join(NotAssigned) == NotAssigned.Join(Unknown) == Unknown); - Expect(Unknown.Join(SurelyAssigned) == SurelyAssigned.Join(Unknown) == Unknown); - Expect(Unknown.Join(Unknown) == Unknown); - - Expect(SurelyAssigned.Then(Unknown) - == SurelyAssigned.Then(NotAssigned) - == SurelyAssigned.Then(SurelyAssigned) - == NotAssigned.Then(SurelyAssigned) - == SurelyAssigned); - Expect(Unknown.Then(NotAssigned) - == Unknown.Then(SurelyAssigned) - == Unknown.Then(Unknown) - == NotAssigned.Then(Unknown) - == Unknown); - Expect(NotAssigned.Then(NotAssigned) - == NotAssigned); - - var x := VarName("x"); - var y := VarName("y"); - var z := Expression.Ident(VarName("z")); - var assigns_x := [Assign(AssignLhs.Ident(x), Expression.Ident(y))]; - var assigns_y := [Assign(AssignLhs.Ident(y), Expression.Ident(x))]; - var cond := Expression.Ident(VarName("cond")); - var unknown_x := [If(cond, assigns_x, assigns_y)]; - var surely_double_x := [If(cond, assigns_x, assigns_x)]; - var call_to_x := [Statement.Call(z, SetBuilderAdd, [], [], Some([x]))]; - var declare_x_again := [DeclareVar(x, Type.Tuple([]), None)]; - Expect(DetectAssignmentStatus(assigns_y, x) == NotAssigned); - Expect(DetectAssignmentStatus(assigns_x, x) == SurelyAssigned); - Expect(DetectAssignmentStatus(assigns_x, y) == NotAssigned); - Expect(DetectAssignmentStatus(assigns_x + assigns_y, y) == SurelyAssigned); - Expect(DetectAssignmentStatus(unknown_x, x) == Unknown); - Expect(DetectAssignmentStatus(surely_double_x, x) == SurelyAssigned); - Expect(DetectAssignmentStatus(surely_double_x, y) == NotAssigned); - Expect(DetectAssignmentStatus(call_to_x, x) == SurelyAssigned); - Expect(DetectAssignmentStatus(call_to_x, y) == NotAssigned); - Expect(DetectAssignmentStatus(call_to_x + assigns_y, y) == SurelyAssigned); - Expect(DetectAssignmentStatus([Labeled("l", assigns_y)] + assigns_x, y) == SurelyAssigned); - Expect(DetectAssignmentStatus([Labeled("l", assigns_x)] + assigns_y, x) == SurelyAssigned); - Expect(DetectAssignmentStatus([Labeled("l", assigns_x)] + assigns_y, x) == SurelyAssigned); - Expect(DetectAssignmentStatus(declare_x_again + assigns_x, x) == NotAssigned); - Expect(DetectAssignmentStatus(declare_x_again + assigns_y, y) == SurelyAssigned); - Expect(DetectAssignmentStatus([Return(z)] + assigns_x, x) == NotAssigned); - Expect(DetectAssignmentStatus([EarlyReturn()] + assigns_x, x) == NotAssigned); - Expect(DetectAssignmentStatus([JumpTailCallStart()] + assigns_x, x) == NotAssigned); - Expect(DetectAssignmentStatus([Print(z)] + assigns_x, x) == SurelyAssigned); - Expect(DetectAssignmentStatus([Print(z)] + assigns_x, x) == SurelyAssigned); - Expect(DetectAssignmentStatus([While(z, [])] + assigns_x, x) == Unknown); - } -} \ No newline at end of file diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-path-simplification.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-path-simplification.dfy index fa63ce28557..c51a856c08a 100644 --- a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-path-simplification.dfy +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-path-simplification.dfy @@ -23,9 +23,10 @@ module FactorPathsOptimizationTest { ShouldBeEqual( apply(crate)( Mod( - "onemodule", [], [ + NoDoc, NoAttr, + "onemodule", [ StructDecl( - Struct([], "test", [T_Decl], + Struct(NoDoc, [], "test", [T_Decl], NamedFields([Field(PUB, Formal("a", std_any_Any.AsType()))]))), // ::std::any::Any ==> Any ImplDecl(Impl([T_Decl], TIdentifier("test").Apply([T]), [])), @@ -35,11 +36,12 @@ module FactorPathsOptimizationTest { // ::std::any::Any ==> Any crate::onemodule::test ==> test ])), Mod( - "onemodule", [], [ + NoDoc, NoAttr, + "onemodule", [ UseDecl(Use(PUB, dafny_runtime.MSel("DafnyType"))), UseDecl(Use(PUB, std_any_Any)), StructDecl( - Struct([], "test", [T_Decl_simp], + Struct(NoDoc, [], "test", [T_Decl_simp], NamedFields([Field(PUB, Formal("a", Any))]))), ImplDecl(Impl([T_Decl_simp], TIdentifier("test").Apply([T]), [])), ImplDecl(ImplFor([T_Decl_simp], Any, TIdentifier("test").Apply([T]), [])) @@ -47,14 +49,16 @@ module FactorPathsOptimizationTest { ShouldBeEqual( apply(crate)( Mod( - "onemodule", [], [ + NoDoc, NoAttr, + "onemodule", [ ImplDecl( ImplFor( [T_Decl], dafny_runtime.MSel("UpcastObject").AsType().Apply([TIdentifier("x")]), TIdentifier("test").Apply([T]), [])) ])), Mod( - "onemodule", [], [ + NoDoc, NoAttr, + "onemodule", [ UseDecl(Use(PUB, dafny_runtime.MSel("DafnyType"))), UseDecl(Use(PUB, dafny_runtime.MSel("UpcastObject"))), ImplDecl( @@ -65,10 +69,11 @@ module FactorPathsOptimizationTest { ShouldBeEqual( apply(crate)( Mod( - "onemodule", [], [ + NoDoc, NoAttr, + "onemodule", [ ConstDecl( Constant( - [], + NoDoc, NoAttr, "dummy", std_any_Any.AsType(), StmtExpr( DeclareVar( @@ -87,7 +92,8 @@ module FactorPathsOptimizationTest { dafny_runtime.MSel("DafnyType").AsType())))) ])), Mod( - "onemodule", [], [ + NoDoc, NoAttr, + "onemodule", [ UseDecl(Use(PUB, std_any_Any)), UseDecl(Use(PUB, std_rc_Rc)), UseDecl(Use(PUB, std_default_Default)), @@ -96,7 +102,7 @@ module FactorPathsOptimizationTest { UseDecl(Use(PUB, dafny_runtime.MSel("DafnyType"))), ConstDecl( Constant( - [], + NoDoc, NoAttr, "dummy", TIdentifier("Any"), StmtExpr( DeclareVar( @@ -121,34 +127,38 @@ module FactorPathsOptimizationTest { ShouldBeEqual( apply(crate)( Mod( - "onemodule", [], [ + NoDoc, NoAttr, + "onemodule", [ TraitDecl( - Trait([], TIdentifier("Something"), [], []) + Trait( + NoDoc, NoAttr, [], + TIdentifier("Something"), [], []) ), ConstDecl( Constant( - [], + NoDoc, NoAttr, "dummyExtern", crate.MSel("anothermodule").MSel("Something").AsType(), RawExpr("nothing"))), ConstDecl( Constant( - [], + NoDoc, NoAttr, "dummyIntern", crate.MSel("onemodule").MSel("Something").AsType(), RawExpr("nothing"))) ])), Mod( - "onemodule", [], [ + NoDoc, NoAttr, + "onemodule", [ TraitDecl( - Trait([], TIdentifier("Something"), [], []) + Trait(NoDoc, NoAttr, [], TIdentifier("Something"), [], []) ), ConstDecl( Constant( - [], + NoDoc, NoAttr, "dummyExtern", crate.MSel("anothermodule").MSel("Something").AsType(), // No simplification RawExpr("nothing"))), ConstDecl( Constant( - [], + NoDoc, NoAttr, "dummyIntern", TIdentifier("Something"), RawExpr("nothing"))) ]) diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-proofs.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-proofs.dfy index 1fd94c4c1f5..0eafa8c8ec9 100644 --- a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-proofs.dfy +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-proofs.dfy @@ -344,7 +344,7 @@ module {:extern "DafnyToRustCompilerProofs"} DafnyToRustCompilerProofs { || is_tuple_builder(i) // ___hMake0, ____hMake1 ... => _T0, _T1 ... || i in reserved_rust // fn, impl, mod ... => r#fn, r#impl, r#mod... || IsDafnyEncodedId(i) // i => i - // create_struct => create_struct + // create_struct => create_struct // c#ons.tant?' => r#_c_hons_dtant_q_k ensures UnescapeIdent(escapeIdent(i)) == i { diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-rast.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-rast.dfy index f487a715b68..87939ae56e1 100644 --- a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-rast.dfy +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-rast.dfy @@ -1,7 +1,7 @@ // Rust AST module RAST - // All ToString methods should produce well-formed Rust code +// All ToString methods should produce well-formed Rust code { import opened Std.Wrappers import Std @@ -53,15 +53,15 @@ module RAST if recurseSubmodules then VisitMod(acc, mod, SelfPath.MSel(mod.name)) else acc case StructDecl(struct) => VisitStructMapping(acc, struct) - case TypeDecl(TypeSynonym(attributes, name, typeParams, tpe)) => + case TypeDecl(TypeSynonym(attributes, _, name, typeParams, tpe)) => var acc := VisitTypeParams(acc, typeParams); var acc := VisitType(acc, tpe); acc - case ConstDecl(Constant(attributes, name, tpe, value)) => + case ConstDecl(Constant(attributes, _, name, tpe, value)) => var acc := VisitType(acc, tpe); var acc := value.Fold(acc, VisitExprSingle, VisitTypeSingle); acc - case EnumDecl(Enum(attributes, name, typeParams, variants)) => + case EnumDecl(Enum(attributes, _, name, typeParams, variants)) => FoldLeft( (acc: T, enumCase: EnumCase) requires enumCase in variants => VisitFields(acc, enumCase.fields), @@ -81,7 +81,7 @@ module RAST function VisitTraitDecl(acc: T, tr: Trait): T { match tr { - case Trait(typeParams, tpe, parents, body) => + case Trait(_, _, typeParams, tpe, parents, body) => var acc := VisitTypeParams(acc, typeParams); var acc := tpe.Fold(acc, VisitTypeSingle); var acc := @@ -97,7 +97,7 @@ module RAST function VisitTopFn(acc: T, t: TopFnDecl): T { match t { - case TopFn(attributes, visibility, fn) => + case TopFn(_, attributes, visibility, fn) => VisitFn(acc, fn) } } @@ -134,7 +134,7 @@ module RAST function VisitMember(acc: T, member: ImplMember): T { match member { case RawImplMember(content) => acc - case FnDecl(pub, fun) => + case FnDecl(docString, attributes, pub, fun) => VisitFn(acc, fun) case TypeDeclMember(name, tpe) => VisitType(acc, tpe) @@ -144,7 +144,7 @@ module RAST } function VisitFn(acc: T, fn: Fn): T { match fn { - case Fn(name, typeParams, formals, returnType, where, body) => + case Fn(name, typeParams, formals, returnType, body) => var acc := VisitTypeParams(acc, typeParams); var acc := FoldLeft( (acc: T, f: Formal) requires f in formals => f.tpe.Fold(acc, VisitTypeSingle), @@ -202,8 +202,8 @@ module RAST function ReplaceStruct(struct: Struct): Struct { match struct { - case Struct(attributes, name, typeParams, fields) => - Struct(attributes, name, + case Struct(docString, attributes, name, typeParams, fields) => + Struct(docString, attributes, name, ReplaceTypeParams(typeParams), ReplaceFields(fields) ) @@ -212,22 +212,22 @@ module RAST function ReplaceTypeDecl(t: TypeSynonym): TypeSynonym { match t { - case TypeSynonym(attributes, name, typeParams, tpe) => - TypeSynonym(attributes, name, ReplaceTypeParams(typeParams), ReplaceType(tpe)) + case TypeSynonym(docString, attributes, name, typeParams, tpe) => + TypeSynonym(docString, attributes, name, ReplaceTypeParams(typeParams), ReplaceType(tpe)) } } function ReplaceConst(t: Constant): Constant { match t { - case Constant(attributes, name, tpe, value) => - Constant(attributes, name, ReplaceType(tpe), ReplaceExpr(value)) + case Constant(docString, attributes, name, tpe, value) => + Constant(docString, attributes, name, ReplaceType(tpe), ReplaceExpr(value)) } } function ReplaceEnum(enum: Enum): Enum { match enum { - case Enum(attributes, name, typeParams, variants) => - Enum(attributes, name, + case Enum(docString, attributes, name, typeParams, variants) => + Enum(docString, attributes, name, ReplaceTypeParams(typeParams), Std.Collections.Seq.Map( (t: EnumCase) => ReplaceEnumCase(t), variants)) @@ -236,8 +236,8 @@ module RAST function ReplaceEnumCase(enumCase: EnumCase): EnumCase { match enumCase { - case EnumCase(name, fields) => - EnumCase(name, ReplaceFields(fields)) + case EnumCase(docString, name, fields) => + EnumCase(docString, name, ReplaceFields(fields)) } } @@ -256,8 +256,10 @@ module RAST function ReplaceTrait(tr: Trait): Trait { match tr { - case Trait(typeParams, tpe, parents, body) => + case Trait(docString, attributes, typeParams, tpe, parents, body) => Trait( + docString, + attributes, ReplaceTypeParams(typeParams), ReplaceType(tpe), Std.Collections.Seq.Map( @@ -268,14 +270,14 @@ module RAST function ReplaceTopFn(t: TopFnDecl): TopFnDecl { match t { - case TopFn(attributes, visibility, fn) => - TopFn(attributes, visibility, ReplaceFn(fn)) + case TopFn(docString, attributes, visibility, fn) => + TopFn(docString, attributes, visibility, ReplaceFn(fn)) } } function ReplaceFn(t: Fn): Fn { match t { - case Fn(name, typeParams, formals, returnType, where, body) => + case Fn(name, typeParams, formals, returnType, body) => Fn( name, ReplaceTypeParams(typeParams), @@ -284,7 +286,6 @@ module RAST formals ), if returnType.None? then None else Some(returnType.value.Replace(ReplaceType)), - where, if body.None? then None else Some(body.value.Replace(ReplaceExpr, ReplaceType)) ) } @@ -305,8 +306,8 @@ module RAST function ReplaceImplMember(t: ImplMember): ImplMember { match t { case RawImplMember(content) => t - case FnDecl(pub, fun) => - FnDecl(pub, ReplaceFn(fun)) + case FnDecl(docString, attributes, pub, fun) => + FnDecl(docString, attributes, pub, ReplaceFn(fun)) case TypeDeclMember(name, tpe) => TypeDeclMember(name, ReplaceType(tpe)) case ImplMemberMacro(expr: Expr) => @@ -350,9 +351,18 @@ module RAST else FoldLeft(f, f(init, xs[0]), xs[1..]) } + function ToDocstringPrefix(docString: string, ind: string): string { + if docString == "" then "" else + "/// " + AddIndent(docString, ind + "/// ") + "\n" + ind + } + datatype Mod = // Rust modules - | Mod(name: string, attributes: seq, body: seq) + | Mod( + docString: string, + attributes: seq, + name: string, + body: seq) | ExternMod(name: string) { function Fold(acc: T, accBuilder: (T, ModDecl) --> T): T @@ -367,7 +377,8 @@ module RAST match this { case ExternMod(name) => "pub mod " + name + ";" - case Mod(name, attributes, body) => + case Mod(docString, attributes, name, body) => + ToDocstringPrefix(docString, ind) + Attribute.ToStringMultiple(attributes, ind) + /* If the module does not start with "use", just separate declarations by one blank line If the module starts with "use", add blank lines only after use declarations */ @@ -422,8 +433,12 @@ module RAST visibility.ToString() + "use " + path.ToString() + ";" } } - datatype TopFnDecl = TopFn(attributes: seq, visibility: Visibility, fn: Fn) { + datatype TopFnDecl = TopFn( + docString: string, + attributes: seq, + visibility: Visibility, fn: Fn) { function ToString(ind: string): string { + ToDocstringPrefix(docString, ind) + Attribute.ToStringMultiple(attributes, ind) + visibility.ToString() + fn.ToString(ind) } @@ -437,10 +452,12 @@ module RAST } datatype Struct = - Struct(attributes: seq, + Struct(docString: string, + attributes: seq, name: string, typeParams: seq, fields: Fields) { function ToString(ind: string): string { + ToDocstringPrefix(docString, ind) + Attribute.ToStringMultiple(attributes, ind) + "pub struct " + name + TypeParamDecl.ToStringMultiple(typeParams, ind) + @@ -450,10 +467,13 @@ module RAST } datatype TypeSynonym = - TypeSynonym(attributes: seq, - name: string, typeParams: seq, tpe: Type) + TypeSynonym( + docString: string, + attributes: seq, + name: string, typeParams: seq, tpe: Type) { function ToString(ind: string): string { + ToDocstringPrefix(docString, ind) + Attribute.ToStringMultiple(attributes, ind) + "pub type " + name + TypeParamDecl.ToStringMultiple(typeParams, ind) + " = " + @@ -462,10 +482,13 @@ module RAST } datatype Constant = - Constant(attributes: seq, - name: string, tpe: Type, value: Expr) + Constant( + docString: string, + attributes: seq, + name: string, tpe: Type, value: Expr) { function ToString(ind: string): string { + ToDocstringPrefix(docString, ind) + Attribute.ToStringMultiple(attributes, ind) + "pub const " + name + ": " + tpe.ToString(ind) + " = " + value.ToString(ind) + ";" @@ -522,19 +545,23 @@ module RAST } datatype EnumCase = - | EnumCase(name: string, fields: Fields) + | EnumCase(docString: string, name: string, fields: Fields) { function ToString(ind: string, newLine: bool): string { + ToDocstringPrefix(docString, ind) + name + fields.ToString(ind, newLine) } } datatype Enum = - Enum(attributes: seq, - name: string, typeParams: seq, - variants: seq) + Enum( + docString: string, + attributes: seq, + name: string, typeParams: seq, + variants: seq) { function ToString(ind: string): string { + ToDocstringPrefix(docString, ind) + Attribute.ToStringMultiple(attributes, ind) + "pub enum " + name + TypeParamDecl.ToStringMultiple(typeParams, ind) @@ -1093,7 +1120,13 @@ module RAST datatype Trait = - | Trait(typeParams: seq, tpe: Type, parents: seq, body: seq) + | Trait( + docString: string, + attributes: seq, + typeParams: seq, + tpe: Type, + parents: seq, + body: seq) { function ToString(ind: string): string { var tpConstraints := Std.Collections.Seq @@ -1110,6 +1143,8 @@ module RAST var where := if additionalConstraints == "" then "" else "\n"+ind+IND+"where\n" + ind + IND + additionalConstraints; + ToDocstringPrefix(docString, ind) + + Attribute.ToStringMultiple(attributes, ind) + "pub trait " + tpe.ToString(ind) + parents + where + " {" + SeqToString(body, (member: ImplMember) => "\n" + ind + IND + member.ToString(ind + IND), "") @@ -1132,11 +1167,14 @@ module RAST datatype ImplMember = | RawImplMember(content: string) | TypeDeclMember(name: string, rhs: Type) // When implementing traits - | FnDecl(pub: Visibility, fun: Fn) + | FnDecl(docString: string, attributes: seq, pub: Visibility, fun: Fn) | ImplMemberMacro(expr: Expr) { function ToString(ind: string): string { - if FnDecl? then pub.ToString() + fun.ToString(ind) + if FnDecl? then + ToDocstringPrefix(docString, ind) + + Attribute.ToStringMultiple(attributes, ind) + + pub.ToString() + fun.ToString(ind) else if ImplMemberMacro? then expr.ToString(ind) + ";" else if TypeDeclMember? then "type " + name + " = " + rhs.ToString(ind) + ";" else assert RawImplMember?; content @@ -1870,14 +1908,12 @@ module RAST datatype Fn = Fn(name: string, typeParams: seq, formals: seq, returnType: Option, - where: string, body: Option) { function ToString(ind: string): string { "fn " + name + TypeParamDecl.ToStringMultiple(typeParams, ind) + "(" + SeqToString(formals, (formal: Formal) => formal.ToString(ind), ", ") + ")" + (match returnType case Some(t) => " -> " + t.ToString(ind) case _ => "") + - (if where == "" then "" else "\n" + ind + IND + where) + match body { case None => ";" case Some(body) => @@ -1887,4 +1923,10 @@ module RAST } } } + + /** Placeholder when there is no Rust docstring */ + const NoDoc := "" + + /** Placeholder when there are no Rust attributes */ + const NoAttr: seq := [] } diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-utils.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-utils.dfy index 6a7089f6ee4..b5064fc6c3d 100644 --- a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-utils.dfy +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-utils.dfy @@ -67,7 +67,7 @@ module DafnyCompilerRustUtils { { if !GatheringModule? then m2 else if !m2.GatheringModule? then this else GatheringModule( - R.Mod(existingMod.name, existingMod.attributes, existingMod.body + m2.existingMod.body), + R.Mod(existingMod.docString + m2.existingMod.docString, existingMod.attributes, existingMod.name, existingMod.body + m2.existingMod.body), MergeSeqMap(submodules, m2.submodules) ) } @@ -82,7 +82,7 @@ module DafnyCompilerRustUtils { else var enclosingModule := containingPath[0]; SeqMap.Single(enclosingModule, - GatheringModule(R.Mod(enclosingModule, [], []), Wrap(containingPath[1..], rawDecl))) + GatheringModule(R.Mod("", [], enclosingModule, []), Wrap(containingPath[1..], rawDecl))) } function ToRust(): R.Mod { if ExternMod? then m else diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust.dfy index 870536688f7..3960a82bfcc 100644 --- a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust.dfy +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust.dfy @@ -107,7 +107,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { error := Some(optExtern.reason); } s := GatheringModule.MergeSeqMap( - GatheringModule.Wrap(ContainingPathToRust(containingPath), R.Mod(modName, attributes, body)), + GatheringModule.Wrap(ContainingPathToRust(containingPath), R.Mod(mod.docString, attributes, modName, body)), allmodules); } } @@ -301,10 +301,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { }*/ body := body + [ R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( "_clone", [], [R.Formal.selfBorrowed], Some(R.Box(R.DynType(fullTraitPath))), - "", Some(R.BoxNew(R.self.Sel("clone").Apply0())))) ]; } else { @@ -332,12 +332,12 @@ module {:extern "DCOMP"} DafnyToRustCompiler { R.dafny_runtime.MSel("UpcastBox").AsType().Apply1(R.DynType(fullTraitPath)), R.TypeApp(genSelfPath, rTypeParams), [ R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( "upcast", [], [R.Formal.selfBorrowed], Some(R.Box(R.DynType(fullTraitPath))), - "", Some(genPathExpr.ApplyType(rTypeParams).FSel("_clone").Apply1(R.self))) // Difference with UpcastStructBox is that there is no .as_ref() ) ])) ]; @@ -403,7 +403,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var className, extern := GetName(c.attributes, c.name, "classes"); - var struct := R.Struct([], className, rTypeParamsDecls, R.NamedFields(fields)); + var struct := R.Struct(c.docString, [], className, rTypeParamsDecls, R.NamedFields(fields)); s := []; if extern.NoExtern? { @@ -424,13 +424,14 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if extern.NoExtern? && className != "_default" { implBody := [ R.FnDecl( + "Allocates an UNINITIALIZED instance. Only the Dafny compiler should use that.", R.NoAttr, R.PUB, - R.Fn(allocate_fn, - [], [], Some(Object(R.SelfOwned)), - "", - Some( - R.dafny_runtime.MSel(allocate).AsExpr().ApplyType1(R.SelfOwned).Apply0() - )) + R.Fn( + allocate_fn, + [], [], Some(Object(R.SelfOwned)), + Some( + R.dafny_runtime.MSel(allocate).AsExpr().ApplyType1(R.SelfOwned).Apply0() + )) ) ] + implBody; } @@ -461,10 +462,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { testMethods := testMethods + [ R.TopFnDecl( R.TopFn( + m.docString, [R.RawAttribute("#[test]")], R.PUB, R.Fn( fnName, [], [], None, - "", Some(R.Identifier("_default").FSel(fnName).Apply([]))) )) ]; @@ -535,10 +536,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { // fn _clone(&self) -> Box; implBody := implBody + [ R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( "_clone", [], [R.Formal.selfBorrowed], Some(R.Box(R.DynType(traitFulltype))), - "", None )) ]; @@ -564,12 +565,12 @@ module {:extern "DCOMP"} DafnyToRustCompiler { R.dafny_runtime.MSel("UpcastBox").AsType().Apply1(R.DynType(parentTpe)), R.Box(R.DynType(traitFulltype)), [ R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn( "upcast", [], [R.Formal.selfBorrowed], Some(R.Box(R.DynType(parentTpe))), - "", Some(traitFullExpr.FSel("_clone").Apply1(R.self.FSel("as_ref").Apply0())) ) )])) @@ -579,6 +580,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { s := [ R.TraitDecl( R.Trait( + t.docString, [], rTypeParamsDecls, traitFulltype, parents, implBody @@ -596,11 +598,11 @@ module {:extern "DCOMP"} DafnyToRustCompiler { R.std.MSel("clone").MSel("Clone").AsType(), R.Box(R.DynType(traitFulltype)), [R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn("clone", [], [ R.Formal.selfBorrowed ], Some(R.SelfOwned), - "", Some(traitFullExpr.FSel("_clone").Apply1(R.self.Sel("as_ref").Apply0())) ))]))]; } @@ -637,6 +639,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { s := [ R.StructDecl( R.Struct( + c.docString, [ R.RawAttribute(attributes), R.RawAttribute("#[repr(transparent)]") @@ -662,10 +665,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var body := R.FnDecl( + "An element of " + newtypeName, [], R.PRIV, R.Fn( "default", [], [], Some(R.SelfOwned), - "", Some(fnBody) )); match c.constraint { @@ -680,10 +683,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { resultingType, [ R.FnDecl( + "Constraint check", R.NoAttr, R.PUB, R.Fn( "is", [], rFormals, Some(R.Bool()), - "", Some(rStmts) )) ] @@ -704,13 +707,13 @@ module {:extern "DCOMP"} DafnyToRustCompiler { R.DafnyPrint, resultingType, [R.FnDecl( + "For Dafny print statements", R.NoAttr, R.PRIV, R.Fn("fmt_print", [], [ R.Formal.selfBorrowed, R.Formal("_formatter", R.BorrowedMut(R.std.MSel("fmt").MSel("Formatter").AsType())), R.Formal("in_seq", R.Type.Bool)], Some(R.std.MSel("fmt").MSel("Result").AsType()), - "", Some(R.dafny_runtime.MSel("DafnyPrint").AsExpr().FSel("fmt_print").Apply( [ R.Borrow(R.self.Sel("0")), R.Identifier("_formatter"), @@ -724,10 +727,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { resultingType, [R.TypeDeclMember("Target", wrappedType), R.FnDecl( + R.NoDoc, R.NoAttr, R.PRIV, R.Fn("deref", [], [R.Formal.selfBorrowed], Some(R.Borrowed(R.Self().MSel("Target").AsType())), - "", Some(R.Borrow(R.self.Sel("0")))))]))]; // Convert a ref to the underlying type to a ref of the wrapped newtype @@ -737,12 +740,12 @@ module {:extern "DCOMP"} DafnyToRustCompiler { rTypeParamsDecls, resultingType, [R.FnDecl( + "SAFETY: The newtype is marked as transparent", R.NoAttr, R.PUB, R.Fn( "_from_ref", [], [R.Formal("o", R.Borrowed(wrappedType))], Some(R.Borrowed(R.Self().AsType())), - "", Some( R.Unsafe( R.Block( @@ -797,6 +800,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { s := [ R.TypeDecl( R.TypeSynonym( + c.docString, [], synonymTypeName, rTypeParamsDecls, resultingType ))]; @@ -812,10 +816,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { s := s + [ R.TopFnDecl( R.TopFn( + "An element of " + synonymTypeName, [], R.PUB, R.Fn( constantName, defaultConstrainedTypeParams, [], Some(resultingType), - "", Some(rStmts.Then(rExpr))) ) ) @@ -913,7 +917,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if isNumeric { namedFields := namedFields.ToNamelessFields(); } - ctors := ctors + [R.EnumCase(escapeName(ctor.name), namedFields)]; + ctors := ctors + [R.EnumCase(ctor.docString, escapeName(ctor.name), namedFields)]; } var unusedTypeParams := (set tp <- rTypeParamsDecls :: tp.name) - usedTypeParams; @@ -998,11 +1002,15 @@ module {:extern "DCOMP"} DafnyToRustCompiler { implBody := implBody + [ R.FnDecl( + if |c.ctors| == 1 then + "Returns a borrow of the field " + callName + else + "Gets the field " + callName + " for all enum members which have it", + [], R.PUB, R.Fn( callName, [], [R.Formal.selfBorrowed], Some(R.Borrowed(formalType)), - "", Some(methodBody) ))]; } @@ -1046,6 +1054,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if |unusedTypeParams| > 0 { ctors := ctors + [ R.EnumCase( + "", "_PhantomVariant", R.NamelessFields( Std.Collections.Seq.Map( @@ -1060,6 +1069,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { s := [R.EnumDecl( R.Enum( + c.docString, if cIsEq then [R.RawAttribute("#[derive(PartialEq, Clone)]")] else @@ -1260,47 +1270,24 @@ module {:extern "DCOMP"} DafnyToRustCompiler { R.std.MSel("default").MSel("Default").AsExpr().FSel("default").Apply0()) ]; } - var defaultConstrainedTypeParams := R.TypeParamDecl.AddConstraintsMultiple( - rTypeParamsDecls, [R.DefaultTrait] - ); var fullType := R.TypeApp(R.TIdentifier(datatypeName), rTypeParams); // Implementation of Default trait when c supports equality if cIsEq { s := s + - [R.ImplDecl( - R.ImplFor( - defaultConstrainedTypeParams, - R.DefaultTrait, - fullType, - [R.FnDecl( - R.PRIV, - R.Fn( - "default", [], [], Some(fullType), - "", - Some( - R.StructBuild( - structName, - structAssignments - ))) - )] - ))]; + [ DefaultDatatypeImpl( + rTypeParamsDecls, + fullType, + structName, + structAssignments)]; } // Implementation of AsRef trait s := s + [ - R.ImplDecl( - R.ImplFor( - rTypeParamsDecls, - R.std.MSel("convert").MSel("AsRef").AsType().Apply1(fullType), - fullType, - [R.FnDecl( - R.PRIV, - R.Fn("as_ref", [], [R.Formal.selfBorrowed], Some(R.SelfBorrowed), - "", - Some(R.self)) - )] - ))]; + AsRefDatatypeImpl( + rTypeParamsDecls, + fullType + )]; } var superTraitImplementations := GenTraitImplementations( path, @@ -1727,13 +1714,13 @@ module {:extern "DCOMP"} DafnyToRustCompiler { fBody := None; } s := R.FnDecl( + m.docString, R.NoAttr, visibility, R.Fn( fnName, typeParams, params, Some(if |retTypeArgs| == 1 then retTypeArgs[0] else R.TupleType(retTypeArgs)), - "", fBody ) ); @@ -4069,7 +4056,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } if externUseDecls != [] { - s := s + R.Mod(DAFNY_EXTERN_MODULE, [], externUseDecls).ToString("") + "\n"; + s := s + R.Mod( + "Flattens all imported externs so that they can be accessed from this module", + [], + DAFNY_EXTERN_MODULE, externUseDecls).ToString("") + "\n"; } var allModules := SeqMap.Empty(); diff --git a/Source/DafnyCore/Coco/Scanner.frame b/Source/DafnyCore/Coco/Scanner.frame index 4ad3667ceb0..f72296e14e1 100644 --- a/Source/DafnyCore/Coco/Scanner.frame +++ b/Source/DafnyCore/Coco/Scanner.frame @@ -469,7 +469,7 @@ public class Scanner { lastWasCr = (ch == '\r'); } NextCh(); - if(triviaTrailing && triviaNewlines == 2 && (ch != '\n' || !lastWasCr)) { + if(triviaTrailing && triviaNewlines == 1 && (ch != '\n' || !lastWasCr)) { triviaTrailing = false; posTrailingEndLeadingStart = pos; } diff --git a/Source/DafnyCore/Dafny.atg b/Source/DafnyCore/Dafny.atg index 94fb00257f6..2568f369a93 100644 --- a/Source/DafnyCore/Dafny.atg +++ b/Source/DafnyCore/Dafny.atg @@ -320,7 +320,6 @@ ModuleDefinition(); List idRefined = null; ModuleDefinition module; @@ -342,7 +341,7 @@ ModuleDefinition TopDecl} @@ -350,7 +349,6 @@ ModuleDefinition parentTraits = new List(); bool isRefining = false; List typeArgs = new List(); @@ -532,10 +529,10 @@ ClassDecl } - ClassName (. tokenWithTrailingDocString = t; .) - [ GenericParameters ] (. tokenWithTrailingDocString = t; .) - [ ExtendsClause - | ellipsis (. isRefining = true; tokenWithTrailingDocString = t; .) + ClassName + [ GenericParameters ] + [ ExtendsClause + | ellipsis (. isRefining = true; .) ] SYNC "{" (. bodyStart = t; .) @@ -548,11 +545,10 @@ ClassDecl parentTraits, out Token tokenWithTrailingDocString, string requiresNonReferenceTraitsFor .> +ExtendsClause<. List parentTraits, string requiresNonReferenceTraitsFor .> = (. Type parentTrait; .) "extends" @@ -565,8 +561,8 @@ ExtendsClause<. List parentTraits, out Token tokenWithTrailingDocString, s $"{requiresNonReferenceTraitsFor} extending traits is not yet enabled by default; use --general-traits=datatype to enable it"); } .) - Type (. parentTraits.Add(parentTrait); tokenWithTrailingDocString = t; .) - {"," Type (. parentTraits.Add(parentTrait); tokenWithTrailingDocString = t; .) } + Type (. parentTraits.Add(parentTrait); .) + {"," Type (. parentTraits.Add(parentTrait); .) } . /*------------------------------------------------------------------------*/ @@ -574,7 +570,6 @@ TraitDecl parentTraits = new List(); bool isRefining = false; List typeArgs = new List(); //traits should not support type parameters at the moment @@ -585,10 +580,10 @@ TraitDecl } - ClassName (. tokenWithTrailingDocString = t; .) - [ GenericParameters ] (. tokenWithTrailingDocString = t; .) - [ ExtendsClause - | ellipsis (. isRefining = true; tokenWithTrailingDocString = t; .) + ClassName + [ GenericParameters ] + [ ExtendsClause + | ellipsis (. isRefining = true; .) ] "{" (. bodyStart = t; .) { (. dmod = new DeclModifierData(); .) @@ -599,7 +594,6 @@ TraitDecl } DatatypeName [ GenericParameters ] - [ ExtendsClause ] + [ ExtendsClause ] ( "=" (. bodyStart = t; .) [ ellipsis (. SemErr(ErrorId.p_bad_datatype_refinement, t, // Help users adjust to the new syntax @@ -672,7 +666,6 @@ DatatypeDecl mm.> "var" (. startToken = startToken ?? t; .) { Attribute } FIdentType (. var f = new Field(new RangeToken(startToken, t), name, dmod.IsGhost, ty, attrs); - mm.Add(f); f.TokenWithTrailingDocString = t; + mm.Add(f); .) { "," (. startToken = t; .) FIdentType (. f = new Field(new RangeToken(startToken, t), name, dmod.IsGhost, ty, attrs); - mm.Add(f); f.TokenWithTrailingDocString = t; + mm.Add(f); .) } OldSemi @@ -761,7 +754,7 @@ ConstantFieldDecl<.DeclModifierData dmod, List/*!*/ mm, bool mo var c = new ConstantField(new RangeToken(dmod.FirstToken, t), name, e, dmod.IsStatic, dmod.IsGhost, dmod.IsOpaque, ty, dmod.Attributes); mm.Add(c); .) - OldSemi (. c.TokenWithTrailingDocString = t; .) + OldSemi ) . @@ -785,7 +778,7 @@ NewtypeDecl { Attribute } NewtypeName [ GenericParameters ] - [ ExtendsClause ] + [ ExtendsClause ] ( "=" [ ellipsis (. SemErr(ErrorId.p_misplaced_ellipsis_in_newtype, t, // Help users adjust to the new syntax @@ -816,9 +809,7 @@ NewtypeDecl SubsetTypeDecl.WKind.CompiledZero, null, parentTraits, members, dmod.Attributes, isRefining: true); .) - ) (. if (td != null) { - td.TokenWithTrailingDocString = t; - } .) + ) . /*------------------------------------------------------------------------*/ @@ -862,7 +853,7 @@ SynonymTypeDecl ] - | ExtendsClause + | ExtendsClause [ TypeMembers ] | TypeMembers ] @@ -873,7 +864,6 @@ SynonymTypeDecl bool isLeastLemma = false; bool isGreatestLemma = false; Token signatureEllipsis = null; - Token tokenWithTrailingDocString = Token.NoToken; Token bodyStart = Token.NoToken; Token bodyEnd = Token.NoToken; AllowedDeclModifiers allowed = AllowedDeclModifiers.None; @@ -1253,7 +1242,7 @@ MethodDecl (. if (isConstructor) { SemErr(ErrorId.p_constructors_have_no_out_parameters, new RangeToken(returnsToken, t), "constructors cannot have out-parameters"); } .) ] | ellipsis (. signatureEllipsis = t; .) - ) (. tokenWithTrailingDocString = t; .) + ) MethodSpec [ IF(isConstructor) @@ -1289,7 +1278,6 @@ MethodDecl new Specification(dec, decAttrs), body, dmod.Attributes, signatureEllipsis); } m.BodyStartTok = bodyStart; - m.TokenWithTrailingDocString = tokenWithTrailingDocString; .) . @@ -1702,7 +1690,6 @@ FunctionDecl bool isPredicate = false; bool isLeastPredicate = false; bool isGreatestPredicate = false; Token/*?*/ headToken = null; // used only for a basic "function" or "predicate" Token/*?*/ functionMethodToken = null; // used only for a basic "function" or "predicate" - Token tokenWithTrailingDocString = Token.NoToken; Token bodyStart = Token.NoToken; Token bodyEnd = Token.NoToken; Token signatureEllipsis = null; @@ -1828,7 +1815,6 @@ FunctionDecl ) (. decreases = isLeastPredicate || isGreatestPredicate ? null : new List(); - tokenWithTrailingDocString = t; .) FunctionSpec (. Token byMethodTok = null; BlockStmt byMethodBody = null; .) @@ -2021,7 +2007,6 @@ FunctionDecl dmod.Attributes, signatureEllipsis); } f.BodyStartTok = bodyStart; - f.TokenWithTrailingDocString = tokenWithTrailingDocString; SystemModuleModifiers.Add(b => b.CreateArrowTypeDecl(formals.Count)); if (isLeastPredicate || isGreatestPredicate) { // also create an arrow type for the corresponding prefix predicate diff --git a/Source/DafnyCore/GeneratedFromDafny/DAST.cs b/Source/DafnyCore/GeneratedFromDafny/DAST.cs index 43a70d575a8..17306167c65 100644 --- a/Source/DafnyCore/GeneratedFromDafny/DAST.cs +++ b/Source/DafnyCore/GeneratedFromDafny/DAST.cs @@ -120,6 +120,7 @@ public Dafny.ISequence dtor_dafny__name { public interface _IModule { bool is_Module { get; } Dafny.ISequence dtor_name { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence dtor_attributes { get; } bool dtor_requiresExterns { get; } Std.Wrappers._IOption> dtor_body { get; } @@ -127,27 +128,30 @@ public interface _IModule { } public class Module : _IModule { public readonly Dafny.ISequence _name; + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence _attributes; public readonly bool _requiresExterns; public readonly Std.Wrappers._IOption> _body; - public Module(Dafny.ISequence name, Dafny.ISequence attributes, bool requiresExterns, Std.Wrappers._IOption> body) { + public Module(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence attributes, bool requiresExterns, Std.Wrappers._IOption> body) { this._name = name; + this._docString = docString; this._attributes = attributes; this._requiresExterns = requiresExterns; this._body = body; } public _IModule DowncastClone() { if (this is _IModule dt) { return dt; } - return new Module(_name, _attributes, _requiresExterns, _body); + return new Module(_name, _docString, _attributes, _requiresExterns, _body); } public override bool Equals(object other) { var oth = other as DAST.Module; - return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._attributes, oth._attributes) && this._requiresExterns == oth._requiresExterns && object.Equals(this._body, oth._body); + return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && this._requiresExterns == oth._requiresExterns && object.Equals(this._body, oth._body); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._requiresExterns)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._body)); @@ -158,6 +162,8 @@ public override string ToString() { s += "("; s += Dafny.Helpers.ToString(this._name); s += ", "; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._attributes); s += ", "; s += Dafny.Helpers.ToString(this._requiresExterns); @@ -166,7 +172,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly DAST._IModule theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, false, Std.Wrappers.Option>.Default()); + private static readonly DAST._IModule theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, false, Std.Wrappers.Option>.Default()); public static DAST._IModule Default() { return theDefault; } @@ -174,11 +180,11 @@ public static DAST._IModule Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IModule create(Dafny.ISequence name, Dafny.ISequence attributes, bool requiresExterns, Std.Wrappers._IOption> body) { - return new Module(name, attributes, requiresExterns, body); + public static _IModule create(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence attributes, bool requiresExterns, Std.Wrappers._IOption> body) { + return new Module(name, docString, attributes, requiresExterns, body); } - public static _IModule create_Module(Dafny.ISequence name, Dafny.ISequence attributes, bool requiresExterns, Std.Wrappers._IOption> body) { - return create(name, attributes, requiresExterns, body); + public static _IModule create_Module(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence attributes, bool requiresExterns, Std.Wrappers._IOption> body) { + return create(name, docString, attributes, requiresExterns, body); } public bool is_Module { get { return true; } } public Dafny.ISequence dtor_name { @@ -186,6 +192,11 @@ public Dafny.ISequence dtor_name { return this._name; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence dtor_attributes { get { return this._attributes; @@ -2751,6 +2762,7 @@ public Dafny.ISequence dtor_id { public interface _IClass { bool is_Class { get; } Dafny.ISequence dtor_name { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence dtor_enclosingModule { get; } Dafny.ISequence dtor_typeParams { get; } Dafny.ISequence dtor_superTraitTypes { get; } @@ -2761,14 +2773,16 @@ public interface _IClass { } public class Class : _IClass { public readonly Dafny.ISequence _name; + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence _enclosingModule; public readonly Dafny.ISequence _typeParams; public readonly Dafny.ISequence _superTraitTypes; public readonly Dafny.ISequence _fields; public readonly Dafny.ISequence _body; public readonly Dafny.ISequence _attributes; - public Class(Dafny.ISequence name, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence superTraitTypes, Dafny.ISequence fields, Dafny.ISequence body, Dafny.ISequence attributes) { + public Class(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence superTraitTypes, Dafny.ISequence fields, Dafny.ISequence body, Dafny.ISequence attributes) { this._name = name; + this._docString = docString; this._enclosingModule = enclosingModule; this._typeParams = typeParams; this._superTraitTypes = superTraitTypes; @@ -2778,16 +2792,17 @@ public Class(Dafny.ISequence name, Dafny.ISequence enclo } public _IClass DowncastClone() { if (this is _IClass dt) { return dt; } - return new Class(_name, _enclosingModule, _typeParams, _superTraitTypes, _fields, _body, _attributes); + return new Class(_name, _docString, _enclosingModule, _typeParams, _superTraitTypes, _fields, _body, _attributes); } public override bool Equals(object other) { var oth = other as DAST.Class; - return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._enclosingModule, oth._enclosingModule) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._superTraitTypes, oth._superTraitTypes) && object.Equals(this._fields, oth._fields) && object.Equals(this._body, oth._body) && object.Equals(this._attributes, oth._attributes); + return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._docString, oth._docString) && object.Equals(this._enclosingModule, oth._enclosingModule) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._superTraitTypes, oth._superTraitTypes) && object.Equals(this._fields, oth._fields) && object.Equals(this._body, oth._body) && object.Equals(this._attributes, oth._attributes); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._enclosingModule)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._typeParams)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._superTraitTypes)); @@ -2801,6 +2816,8 @@ public override string ToString() { s += "("; s += Dafny.Helpers.ToString(this._name); s += ", "; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._enclosingModule); s += ", "; s += Dafny.Helpers.ToString(this._typeParams); @@ -2815,7 +2832,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly DAST._IClass theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty); + private static readonly DAST._IClass theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty); public static DAST._IClass Default() { return theDefault; } @@ -2823,11 +2840,11 @@ public static DAST._IClass Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IClass create(Dafny.ISequence name, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence superTraitTypes, Dafny.ISequence fields, Dafny.ISequence body, Dafny.ISequence attributes) { - return new Class(name, enclosingModule, typeParams, superTraitTypes, fields, body, attributes); + public static _IClass create(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence superTraitTypes, Dafny.ISequence fields, Dafny.ISequence body, Dafny.ISequence attributes) { + return new Class(name, docString, enclosingModule, typeParams, superTraitTypes, fields, body, attributes); } - public static _IClass create_Class(Dafny.ISequence name, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence superTraitTypes, Dafny.ISequence fields, Dafny.ISequence body, Dafny.ISequence attributes) { - return create(name, enclosingModule, typeParams, superTraitTypes, fields, body, attributes); + public static _IClass create_Class(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence superTraitTypes, Dafny.ISequence fields, Dafny.ISequence body, Dafny.ISequence attributes) { + return create(name, docString, enclosingModule, typeParams, superTraitTypes, fields, body, attributes); } public bool is_Class { get { return true; } } public Dafny.ISequence dtor_name { @@ -2835,6 +2852,11 @@ public Dafny.ISequence dtor_name { return this._name; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence dtor_enclosingModule { get { return this._enclosingModule; @@ -2870,6 +2892,7 @@ public Dafny.ISequence dtor_attributes { public interface _ITrait { bool is_Trait { get; } Dafny.ISequence dtor_name { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence dtor_typeParams { get; } DAST._ITraitType dtor_traitType { get; } Dafny.ISequence dtor_parents { get; } @@ -2879,13 +2902,15 @@ public interface _ITrait { } public class Trait : _ITrait { public readonly Dafny.ISequence _name; + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence _typeParams; public readonly DAST._ITraitType _traitType; public readonly Dafny.ISequence _parents; public readonly Dafny.ISequence _body; public readonly Dafny.ISequence _attributes; - public Trait(Dafny.ISequence name, Dafny.ISequence typeParams, DAST._ITraitType traitType, Dafny.ISequence parents, Dafny.ISequence body, Dafny.ISequence attributes) { + public Trait(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence typeParams, DAST._ITraitType traitType, Dafny.ISequence parents, Dafny.ISequence body, Dafny.ISequence attributes) { this._name = name; + this._docString = docString; this._typeParams = typeParams; this._traitType = traitType; this._parents = parents; @@ -2894,16 +2919,17 @@ public Trait(Dafny.ISequence name, Dafny.ISequence.Empty, Dafny.Sequence.Empty, DAST.TraitType.Default(), Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty); + private static readonly DAST._ITrait theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, DAST.TraitType.Default(), Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty); public static DAST._ITrait Default() { return theDefault; } @@ -2936,11 +2964,11 @@ public static DAST._ITrait Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _ITrait create(Dafny.ISequence name, Dafny.ISequence typeParams, DAST._ITraitType traitType, Dafny.ISequence parents, Dafny.ISequence body, Dafny.ISequence attributes) { - return new Trait(name, typeParams, traitType, parents, body, attributes); + public static _ITrait create(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence typeParams, DAST._ITraitType traitType, Dafny.ISequence parents, Dafny.ISequence body, Dafny.ISequence attributes) { + return new Trait(name, docString, typeParams, traitType, parents, body, attributes); } - public static _ITrait create_Trait(Dafny.ISequence name, Dafny.ISequence typeParams, DAST._ITraitType traitType, Dafny.ISequence parents, Dafny.ISequence body, Dafny.ISequence attributes) { - return create(name, typeParams, traitType, parents, body, attributes); + public static _ITrait create_Trait(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence typeParams, DAST._ITraitType traitType, Dafny.ISequence parents, Dafny.ISequence body, Dafny.ISequence attributes) { + return create(name, docString, typeParams, traitType, parents, body, attributes); } public bool is_Trait { get { return true; } } public Dafny.ISequence dtor_name { @@ -2948,6 +2976,11 @@ public Dafny.ISequence dtor_name { return this._name; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence dtor_typeParams { get { return this._typeParams; @@ -2978,6 +3011,7 @@ public Dafny.ISequence dtor_attributes { public interface _IDatatype { bool is_Datatype { get; } Dafny.ISequence dtor_name { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence dtor_enclosingModule { get; } Dafny.ISequence dtor_typeParams { get; } Dafny.ISequence dtor_ctors { get; } @@ -2989,6 +3023,7 @@ public interface _IDatatype { } public class Datatype : _IDatatype { public readonly Dafny.ISequence _name; + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence _enclosingModule; public readonly Dafny.ISequence _typeParams; public readonly Dafny.ISequence _ctors; @@ -2996,8 +3031,9 @@ public class Datatype : _IDatatype { public readonly bool _isCo; public readonly Dafny.ISequence _attributes; public readonly Dafny.ISequence _superTraitTypes; - public Datatype(Dafny.ISequence name, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence ctors, Dafny.ISequence body, bool isCo, Dafny.ISequence attributes, Dafny.ISequence superTraitTypes) { + public Datatype(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence ctors, Dafny.ISequence body, bool isCo, Dafny.ISequence attributes, Dafny.ISequence superTraitTypes) { this._name = name; + this._docString = docString; this._enclosingModule = enclosingModule; this._typeParams = typeParams; this._ctors = ctors; @@ -3008,16 +3044,17 @@ public Datatype(Dafny.ISequence name, Dafny.ISequence en } public _IDatatype DowncastClone() { if (this is _IDatatype dt) { return dt; } - return new Datatype(_name, _enclosingModule, _typeParams, _ctors, _body, _isCo, _attributes, _superTraitTypes); + return new Datatype(_name, _docString, _enclosingModule, _typeParams, _ctors, _body, _isCo, _attributes, _superTraitTypes); } public override bool Equals(object other) { var oth = other as DAST.Datatype; - return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._enclosingModule, oth._enclosingModule) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._ctors, oth._ctors) && object.Equals(this._body, oth._body) && this._isCo == oth._isCo && object.Equals(this._attributes, oth._attributes) && object.Equals(this._superTraitTypes, oth._superTraitTypes); + return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._docString, oth._docString) && object.Equals(this._enclosingModule, oth._enclosingModule) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._ctors, oth._ctors) && object.Equals(this._body, oth._body) && this._isCo == oth._isCo && object.Equals(this._attributes, oth._attributes) && object.Equals(this._superTraitTypes, oth._superTraitTypes); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._enclosingModule)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._typeParams)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._ctors)); @@ -3032,6 +3069,8 @@ public override string ToString() { s += "("; s += Dafny.Helpers.ToString(this._name); s += ", "; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._enclosingModule); s += ", "; s += Dafny.Helpers.ToString(this._typeParams); @@ -3048,7 +3087,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly DAST._IDatatype theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, false, Dafny.Sequence.Empty, Dafny.Sequence.Empty); + private static readonly DAST._IDatatype theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, false, Dafny.Sequence.Empty, Dafny.Sequence.Empty); public static DAST._IDatatype Default() { return theDefault; } @@ -3056,11 +3095,11 @@ public static DAST._IDatatype Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IDatatype create(Dafny.ISequence name, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence ctors, Dafny.ISequence body, bool isCo, Dafny.ISequence attributes, Dafny.ISequence superTraitTypes) { - return new Datatype(name, enclosingModule, typeParams, ctors, body, isCo, attributes, superTraitTypes); + public static _IDatatype create(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence ctors, Dafny.ISequence body, bool isCo, Dafny.ISequence attributes, Dafny.ISequence superTraitTypes) { + return new Datatype(name, docString, enclosingModule, typeParams, ctors, body, isCo, attributes, superTraitTypes); } - public static _IDatatype create_Datatype(Dafny.ISequence name, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence ctors, Dafny.ISequence body, bool isCo, Dafny.ISequence attributes, Dafny.ISequence superTraitTypes) { - return create(name, enclosingModule, typeParams, ctors, body, isCo, attributes, superTraitTypes); + public static _IDatatype create_Datatype(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence enclosingModule, Dafny.ISequence typeParams, Dafny.ISequence ctors, Dafny.ISequence body, bool isCo, Dafny.ISequence attributes, Dafny.ISequence superTraitTypes) { + return create(name, docString, enclosingModule, typeParams, ctors, body, isCo, attributes, superTraitTypes); } public bool is_Datatype { get { return true; } } public Dafny.ISequence dtor_name { @@ -3068,6 +3107,11 @@ public Dafny.ISequence dtor_name { return this._name; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence dtor_enclosingModule { get { return this._enclosingModule; @@ -3172,31 +3216,35 @@ public Std.Wrappers._IOption> dtor_callName { public interface _IDatatypeCtor { bool is_DatatypeCtor { get; } Dafny.ISequence dtor_name { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence dtor_args { get; } bool dtor_hasAnyArgs { get; } _IDatatypeCtor DowncastClone(); } public class DatatypeCtor : _IDatatypeCtor { public readonly Dafny.ISequence _name; + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence _args; public readonly bool _hasAnyArgs; - public DatatypeCtor(Dafny.ISequence name, Dafny.ISequence args, bool hasAnyArgs) { + public DatatypeCtor(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence args, bool hasAnyArgs) { this._name = name; + this._docString = docString; this._args = args; this._hasAnyArgs = hasAnyArgs; } public _IDatatypeCtor DowncastClone() { if (this is _IDatatypeCtor dt) { return dt; } - return new DatatypeCtor(_name, _args, _hasAnyArgs); + return new DatatypeCtor(_name, _docString, _args, _hasAnyArgs); } public override bool Equals(object other) { var oth = other as DAST.DatatypeCtor; - return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._args, oth._args) && this._hasAnyArgs == oth._hasAnyArgs; + return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._docString, oth._docString) && object.Equals(this._args, oth._args) && this._hasAnyArgs == oth._hasAnyArgs; } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._args)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._hasAnyArgs)); return (int) hash; @@ -3206,13 +3254,15 @@ public override string ToString() { s += "("; s += Dafny.Helpers.ToString(this._name); s += ", "; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._args); s += ", "; s += Dafny.Helpers.ToString(this._hasAnyArgs); s += ")"; return s; } - private static readonly DAST._IDatatypeCtor theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, false); + private static readonly DAST._IDatatypeCtor theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, false); public static DAST._IDatatypeCtor Default() { return theDefault; } @@ -3220,11 +3270,11 @@ public static DAST._IDatatypeCtor Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IDatatypeCtor create(Dafny.ISequence name, Dafny.ISequence args, bool hasAnyArgs) { - return new DatatypeCtor(name, args, hasAnyArgs); + public static _IDatatypeCtor create(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence args, bool hasAnyArgs) { + return new DatatypeCtor(name, docString, args, hasAnyArgs); } - public static _IDatatypeCtor create_DatatypeCtor(Dafny.ISequence name, Dafny.ISequence args, bool hasAnyArgs) { - return create(name, args, hasAnyArgs); + public static _IDatatypeCtor create_DatatypeCtor(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence args, bool hasAnyArgs) { + return create(name, docString, args, hasAnyArgs); } public bool is_DatatypeCtor { get { return true; } } public Dafny.ISequence dtor_name { @@ -3232,6 +3282,11 @@ public Dafny.ISequence dtor_name { return this._name; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence dtor_args { get { return this._args; @@ -3247,6 +3302,7 @@ public bool dtor_hasAnyArgs { public interface _INewtype { bool is_Newtype { get; } Dafny.ISequence dtor_name { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence dtor_typeParams { get; } DAST._IType dtor_base { get; } DAST._INewtypeRange dtor_range { get; } @@ -3259,6 +3315,7 @@ public interface _INewtype { } public class Newtype : _INewtype { public readonly Dafny.ISequence _name; + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence _typeParams; public readonly DAST._IType _base; public readonly DAST._INewtypeRange _range; @@ -3267,8 +3324,9 @@ public class Newtype : _INewtype { public readonly Std.Wrappers._IOption _witnessExpr; public readonly Dafny.ISequence _attributes; public readonly Dafny.ISequence _classItems; - public Newtype(Dafny.ISequence name, Dafny.ISequence typeParams, DAST._IType @base, DAST._INewtypeRange range, Std.Wrappers._IOption constraint, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes, Dafny.ISequence classItems) { + public Newtype(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence typeParams, DAST._IType @base, DAST._INewtypeRange range, Std.Wrappers._IOption constraint, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes, Dafny.ISequence classItems) { this._name = name; + this._docString = docString; this._typeParams = typeParams; this._base = @base; this._range = range; @@ -3280,16 +3338,17 @@ public Newtype(Dafny.ISequence name, Dafny.ISequence.Empty, Dafny.Sequence.Empty, DAST.Type.Default(), DAST.NewtypeRange.Default(), Std.Wrappers.Option.Default(), Dafny.Sequence.Empty, Std.Wrappers.Option.Default(), Dafny.Sequence.Empty, Dafny.Sequence.Empty); + private static readonly DAST._INewtype theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, DAST.Type.Default(), DAST.NewtypeRange.Default(), Std.Wrappers.Option.Default(), Dafny.Sequence.Empty, Std.Wrappers.Option.Default(), Dafny.Sequence.Empty, Dafny.Sequence.Empty); public static DAST._INewtype Default() { return theDefault; } @@ -3331,11 +3392,11 @@ public static DAST._INewtype Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _INewtype create(Dafny.ISequence name, Dafny.ISequence typeParams, DAST._IType @base, DAST._INewtypeRange range, Std.Wrappers._IOption constraint, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes, Dafny.ISequence classItems) { - return new Newtype(name, typeParams, @base, range, constraint, witnessStmts, witnessExpr, attributes, classItems); + public static _INewtype create(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence typeParams, DAST._IType @base, DAST._INewtypeRange range, Std.Wrappers._IOption constraint, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes, Dafny.ISequence classItems) { + return new Newtype(name, docString, typeParams, @base, range, constraint, witnessStmts, witnessExpr, attributes, classItems); } - public static _INewtype create_Newtype(Dafny.ISequence name, Dafny.ISequence typeParams, DAST._IType @base, DAST._INewtypeRange range, Std.Wrappers._IOption constraint, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes, Dafny.ISequence classItems) { - return create(name, typeParams, @base, range, constraint, witnessStmts, witnessExpr, attributes, classItems); + public static _INewtype create_Newtype(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence typeParams, DAST._IType @base, DAST._INewtypeRange range, Std.Wrappers._IOption constraint, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes, Dafny.ISequence classItems) { + return create(name, docString, typeParams, @base, range, constraint, witnessStmts, witnessExpr, attributes, classItems); } public bool is_Newtype { get { return true; } } public Dafny.ISequence dtor_name { @@ -3343,6 +3404,11 @@ public Dafny.ISequence dtor_name { return this._name; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence dtor_typeParams { get { return this._typeParams; @@ -3452,6 +3518,7 @@ public Dafny.ISequence dtor_constraintStmts { public interface _ISynonymType { bool is_SynonymType { get; } Dafny.ISequence dtor_name { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence dtor_typeParams { get; } DAST._IType dtor_base { get; } Dafny.ISequence dtor_witnessStmts { get; } @@ -3461,13 +3528,15 @@ public interface _ISynonymType { } public class SynonymType : _ISynonymType { public readonly Dafny.ISequence _name; + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence _typeParams; public readonly DAST._IType _base; public readonly Dafny.ISequence _witnessStmts; public readonly Std.Wrappers._IOption _witnessExpr; public readonly Dafny.ISequence _attributes; - public SynonymType(Dafny.ISequence name, Dafny.ISequence typeParams, DAST._IType @base, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes) { + public SynonymType(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence typeParams, DAST._IType @base, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes) { this._name = name; + this._docString = docString; this._typeParams = typeParams; this._base = @base; this._witnessStmts = witnessStmts; @@ -3476,16 +3545,17 @@ public SynonymType(Dafny.ISequence name, Dafny.ISequence.Empty, Dafny.Sequence.Empty, DAST.Type.Default(), Dafny.Sequence.Empty, Std.Wrappers.Option.Default(), Dafny.Sequence.Empty); + private static readonly DAST._ISynonymType theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, DAST.Type.Default(), Dafny.Sequence.Empty, Std.Wrappers.Option.Default(), Dafny.Sequence.Empty); public static DAST._ISynonymType Default() { return theDefault; } @@ -3518,11 +3590,11 @@ public static DAST._ISynonymType Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _ISynonymType create(Dafny.ISequence name, Dafny.ISequence typeParams, DAST._IType @base, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes) { - return new SynonymType(name, typeParams, @base, witnessStmts, witnessExpr, attributes); + public static _ISynonymType create(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence typeParams, DAST._IType @base, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes) { + return new SynonymType(name, docString, typeParams, @base, witnessStmts, witnessExpr, attributes); } - public static _ISynonymType create_SynonymType(Dafny.ISequence name, Dafny.ISequence typeParams, DAST._IType @base, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes) { - return create(name, typeParams, @base, witnessStmts, witnessExpr, attributes); + public static _ISynonymType create_SynonymType(Dafny.ISequence name, Dafny.ISequence docString, Dafny.ISequence typeParams, DAST._IType @base, Dafny.ISequence witnessStmts, Std.Wrappers._IOption witnessExpr, Dafny.ISequence attributes) { + return create(name, docString, typeParams, @base, witnessStmts, witnessExpr, attributes); } public bool is_SynonymType { get { return true; } } public Dafny.ISequence dtor_name { @@ -3530,6 +3602,11 @@ public Dafny.ISequence dtor_name { return this._name; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence dtor_typeParams { get { return this._typeParams; @@ -3771,6 +3848,7 @@ public Dafny.ISequence dtor_attributes { public interface _IMethod { bool is_Method { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence dtor_attributes { get; } bool dtor_isStatic { get; } bool dtor_hasBody { get; } @@ -3786,6 +3864,7 @@ public interface _IMethod { _IMethod DowncastClone(); } public class Method : _IMethod { + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence _attributes; public readonly bool _isStatic; public readonly bool _hasBody; @@ -3798,7 +3877,8 @@ public class Method : _IMethod { public readonly Dafny.ISequence _body; public readonly Dafny.ISequence _outTypes; public readonly Std.Wrappers._IOption>> _outVars; - public Method(Dafny.ISequence attributes, bool isStatic, bool hasBody, bool outVarsAreUninitFieldsToAssign, bool wasFunction, Std.Wrappers._IOption>> overridingPath, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence @params, Dafny.ISequence body, Dafny.ISequence outTypes, Std.Wrappers._IOption>> outVars) { + public Method(Dafny.ISequence docString, Dafny.ISequence attributes, bool isStatic, bool hasBody, bool outVarsAreUninitFieldsToAssign, bool wasFunction, Std.Wrappers._IOption>> overridingPath, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence @params, Dafny.ISequence body, Dafny.ISequence outTypes, Std.Wrappers._IOption>> outVars) { + this._docString = docString; this._attributes = attributes; this._isStatic = isStatic; this._hasBody = hasBody; @@ -3814,15 +3894,16 @@ public Method(Dafny.ISequence attributes, bool isStatic, bool } public _IMethod DowncastClone() { if (this is _IMethod dt) { return dt; } - return new Method(_attributes, _isStatic, _hasBody, _outVarsAreUninitFieldsToAssign, _wasFunction, _overridingPath, _name, _typeParams, _params, _body, _outTypes, _outVars); + return new Method(_docString, _attributes, _isStatic, _hasBody, _outVarsAreUninitFieldsToAssign, _wasFunction, _overridingPath, _name, _typeParams, _params, _body, _outTypes, _outVars); } public override bool Equals(object other) { var oth = other as DAST.Method; - return oth != null && object.Equals(this._attributes, oth._attributes) && this._isStatic == oth._isStatic && this._hasBody == oth._hasBody && this._outVarsAreUninitFieldsToAssign == oth._outVarsAreUninitFieldsToAssign && this._wasFunction == oth._wasFunction && object.Equals(this._overridingPath, oth._overridingPath) && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._params, oth._params) && object.Equals(this._body, oth._body) && object.Equals(this._outTypes, oth._outTypes) && object.Equals(this._outVars, oth._outVars); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && this._isStatic == oth._isStatic && this._hasBody == oth._hasBody && this._outVarsAreUninitFieldsToAssign == oth._outVarsAreUninitFieldsToAssign && this._wasFunction == oth._wasFunction && object.Equals(this._overridingPath, oth._overridingPath) && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._params, oth._params) && object.Equals(this._body, oth._body) && object.Equals(this._outTypes, oth._outTypes) && object.Equals(this._outVars, oth._outVars); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._isStatic)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._hasBody)); @@ -3840,6 +3921,8 @@ public override int GetHashCode() { public override string ToString() { string s = "DAST.Method.Method"; s += "("; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._attributes); s += ", "; s += Dafny.Helpers.ToString(this._isStatic); @@ -3866,7 +3949,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly DAST._IMethod theDefault = create(Dafny.Sequence.Empty, false, false, false, false, Std.Wrappers.Option>>.Default(), Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Std.Wrappers.Option>>.Default()); + private static readonly DAST._IMethod theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, false, false, false, false, Std.Wrappers.Option>>.Default(), Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Std.Wrappers.Option>>.Default()); public static DAST._IMethod Default() { return theDefault; } @@ -3874,13 +3957,18 @@ public static DAST._IMethod Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IMethod create(Dafny.ISequence attributes, bool isStatic, bool hasBody, bool outVarsAreUninitFieldsToAssign, bool wasFunction, Std.Wrappers._IOption>> overridingPath, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence @params, Dafny.ISequence body, Dafny.ISequence outTypes, Std.Wrappers._IOption>> outVars) { - return new Method(attributes, isStatic, hasBody, outVarsAreUninitFieldsToAssign, wasFunction, overridingPath, name, typeParams, @params, body, outTypes, outVars); + public static _IMethod create(Dafny.ISequence docString, Dafny.ISequence attributes, bool isStatic, bool hasBody, bool outVarsAreUninitFieldsToAssign, bool wasFunction, Std.Wrappers._IOption>> overridingPath, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence @params, Dafny.ISequence body, Dafny.ISequence outTypes, Std.Wrappers._IOption>> outVars) { + return new Method(docString, attributes, isStatic, hasBody, outVarsAreUninitFieldsToAssign, wasFunction, overridingPath, name, typeParams, @params, body, outTypes, outVars); } - public static _IMethod create_Method(Dafny.ISequence attributes, bool isStatic, bool hasBody, bool outVarsAreUninitFieldsToAssign, bool wasFunction, Std.Wrappers._IOption>> overridingPath, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence @params, Dafny.ISequence body, Dafny.ISequence outTypes, Std.Wrappers._IOption>> outVars) { - return create(attributes, isStatic, hasBody, outVarsAreUninitFieldsToAssign, wasFunction, overridingPath, name, typeParams, @params, body, outTypes, outVars); + public static _IMethod create_Method(Dafny.ISequence docString, Dafny.ISequence attributes, bool isStatic, bool hasBody, bool outVarsAreUninitFieldsToAssign, bool wasFunction, Std.Wrappers._IOption>> overridingPath, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence @params, Dafny.ISequence body, Dafny.ISequence outTypes, Std.Wrappers._IOption>> outVars) { + return create(docString, attributes, isStatic, hasBody, outVarsAreUninitFieldsToAssign, wasFunction, overridingPath, name, typeParams, @params, body, outTypes, outVars); } public bool is_Method { get { return true; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence dtor_attributes { get { return this._attributes; diff --git a/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs b/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs index 2cb49767111..1cf2e5f77fd 100644 --- a/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs +++ b/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs @@ -83,7 +83,7 @@ public bool HasAttribute(Dafny.ISequence attributes, Dafny.ISe } else if ((_4_optExtern).is_UnsupportedExtern) { (this).error = Std.Wrappers.Option>.create_Some((_4_optExtern).dtor_reason); } - s = DafnyCompilerRustUtils.GatheringModule.MergeSeqMap(DafnyCompilerRustUtils.GatheringModule.Wrap(Defs.__default.ContainingPathToRust(_2_containingPath), RAST.Mod.create_Mod(_3_modName, _5_attributes, _6_body)), _7_allmodules); + s = DafnyCompilerRustUtils.GatheringModule.MergeSeqMap(DafnyCompilerRustUtils.GatheringModule.Wrap(Defs.__default.ContainingPathToRust(_2_containingPath), RAST.Mod.create_Mod((mod).dtor_docString, _5_attributes, _3_modName, _6_body)), _7_allmodules); } return s; } @@ -333,7 +333,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc } } if ((_7_traitType).is_GeneralTrait) { - _11_body = Dafny.Sequence.Concat(_11_body, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("_clone"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.Box(RAST.Type.create_DynType(_12_fullTraitPath))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(RAST.__default.BoxNew(((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("clone"))).Apply0())))))); + _11_body = Dafny.Sequence.Concat(_11_body, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("_clone"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.Box(RAST.Type.create_DynType(_12_fullTraitPath))), Std.Wrappers.Option.create_Some(RAST.__default.BoxNew(((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("clone"))).Apply0())))))); } else { if (((kind).Equals(Dafny.Sequence.UnicodeFromString("datatype"))) || ((kind).Equals(Dafny.Sequence.UnicodeFromString("newtype")))) { RAST._IExpr _15_dummy; @@ -352,7 +352,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc Dafny.ISequence _rhs1 = Dafny.Sequence.UnicodeFromString("UpcastStructBoxFn!"); _17_upcastTraitToImplement = _rhs0; _18_upcastTraitFn = _rhs1; - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("UpcastBox"))).AsType()).Apply1(RAST.Type.create_DynType(_12_fullTraitPath)), RAST.Type.create_TypeApp(_1_genSelfPath, rTypeParams), Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("upcast"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.Box(RAST.Type.create_DynType(_12_fullTraitPath))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((((_2_genPathExpr).ApplyType(rTypeParams)).FSel(Dafny.Sequence.UnicodeFromString("_clone"))).Apply1(RAST.__default.self))))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("UpcastBox"))).AsType()).Apply1(RAST.Type.create_DynType(_12_fullTraitPath)), RAST.Type.create_TypeApp(_1_genSelfPath, rTypeParams), Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("upcast"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.Box(RAST.Type.create_DynType(_12_fullTraitPath))), Std.Wrappers.Option.create_Some((((_2_genPathExpr).ApplyType(rTypeParams)).FSel(Dafny.Sequence.UnicodeFromString("_clone"))).Apply1(RAST.__default.self))))))))); } else { s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.dafny__runtime).MSel((this).Upcast)).AsType()).Apply(Dafny.Sequence.FromElements(RAST.Type.create_DynType(_12_fullTraitPath))), RAST.Type.create_TypeApp(_1_genSelfPath, rTypeParams), Dafny.Sequence.FromElements(RAST.ImplMember.create_ImplMemberMacro((((RAST.__default.dafny__runtime).MSel((this).UpcastFnMacro)).AsExpr()).Apply1(RAST.Expr.create_ExprFromType(RAST.Type.create_DynType(_12_fullTraitPath))))))))); } @@ -437,7 +437,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc _16_className = _out9; _17_extern = _out10; RAST._IStruct _18_struct; - _18_struct = RAST.Struct.create(Dafny.Sequence>.FromElements(), _16_className, _2_rTypeParamsDecls, RAST.Fields.create_NamedFields(_4_fields)); + _18_struct = RAST.Struct.create((c).dtor_docString, Dafny.Sequence>.FromElements(), _16_className, _2_rTypeParamsDecls, RAST.Fields.create_NamedFields(_4_fields)); s = Dafny.Sequence.FromElements(); if ((_17_extern).is_NoExtern) { s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_StructDecl(_18_struct))); @@ -450,7 +450,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc _19_implBody = _out11; _20_traitBodies = _out12; if (((_17_extern).is_NoExtern) && (!(_16_className).Equals(Dafny.Sequence.UnicodeFromString("_default")))) { - _19_implBody = Dafny.Sequence.Concat(Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PUB(), RAST.Fn.create((this).allocate__fn, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some((this).Object(RAST.__default.SelfOwned)), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(((((RAST.__default.dafny__runtime).MSel((this).allocate)).AsExpr()).ApplyType1(RAST.__default.SelfOwned)).Apply0())))), _19_implBody); + _19_implBody = Dafny.Sequence.Concat(Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(Dafny.Sequence.UnicodeFromString("Allocates an UNINITIALIZED instance. Only the Dafny compiler should use that."), RAST.__default.NoAttr, RAST.Visibility.create_PUB(), RAST.Fn.create((this).allocate__fn, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some((this).Object(RAST.__default.SelfOwned)), Std.Wrappers.Option.create_Some(((((RAST.__default.dafny__runtime).MSel((this).allocate)).AsExpr()).ApplyType1(RAST.__default.SelfOwned)).Apply0())))), _19_implBody); } RAST._IType _21_selfTypeForImpl = RAST.Type.Default(); if (((_17_extern).is_NoExtern) || ((_17_extern).is_UnsupportedExtern)) { @@ -480,7 +480,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc if (((this).HasAttribute((_25_m).dtor_attributes, Dafny.Sequence.UnicodeFromString("test"))) && ((new BigInteger(((_25_m).dtor_params).Count)).Sign == 0)) { Dafny.ISequence _27_fnName; _27_fnName = Defs.__default.escapeName((_25_m).dtor_name); - _23_testMethods = Dafny.Sequence.Concat(_23_testMethods, Dafny.Sequence.FromElements(RAST.ModDecl.create_TopFnDecl(RAST.TopFnDecl.create(Dafny.Sequence>.FromElements(Dafny.Sequence.UnicodeFromString("#[test]")), RAST.Visibility.create_PUB(), RAST.Fn.create(_27_fnName, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_None(), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_default"))).FSel(_27_fnName)).Apply(Dafny.Sequence.FromElements()))))))); + _23_testMethods = Dafny.Sequence.Concat(_23_testMethods, Dafny.Sequence.FromElements(RAST.ModDecl.create_TopFnDecl(RAST.TopFnDecl.create((_25_m).dtor_docString, Dafny.Sequence>.FromElements(Dafny.Sequence.UnicodeFromString("#[test]")), RAST.Visibility.create_PUB(), RAST.Fn.create(_27_fnName, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_default"))).FSel(_27_fnName)).Apply(Dafny.Sequence.FromElements()))))))); } } s = Dafny.Sequence.Concat(s, _23_testMethods); @@ -551,7 +551,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc _12_implBody = _out3; _13___v5 = _out4; if (((t).dtor_traitType).is_GeneralTrait) { - _12_implBody = Dafny.Sequence.Concat(_12_implBody, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("_clone"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.Box(RAST.Type.create_DynType(_10_traitFulltype))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_None())))); + _12_implBody = Dafny.Sequence.Concat(_12_implBody, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("_clone"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.Box(RAST.Type.create_DynType(_10_traitFulltype))), Std.Wrappers.Option.create_None())))); } Dafny.ISequence _14_parents; _14_parents = Dafny.Sequence.FromElements(); @@ -574,12 +574,12 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc } _14_parents = Dafny.Sequence.Concat(_14_parents, Dafny.Sequence.FromElements((((RAST.__default.dafny__runtime).MSel(_19_upcastTrait)).AsType()).Apply1(RAST.Type.create_DynType(_18_parentTpe)))); if ((_17_parentTyp).IsGeneralTrait()) { - _15_upcastImplemented = Dafny.Sequence.Concat(_15_upcastImplemented, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_1_rTypeParamsDecls, (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("UpcastBox"))).AsType()).Apply1(RAST.Type.create_DynType(_18_parentTpe)), RAST.__default.Box(RAST.Type.create_DynType(_10_traitFulltype)), Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("upcast"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.Box(RAST.Type.create_DynType(_18_parentTpe))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(((_11_traitFullExpr).FSel(Dafny.Sequence.UnicodeFromString("_clone"))).Apply1(((RAST.__default.self).FSel(Dafny.Sequence.UnicodeFromString("as_ref"))).Apply0()))))))))); + _15_upcastImplemented = Dafny.Sequence.Concat(_15_upcastImplemented, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_1_rTypeParamsDecls, (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("UpcastBox"))).AsType()).Apply1(RAST.Type.create_DynType(_18_parentTpe)), RAST.__default.Box(RAST.Type.create_DynType(_10_traitFulltype)), Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("upcast"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.Box(RAST.Type.create_DynType(_18_parentTpe))), Std.Wrappers.Option.create_Some(((_11_traitFullExpr).FSel(Dafny.Sequence.UnicodeFromString("_clone"))).Apply1(((RAST.__default.self).FSel(Dafny.Sequence.UnicodeFromString("as_ref"))).Apply0()))))))))); } } - s = Dafny.Sequence.FromElements(RAST.ModDecl.create_TraitDecl(RAST.Trait.create(_1_rTypeParamsDecls, _10_traitFulltype, _14_parents, _12_implBody))); + s = Dafny.Sequence.FromElements(RAST.ModDecl.create_TraitDecl(RAST.Trait.create((t).dtor_docString, Dafny.Sequence>.FromElements(), _1_rTypeParamsDecls, _10_traitFulltype, _14_parents, _12_implBody))); if (((t).dtor_traitType).is_GeneralTrait) { - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_1_rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("clone"))).MSel(Dafny.Sequence.UnicodeFromString("Clone"))).AsType(), RAST.__default.Box(RAST.Type.create_DynType(_10_traitFulltype)), Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("clone"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.SelfOwned), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(((_11_traitFullExpr).FSel(Dafny.Sequence.UnicodeFromString("_clone"))).Apply1(((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("as_ref"))).Apply0()))))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_1_rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("clone"))).MSel(Dafny.Sequence.UnicodeFromString("Clone"))).AsType(), RAST.__default.Box(RAST.Type.create_DynType(_10_traitFulltype)), Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("clone"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.SelfOwned), Std.Wrappers.Option.create_Some(((_11_traitFullExpr).FSel(Dafny.Sequence.UnicodeFromString("_clone"))).Apply1(((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("as_ref"))).Apply0()))))))))); } s = Dafny.Sequence.Concat(s, _15_upcastImplemented); return s; @@ -621,7 +621,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc } else { _9_attributes = Dafny.Sequence.UnicodeFromString("#[derive(Clone, PartialEq)]"); } - s = Dafny.Sequence.FromElements(RAST.ModDecl.create_StructDecl(RAST.Struct.create(Dafny.Sequence>.FromElements(_9_attributes, Dafny.Sequence.UnicodeFromString("#[repr(transparent)]")), _7_newtypeName, _2_rTypeParamsDecls, RAST.Fields.create_NamelessFields(Dafny.Sequence.FromElements(RAST.NamelessField.create(RAST.Visibility.create_PUB(), _4_wrappedType)))))); + s = Dafny.Sequence.FromElements(RAST.ModDecl.create_StructDecl(RAST.Struct.create((c).dtor_docString, Dafny.Sequence>.FromElements(_9_attributes, Dafny.Sequence.UnicodeFromString("#[repr(transparent)]")), _7_newtypeName, _2_rTypeParamsDecls, RAST.Fields.create_NamelessFields(Dafny.Sequence.FromElements(RAST.NamelessField.create(RAST.Visibility.create_PUB(), _4_wrappedType)))))); RAST._IExpr _10_fnBody = RAST.Expr.Default(); Std.Wrappers._IOption _source0 = (c).dtor_witnessExpr; { @@ -652,7 +652,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc } after_match0: ; RAST._IImplMember _16_body; - _16_body = RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("default"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some(RAST.__default.SelfOwned), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(_10_fnBody))); + _16_body = RAST.ImplMember.create_FnDecl(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("An element of "), _7_newtypeName), Dafny.Sequence>.FromElements(), RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("default"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some(RAST.__default.SelfOwned), Std.Wrappers.Option.create_Some(_10_fnBody))); Std.Wrappers._IOption _source1 = (c).dtor_constraint; { if (_source1.is_None) { @@ -677,13 +677,13 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc Dafny.ISequence _out10; _out10 = (this).GenParams(Dafny.Sequence.FromElements(_17_formal), false); _22_rFormals = _out10; - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(_2_rTypeParamsDecls, _8_resultingType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PUB(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("is"), Dafny.Sequence.FromElements(), _22_rFormals, Std.Wrappers.Option.create_Some(RAST.Type.create_Bool()), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(_19_rStmts)))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(_2_rTypeParamsDecls, _8_resultingType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(Dafny.Sequence.UnicodeFromString("Constraint check"), RAST.__default.NoAttr, RAST.Visibility.create_PUB(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("is"), Dafny.Sequence.FromElements(), _22_rFormals, Std.Wrappers.Option.create_Some(RAST.Type.create_Bool()), Std.Wrappers.Option.create_Some(_19_rStmts)))))))); } after_match1: ; s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, RAST.__default.DefaultTrait, _8_resultingType, Dafny.Sequence.FromElements(_16_body))))); - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, RAST.__default.DafnyPrint, _8_resultingType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("fmt_print"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("_formatter"), RAST.Type.create_BorrowedMut((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Formatter"))).AsType())), RAST.Formal.create(Dafny.Sequence.UnicodeFromString("in_seq"), RAST.Type.create_Bool())), Std.Wrappers.Option.create_Some((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Result"))).AsType()), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyPrint"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("fmt_print"))).Apply(Dafny.Sequence.FromElements(RAST.__default.Borrow((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0"))), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_formatter")), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("in_seq")))))))))))); - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("ops"))).MSel(Dafny.Sequence.UnicodeFromString("Deref"))).AsType(), _8_resultingType, Dafny.Sequence.FromElements(RAST.ImplMember.create_TypeDeclMember(Dafny.Sequence.UnicodeFromString("Target"), _4_wrappedType), RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("deref"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.Type.create_Borrowed(((RAST.Path.create_Self()).MSel(Dafny.Sequence.UnicodeFromString("Target"))).AsType())), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(RAST.__default.Borrow((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0"))))))))))); - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(_2_rTypeParamsDecls, _8_resultingType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PUB(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("_from_ref"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.create(Dafny.Sequence.UnicodeFromString("o"), RAST.Type.create_Borrowed(_4_wrappedType))), Std.Wrappers.Option.create_Some(RAST.Type.create_Borrowed((RAST.Path.create_Self()).AsType())), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(RAST.__default.Unsafe(RAST.Expr.create_Block(((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("mem"))).MSel(Dafny.Sequence.UnicodeFromString("transmute"))).AsExpr()).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("o"))))))))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, RAST.__default.DafnyPrint, _8_resultingType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(Dafny.Sequence.UnicodeFromString("For Dafny print statements"), RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("fmt_print"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("_formatter"), RAST.Type.create_BorrowedMut((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Formatter"))).AsType())), RAST.Formal.create(Dafny.Sequence.UnicodeFromString("in_seq"), RAST.Type.create_Bool())), Std.Wrappers.Option.create_Some((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Result"))).AsType()), Std.Wrappers.Option.create_Some(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyPrint"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("fmt_print"))).Apply(Dafny.Sequence.FromElements(RAST.__default.Borrow((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0"))), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_formatter")), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("in_seq")))))))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("ops"))).MSel(Dafny.Sequence.UnicodeFromString("Deref"))).AsType(), _8_resultingType, Dafny.Sequence.FromElements(RAST.ImplMember.create_TypeDeclMember(Dafny.Sequence.UnicodeFromString("Target"), _4_wrappedType), RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("deref"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.Type.create_Borrowed(((RAST.Path.create_Self()).MSel(Dafny.Sequence.UnicodeFromString("Target"))).AsType())), Std.Wrappers.Option.create_Some(RAST.__default.Borrow((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0"))))))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(_2_rTypeParamsDecls, _8_resultingType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(Dafny.Sequence.UnicodeFromString("SAFETY: The newtype is marked as transparent"), RAST.__default.NoAttr, RAST.Visibility.create_PUB(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("_from_ref"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.create(Dafny.Sequence.UnicodeFromString("o"), RAST.Type.create_Borrowed(_4_wrappedType))), Std.Wrappers.Option.create_Some(RAST.Type.create_Borrowed((RAST.Path.create_Self()).AsType())), Std.Wrappers.Option.create_Some(RAST.__default.Unsafe(RAST.Expr.create_Block(((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("mem"))).MSel(Dafny.Sequence.UnicodeFromString("transmute"))).AsExpr()).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("o"))))))))))))); Dafny.ISequence _23_rTypeParamsDeclsWithHash; _23_rTypeParamsDeclsWithHash = RAST.TypeParamDecl.AddConstraintsMultiple(_2_rTypeParamsDecls, Dafny.Sequence.FromElements(RAST.__default.Hash)); s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(Defs.__default.HashImpl(_23_rTypeParamsDeclsWithHash, _8_resultingType, (((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("self"))).Sel(Dafny.Sequence.UnicodeFromString("0"))).Sel(Dafny.Sequence.UnicodeFromString("hash"))).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_state")))))); @@ -727,7 +727,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc RAST._IType _out3; _out3 = (this).GenType((c).dtor_base, Defs.GenTypeContext.@default()); _4_resultingType = _out3; - s = Dafny.Sequence.FromElements(RAST.ModDecl.create_TypeDecl(RAST.TypeSynonym.create(Dafny.Sequence>.FromElements(), _3_synonymTypeName, _2_rTypeParamsDecls, _4_resultingType))); + s = Dafny.Sequence.FromElements(RAST.ModDecl.create_TypeDecl(RAST.TypeSynonym.create((c).dtor_docString, Dafny.Sequence>.FromElements(), _3_synonymTypeName, _2_rTypeParamsDecls, _4_resultingType))); Dafny.ISequence _5_defaultConstrainedTypeParams; _5_defaultConstrainedTypeParams = RAST.TypeParamDecl.AddConstraintsMultiple(_2_rTypeParamsDecls, Dafny.Sequence.FromElements(RAST.__default.DefaultTrait)); Std.Wrappers._IOption _source0 = (c).dtor_witnessExpr; @@ -757,7 +757,7 @@ public void GetName(Dafny.ISequence attributes, Dafny.ISequenc _12___v11 = _out9; Dafny.ISequence _13_constantName; _13_constantName = Defs.__default.escapeName(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_init_"), ((c).dtor_name))); - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_TopFnDecl(RAST.TopFnDecl.create(Dafny.Sequence>.FromElements(), RAST.Visibility.create_PUB(), RAST.Fn.create(_13_constantName, _5_defaultConstrainedTypeParams, Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some(_4_resultingType), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((_7_rStmts).Then(_10_rExpr))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_TopFnDecl(RAST.TopFnDecl.create(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("An element of "), _3_synonymTypeName), Dafny.Sequence>.FromElements(), RAST.Visibility.create_PUB(), RAST.Fn.create(_13_constantName, _5_defaultConstrainedTypeParams, Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some(_4_resultingType), Std.Wrappers.Option.create_Some((_7_rStmts).Then(_10_rExpr))))))); } goto after_match0; } @@ -949,7 +949,7 @@ public RAST._IExpr writeStr(Dafny.ISequence s, bool final) if (_13_isNumeric) { _19_namedFields = (_19_namedFields).ToNamelessFields(); } - _5_ctors = Dafny.Sequence.Concat(_5_ctors, Dafny.Sequence.FromElements(RAST.EnumCase.create(Defs.__default.escapeName((_11_ctor).dtor_name), _19_namedFields))); + _5_ctors = Dafny.Sequence.Concat(_5_ctors, Dafny.Sequence.FromElements(RAST.EnumCase.create((_11_ctor).dtor_docString, Defs.__default.escapeName((_11_ctor).dtor_name), _19_namedFields))); } Dafny.ISet> _20_unusedTypeParams; _20_unusedTypeParams = Dafny.Set>.Difference(Dafny.Helpers.Id, Dafny.ISet>>>((_21_rTypeParamsDecls) => ((System.Func>>)(() => { @@ -1046,7 +1046,7 @@ public RAST._IExpr writeStr(Dafny.ISequence s, bool final) } RAST._IExpr _46_methodBody; _46_methodBody = RAST.Expr.create_Match(RAST.__default.self, _34_cases); - _26_implBody = Dafny.Sequence.Concat(_26_implBody, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PUB(), RAST.Fn.create(_32_callName, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.Type.create_Borrowed(_33_formalType)), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(_46_methodBody))))); + _26_implBody = Dafny.Sequence.Concat(_26_implBody, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl((((new BigInteger(((c).dtor_ctors).Count)) == (BigInteger.One)) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Returns a borrow of the field "), _32_callName)) : (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Gets the field "), _32_callName), Dafny.Sequence.UnicodeFromString(" for all enum members which have it")))), Dafny.Sequence>.FromElements(), RAST.Visibility.create_PUB(), RAST.Fn.create(_32_callName, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.Type.create_Borrowed(_33_formalType)), Std.Wrappers.Option.create_Some(_46_methodBody))))); } } } @@ -1112,14 +1112,14 @@ public RAST._IExpr writeStr(Dafny.ISequence s, bool final) } after_2_0: ; if ((new BigInteger((_20_unusedTypeParams).Count)).Sign == 1) { - _5_ctors = Dafny.Sequence.Concat(_5_ctors, Dafny.Sequence.FromElements(RAST.EnumCase.create(Dafny.Sequence.UnicodeFromString("_PhantomVariant"), RAST.Fields.create_NamelessFields(Std.Collections.Seq.__default.Map(((System.Func)((_66_tpe) => { + _5_ctors = Dafny.Sequence.Concat(_5_ctors, Dafny.Sequence.FromElements(RAST.EnumCase.create(Dafny.Sequence.UnicodeFromString(""), Dafny.Sequence.UnicodeFromString("_PhantomVariant"), RAST.Fields.create_NamelessFields(Std.Collections.Seq.__default.Map(((System.Func)((_66_tpe) => { return RAST.NamelessField.create(RAST.Visibility.create_PRIV(), _66_tpe); })), _53_types))))); } } bool _67_cIsEq; _67_cIsEq = (this).DatatypeIsEq(c); - s = Dafny.Sequence.FromElements(RAST.ModDecl.create_EnumDecl(RAST.Enum.create(((_67_cIsEq) ? (Dafny.Sequence>.FromElements(Dafny.Sequence.UnicodeFromString("#[derive(PartialEq, Clone)]"))) : (Dafny.Sequence>.FromElements(Dafny.Sequence.UnicodeFromString("#[derive(Clone)]")))), _3_datatypeName, _2_rTypeParamsDecls, _5_ctors)), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(_2_rTypeParamsDecls, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_3_datatypeName), _1_rTypeParams), _26_implBody))); + s = Dafny.Sequence.FromElements(RAST.ModDecl.create_EnumDecl(RAST.Enum.create((c).dtor_docString, ((_67_cIsEq) ? (Dafny.Sequence>.FromElements(Dafny.Sequence.UnicodeFromString("#[derive(PartialEq, Clone)]"))) : (Dafny.Sequence>.FromElements(Dafny.Sequence.UnicodeFromString("#[derive(Clone)]")))), _3_datatypeName, _2_rTypeParamsDecls, _5_ctors)), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(_2_rTypeParamsDecls, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_3_datatypeName), _1_rTypeParams), _26_implBody))); Dafny.ISequence _68_printImplBodyCases; _68_printImplBodyCases = Dafny.Sequence.FromElements(); Dafny.ISequence _69_hashImplBodyCases; @@ -1262,20 +1262,18 @@ public RAST._IExpr writeStr(Dafny.ISequence s, bool final) _104_dtor = ((((c).dtor_ctors).Select(BigInteger.Zero)).dtor_args).Select(_103_i); _102_structAssignments = Dafny.Sequence.Concat(_102_structAssignments, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(Defs.__default.escapeVar(((_104_dtor).dtor_formal).dtor_name), (((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("default"))).MSel(Dafny.Sequence.UnicodeFromString("Default"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("default"))).Apply0()))); } - Dafny.ISequence _105_defaultConstrainedTypeParams; - _105_defaultConstrainedTypeParams = RAST.TypeParamDecl.AddConstraintsMultiple(_2_rTypeParamsDecls, Dafny.Sequence.FromElements(RAST.__default.DefaultTrait)); - RAST._IType _106_fullType; - _106_fullType = RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_3_datatypeName), _1_rTypeParams); + RAST._IType _105_fullType; + _105_fullType = RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_3_datatypeName), _1_rTypeParams); if (_67_cIsEq) { - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_105_defaultConstrainedTypeParams, RAST.__default.DefaultTrait, _106_fullType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("default"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some(_106_fullType), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(RAST.Expr.create_StructBuild(_101_structName, _102_structAssignments))))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(Defs.__default.DefaultDatatypeImpl(_2_rTypeParamsDecls, _105_fullType, _101_structName, _102_structAssignments))); } - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, ((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("convert"))).MSel(Dafny.Sequence.UnicodeFromString("AsRef"))).AsType()).Apply1(_106_fullType), _106_fullType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("as_ref"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.SelfBorrowed), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(RAST.__default.self)))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(Defs.__default.AsRefDatatypeImpl(_2_rTypeParamsDecls, _105_fullType))); } - Dafny.ISequence _107_superTraitImplementations; + Dafny.ISequence _106_superTraitImplementations; Dafny.ISequence _out16; _out16 = (this).GenTraitImplementations(path, _1_rTypeParams, _2_rTypeParamsDecls, (c).dtor_superTraitTypes, _25_traitBodies, _4_extern, Dafny.Sequence.UnicodeFromString("datatype")); - _107_superTraitImplementations = _out16; - s = Dafny.Sequence.Concat(s, _107_superTraitImplementations); + _106_superTraitImplementations = _out16; + s = Dafny.Sequence.Concat(s, _106_superTraitImplementations); return s; } public RAST._IPath GenPath(Dafny.ISequence> p, bool escape) @@ -1985,7 +1983,7 @@ public RAST._IImplMember GenMethod(DAST._IMethod m, bool forTrait, DAST._IType e _32_env = Defs.Environment.create(_1_paramNames, _2_paramTypes, Dafny.Set>.FromElements()); _31_fBody = Std.Wrappers.Option.create_None(); } - s = RAST.ImplMember.create_FnDecl(_21_visibility, RAST.Fn.create(_7_fnName, _25_typeParams, _0_params, Std.Wrappers.Option.create_Some((((new BigInteger((_18_retTypeArgs).Count)) == (BigInteger.One)) ? ((_18_retTypeArgs).Select(BigInteger.Zero)) : (RAST.Type.create_TupleType(_18_retTypeArgs)))), Dafny.Sequence.UnicodeFromString(""), _31_fBody)); + s = RAST.ImplMember.create_FnDecl((m).dtor_docString, RAST.__default.NoAttr, _21_visibility, RAST.Fn.create(_7_fnName, _25_typeParams, _0_params, Std.Wrappers.Option.create_Some((((new BigInteger((_18_retTypeArgs).Count)) == (BigInteger.One)) ? ((_18_retTypeArgs).Select(BigInteger.Zero)) : (RAST.Type.create_TupleType(_18_retTypeArgs)))), _31_fBody)); return s; } public void GenStmts(Dafny.ISequence stmts, Defs._ISelfInfo selfIdent, Defs._IEnvironment env, bool isLast, Std.Wrappers._IOption>> earlyReturn, out RAST._IExpr generated, out Dafny.ISet> readIdents, out Defs._IEnvironment newEnv) @@ -6741,7 +6739,7 @@ public RAST._IExpr Error(Dafny.ISequence message, RAST._IExpr defaul _0_externUseDecls = Dafny.Sequence.Concat(_0_externUseDecls, Dafny.Sequence.FromElements(RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), ((RAST.__default.crate).MSel(_3_externalMod)).MSel(Dafny.Sequence.UnicodeFromString("*")))))); } if (!(_0_externUseDecls).Equals(Dafny.Sequence.FromElements())) { - s = Dafny.Sequence.Concat(Dafny.Sequence.Concat(s, (RAST.Mod.create_Mod(Defs.__default.DAFNY__EXTERN__MODULE, Dafny.Sequence>.FromElements(), _0_externUseDecls))._ToString(Dafny.Sequence.UnicodeFromString(""))), Dafny.Sequence.UnicodeFromString("\n")); + s = Dafny.Sequence.Concat(Dafny.Sequence.Concat(s, (RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString("Flattens all imported externs so that they can be accessed from this module"), Dafny.Sequence>.FromElements(), Defs.__default.DAFNY__EXTERN__MODULE, _0_externUseDecls))._ToString(Dafny.Sequence.UnicodeFromString(""))), Dafny.Sequence.UnicodeFromString("\n")); } DafnyCompilerRustUtils._ISeqMap, DafnyCompilerRustUtils._IGatheringModule> _5_allModules; _5_allModules = DafnyCompilerRustUtils.SeqMap, DafnyCompilerRustUtils._IGatheringModule>.Empty(); diff --git a/Source/DafnyCore/GeneratedFromDafny/DafnyCompilerRustUtils.cs b/Source/DafnyCore/GeneratedFromDafny/DafnyCompilerRustUtils.cs index 126e270a319..061db1db0df 100644 --- a/Source/DafnyCore/GeneratedFromDafny/DafnyCompilerRustUtils.cs +++ b/Source/DafnyCore/GeneratedFromDafny/DafnyCompilerRustUtils.cs @@ -228,7 +228,7 @@ public DafnyCompilerRustUtils._IGatheringModule Merge(DafnyCompilerRustUtils._IG } else if (!((m2).is_GatheringModule)) { return this; } else { - return DafnyCompilerRustUtils.GatheringModule.create_GatheringModule(RAST.Mod.create_Mod(((this).dtor_existingMod).dtor_name, ((this).dtor_existingMod).dtor_attributes, Dafny.Sequence.Concat(((this).dtor_existingMod).dtor_body, ((m2).dtor_existingMod).dtor_body)), DafnyCompilerRustUtils.GatheringModule.MergeSeqMap((this).dtor_submodules, (m2).dtor_submodules)); + return DafnyCompilerRustUtils.GatheringModule.create_GatheringModule(RAST.Mod.create_Mod(Dafny.Sequence.Concat(((this).dtor_existingMod).dtor_docString, ((m2).dtor_existingMod).dtor_docString), ((this).dtor_existingMod).dtor_attributes, ((this).dtor_existingMod).dtor_name, Dafny.Sequence.Concat(((this).dtor_existingMod).dtor_body, ((m2).dtor_existingMod).dtor_body)), DafnyCompilerRustUtils.GatheringModule.MergeSeqMap((this).dtor_submodules, (m2).dtor_submodules)); } } public static DafnyCompilerRustUtils._ISeqMap, DafnyCompilerRustUtils._IGatheringModule> Wrap(Dafny.ISequence> containingPath, RAST._IMod rawDecl) @@ -242,7 +242,7 @@ public DafnyCompilerRustUtils._IGatheringModule Merge(DafnyCompilerRustUtils._IG } } else { Dafny.ISequence _1_enclosingModule = (containingPath).Select(BigInteger.Zero); - return DafnyCompilerRustUtils.SeqMap, DafnyCompilerRustUtils._IGatheringModule>.Single(_1_enclosingModule, DafnyCompilerRustUtils.GatheringModule.create_GatheringModule(RAST.Mod.create_Mod(_1_enclosingModule, Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements()), DafnyCompilerRustUtils.GatheringModule.Wrap((containingPath).Drop(BigInteger.One), rawDecl))); + return DafnyCompilerRustUtils.SeqMap, DafnyCompilerRustUtils._IGatheringModule>.Single(_1_enclosingModule, DafnyCompilerRustUtils.GatheringModule.create_GatheringModule(RAST.Mod.create_Mod(Dafny.Sequence.UnicodeFromString(""), Dafny.Sequence>.FromElements(), _1_enclosingModule, Dafny.Sequence.FromElements()), DafnyCompilerRustUtils.GatheringModule.Wrap((containingPath).Drop(BigInteger.One), rawDecl))); } } public RAST._IMod ToRust() { @@ -262,7 +262,7 @@ public RAST._IMod ToRust() { } return Dafny.Sequence.FromArray(arr13); }))()); - return RAST.Mod.create_Mod((_2_dt__update__tmp_h0).dtor_name, (_2_dt__update__tmp_h0).dtor_attributes, _3_dt__update_hbody_h0); + return RAST.Mod.create_Mod((_2_dt__update__tmp_h0).dtor_docString, (_2_dt__update__tmp_h0).dtor_attributes, (_2_dt__update__tmp_h0).dtor_name, _3_dt__update_hbody_h0); } } } diff --git a/Source/DafnyCore/GeneratedFromDafny/Defs.cs b/Source/DafnyCore/GeneratedFromDafny/Defs.cs index 8dd213c96bd..2e190842a7a 100644 --- a/Source/DafnyCore/GeneratedFromDafny/Defs.cs +++ b/Source/DafnyCore/GeneratedFromDafny/Defs.cs @@ -468,25 +468,34 @@ public static RAST._IExpr UnreachablePanicIfVerified(Defs._IPointerType pointerT return (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("panic!"))).Apply1(RAST.Expr.create_LiteralString(optText, false, false)); } } + public static RAST._IModDecl DefaultDatatypeImpl(Dafny.ISequence rTypeParamsDecls, RAST._IType datatypeType, RAST._IExpr datatypeName, Dafny.ISequence structAssignments) + { + Dafny.ISequence _0_defaultConstrainedTypeParams = RAST.TypeParamDecl.AddConstraintsMultiple(rTypeParamsDecls, Dafny.Sequence.FromElements(RAST.__default.DefaultTrait)); + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_0_defaultConstrainedTypeParams, RAST.__default.DefaultTrait, datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("default"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some(datatypeType), Std.Wrappers.Option.create_Some(RAST.Expr.create_StructBuild(datatypeName, structAssignments))))))); + } + public static RAST._IModDecl AsRefDatatypeImpl(Dafny.ISequence rTypeParamsDecls, RAST._IType datatypeType) + { + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, ((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("convert"))).MSel(Dafny.Sequence.UnicodeFromString("AsRef"))).AsType()).Apply1(datatypeType), datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("as_ref"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.SelfBorrowed), Std.Wrappers.Option.create_Some(RAST.__default.self)))))); + } public static RAST._IModDecl DebugImpl(Dafny.ISequence rTypeParamsDecls, RAST._IType datatypeType, Dafny.ISequence rTypeParams) { - return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Debug"))).AsType(), datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("fmt"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("f"), RAST.Type.create_BorrowedMut((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Formatter"))).AsType()))), Std.Wrappers.Option.create_Some((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Result"))).AsType()), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyPrint"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("fmt_print"))).Apply(Dafny.Sequence.FromElements(RAST.__default.self, RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("f")), RAST.Expr.create_LiteralBool(true))))))))); + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Debug"))).AsType(), datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("fmt"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("f"), RAST.Type.create_BorrowedMut((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Formatter"))).AsType()))), Std.Wrappers.Option.create_Some((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Result"))).AsType()), Std.Wrappers.Option.create_Some(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyPrint"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("fmt_print"))).Apply(Dafny.Sequence.FromElements(RAST.__default.self, RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("f")), RAST.Expr.create_LiteralBool(true))))))))); } public static RAST._IModDecl PrintImpl(Dafny.ISequence rTypeParamsDecls, RAST._IType datatypeType, Dafny.ISequence rTypeParams, RAST._IExpr printImplBody) { - return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, RAST.__default.DafnyPrint, datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("fmt_print"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("_formatter"), RAST.Type.create_BorrowedMut((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Formatter"))).AsType())), RAST.Formal.create(Dafny.Sequence.UnicodeFromString("_in_seq"), RAST.Type.create_Bool())), Std.Wrappers.Option.create_Some(RAST.__default.RawType(Dafny.Sequence.UnicodeFromString("std::fmt::Result"))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(printImplBody)))))); + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, RAST.__default.DafnyPrint, datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("fmt_print"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("_formatter"), RAST.Type.create_BorrowedMut((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Formatter"))).AsType())), RAST.Formal.create(Dafny.Sequence.UnicodeFromString("_in_seq"), RAST.Type.create_Bool())), Std.Wrappers.Option.create_Some(RAST.__default.RawType(Dafny.Sequence.UnicodeFromString("std::fmt::Result"))), Std.Wrappers.Option.create_Some(printImplBody)))))); } public static RAST._IModDecl CoerceImpl(Dafny.ISequence rTypeParamsDecls, Dafny.ISequence datatypeName, RAST._IType datatypeType, Dafny.ISequence rCoerceTypeParams, Dafny.ISequence coerceArguments, Dafny.ISequence coerceTypes, RAST._IExpr coerceImplBody) { - return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(rTypeParamsDecls, datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PUB(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("coerce"), rCoerceTypeParams, coerceArguments, Std.Wrappers.Option.create_Some(RAST.__default.Rc(RAST.Type.create_ImplType(RAST.Type.create_FnType(Dafny.Sequence.FromElements(datatypeType), RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(datatypeName), coerceTypes))))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(RAST.__default.RcNew(RAST.Expr.create_Lambda(Dafny.Sequence.FromElements(RAST.Formal.create(Dafny.Sequence.UnicodeFromString("this"), RAST.__default.SelfOwned)), Std.Wrappers.Option.create_Some(RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(datatypeName), coerceTypes)), coerceImplBody)))))))); + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(rTypeParamsDecls, datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(Dafny.Sequence.UnicodeFromString("Given type parameter conversions, returns a lambda to convert this structure"), RAST.__default.NoAttr, RAST.Visibility.create_PUB(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("coerce"), rCoerceTypeParams, coerceArguments, Std.Wrappers.Option.create_Some(RAST.__default.Rc(RAST.Type.create_ImplType(RAST.Type.create_FnType(Dafny.Sequence.FromElements(datatypeType), RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(datatypeName), coerceTypes))))), Std.Wrappers.Option.create_Some(RAST.__default.RcNew(RAST.Expr.create_Lambda(Dafny.Sequence.FromElements(RAST.Formal.create(Dafny.Sequence.UnicodeFromString("this"), RAST.__default.SelfOwned)), Std.Wrappers.Option.create_Some(RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(datatypeName), coerceTypes)), coerceImplBody)))))))); } public static RAST._IModDecl SingletonsImpl(Dafny.ISequence rTypeParamsDecls, RAST._IType datatypeType, RAST._IType instantiationType, Dafny.ISequence singletonConstructors) { - return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(rTypeParamsDecls, datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PUB(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("_AllSingletonConstructors"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("SequenceIter"))).AsType()).Apply(Dafny.Sequence.FromElements(instantiationType))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("seq!"))).AsExpr()).Apply(singletonConstructors)).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply0())))))); + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(rTypeParamsDecls, datatypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Enumerates all possible values of "), (datatypeType)._ToString(Dafny.Sequence.UnicodeFromString(""))), Dafny.Sequence>.FromElements(), RAST.Visibility.create_PUB(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("_AllSingletonConstructors"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("SequenceIter"))).AsType()).Apply(Dafny.Sequence.FromElements(instantiationType))), Std.Wrappers.Option.create_Some((((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("seq!"))).AsExpr()).Apply(singletonConstructors)).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply0())))))); } public static RAST._IModDecl HashImpl(Dafny.ISequence rTypeParamsDeclsWithHash, RAST._IType datatypeOrNewtypeType, RAST._IExpr hashImplBody) { - return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDeclsWithHash, RAST.__default.Hash, datatypeOrNewtypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("hash"), Dafny.Sequence.FromElements(RAST.TypeParamDecl.create(Dafny.Sequence.UnicodeFromString("_H"), Dafny.Sequence.FromElements((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("hash"))).MSel(Dafny.Sequence.UnicodeFromString("Hasher"))).AsType()))), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("_state"), RAST.Type.create_BorrowedMut(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("_H"))))), Std.Wrappers.Option.create_None(), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(hashImplBody)))))); + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDeclsWithHash, RAST.__default.Hash, datatypeOrNewtypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("hash"), Dafny.Sequence.FromElements(RAST.TypeParamDecl.create(Dafny.Sequence.UnicodeFromString("_H"), Dafny.Sequence.FromElements((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("hash"))).MSel(Dafny.Sequence.UnicodeFromString("Hasher"))).AsType()))), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("_state"), RAST.Type.create_BorrowedMut(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("_H"))))), Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(hashImplBody)))))); } public static RAST._IModDecl UnaryOpsImpl(Dafny.Rune op, Dafny.ISequence rTypeParamsDecls, RAST._IType newtypeType, Dafny.ISequence newtypeConstructor) { @@ -498,7 +507,7 @@ public static RAST._IModDecl UnaryOpsImpl(Dafny.Rune op, Dafny.ISequence _0_traitName = _let_tmp_rhs0.dtor__0; Dafny.ISequence _1_methodName = _let_tmp_rhs0.dtor__1; - return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("ops"))).MSel(_0_traitName)).AsType(), newtypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_TypeDeclMember(Dafny.Sequence.UnicodeFromString("Output"), newtypeType), RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(_1_methodName, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfOwned), Std.Wrappers.Option.create_Some(RAST.__default.SelfOwned), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((RAST.Expr.create_Identifier(newtypeConstructor)).Apply1(RAST.Expr.create_UnaryOp(Dafny.Sequence.FromElements(op), (RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0")), DAST.Format.UnaryOpFormat.create_NoFormat())))))))); + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("ops"))).MSel(_0_traitName)).AsType(), newtypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_TypeDeclMember(Dafny.Sequence.UnicodeFromString("Output"), newtypeType), RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(_1_methodName, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfOwned), Std.Wrappers.Option.create_Some(RAST.__default.SelfOwned), Std.Wrappers.Option.create_Some((RAST.Expr.create_Identifier(newtypeConstructor)).Apply1(RAST.Expr.create_UnaryOp(Dafny.Sequence.FromElements(op), (RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0")), DAST.Format.UnaryOpFormat.create_NoFormat())))))))); } public static RAST._IModDecl OpsImpl(Dafny.Rune op, Dafny.ISequence rTypeParamsDecls, RAST._IType newtypeType, Dafny.ISequence newtypeConstructor) { @@ -525,11 +534,11 @@ public static RAST._IModDecl OpsImpl(Dafny.Rune op, Dafny.ISequence _0_traitName = _let_tmp_rhs0.dtor__0; Dafny.ISequence _1_methodName = _let_tmp_rhs0.dtor__1; - return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("ops"))).MSel(_0_traitName)).AsType(), newtypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_TypeDeclMember(Dafny.Sequence.UnicodeFromString("Output"), newtypeType), RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(_1_methodName, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfOwned, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("other"), RAST.__default.SelfOwned)), Std.Wrappers.Option.create_Some(RAST.__default.SelfOwned), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((RAST.Expr.create_Identifier(newtypeConstructor)).Apply1(RAST.Expr.create_BinaryOp(Dafny.Sequence.FromElements(op), (RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0")), (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("other"))).Sel(Dafny.Sequence.UnicodeFromString("0")), DAST.Format.BinaryOpFormat.create_NoFormat())))))))); + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("ops"))).MSel(_0_traitName)).AsType(), newtypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_TypeDeclMember(Dafny.Sequence.UnicodeFromString("Output"), newtypeType), RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(_1_methodName, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfOwned, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("other"), RAST.__default.SelfOwned)), Std.Wrappers.Option.create_Some(RAST.__default.SelfOwned), Std.Wrappers.Option.create_Some((RAST.Expr.create_Identifier(newtypeConstructor)).Apply1(RAST.Expr.create_BinaryOp(Dafny.Sequence.FromElements(op), (RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0")), (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("other"))).Sel(Dafny.Sequence.UnicodeFromString("0")), DAST.Format.BinaryOpFormat.create_NoFormat())))))))); } public static RAST._IModDecl PartialOrdImpl(Dafny.ISequence rTypeParamsDecls, RAST._IType newtypeType, Dafny.ISequence newtypeConstructor) { - return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("cmp"))).MSel(Dafny.Sequence.UnicodeFromString("PartialOrd"))).AsType(), newtypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("partial_cmp"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("other"), RAST.__default.SelfBorrowed)), Std.Wrappers.Option.create_Some(((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("option"))).MSel(Dafny.Sequence.UnicodeFromString("Option"))).AsType()).Apply1((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("cmp"))).MSel(Dafny.Sequence.UnicodeFromString("Ordering"))).AsType())), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("cmp"))).MSel(Dafny.Sequence.UnicodeFromString("PartialOrd"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("partial_cmp"))).Apply(Dafny.Sequence.FromElements(RAST.__default.Borrow((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0"))), RAST.__default.Borrow((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("other"))).Sel(Dafny.Sequence.UnicodeFromString("0"))))))))))); + return RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(rTypeParamsDecls, (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("cmp"))).MSel(Dafny.Sequence.UnicodeFromString("PartialOrd"))).AsType(), newtypeType, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.__default.NoDoc, RAST.__default.NoAttr, RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("partial_cmp"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(RAST.Formal.selfBorrowed, RAST.Formal.create(Dafny.Sequence.UnicodeFromString("other"), RAST.__default.SelfBorrowed)), Std.Wrappers.Option.create_Some(((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("option"))).MSel(Dafny.Sequence.UnicodeFromString("Option"))).AsType()).Apply1((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("cmp"))).MSel(Dafny.Sequence.UnicodeFromString("Ordering"))).AsType())), Std.Wrappers.Option.create_Some((((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("cmp"))).MSel(Dafny.Sequence.UnicodeFromString("PartialOrd"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("partial_cmp"))).Apply(Dafny.Sequence.FromElements(RAST.__default.Borrow((RAST.__default.self).Sel(Dafny.Sequence.UnicodeFromString("0"))), RAST.__default.Borrow((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("other"))).Sel(Dafny.Sequence.UnicodeFromString("0"))))))))))); } public static Defs._IAssignmentStatus DetectAssignmentStatus(Dafny.ISequence stmts__remainder, Dafny.ISequence dafny__name) { diff --git a/Source/DafnyCore/GeneratedFromDafny/FactorPathsOptimization.cs b/Source/DafnyCore/GeneratedFromDafny/FactorPathsOptimization.cs index c16bca4427a..2308d3c7675 100644 --- a/Source/DafnyCore/GeneratedFromDafny/FactorPathsOptimization.cs +++ b/Source/DafnyCore/GeneratedFromDafny/FactorPathsOptimization.cs @@ -31,7 +31,7 @@ public static RAST._IMod applyPrefix(RAST._IMod mod, RAST._IPath SelfPath) RAST._IMod _3_mod = (FactorPathsOptimization.__default.PathSimplifier(_1_pathsToRemove)).ReplaceMod(mod, SelfPath); RAST._IMod _4_dt__update__tmp_h0 = _3_mod; Dafny.ISequence _5_dt__update_hbody_h0 = Dafny.Sequence.Concat(_2_imports, (_3_mod).dtor_body); - return RAST.Mod.create_Mod((_4_dt__update__tmp_h0).dtor_name, (_4_dt__update__tmp_h0).dtor_attributes, _5_dt__update_hbody_h0); + return RAST.Mod.create_Mod((_4_dt__update__tmp_h0).dtor_docString, (_4_dt__update__tmp_h0).dtor_attributes, (_4_dt__update__tmp_h0).dtor_name, _5_dt__update_hbody_h0); } } public static __T UniqueElementOf<__T>(Dafny.ISet<__T> s) { diff --git a/Source/DafnyCore/GeneratedFromDafny/RAST.cs b/Source/DafnyCore/GeneratedFromDafny/RAST.cs index 5f2fbfec458..8c0c742cf26 100644 --- a/Source/DafnyCore/GeneratedFromDafny/RAST.cs +++ b/Source/DafnyCore/GeneratedFromDafny/RAST.cs @@ -30,6 +30,14 @@ public static __A FoldLeft<__A, __T>(Func<__A, __T, __A> f, __A init, Dafny.ISeq goto TAIL_CALL_START; } } + public static Dafny.ISequence ToDocstringPrefix(Dafny.ISequence docString, Dafny.ISequence ind) + { + if ((docString).Equals(Dafny.Sequence.UnicodeFromString(""))) { + return Dafny.Sequence.UnicodeFromString(""); + } else { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("/// "), RAST.__default.AddIndent(docString, Dafny.Sequence.Concat(ind, Dafny.Sequence.UnicodeFromString("/// ")))), Dafny.Sequence.UnicodeFromString("\n")), ind); + } + } public static Dafny.ISequence SeqToString<__T>(Dafny.ISequence<__T> s, Func<__T, Dafny.ISequence> f, Dafny.ISequence separator) { if ((new BigInteger((s).Count)).Sign == 0) { @@ -165,6 +173,9 @@ public static RAST._IExpr RcNew(RAST._IExpr underlying) { public static RAST._IExpr IntoUsize(RAST._IExpr underlying) { return (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyUsize"))).FSel(Dafny.Sequence.UnicodeFromString("into_usize"))).Apply1(underlying); } + public static Dafny.ISequence IND { get { + return Dafny.Sequence.UnicodeFromString(" "); + } } public static RAST._IType SelfOwned { get { return (RAST.Path.create_Self()).AsType(); } } @@ -255,9 +266,6 @@ public static RAST._IExpr MaybeUninitExpr { get { public static RAST._IPath MaybePlaceboPath { get { return (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("MaybePlacebo")); } } - public static Dafny.ISequence IND { get { - return Dafny.Sequence.UnicodeFromString(" "); - } } public static RAST._IExpr self { get { return RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("self")); } } @@ -297,9 +305,15 @@ public static RAST._IExpr std__rc__Rc__new { get { public static RAST._IExpr std__default__Default__default { get { return ((RAST.__default.std__default__Default).FSel(Dafny.Sequence.UnicodeFromString("default"))).Apply0(); } } + public static Dafny.ISequence> NoAttr { get { + return Dafny.Sequence>.FromElements(); + } } public static BigInteger MAX__TUPLE__SIZE { get { return new BigInteger(12); } } + public static Dafny.ISequence NoDoc { get { + return Dafny.Sequence.UnicodeFromString(""); + } } } public interface _IRASTTopDownVisitor { @@ -452,7 +466,7 @@ public T VisitModMapping(T acc, RAST._IModDecl modDecl, RAST._IPath SelfPath) { if (_source0.is_TypeDecl) { RAST._ITypeSynonym tpe0 = _source0.dtor_tpe; - Dafny.ISequence> _3_attributes = tpe0.dtor_attributes; + Dafny.ISequence _3_attributes = tpe0.dtor_docString; Dafny.ISequence _4_name = tpe0.dtor_name; Dafny.ISequence _5_typeParams = tpe0.dtor_typeParams; RAST._IType _6_tpe = tpe0.dtor_tpe; @@ -464,7 +478,7 @@ public T VisitModMapping(T acc, RAST._IModDecl modDecl, RAST._IPath SelfPath) { if (_source0.is_ConstDecl) { RAST._IConstant c0 = _source0.dtor_c; - Dafny.ISequence> _9_attributes = c0.dtor_attributes; + Dafny.ISequence _9_attributes = c0.dtor_docString; Dafny.ISequence _10_name = c0.dtor_name; RAST._IType _11_tpe = c0.dtor_tpe; RAST._IExpr _12_value = c0.dtor_value; @@ -476,7 +490,7 @@ public T VisitModMapping(T acc, RAST._IModDecl modDecl, RAST._IPath SelfPath) { if (_source0.is_EnumDecl) { RAST._IEnum enum0 = _source0.dtor_enum; - Dafny.ISequence> _15_attributes = enum0.dtor_attributes; + Dafny.ISequence _15_attributes = enum0.dtor_docString; Dafny.ISequence _16_name = enum0.dtor_name; Dafny.ISequence _17_typeParams = enum0.dtor_typeParams; Dafny.ISequence _18_variants = enum0.dtor_variants; @@ -588,21 +602,23 @@ public T VisitMember(T acc, RAST._IImplMember member) } { if (_source0.is_FnDecl) { - RAST._IVisibility _1_pub = _source0.dtor_pub; - RAST._IFn _2_fun = _source0.dtor_fun; - return (this).VisitFn(acc, _2_fun); + Dafny.ISequence _1_docString = _source0.dtor_docString; + Dafny.ISequence> _2_attributes = _source0.dtor_attributes; + RAST._IVisibility _3_pub = _source0.dtor_pub; + RAST._IFn _4_fun = _source0.dtor_fun; + return (this).VisitFn(acc, _4_fun); } } { if (_source0.is_TypeDeclMember) { - Dafny.ISequence _3_name = _source0.dtor_name; - RAST._IType _4_tpe = _source0.dtor_rhs; - return (this).VisitType(acc, _4_tpe); + Dafny.ISequence _5_name = _source0.dtor_name; + RAST._IType _6_tpe = _source0.dtor_rhs; + return (this).VisitType(acc, _6_tpe); } } { - RAST._IExpr _5_expr = _source0.dtor_expr; - return (_5_expr).Fold(acc, (this).dtor_VisitExprSingle, (this).dtor_VisitTypeSingle); + RAST._IExpr _7_expr = _source0.dtor_expr; + return (_7_expr).Fold(acc, (this).dtor_VisitExprSingle, (this).dtor_VisitTypeSingle); } } public T VisitFn(T acc, RAST._IFn fn) @@ -613,15 +629,14 @@ public T VisitFn(T acc, RAST._IFn fn) Dafny.ISequence _1_typeParams = _source0.dtor_typeParams; Dafny.ISequence _2_formals = _source0.dtor_formals; Std.Wrappers._IOption _3_returnType = _source0.dtor_returnType; - Dafny.ISequence _4_where = _source0.dtor_where; - Std.Wrappers._IOption _5_body = _source0.dtor_body; - T _6_acc = (this).VisitTypeParams(acc, _1_typeParams); - T _7_acc = RAST.__default.FoldLeft(Dafny.Helpers.Id, Func>>((_8_formals) => ((System.Func)((_9_acc, _10_f) => { - return ((_10_f).dtor_tpe).Fold(_9_acc, (this).dtor_VisitTypeSingle); - })))(_2_formals), _6_acc, _2_formals); - T _11_acc = (((_3_returnType).is_None) ? (_7_acc) : (((_3_returnType).dtor_value).Fold(_7_acc, (this).dtor_VisitTypeSingle))); - T _12_acc = (((_5_body).is_None) ? (_11_acc) : (((_5_body).dtor_value).Fold(_11_acc, (this).dtor_VisitExprSingle, (this).dtor_VisitTypeSingle))); - return _12_acc; + Std.Wrappers._IOption _4_body = _source0.dtor_body; + T _5_acc = (this).VisitTypeParams(acc, _1_typeParams); + T _6_acc = RAST.__default.FoldLeft(Dafny.Helpers.Id, Func>>((_7_formals) => ((System.Func)((_8_acc, _9_f) => { + return ((_9_f).dtor_tpe).Fold(_8_acc, (this).dtor_VisitTypeSingle); + })))(_2_formals), _5_acc, _2_formals); + T _10_acc = (((_3_returnType).is_None) ? (_6_acc) : (((_3_returnType).dtor_value).Fold(_6_acc, (this).dtor_VisitTypeSingle))); + T _11_acc = (((_4_body).is_None) ? (_10_acc) : (((_4_body).dtor_value).Fold(_10_acc, (this).dtor_VisitExprSingle, (this).dtor_VisitTypeSingle))); + return _11_acc; } } } @@ -727,7 +742,7 @@ public RAST._IMod ReplaceMod(RAST._IMod mod, RAST._IPath SelfPath) })))(SelfPath, mod)); RAST._IMod _5_dt__update__tmp_h0 = mod; Dafny.ISequence _6_dt__update_hbody_h0 = _0_newModDeclarations; - return RAST.Mod.create_Mod((_5_dt__update__tmp_h0).dtor_name, (_5_dt__update__tmp_h0).dtor_attributes, _6_dt__update_hbody_h0); + return RAST.Mod.create_Mod((_5_dt__update__tmp_h0).dtor_docString, (_5_dt__update__tmp_h0).dtor_attributes, (_5_dt__update__tmp_h0).dtor_name, _6_dt__update_hbody_h0); } } public RAST._IModDecl ReplaceModDecl(RAST._IModDecl modDecl, RAST._IPath SelfPath) @@ -789,51 +804,56 @@ public RAST._IModDecl ReplaceModDecl(RAST._IModDecl modDecl, RAST._IPath SelfPat public RAST._IStruct ReplaceStruct(RAST._IStruct @struct) { RAST._IStruct _source0 = @struct; { - Dafny.ISequence> _0_attributes = _source0.dtor_attributes; - Dafny.ISequence _1_name = _source0.dtor_name; - Dafny.ISequence _2_typeParams = _source0.dtor_typeParams; - RAST._IFields _3_fields = _source0.dtor_fields; - return RAST.Struct.create(_0_attributes, _1_name, (this).ReplaceTypeParams(_2_typeParams), (this).ReplaceFields(_3_fields)); + Dafny.ISequence _0_docString = _source0.dtor_docString; + Dafny.ISequence> _1_attributes = _source0.dtor_attributes; + Dafny.ISequence _2_name = _source0.dtor_name; + Dafny.ISequence _3_typeParams = _source0.dtor_typeParams; + RAST._IFields _4_fields = _source0.dtor_fields; + return RAST.Struct.create(_0_docString, _1_attributes, _2_name, (this).ReplaceTypeParams(_3_typeParams), (this).ReplaceFields(_4_fields)); } } public RAST._ITypeSynonym ReplaceTypeDecl(RAST._ITypeSynonym t) { RAST._ITypeSynonym _source0 = t; { - Dafny.ISequence> _0_attributes = _source0.dtor_attributes; - Dafny.ISequence _1_name = _source0.dtor_name; - Dafny.ISequence _2_typeParams = _source0.dtor_typeParams; - RAST._IType _3_tpe = _source0.dtor_tpe; - return RAST.TypeSynonym.create(_0_attributes, _1_name, (this).ReplaceTypeParams(_2_typeParams), (this).ReplaceType(_3_tpe)); + Dafny.ISequence _0_docString = _source0.dtor_docString; + Dafny.ISequence> _1_attributes = _source0.dtor_attributes; + Dafny.ISequence _2_name = _source0.dtor_name; + Dafny.ISequence _3_typeParams = _source0.dtor_typeParams; + RAST._IType _4_tpe = _source0.dtor_tpe; + return RAST.TypeSynonym.create(_0_docString, _1_attributes, _2_name, (this).ReplaceTypeParams(_3_typeParams), (this).ReplaceType(_4_tpe)); } } public RAST._IConstant ReplaceConst(RAST._IConstant t) { RAST._IConstant _source0 = t; { - Dafny.ISequence> _0_attributes = _source0.dtor_attributes; - Dafny.ISequence _1_name = _source0.dtor_name; - RAST._IType _2_tpe = _source0.dtor_tpe; - RAST._IExpr _3_value = _source0.dtor_value; - return RAST.Constant.create(_0_attributes, _1_name, (this).ReplaceType(_2_tpe), (this).ReplaceExpr(_3_value)); + Dafny.ISequence _0_docString = _source0.dtor_docString; + Dafny.ISequence> _1_attributes = _source0.dtor_attributes; + Dafny.ISequence _2_name = _source0.dtor_name; + RAST._IType _3_tpe = _source0.dtor_tpe; + RAST._IExpr _4_value = _source0.dtor_value; + return RAST.Constant.create(_0_docString, _1_attributes, _2_name, (this).ReplaceType(_3_tpe), (this).ReplaceExpr(_4_value)); } } public RAST._IEnum ReplaceEnum(RAST._IEnum @enum) { RAST._IEnum _source0 = @enum; { - Dafny.ISequence> _0_attributes = _source0.dtor_attributes; - Dafny.ISequence _1_name = _source0.dtor_name; - Dafny.ISequence _2_typeParams = _source0.dtor_typeParams; - Dafny.ISequence _3_variants = _source0.dtor_variants; - return RAST.Enum.create(_0_attributes, _1_name, (this).ReplaceTypeParams(_2_typeParams), Std.Collections.Seq.__default.Map(((System.Func)((_4_t) => { - return (this).ReplaceEnumCase(_4_t); -})), _3_variants)); + Dafny.ISequence _0_docString = _source0.dtor_docString; + Dafny.ISequence> _1_attributes = _source0.dtor_attributes; + Dafny.ISequence _2_name = _source0.dtor_name; + Dafny.ISequence _3_typeParams = _source0.dtor_typeParams; + Dafny.ISequence _4_variants = _source0.dtor_variants; + return RAST.Enum.create(_0_docString, _1_attributes, _2_name, (this).ReplaceTypeParams(_3_typeParams), Std.Collections.Seq.__default.Map(((System.Func)((_5_t) => { + return (this).ReplaceEnumCase(_5_t); +})), _4_variants)); } } public RAST._IEnumCase ReplaceEnumCase(RAST._IEnumCase enumCase) { RAST._IEnumCase _source0 = enumCase; { - Dafny.ISequence _0_name = _source0.dtor_name; - RAST._IFields _1_fields = _source0.dtor_fields; - return RAST.EnumCase.create(_0_name, (this).ReplaceFields(_1_fields)); + Dafny.ISequence _0_docString = _source0.dtor_docString; + Dafny.ISequence _1_name = _source0.dtor_name; + RAST._IFields _2_fields = _source0.dtor_fields; + return RAST.EnumCase.create(_0_docString, _1_name, (this).ReplaceFields(_2_fields)); } } public RAST._IImpl ReplaceImplDecl(RAST._IImpl impl) { @@ -857,22 +877,25 @@ public RAST._IImpl ReplaceImplDecl(RAST._IImpl impl) { public RAST._ITrait ReplaceTrait(RAST._ITrait tr) { RAST._ITrait _source0 = tr; { - Dafny.ISequence _0_typeParams = _source0.dtor_typeParams; - RAST._IType _1_tpe = _source0.dtor_tpe; - Dafny.ISequence _2_parents = _source0.dtor_parents; - Dafny.ISequence _3_body = _source0.dtor_body; - return RAST.Trait.create((this).ReplaceTypeParams(_0_typeParams), (this).ReplaceType(_1_tpe), Std.Collections.Seq.__default.Map(((System.Func)((_4_t) => { - return (this).ReplaceType(_4_t); -})), _2_parents), (this).ReplaceBody(_3_body)); + Dafny.ISequence _0_docString = _source0.dtor_docString; + Dafny.ISequence> _1_attributes = _source0.dtor_attributes; + Dafny.ISequence _2_typeParams = _source0.dtor_typeParams; + RAST._IType _3_tpe = _source0.dtor_tpe; + Dafny.ISequence _4_parents = _source0.dtor_parents; + Dafny.ISequence _5_body = _source0.dtor_body; + return RAST.Trait.create(_0_docString, _1_attributes, (this).ReplaceTypeParams(_2_typeParams), (this).ReplaceType(_3_tpe), Std.Collections.Seq.__default.Map(((System.Func)((_6_t) => { + return (this).ReplaceType(_6_t); +})), _4_parents), (this).ReplaceBody(_5_body)); } } public RAST._ITopFnDecl ReplaceTopFn(RAST._ITopFnDecl t) { RAST._ITopFnDecl _source0 = t; { - Dafny.ISequence> _0_attributes = _source0.dtor_attributes; - RAST._IVisibility _1_visibility = _source0.dtor_visibility; - RAST._IFn _2_fn = _source0.dtor_fn; - return RAST.TopFnDecl.create(_0_attributes, _1_visibility, (this).ReplaceFn(_2_fn)); + Dafny.ISequence _0_docString = _source0.dtor_docString; + Dafny.ISequence> _1_attributes = _source0.dtor_attributes; + RAST._IVisibility _2_visibility = _source0.dtor_visibility; + RAST._IFn _3_fn = _source0.dtor_fn; + return RAST.TopFnDecl.create(_0_docString, _1_attributes, _2_visibility, (this).ReplaceFn(_3_fn)); } } public RAST._IFn ReplaceFn(RAST._IFn t) { @@ -882,11 +905,10 @@ public RAST._IFn ReplaceFn(RAST._IFn t) { Dafny.ISequence _1_typeParams = _source0.dtor_typeParams; Dafny.ISequence _2_formals = _source0.dtor_formals; Std.Wrappers._IOption _3_returnType = _source0.dtor_returnType; - Dafny.ISequence _4_where = _source0.dtor_where; - Std.Wrappers._IOption _5_body = _source0.dtor_body; - return RAST.Fn.create(_0_name, (this).ReplaceTypeParams(_1_typeParams), Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func>>((_6_formals) => ((System.Func)((_7_f) => { - return (_7_f).Replace(this.ReplaceType); -})))(_2_formals), _2_formals), (((_3_returnType).is_None) ? (Std.Wrappers.Option.create_None()) : (Std.Wrappers.Option.create_Some(((_3_returnType).dtor_value).Replace(this.ReplaceType)))), _4_where, (((_5_body).is_None) ? (Std.Wrappers.Option.create_None()) : (Std.Wrappers.Option.create_Some(((_5_body).dtor_value).Replace(this.ReplaceExpr, this.ReplaceType))))); + Std.Wrappers._IOption _4_body = _source0.dtor_body; + return RAST.Fn.create(_0_name, (this).ReplaceTypeParams(_1_typeParams), Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func>>((_5_formals) => ((System.Func)((_6_f) => { + return (_6_f).Replace(this.ReplaceType); +})))(_2_formals), _2_formals), (((_3_returnType).is_None) ? (Std.Wrappers.Option.create_None()) : (Std.Wrappers.Option.create_Some(((_3_returnType).dtor_value).Replace(this.ReplaceType)))), (((_4_body).is_None) ? (Std.Wrappers.Option.create_None()) : (Std.Wrappers.Option.create_Some(((_4_body).dtor_value).Replace(this.ReplaceExpr, this.ReplaceType))))); } } public RAST._IUse ReplaceUse(RAST._IUse use) { @@ -912,21 +934,23 @@ public RAST._IImplMember ReplaceImplMember(RAST._IImplMember t) { } { if (_source0.is_FnDecl) { - RAST._IVisibility _1_pub = _source0.dtor_pub; - RAST._IFn _2_fun = _source0.dtor_fun; - return RAST.ImplMember.create_FnDecl(_1_pub, (this).ReplaceFn(_2_fun)); + Dafny.ISequence _1_docString = _source0.dtor_docString; + Dafny.ISequence> _2_attributes = _source0.dtor_attributes; + RAST._IVisibility _3_pub = _source0.dtor_pub; + RAST._IFn _4_fun = _source0.dtor_fun; + return RAST.ImplMember.create_FnDecl(_1_docString, _2_attributes, _3_pub, (this).ReplaceFn(_4_fun)); } } { if (_source0.is_TypeDeclMember) { - Dafny.ISequence _3_name = _source0.dtor_name; - RAST._IType _4_tpe = _source0.dtor_rhs; - return RAST.ImplMember.create_TypeDeclMember(_3_name, (this).ReplaceType(_4_tpe)); + Dafny.ISequence _5_name = _source0.dtor_name; + RAST._IType _6_tpe = _source0.dtor_rhs; + return RAST.ImplMember.create_TypeDeclMember(_5_name, (this).ReplaceType(_6_tpe)); } } { - RAST._IExpr _5_expr = _source0.dtor_expr; - return RAST.ImplMember.create_ImplMemberMacro((this).ReplaceExpr(_5_expr)); + RAST._IExpr _7_expr = _source0.dtor_expr; + return RAST.ImplMember.create_ImplMemberMacro((this).ReplaceExpr(_7_expr)); } } public RAST._IExpr ReplaceExpr(RAST._IExpr e) { @@ -964,8 +988,9 @@ public RAST._IFields ReplaceFields(RAST._IFields fields) { public interface _IMod { bool is_Mod { get; } bool is_ExternMod { get; } - Dafny.ISequence dtor_name { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence> dtor_attributes { get; } + Dafny.ISequence dtor_name { get; } Dafny.ISequence dtor_body { get; } _IMod DowncastClone(); __T Fold<__T>(__T acc, Func<__T, RAST._IModDecl, __T> accBuilder); @@ -974,7 +999,7 @@ public interface _IMod { public abstract class Mod : _IMod { public Mod() { } - private static readonly RAST._IMod theDefault = create_Mod(Dafny.Sequence.Empty, Dafny.Sequence>.Empty, Dafny.Sequence.Empty); + private static readonly RAST._IMod theDefault = create_Mod(Dafny.Sequence.Empty, Dafny.Sequence>.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty); public static RAST._IMod Default() { return theDefault; } @@ -982,19 +1007,18 @@ public static RAST._IMod Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IMod create_Mod(Dafny.ISequence name, Dafny.ISequence> attributes, Dafny.ISequence body) { - return new Mod_Mod(name, attributes, body); + public static _IMod create_Mod(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence body) { + return new Mod_Mod(docString, attributes, name, body); } public static _IMod create_ExternMod(Dafny.ISequence name) { return new Mod_ExternMod(name); } public bool is_Mod { get { return this is Mod_Mod; } } public bool is_ExternMod { get { return this is Mod_ExternMod; } } - public Dafny.ISequence dtor_name { + public Dafny.ISequence dtor_docString { get { var d = this; - if (d is Mod_Mod) { return ((Mod_Mod)d)._name; } - return ((Mod_ExternMod)d)._name; + return ((Mod_Mod)d)._docString; } } public Dafny.ISequence> dtor_attributes { @@ -1003,6 +1027,13 @@ public Dafny.ISequence> dtor_attributes { return ((Mod_Mod)d)._attributes; } } + public Dafny.ISequence dtor_name { + get { + var d = this; + if (d is Mod_Mod) { return ((Mod_Mod)d)._name; } + return ((Mod_ExternMod)d)._name; + } + } public Dafny.ISequence dtor_body { get { var d = this; @@ -1033,47 +1064,53 @@ public __T Fold<__T>(__T acc, Func<__T, RAST._IModDecl, __T> accBuilder) } } { - Dafny.ISequence _1_name = _source0.dtor_name; + Dafny.ISequence _1_docString = _source0.dtor_docString; Dafny.ISequence> _2_attributes = _source0.dtor_attributes; - Dafny.ISequence _3_body = _source0.dtor_body; - return Dafny.Sequence.Concat(RAST.Attribute.ToStringMultiple(_2_attributes, ind), Dafny.Helpers.Let>(((new BigInteger((_3_body).Count)).Sign == 1) && (((_3_body).Select(BigInteger.Zero)).is_UseDecl), _pat_let13_0 => Dafny.Helpers.Let>(_pat_let13_0, _4_startWithUse => Dafny.Helpers.Let, Dafny.ISequence>(((_4_startWithUse) ? (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _pat_let_tv0), RAST.__default.IND)) : (Dafny.Sequence.UnicodeFromString(""))), _pat_let14_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let14_0, _5_prefixIfNotUseDecl => Dafny.Helpers.Let, Dafny.ISequence>(((_4_startWithUse) ? (Dafny.Sequence.Concat(_pat_let_tv1, RAST.__default.IND)) : (Dafny.Sequence.UnicodeFromString(""))), _pat_let15_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let15_0, _6_prefixIfUseDecl => Dafny.Helpers.Let, Dafny.ISequence>(((_4_startWithUse) ? (Dafny.Sequence.UnicodeFromString("\n")) : (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n\n"), _pat_let_tv2), RAST.__default.IND))), _pat_let16_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let16_0, _7_infixDecl => Dafny.Helpers.Let, Dafny.ISequence>(((_4_startWithUse) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat(_pat_let_tv3, RAST.__default.IND))), _pat_let17_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let17_0, _8_initialIdent => Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("pub mod "), _1_name), Dafny.Sequence.UnicodeFromString(" {")), Dafny.Sequence.UnicodeFromString("\n")), _8_initialIdent), RAST.__default.SeqToString(_3_body, Dafny.Helpers.Id, Dafny.ISequence, Dafny.ISequence, Func>>>((_9_prefixIfUseDecl, _10_prefixIfNotUseDecl, _11_ind) => ((System.Func>)((_12_modDecl) => { - return Dafny.Sequence.Concat((((_12_modDecl).is_UseDecl) ? (_9_prefixIfUseDecl) : (_10_prefixIfNotUseDecl)), (_12_modDecl)._ToString(Dafny.Sequence.Concat(_11_ind, RAST.__default.IND))); - })))(_6_prefixIfUseDecl, _5_prefixIfNotUseDecl, _pat_let_tv4), _7_infixDecl)), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv5), Dafny.Sequence.UnicodeFromString("}"))))))))))))); + Dafny.ISequence _3_name = _source0.dtor_name; + Dafny.ISequence _4_body = _source0.dtor_body; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.__default.ToDocstringPrefix(_1_docString, ind), RAST.Attribute.ToStringMultiple(_2_attributes, ind)), Dafny.Helpers.Let>(((new BigInteger((_4_body).Count)).Sign == 1) && (((_4_body).Select(BigInteger.Zero)).is_UseDecl), _pat_let13_0 => Dafny.Helpers.Let>(_pat_let13_0, _5_startWithUse => Dafny.Helpers.Let, Dafny.ISequence>(((_5_startWithUse) ? (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _pat_let_tv0), RAST.__default.IND)) : (Dafny.Sequence.UnicodeFromString(""))), _pat_let14_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let14_0, _6_prefixIfNotUseDecl => Dafny.Helpers.Let, Dafny.ISequence>(((_5_startWithUse) ? (Dafny.Sequence.Concat(_pat_let_tv1, RAST.__default.IND)) : (Dafny.Sequence.UnicodeFromString(""))), _pat_let15_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let15_0, _7_prefixIfUseDecl => Dafny.Helpers.Let, Dafny.ISequence>(((_5_startWithUse) ? (Dafny.Sequence.UnicodeFromString("\n")) : (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n\n"), _pat_let_tv2), RAST.__default.IND))), _pat_let16_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let16_0, _8_infixDecl => Dafny.Helpers.Let, Dafny.ISequence>(((_5_startWithUse) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat(_pat_let_tv3, RAST.__default.IND))), _pat_let17_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let17_0, _9_initialIdent => Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("pub mod "), _3_name), Dafny.Sequence.UnicodeFromString(" {")), Dafny.Sequence.UnicodeFromString("\n")), _9_initialIdent), RAST.__default.SeqToString(_4_body, Dafny.Helpers.Id, Dafny.ISequence, Dafny.ISequence, Func>>>((_10_prefixIfUseDecl, _11_prefixIfNotUseDecl, _12_ind) => ((System.Func>)((_13_modDecl) => { + return Dafny.Sequence.Concat((((_13_modDecl).is_UseDecl) ? (_10_prefixIfUseDecl) : (_11_prefixIfNotUseDecl)), (_13_modDecl)._ToString(Dafny.Sequence.Concat(_12_ind, RAST.__default.IND))); + })))(_7_prefixIfUseDecl, _6_prefixIfNotUseDecl, _pat_let_tv4), _8_infixDecl)), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv5), Dafny.Sequence.UnicodeFromString("}"))))))))))))); } } } public class Mod_Mod : Mod { - public readonly Dafny.ISequence _name; + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence> _attributes; + public readonly Dafny.ISequence _name; public readonly Dafny.ISequence _body; - public Mod_Mod(Dafny.ISequence name, Dafny.ISequence> attributes, Dafny.ISequence body) : base() { - this._name = name; + public Mod_Mod(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence body) : base() { + this._docString = docString; this._attributes = attributes; + this._name = name; this._body = body; } public override _IMod DowncastClone() { if (this is _IMod dt) { return dt; } - return new Mod_Mod(_name, _attributes, _body); + return new Mod_Mod(_docString, _attributes, _name, _body); } public override bool Equals(object other) { var oth = other as RAST.Mod_Mod; - return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._attributes, oth._attributes) && object.Equals(this._body, oth._body); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && object.Equals(this._name, oth._name) && object.Equals(this._body, oth._body); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; - hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._body)); return (int) hash; } public override string ToString() { string s = "RAST.Mod.Mod"; s += "("; - s += this._name.ToVerbatimString(true); + s += this._docString.ToVerbatimString(true); s += ", "; s += Dafny.Helpers.ToString(this._attributes); s += ", "; + s += this._name.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._body); s += ")"; return s; @@ -1567,6 +1604,7 @@ public RAST._IPath dtor_path { public interface _ITopFnDecl { bool is_TopFn { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence> dtor_attributes { get; } RAST._IVisibility dtor_visibility { get; } RAST._IFn dtor_fn { get; } @@ -1574,25 +1612,28 @@ public interface _ITopFnDecl { Dafny.ISequence _ToString(Dafny.ISequence ind); } public class TopFnDecl : _ITopFnDecl { + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence> _attributes; public readonly RAST._IVisibility _visibility; public readonly RAST._IFn _fn; - public TopFnDecl(Dafny.ISequence> attributes, RAST._IVisibility visibility, RAST._IFn fn) { + public TopFnDecl(Dafny.ISequence docString, Dafny.ISequence> attributes, RAST._IVisibility visibility, RAST._IFn fn) { + this._docString = docString; this._attributes = attributes; this._visibility = visibility; this._fn = fn; } public _ITopFnDecl DowncastClone() { if (this is _ITopFnDecl dt) { return dt; } - return new TopFnDecl(_attributes, _visibility, _fn); + return new TopFnDecl(_docString, _attributes, _visibility, _fn); } public override bool Equals(object other) { var oth = other as RAST.TopFnDecl; - return oth != null && object.Equals(this._attributes, oth._attributes) && object.Equals(this._visibility, oth._visibility) && object.Equals(this._fn, oth._fn); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && object.Equals(this._visibility, oth._visibility) && object.Equals(this._fn, oth._fn); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._visibility)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._fn)); @@ -1601,6 +1642,8 @@ public override int GetHashCode() { public override string ToString() { string s = "RAST.TopFnDecl.TopFn"; s += "("; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._attributes); s += ", "; s += Dafny.Helpers.ToString(this._visibility); @@ -1609,7 +1652,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly RAST._ITopFnDecl theDefault = create(Dafny.Sequence>.Empty, RAST.Visibility.Default(), RAST.Fn.Default()); + private static readonly RAST._ITopFnDecl theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence>.Empty, RAST.Visibility.Default(), RAST.Fn.Default()); public static RAST._ITopFnDecl Default() { return theDefault; } @@ -1617,13 +1660,18 @@ public static RAST._ITopFnDecl Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _ITopFnDecl create(Dafny.ISequence> attributes, RAST._IVisibility visibility, RAST._IFn fn) { - return new TopFnDecl(attributes, visibility, fn); + public static _ITopFnDecl create(Dafny.ISequence docString, Dafny.ISequence> attributes, RAST._IVisibility visibility, RAST._IFn fn) { + return new TopFnDecl(docString, attributes, visibility, fn); } - public static _ITopFnDecl create_TopFn(Dafny.ISequence> attributes, RAST._IVisibility visibility, RAST._IFn fn) { - return create(attributes, visibility, fn); + public static _ITopFnDecl create_TopFn(Dafny.ISequence docString, Dafny.ISequence> attributes, RAST._IVisibility visibility, RAST._IFn fn) { + return create(docString, attributes, visibility, fn); } public bool is_TopFn { get { return true; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence> dtor_attributes { get { return this._attributes; @@ -1640,7 +1688,7 @@ public RAST._IFn dtor_fn { } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind), ((this).dtor_visibility)._ToString()), ((this).dtor_fn)._ToString(ind)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.__default.ToDocstringPrefix((this).dtor_docString, ind), RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind)), ((this).dtor_visibility)._ToString()), ((this).dtor_fn)._ToString(ind)); } } @@ -1703,6 +1751,7 @@ public Dafny.ISequence dtor_content { public interface _IStruct { bool is_Struct { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence> dtor_attributes { get; } Dafny.ISequence dtor_name { get; } Dafny.ISequence dtor_typeParams { get; } @@ -1711,11 +1760,13 @@ public interface _IStruct { Dafny.ISequence _ToString(Dafny.ISequence ind); } public class Struct : _IStruct { + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence> _attributes; public readonly Dafny.ISequence _name; public readonly Dafny.ISequence _typeParams; public readonly RAST._IFields _fields; - public Struct(Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IFields fields) { + public Struct(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IFields fields) { + this._docString = docString; this._attributes = attributes; this._name = name; this._typeParams = typeParams; @@ -1723,15 +1774,16 @@ public Struct(Dafny.ISequence> attributes, Dafny.ISe } public _IStruct DowncastClone() { if (this is _IStruct dt) { return dt; } - return new Struct(_attributes, _name, _typeParams, _fields); + return new Struct(_docString, _attributes, _name, _typeParams, _fields); } public override bool Equals(object other) { var oth = other as RAST.Struct; - return oth != null && object.Equals(this._attributes, oth._attributes) && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._fields, oth._fields); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._fields, oth._fields); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._typeParams)); @@ -1741,6 +1793,8 @@ public override int GetHashCode() { public override string ToString() { string s = "RAST.Struct.Struct"; s += "("; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._attributes); s += ", "; s += this._name.ToVerbatimString(true); @@ -1751,7 +1805,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly RAST._IStruct theDefault = create(Dafny.Sequence>.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, RAST.Fields.Default()); + private static readonly RAST._IStruct theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence>.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, RAST.Fields.Default()); public static RAST._IStruct Default() { return theDefault; } @@ -1759,13 +1813,18 @@ public static RAST._IStruct Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IStruct create(Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IFields fields) { - return new Struct(attributes, name, typeParams, fields); + public static _IStruct create(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IFields fields) { + return new Struct(docString, attributes, name, typeParams, fields); } - public static _IStruct create_Struct(Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IFields fields) { - return create(attributes, name, typeParams, fields); + public static _IStruct create_Struct(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IFields fields) { + return create(docString, attributes, name, typeParams, fields); } public bool is_Struct { get { return true; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence> dtor_attributes { get { return this._attributes; @@ -1787,12 +1846,13 @@ public RAST._IFields dtor_fields { } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind), Dafny.Sequence.UnicodeFromString("pub struct ")), (this).dtor_name), RAST.TypeParamDecl.ToStringMultiple((this).dtor_typeParams, ind)), ((this).dtor_fields)._ToString(ind, ((this).dtor_fields).is_NamedFields)), ((((this).dtor_fields).is_NamelessFields) ? (Dafny.Sequence.UnicodeFromString(";")) : (Dafny.Sequence.UnicodeFromString("")))); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.__default.ToDocstringPrefix((this).dtor_docString, ind), RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind)), Dafny.Sequence.UnicodeFromString("pub struct ")), (this).dtor_name), RAST.TypeParamDecl.ToStringMultiple((this).dtor_typeParams, ind)), ((this).dtor_fields)._ToString(ind, ((this).dtor_fields).is_NamedFields)), ((((this).dtor_fields).is_NamelessFields) ? (Dafny.Sequence.UnicodeFromString(";")) : (Dafny.Sequence.UnicodeFromString("")))); } } public interface _ITypeSynonym { bool is_TypeSynonym { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence> dtor_attributes { get; } Dafny.ISequence dtor_name { get; } Dafny.ISequence dtor_typeParams { get; } @@ -1801,11 +1861,13 @@ public interface _ITypeSynonym { Dafny.ISequence _ToString(Dafny.ISequence ind); } public class TypeSynonym : _ITypeSynonym { + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence> _attributes; public readonly Dafny.ISequence _name; public readonly Dafny.ISequence _typeParams; public readonly RAST._IType _tpe; - public TypeSynonym(Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IType tpe) { + public TypeSynonym(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IType tpe) { + this._docString = docString; this._attributes = attributes; this._name = name; this._typeParams = typeParams; @@ -1813,15 +1875,16 @@ public TypeSynonym(Dafny.ISequence> attributes, Dafn } public _ITypeSynonym DowncastClone() { if (this is _ITypeSynonym dt) { return dt; } - return new TypeSynonym(_attributes, _name, _typeParams, _tpe); + return new TypeSynonym(_docString, _attributes, _name, _typeParams, _tpe); } public override bool Equals(object other) { var oth = other as RAST.TypeSynonym; - return oth != null && object.Equals(this._attributes, oth._attributes) && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._tpe, oth._tpe); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._tpe, oth._tpe); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._typeParams)); @@ -1831,6 +1894,8 @@ public override int GetHashCode() { public override string ToString() { string s = "RAST.TypeSynonym.TypeSynonym"; s += "("; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._attributes); s += ", "; s += this._name.ToVerbatimString(true); @@ -1841,7 +1906,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly RAST._ITypeSynonym theDefault = create(Dafny.Sequence>.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, RAST.Type.Default()); + private static readonly RAST._ITypeSynonym theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence>.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, RAST.Type.Default()); public static RAST._ITypeSynonym Default() { return theDefault; } @@ -1849,13 +1914,18 @@ public static RAST._ITypeSynonym Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _ITypeSynonym create(Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IType tpe) { - return new TypeSynonym(attributes, name, typeParams, tpe); + public static _ITypeSynonym create(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IType tpe) { + return new TypeSynonym(docString, attributes, name, typeParams, tpe); } - public static _ITypeSynonym create_TypeSynonym(Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IType tpe) { - return create(attributes, name, typeParams, tpe); + public static _ITypeSynonym create_TypeSynonym(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, RAST._IType tpe) { + return create(docString, attributes, name, typeParams, tpe); } public bool is_TypeSynonym { get { return true; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence> dtor_attributes { get { return this._attributes; @@ -1877,12 +1947,13 @@ public RAST._IType dtor_tpe { } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind), Dafny.Sequence.UnicodeFromString("pub type ")), (this).dtor_name), RAST.TypeParamDecl.ToStringMultiple((this).dtor_typeParams, ind)), Dafny.Sequence.UnicodeFromString(" = ")), ((this).dtor_tpe)._ToString(ind)), Dafny.Sequence.UnicodeFromString(";")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.__default.ToDocstringPrefix((this).dtor_docString, ind), RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind)), Dafny.Sequence.UnicodeFromString("pub type ")), (this).dtor_name), RAST.TypeParamDecl.ToStringMultiple((this).dtor_typeParams, ind)), Dafny.Sequence.UnicodeFromString(" = ")), ((this).dtor_tpe)._ToString(ind)), Dafny.Sequence.UnicodeFromString(";")); } } public interface _IConstant { bool is_Constant { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence> dtor_attributes { get; } Dafny.ISequence dtor_name { get; } RAST._IType dtor_tpe { get; } @@ -1891,11 +1962,13 @@ public interface _IConstant { Dafny.ISequence _ToString(Dafny.ISequence ind); } public class Constant : _IConstant { + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence> _attributes; public readonly Dafny.ISequence _name; public readonly RAST._IType _tpe; public readonly RAST._IExpr _value; - public Constant(Dafny.ISequence> attributes, Dafny.ISequence name, RAST._IType tpe, RAST._IExpr @value) { + public Constant(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, RAST._IType tpe, RAST._IExpr @value) { + this._docString = docString; this._attributes = attributes; this._name = name; this._tpe = tpe; @@ -1903,15 +1976,16 @@ public Constant(Dafny.ISequence> attributes, Dafny.I } public _IConstant DowncastClone() { if (this is _IConstant dt) { return dt; } - return new Constant(_attributes, _name, _tpe, _value); + return new Constant(_docString, _attributes, _name, _tpe, _value); } public override bool Equals(object other) { var oth = other as RAST.Constant; - return oth != null && object.Equals(this._attributes, oth._attributes) && object.Equals(this._name, oth._name) && object.Equals(this._tpe, oth._tpe) && object.Equals(this._value, oth._value); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && object.Equals(this._name, oth._name) && object.Equals(this._tpe, oth._tpe) && object.Equals(this._value, oth._value); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._tpe)); @@ -1921,6 +1995,8 @@ public override int GetHashCode() { public override string ToString() { string s = "RAST.Constant.Constant"; s += "("; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._attributes); s += ", "; s += this._name.ToVerbatimString(true); @@ -1931,7 +2007,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly RAST._IConstant theDefault = create(Dafny.Sequence>.Empty, Dafny.Sequence.Empty, RAST.Type.Default(), RAST.Expr.Default()); + private static readonly RAST._IConstant theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence>.Empty, Dafny.Sequence.Empty, RAST.Type.Default(), RAST.Expr.Default()); public static RAST._IConstant Default() { return theDefault; } @@ -1939,13 +2015,18 @@ public static RAST._IConstant Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IConstant create(Dafny.ISequence> attributes, Dafny.ISequence name, RAST._IType tpe, RAST._IExpr @value) { - return new Constant(attributes, name, tpe, @value); + public static _IConstant create(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, RAST._IType tpe, RAST._IExpr @value) { + return new Constant(docString, attributes, name, tpe, @value); } - public static _IConstant create_Constant(Dafny.ISequence> attributes, Dafny.ISequence name, RAST._IType tpe, RAST._IExpr @value) { - return create(attributes, name, tpe, @value); + public static _IConstant create_Constant(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, RAST._IType tpe, RAST._IExpr @value) { + return create(docString, attributes, name, tpe, @value); } public bool is_Constant { get { return true; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence> dtor_attributes { get { return this._attributes; @@ -1967,7 +2048,7 @@ public RAST._IExpr dtor_value { } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind), Dafny.Sequence.UnicodeFromString("pub const ")), (this).dtor_name), Dafny.Sequence.UnicodeFromString(": ")), ((this).dtor_tpe)._ToString(ind)), Dafny.Sequence.UnicodeFromString(" = ")), ((this).dtor_value)._ToString(ind)), Dafny.Sequence.UnicodeFromString(";")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.__default.ToDocstringPrefix((this).dtor_docString, ind), RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind)), Dafny.Sequence.UnicodeFromString("pub const ")), (this).dtor_name), Dafny.Sequence.UnicodeFromString(": ")), ((this).dtor_tpe)._ToString(ind)), Dafny.Sequence.UnicodeFromString(" = ")), ((this).dtor_value)._ToString(ind)), Dafny.Sequence.UnicodeFromString(";")); } } @@ -2238,29 +2319,33 @@ public override string ToString() { public interface _IEnumCase { bool is_EnumCase { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence dtor_name { get; } RAST._IFields dtor_fields { get; } _IEnumCase DowncastClone(); Dafny.ISequence _ToString(Dafny.ISequence ind, bool newLine); } public class EnumCase : _IEnumCase { + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence _name; public readonly RAST._IFields _fields; - public EnumCase(Dafny.ISequence name, RAST._IFields fields) { + public EnumCase(Dafny.ISequence docString, Dafny.ISequence name, RAST._IFields fields) { + this._docString = docString; this._name = name; this._fields = fields; } public _IEnumCase DowncastClone() { if (this is _IEnumCase dt) { return dt; } - return new EnumCase(_name, _fields); + return new EnumCase(_docString, _name, _fields); } public override bool Equals(object other) { var oth = other as RAST.EnumCase; - return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._fields, oth._fields); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._name, oth._name) && object.Equals(this._fields, oth._fields); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._fields)); return (int) hash; @@ -2268,13 +2353,15 @@ public override int GetHashCode() { public override string ToString() { string s = "RAST.EnumCase.EnumCase"; s += "("; + s += this._docString.ToVerbatimString(true); + s += ", "; s += this._name.ToVerbatimString(true); s += ", "; s += Dafny.Helpers.ToString(this._fields); s += ")"; return s; } - private static readonly RAST._IEnumCase theDefault = create(Dafny.Sequence.Empty, RAST.Fields.Default()); + private static readonly RAST._IEnumCase theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, RAST.Fields.Default()); public static RAST._IEnumCase Default() { return theDefault; } @@ -2282,13 +2369,18 @@ public static RAST._IEnumCase Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IEnumCase create(Dafny.ISequence name, RAST._IFields fields) { - return new EnumCase(name, fields); + public static _IEnumCase create(Dafny.ISequence docString, Dafny.ISequence name, RAST._IFields fields) { + return new EnumCase(docString, name, fields); } - public static _IEnumCase create_EnumCase(Dafny.ISequence name, RAST._IFields fields) { - return create(name, fields); + public static _IEnumCase create_EnumCase(Dafny.ISequence docString, Dafny.ISequence name, RAST._IFields fields) { + return create(docString, name, fields); } public bool is_EnumCase { get { return true; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence dtor_name { get { return this._name; @@ -2301,12 +2393,13 @@ public RAST._IFields dtor_fields { } public Dafny.ISequence _ToString(Dafny.ISequence ind, bool newLine) { - return Dafny.Sequence.Concat((this).dtor_name, ((this).dtor_fields)._ToString(ind, newLine)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.__default.ToDocstringPrefix((this).dtor_docString, ind), (this).dtor_name), ((this).dtor_fields)._ToString(ind, newLine)); } } public interface _IEnum { bool is_Enum { get; } + Dafny.ISequence dtor_docString { get; } Dafny.ISequence> dtor_attributes { get; } Dafny.ISequence dtor_name { get; } Dafny.ISequence dtor_typeParams { get; } @@ -2315,11 +2408,13 @@ public interface _IEnum { Dafny.ISequence _ToString(Dafny.ISequence ind); } public class Enum : _IEnum { + public readonly Dafny.ISequence _docString; public readonly Dafny.ISequence> _attributes; public readonly Dafny.ISequence _name; public readonly Dafny.ISequence _typeParams; public readonly Dafny.ISequence _variants; - public Enum(Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence variants) { + public Enum(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence variants) { + this._docString = docString; this._attributes = attributes; this._name = name; this._typeParams = typeParams; @@ -2327,15 +2422,16 @@ public Enum(Dafny.ISequence> attributes, Dafny.ISequ } public _IEnum DowncastClone() { if (this is _IEnum dt) { return dt; } - return new Enum(_attributes, _name, _typeParams, _variants); + return new Enum(_docString, _attributes, _name, _typeParams, _variants); } public override bool Equals(object other) { var oth = other as RAST.Enum; - return oth != null && object.Equals(this._attributes, oth._attributes) && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._variants, oth._variants); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._variants, oth._variants); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._typeParams)); @@ -2345,6 +2441,8 @@ public override int GetHashCode() { public override string ToString() { string s = "RAST.Enum.Enum"; s += "("; + s += this._docString.ToVerbatimString(true); + s += ", "; s += Dafny.Helpers.ToString(this._attributes); s += ", "; s += this._name.ToVerbatimString(true); @@ -2355,7 +2453,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly RAST._IEnum theDefault = create(Dafny.Sequence>.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty); + private static readonly RAST._IEnum theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence>.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty); public static RAST._IEnum Default() { return theDefault; } @@ -2363,13 +2461,18 @@ public static RAST._IEnum Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IEnum create(Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence variants) { - return new Enum(attributes, name, typeParams, variants); + public static _IEnum create(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence variants) { + return new Enum(docString, attributes, name, typeParams, variants); } - public static _IEnum create_Enum(Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence variants) { - return create(attributes, name, typeParams, variants); + public static _IEnum create_Enum(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence variants) { + return create(docString, attributes, name, typeParams, variants); } public bool is_Enum { get { return true; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } public Dafny.ISequence> dtor_attributes { get { return this._attributes; @@ -2391,7 +2494,7 @@ public Dafny.ISequence dtor_variants { } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind), Dafny.Sequence.UnicodeFromString("pub enum ")), (this).dtor_name), RAST.TypeParamDecl.ToStringMultiple((this).dtor_typeParams, ind)), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString((this).dtor_variants, Dafny.Helpers.Id, Func>>>((_0_ind) => ((System.Func>)((_1_variant) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.__default.ToDocstringPrefix((this).dtor_docString, ind), RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind)), Dafny.Sequence.UnicodeFromString("pub enum ")), (this).dtor_name), RAST.TypeParamDecl.ToStringMultiple((this).dtor_typeParams, ind)), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString((this).dtor_variants, Dafny.Helpers.Id, Func>>>((_0_ind) => ((System.Func>)((_1_variant) => { return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _0_ind), RAST.__default.IND), (_1_variant)._ToString(Dafny.Sequence.Concat(_0_ind, RAST.__default.IND), true)); })))(ind), Dafny.Sequence.UnicodeFromString(","))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } @@ -4424,6 +4527,8 @@ public override string ToString() { public interface _ITrait { bool is_Trait { get; } + Dafny.ISequence dtor_docString { get; } + Dafny.ISequence> dtor_attributes { get; } Dafny.ISequence dtor_typeParams { get; } RAST._IType dtor_tpe { get; } Dafny.ISequence dtor_parents { get; } @@ -4432,11 +4537,15 @@ public interface _ITrait { Dafny.ISequence _ToString(Dafny.ISequence ind); } public class Trait : _ITrait { + public readonly Dafny.ISequence _docString; + public readonly Dafny.ISequence> _attributes; public readonly Dafny.ISequence _typeParams; public readonly RAST._IType _tpe; public readonly Dafny.ISequence _parents; public readonly Dafny.ISequence _body; - public Trait(Dafny.ISequence typeParams, RAST._IType tpe, Dafny.ISequence parents, Dafny.ISequence body) { + public Trait(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence typeParams, RAST._IType tpe, Dafny.ISequence parents, Dafny.ISequence body) { + this._docString = docString; + this._attributes = attributes; this._typeParams = typeParams; this._tpe = tpe; this._parents = parents; @@ -4444,15 +4553,17 @@ public Trait(Dafny.ISequence typeParams, RAST._IType tpe, } public _ITrait DowncastClone() { if (this is _ITrait dt) { return dt; } - return new Trait(_typeParams, _tpe, _parents, _body); + return new Trait(_docString, _attributes, _typeParams, _tpe, _parents, _body); } public override bool Equals(object other) { var oth = other as RAST.Trait; - return oth != null && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._tpe, oth._tpe) && object.Equals(this._parents, oth._parents) && object.Equals(this._body, oth._body); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._tpe, oth._tpe) && object.Equals(this._parents, oth._parents) && object.Equals(this._body, oth._body); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._typeParams)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._tpe)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._parents)); @@ -4462,6 +4573,10 @@ public override int GetHashCode() { public override string ToString() { string s = "RAST.Trait.Trait"; s += "("; + s += this._docString.ToVerbatimString(true); + s += ", "; + s += Dafny.Helpers.ToString(this._attributes); + s += ", "; s += Dafny.Helpers.ToString(this._typeParams); s += ", "; s += Dafny.Helpers.ToString(this._tpe); @@ -4472,7 +4587,7 @@ public override string ToString() { s += ")"; return s; } - private static readonly RAST._ITrait theDefault = create(Dafny.Sequence.Empty, RAST.Type.Default(), Dafny.Sequence.Empty, Dafny.Sequence.Empty); + private static readonly RAST._ITrait theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence>.Empty, Dafny.Sequence.Empty, RAST.Type.Default(), Dafny.Sequence.Empty, Dafny.Sequence.Empty); public static RAST._ITrait Default() { return theDefault; } @@ -4480,13 +4595,23 @@ public static RAST._ITrait Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _ITrait create(Dafny.ISequence typeParams, RAST._IType tpe, Dafny.ISequence parents, Dafny.ISequence body) { - return new Trait(typeParams, tpe, parents, body); + public static _ITrait create(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence typeParams, RAST._IType tpe, Dafny.ISequence parents, Dafny.ISequence body) { + return new Trait(docString, attributes, typeParams, tpe, parents, body); } - public static _ITrait create_Trait(Dafny.ISequence typeParams, RAST._IType tpe, Dafny.ISequence parents, Dafny.ISequence body) { - return create(typeParams, tpe, parents, body); + public static _ITrait create_Trait(Dafny.ISequence docString, Dafny.ISequence> attributes, Dafny.ISequence typeParams, RAST._IType tpe, Dafny.ISequence parents, Dafny.ISequence body) { + return create(docString, attributes, typeParams, tpe, parents, body); } public bool is_Trait { get { return true; } } + public Dafny.ISequence dtor_docString { + get { + return this._docString; + } + } + public Dafny.ISequence> dtor_attributes { + get { + return this._attributes; + } + } public Dafny.ISequence dtor_typeParams { get { return this._typeParams; @@ -4518,7 +4643,7 @@ public Dafny.ISequence dtor_body { return (_7_t)._ToString(Dafny.Sequence.Concat(_6_ind, RAST.__default.IND)); })))(ind), Dafny.Sequence.UnicodeFromString(" + "))))); Dafny.ISequence _8_where = (((_2_additionalConstraints).Equals(Dafny.Sequence.UnicodeFromString(""))) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind), RAST.__default.IND), Dafny.Sequence.UnicodeFromString("where\n")), ind), RAST.__default.IND), _2_additionalConstraints))); - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("pub trait "), ((this).dtor_tpe)._ToString(ind)), _5_parents), _8_where), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString((this).dtor_body, Dafny.Helpers.Id, Func>>>((_9_ind) => ((System.Func>)((_10_member) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.__default.ToDocstringPrefix((this).dtor_docString, ind), RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind)), Dafny.Sequence.UnicodeFromString("pub trait ")), ((this).dtor_tpe)._ToString(ind)), _5_parents), _8_where), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString((this).dtor_body, Dafny.Helpers.Id, Func>>>((_9_ind) => ((System.Func>)((_10_member) => { return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _9_ind), RAST.__default.IND), (_10_member)._ToString(Dafny.Sequence.Concat(_9_ind, RAST.__default.IND))); })))(ind), Dafny.Sequence.UnicodeFromString(""))), (((new BigInteger(((this).dtor_body).Count)).Sign == 0) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind)))), Dafny.Sequence.UnicodeFromString("}")); } @@ -4675,6 +4800,8 @@ public interface _IImplMember { Dafny.ISequence dtor_content { get; } Dafny.ISequence dtor_name { get; } RAST._IType dtor_rhs { get; } + Dafny.ISequence dtor_docString { get; } + Dafny.ISequence> dtor_attributes { get; } RAST._IVisibility dtor_pub { get; } RAST._IFn dtor_fun { get; } RAST._IExpr dtor_expr { get; } @@ -4698,8 +4825,8 @@ public static _IImplMember create_RawImplMember(Dafny.ISequence cont public static _IImplMember create_TypeDeclMember(Dafny.ISequence name, RAST._IType rhs) { return new ImplMember_TypeDeclMember(name, rhs); } - public static _IImplMember create_FnDecl(RAST._IVisibility pub, RAST._IFn fun) { - return new ImplMember_FnDecl(pub, fun); + public static _IImplMember create_FnDecl(Dafny.ISequence docString, Dafny.ISequence> attributes, RAST._IVisibility pub, RAST._IFn fun) { + return new ImplMember_FnDecl(docString, attributes, pub, fun); } public static _IImplMember create_ImplMemberMacro(RAST._IExpr expr) { return new ImplMember_ImplMemberMacro(expr); @@ -4726,6 +4853,18 @@ public RAST._IType dtor_rhs { return ((ImplMember_TypeDeclMember)d)._rhs; } } + public Dafny.ISequence dtor_docString { + get { + var d = this; + return ((ImplMember_FnDecl)d)._docString; + } + } + public Dafny.ISequence> dtor_attributes { + get { + var d = this; + return ((ImplMember_FnDecl)d)._attributes; + } + } public RAST._IVisibility dtor_pub { get { var d = this; @@ -4747,7 +4886,7 @@ public RAST._IExpr dtor_expr { public abstract _IImplMember DowncastClone(); public Dafny.ISequence _ToString(Dafny.ISequence ind) { if ((this).is_FnDecl) { - return Dafny.Sequence.Concat(((this).dtor_pub)._ToString(), ((this).dtor_fun)._ToString(ind)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(RAST.__default.ToDocstringPrefix((this).dtor_docString, ind), RAST.Attribute.ToStringMultiple((this).dtor_attributes, ind)), ((this).dtor_pub)._ToString()), ((this).dtor_fun)._ToString(ind)); } else if ((this).is_ImplMemberMacro) { return Dafny.Sequence.Concat(((this).dtor_expr)._ToString(ind), Dafny.Sequence.UnicodeFromString(";")); } else if ((this).is_TypeDeclMember) { @@ -4817,23 +4956,29 @@ public override string ToString() { } } public class ImplMember_FnDecl : ImplMember { + public readonly Dafny.ISequence _docString; + public readonly Dafny.ISequence> _attributes; public readonly RAST._IVisibility _pub; public readonly RAST._IFn _fun; - public ImplMember_FnDecl(RAST._IVisibility pub, RAST._IFn fun) : base() { + public ImplMember_FnDecl(Dafny.ISequence docString, Dafny.ISequence> attributes, RAST._IVisibility pub, RAST._IFn fun) : base() { + this._docString = docString; + this._attributes = attributes; this._pub = pub; this._fun = fun; } public override _IImplMember DowncastClone() { if (this is _IImplMember dt) { return dt; } - return new ImplMember_FnDecl(_pub, _fun); + return new ImplMember_FnDecl(_docString, _attributes, _pub, _fun); } public override bool Equals(object other) { var oth = other as RAST.ImplMember_FnDecl; - return oth != null && object.Equals(this._pub, oth._pub) && object.Equals(this._fun, oth._fun); + return oth != null && object.Equals(this._docString, oth._docString) && object.Equals(this._attributes, oth._attributes) && object.Equals(this._pub, oth._pub) && object.Equals(this._fun, oth._fun); } public override int GetHashCode() { ulong hash = 5381; hash = ((hash << 5) + hash) + 2; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._docString)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._attributes)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._pub)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._fun)); return (int) hash; @@ -4841,6 +4986,10 @@ public override int GetHashCode() { public override string ToString() { string s = "RAST.ImplMember.FnDecl"; s += "("; + s += this._docString.ToVerbatimString(true); + s += ", "; + s += Dafny.Helpers.ToString(this._attributes); + s += ", "; s += Dafny.Helpers.ToString(this._pub); s += ", "; s += Dafny.Helpers.ToString(this._fun); @@ -8642,7 +8791,6 @@ public interface _IFn { Dafny.ISequence dtor_typeParams { get; } Dafny.ISequence dtor_formals { get; } Std.Wrappers._IOption dtor_returnType { get; } - Dafny.ISequence dtor_where { get; } Std.Wrappers._IOption dtor_body { get; } _IFn DowncastClone(); Dafny.ISequence _ToString(Dafny.ISequence ind); @@ -8652,23 +8800,21 @@ public class Fn : _IFn { public readonly Dafny.ISequence _typeParams; public readonly Dafny.ISequence _formals; public readonly Std.Wrappers._IOption _returnType; - public readonly Dafny.ISequence _where; public readonly Std.Wrappers._IOption _body; - public Fn(Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence formals, Std.Wrappers._IOption returnType, Dafny.ISequence @where, Std.Wrappers._IOption body) { + public Fn(Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence formals, Std.Wrappers._IOption returnType, Std.Wrappers._IOption body) { this._name = name; this._typeParams = typeParams; this._formals = formals; this._returnType = returnType; - this._where = @where; this._body = body; } public _IFn DowncastClone() { if (this is _IFn dt) { return dt; } - return new Fn(_name, _typeParams, _formals, _returnType, _where, _body); + return new Fn(_name, _typeParams, _formals, _returnType, _body); } public override bool Equals(object other) { var oth = other as RAST.Fn; - return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._formals, oth._formals) && object.Equals(this._returnType, oth._returnType) && object.Equals(this._where, oth._where) && object.Equals(this._body, oth._body); + return oth != null && object.Equals(this._name, oth._name) && object.Equals(this._typeParams, oth._typeParams) && object.Equals(this._formals, oth._formals) && object.Equals(this._returnType, oth._returnType) && object.Equals(this._body, oth._body); } public override int GetHashCode() { ulong hash = 5381; @@ -8677,7 +8823,6 @@ public override int GetHashCode() { hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._typeParams)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._formals)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._returnType)); - hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._where)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._body)); return (int) hash; } @@ -8692,13 +8837,11 @@ public override string ToString() { s += ", "; s += Dafny.Helpers.ToString(this._returnType); s += ", "; - s += this._where.ToVerbatimString(true); - s += ", "; s += Dafny.Helpers.ToString(this._body); s += ")"; return s; } - private static readonly RAST._IFn theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Std.Wrappers.Option.Default(), Dafny.Sequence.Empty, Std.Wrappers.Option.Default()); + private static readonly RAST._IFn theDefault = create(Dafny.Sequence.Empty, Dafny.Sequence.Empty, Dafny.Sequence.Empty, Std.Wrappers.Option.Default(), Std.Wrappers.Option.Default()); public static RAST._IFn Default() { return theDefault; } @@ -8706,11 +8849,11 @@ public static RAST._IFn Default() { public static Dafny.TypeDescriptor _TypeDescriptor() { return _TYPE; } - public static _IFn create(Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence formals, Std.Wrappers._IOption returnType, Dafny.ISequence @where, Std.Wrappers._IOption body) { - return new Fn(name, typeParams, formals, returnType, @where, body); + public static _IFn create(Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence formals, Std.Wrappers._IOption returnType, Std.Wrappers._IOption body) { + return new Fn(name, typeParams, formals, returnType, body); } - public static _IFn create_Fn(Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence formals, Std.Wrappers._IOption returnType, Dafny.ISequence @where, Std.Wrappers._IOption body) { - return create(name, typeParams, formals, returnType, @where, body); + public static _IFn create_Fn(Dafny.ISequence name, Dafny.ISequence typeParams, Dafny.ISequence formals, Std.Wrappers._IOption returnType, Std.Wrappers._IOption body) { + return create(name, typeParams, formals, returnType, body); } public bool is_Fn { get { return true; } } public Dafny.ISequence dtor_name { @@ -8733,18 +8876,13 @@ public Std.Wrappers._IOption dtor_returnType { return this._returnType; } } - public Dafny.ISequence dtor_where { - get { - return this._where; - } - } public Std.Wrappers._IOption dtor_body { get { return this._body; } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("fn "), (this).dtor_name), RAST.TypeParamDecl.ToStringMultiple((this).dtor_typeParams, ind)), Dafny.Sequence.UnicodeFromString("(")), RAST.__default.SeqToString((this).dtor_formals, Dafny.Helpers.Id, Func>>>((_0_ind) => ((System.Func>)((_1_formal) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("fn "), (this).dtor_name), RAST.TypeParamDecl.ToStringMultiple((this).dtor_typeParams, ind)), Dafny.Sequence.UnicodeFromString("(")), RAST.__default.SeqToString((this).dtor_formals, Dafny.Helpers.Id, Func>>>((_0_ind) => ((System.Func>)((_1_formal) => { return (_1_formal)._ToString(_0_ind); })))(ind), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(")")), ((System.Func>)(() => { Std.Wrappers._IOption _source0 = (this).dtor_returnType; @@ -8757,7 +8895,7 @@ public Std.Wrappers._IOption dtor_body { { return Dafny.Sequence.UnicodeFromString(""); } - }))()), ((((this).dtor_where).Equals(Dafny.Sequence.UnicodeFromString(""))) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind), RAST.__default.IND), (this).dtor_where)))), ((System.Func>)(() => { + }))()), ((System.Func>)(() => { Std.Wrappers._IOption _source1 = (this).dtor_body; { if (_source1.is_None) { diff --git a/Source/DafnyCore/Generic/Node.cs b/Source/DafnyCore/Generic/Node.cs index 551c6f2c7e0..c292997423e 100644 --- a/Source/DafnyCore/Generic/Node.cs +++ b/Source/DafnyCore/Generic/Node.cs @@ -189,19 +189,18 @@ public ISet Visit(Func beforeChildren = null, Action } // Docstring from start token is extracted only if using "/** ... */" syntax, and only the last one is considered - protected string GetTriviaContainingDocstringFromStartTokenOrNull() { + protected bool GetStartTriviaDocstring(out string trivia) { var matches = StartDocstringExtractor.Matches(StartToken.LeadingTrivia); + trivia = null; if (matches.Count > 0) { - return matches[^1].Value; - } - - if (StartToken.Prev is { val: "|" or "{" }) { + trivia = matches[^1].Value; + } else if (StartToken.Prev is { val: "|" or "{" }) { matches = StartDocstringExtractor.Matches(StartToken.Prev.TrailingTrivia); if (matches.Count > 0) { - return matches[^1].Value; + trivia = matches[^1].Value; } } - return null; + return trivia is not ("" or null); } } diff --git a/Source/DafnyLanguageServer.Test/Lookup/HoverTest.cs b/Source/DafnyLanguageServer.Test/Lookup/HoverTest.cs index cfe68398e5b..6b0e8e60823 100644 --- a/Source/DafnyLanguageServer.Test/Lookup/HoverTest.cs +++ b/Source/DafnyLanguageServer.Test/Lookup/HoverTest.cs @@ -570,15 +570,15 @@ predicate pm() * @returns 1 no matter what*/ function g(k: int, l: int): int { 1 } -// No comment for pt +/** A comment for pt */ twostate predicate pt() { true } least predicate pl() - // No comment for pl + // A comment for pl { true } -// A comment for pg -// That spans two lines +/** A comment for pg + * That spans two lines */ greatest predicate pg() { true } /** Returns an integer without guarantee @@ -602,8 +602,7 @@ static method m() {} /** Should be the number of x in C */ var x: int - const X: int - // The expected number of x + const X: int // The expected number of x } function f(): int @@ -642,9 +641,9 @@ method test(d: D, t: T, e: Even) { var x2 := pg(); // ^[A comment for pg\nThat spans two lines] var x3 := pl(); -// ^[No comment for pl] +// ^[A comment for pl] var x4 := pt(); -// ^[No comment for pt] +// ^[A comment for pt] var xg := g(0, 1); // ^[Rich comment\n@param k The input\n that is ignored\n@param l The second input that is ignored\n@returns 1 no matter what] C.m(); // TODO diff --git a/Source/DafnyPipeline.Test/DocstringTest.cs b/Source/DafnyPipeline.Test/DocstringTest.cs index 935b7454ed2..416f157909e 100644 --- a/Source/DafnyPipeline.Test/DocstringTest.cs +++ b/Source/DafnyPipeline.Test/DocstringTest.cs @@ -8,6 +8,7 @@ using DafnyCore.Test; using DafnyTestGeneration; using Microsoft.Dafny; +using Nerdbank.Streams; using Xunit; using Xunit.Abstractions; @@ -36,6 +37,353 @@ public DocstringTest(ITestOutputHelper output) { private Newlines currentNewlines; + [Fact] + public async Task DocStringForAbstractTypeDecl() { + var programString = @" +// Not docstring +type AB(==) // [START Docstring0 END Docstring0] +// Not docstring + +// Not docstring +type AC // [START Docstring1 +// END Docstring1] +{ +} + +/** [START Docstring2 END Docstring2] */ +type AD +// Not docstring + +// Just a comment because not using the adequate syntax +type NoDocstring3 +// Not docstring + +// Not docstring +type AF { } // [START Docstring4 END Docstring4] +// Not docstring +"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForClassLikeDecl() { + var programString = @" +// Not docstring +class A { } // [START Docstring0 END Docstring0] +// Not docstring + +// Not docstring +class AC // [START Docstring1 +// END Docstring1] +{ +} + +/** [START Docstring2 END Docstring2] */ +trait AT {} +// Just a comment + +/** [START Docstring3 END Docstring3] */ +trait AT {} // Not a docstring because the syntax above looks more like a docstring +// Just a comment + +// Not docstring +class AC2 extends AT // [START Docstring4 +// END Docstring4] +{ +} + +// No docstring +class NoDocstring5 {} +// No docstring + +/** [START Docstring6 END Docstring6] */ +class AD {} +// Not docstring +"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForDatatypeDecl() { + var programString = @" +/** [START Docstring0 END Docstring0] */ +datatype X = FirstCtor() // [START Docstring1 END Docstring1] +// No docstring + +/* No docstring */ +datatype Y // [START Docstring2 +// END Docstring2] += +/** [START Docstring3 END Docstring3] */ +SecondCtor() +"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForConstVar() { + var programString = @" +class NoDocstring0 { + const NoDocstring1: int + /** [START Docstring2 END Docstring2] */ + const a2: int + const a3: int /** [START Docstring3 END Docstring3] */ + const a4: int := 5 /** [START Docstring4 END Docstring4] */ + const a5: int + // [START Docstring5 + // END Docstring5] + := 5 + + var NoDocstring6: int + /** [START Docstring7 END Docstring7] */ + var a7: int + var a8: int // [START Docstring8 END Docstring8] +} +"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForFunctions() { + var programString = @" +class NoDocstring0 { + /** [START Docstring1 END Docstring1] */ + function Test1(): int + function Test2(): int // [START Docstring2 END Docstring2] + /** [START Docstring3 END Docstring3] */ + function Test3(): int { 1 } // Not docstring + function Test4(): int { 2 } // [START Docstring4 END Docstring4] + /* Not docstring */ + function Test5(): int // [START Docstring5 + // END Docstring5] + { + 1 + } + + /** [START Docstring6 END Docstring6] */ + function Test6(): (r: int) + function Test7(): (r: int) // [START Docstring7 END Docstring7] + /** [START Docstring8 END Docstring8] */ + function Test8(): (r: int) { 1 } // Not docstring + function Test9(): (r: int) { 2 } // [START Docstring9 END Docstring9] + /* Not docstring */ + function Test10(): (r: int) // [START Docstring10 + // END Docstring10] + { + 1 + } +} +"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForMethods() { + var programString = @" +class NoDocstring0 { + /** [START Docstring1 END Docstring1] */ + method Test1() + method Test2() // [START Docstring2 END Docstring2] + /** [START Docstring3 END Docstring3] */ + method Test3() {} // Not docstring + method Test4() { } // [START Docstring4 END Docstring4] + /* Just a comment */ + method Test5() // [START Docstring5 + // END Docstring5] + { + } + + /** [START Docstring6 END Docstring6] */ + method Test6() returns (r: int) + method Test7() returns (r: int) // [START Docstring7 END Docstring7] + /** [START Docstring8 END Docstring8] */ + method Test8() returns (r: int) { } // Not docstring + method Test9() returns (r: int) { } // [START Docstring9 END Docstring9] + /* Not docstring */ + method Test10() returns (r: int) // [START Docstring10 + // END Docstring10] + { + } +} +"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForIterators() { + var programString = @" +/** [START Docstring0 END Docstring0] */ +iterator Gen(start: int) yields (x: int) // Just a comment + yield ensures true +{} + +/* Just a comment */ +iterator Gen(start: int) yields (x: int) // [START Docstring1 END Docstring1] + yield ensures true +{} + +/* Just a comment */ +iterator Gen(start: int) yields (x: int) + yield ensures true +{} // [START Docstring2 END Docstring2] +// Just a comment +"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForModules() { + var programString = @" +/** [START Docstring0 END Docstring0] */ +module Module0 { + // No docstring for this module + module NoDocstring1 {} + module Module2 {} // [START Docstring2 END Docstring2] + /** [START Docstring3 END Docstring3] */ + module Module3 {} // Not docstring + + module Test4 refines Else // [START Docstring4 + // END Docstring4] + { + } +} +"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForExportSets() { + var programString = @" +module NoDocstring0 { + /** [START Docstring1 END Docstring1] */ + export provides A, B, C + + // Just a comment + export + // [START Docstring2 END Docstring2] + provides D, E, F + + // Just a comment + export All + // [START Docstring3 END Docstring3] + provides D, E + + // Just a comment + export AllBis + provides D, E // [START Docstring4 END Docstring4] + // Just a comment +}"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForNewtypes() { + var programString = @" +/** [START Docstring0 END Docstring0] */ +newtype Int0 = x: int | true // Not docstring + +newtype Int1 = x: int | true { predicate NoDocstring2() { x == 0 } } // [START Docstring1 END Docstring1] + +/** [START Docstring3 END Docstring3] */ +newtype Int3 = x: int | true { predicate NoDocstring4() { x == 0 } } // Not docstring + +/* Not docstring */ +newtype Int5 + // [START Docstring5 + // END Docstring5] += x: int | true // Not docstring + +newtype Int6 = x: int | true witness 0 // [START Docstring6 END Docstring6] +"; + await TestAllDocstrings(programString); + } + + [Fact] + public async Task DocStringForSynonymTypes() { + var programString = @" +/** [START Docstring0 END Docstring0] */ +type Int0 = x: int | true // Not docstring + +type Int1 = x: int | true witness 0 // [START Docstring1 END Docstring1] + +/** [START Docstring2 END Docstring2] */ +type Int2 = x: int | true // Not docstring + +/* Not docstring */ +type Int3 + // [START Docstring3 + // END Docstring3] += x: int | true // Not docstring +"; + await TestAllDocstrings(programString); + } + + private async Task TestAllDocstrings(string programString) { + var options = DafnyOptions.CreateUsingOldParser(new BufferTextWriter()); + foreach (Newlines newLinesType in Enum.GetValues(typeof(Newlines))) { + currentNewlines = newLinesType; + programString = AdjustNewlines(programString); + + var reporter = new BatchErrorReporter(options); + var dafnyProgram = await Utils.Parse(reporter, programString, false); + if (reporter.ErrorCount != 0) { + throw new Exception(reporter.AllMessagesByLevel[ErrorLevel.Error][0].ToString()); + } + Assert.Equal(0, reporter.ErrorCount); + var topLevelDecls = dafnyProgram.DefaultModuleDef.TopLevelDecls.ToList(); + var hasDocString = topLevelDecls.OfType().SelectMany(i => { + var result = new List { i }; + if (i is DatatypeDecl d) { + foreach (var ctor in d.Ctors) { + result.Add(ctor); + } + } + + if (i is TopLevelDeclWithMembers memberContainer) { + foreach (var member in memberContainer.Members) { + if (member is IHasDocstring hasDocstring) { + result.Add(hasDocstring); + } + } + } + + if (i is LiteralModuleDecl modDecl) { + foreach (var innerDecl in modDecl.ModuleDef.TopLevelDecls) { + if (innerDecl is IHasDocstring hasDocstring) { + result.Add(hasDocstring); + } + } + } + + return result; + }).ToList(); + var matches = new Regex($@"Docstring(\d+)").Matches(programString); + var highestDocstringIndex = 0; + for (var i = 0; i < matches.Count; i++) { + var match = matches[i]; + var index = int.Parse(match.Groups[1].Value); + if (index > highestDocstringIndex) { + highestDocstringIndex = index; + } + } + + Assert.Equal(hasDocString.Count - 1, highestDocstringIndex); + for (var i = 0; i < hasDocString.Count; i++) { + var iHasDocString = hasDocString[i]; + var triviaWithDocstring = AdjustNewlines(iHasDocString.GetTriviaContainingDocstring() ?? ""); + if (!(new Regex($@"\[START Docstring{i}[\s\S]*END Docstring{i}\]")).IsMatch(triviaWithDocstring)) { + if (iHasDocString is Declaration decl && decl.Name.Contains("NoDocstring")) { + // OK + } else { + Assert.True(false, $"\"[START Docstring{i}...END Docstring{i}]\" not found in {triviaWithDocstring}"); + } + } else { + Assert.Equal(triviaWithDocstring.Trim(), triviaWithDocstring); + } + } + } + } + [Fact] async Task DocstringWorksForPredicates() { await DocstringWorksFor(@" @@ -72,8 +420,8 @@ function Test2(i: int): int { i + 2 } // Trailing comment -// Test3 computes an int -// It takes an int and adds 3 to it +/** Test3 computes an int + * It takes an int and adds 3 to it */ ghost function Test3(i: int): int { i + 3 } @@ -88,8 +436,8 @@ function Test5(i: int): int * It takes an int and adds 5 to it */ { i + 5 } -function Test6(i: int): int -/** Test6 computes an int +function Test6(i: int): int /** + * Test6 computes an int * It takes an int and adds 6 to it */ function Test7(i: int): (j: int) @@ -99,7 +447,7 @@ It takes an int and adds 7 to it */ function Test8(i: int): int /* Test8 computes an int - It takes an int and adds 8 to it */ + * It takes an int and adds 8 to it */ { i + 8 } function Test9(i: int): int /* @@ -109,7 +457,7 @@ It takes an int and adds 9 to it */ function Test10(i: int): int /* Test10 computes an int - It takes an int and adds 10 to it */ + * It takes an int and adds 10 to it */ { i + 10 } function Test11(i: int): int @@ -136,8 +484,8 @@ static predicate Test1(i: int) { i == 1 } // Unrelated trailing comment - // Test2 checks if an int - // is equal to 2 + /** Test2 checks if an int + * is equal to 2 */ static predicate Test2(i: int) { i == 2 } } @@ -161,8 +509,8 @@ lemma ComputeThing2(i: int) returns (j: int) { print i; } // Unattached comment -method ComputeThing3(i: int) returns (j: int) - // ComputeThing3 prints something to the screen +method ComputeThing3(i: int) returns (j: int) /* + ComputeThing3 prints something to the screen */ // Unattached comment method ComputeThing4(i: int) @@ -179,15 +527,13 @@ method ComputeThing4(i: int) public async Task DocstringWorksForConst() { await DocstringWorksFor(@" class X { - const x2 := 29 - // The biggest prime number less than 30 + const x2 := 29 // The biggest prime number less than 30 /** The biggest prime number less than 20 */ const x1 := 19 // Unrelated todo - const x3 := 37 - // The biggest prime number less than 40 + const x3 := 37 // The biggest prime number less than 40 } ", new List<(string nodeTokenValue, string? expectedDocstring)> { ("x1", "The biggest prime number less than 20"), @@ -198,25 +544,23 @@ class X { [Fact] public async Task DocstringWorksForSubsetType() { await DocstringWorksFor(@" -type Odd = x: int | x % 2 == 1 witness 1 -// Type of numbers that are not divisible by 2 +type Odd = x: int | x % 2 == 1 witness 1 // Type of numbers that are not divisible by 2 /** Type of numbers divisible by 2 */ type Even = x: int | x % 2 == 1 witness 1 // Unrelated comment -type Weird = x: int | x % 2 == x % 3 witness 0 -// Type of numbers whose remainder modulo 2 or 3 is the same +type Weird = x: int | x % 2 == x % 3 witness 0 // Type of numbers whose remainder modulo 2 or 3 is the same // Unattached comment -newtype Digit = x: int | 0 <= x < 10 -// A single digit +newtype Digit = x: int | 0 <= x < 10 // A single digit /** A hex digit */ newtype HexDigit = x: int | 0 <= x < 16 -newtype BinDigit = x: int | 0 <= x < 2 witness 1 -// A binary digit +newtype BinDigit + // A binary digit + = x: int | 0 <= x < 2 witness 1 { function flip(): BinDigit { 1 - this @@ -224,13 +568,10 @@ function flip(): BinDigit { } // Unrelated comment -type Weird = x: int | x % 2 == x % 3 witness 0 -// Type of numbers whose remainder modulo 2 or 3 is the same - +type Weird = x: int | x % 2 == x % 3 witness 0 // Type of numbers whose remainder modulo 2 or 3 is the same // Unattached comment -type ZeroOrMore = nat -// ZeroOrMore is the same as nat +type ZeroOrMore = nat // ZeroOrMore is the same as nat /** ZeroOrMore2 is the same as nat */ type ZeroOrMore2 = nat @@ -263,14 +604,12 @@ type AbstractType2 public async Task DocstringWorksForDatatypes() { await DocstringWorksFor(@" // Unrelated comment -datatype State = +datatype State // A typical log message from a process monitoring + = // Unrelated comment + Begin(time: int) // The beginning of the process | // Unrelated comment - Begin(time: int) - // The beginning of the process - | // Unrelated comment - End(time: int) - // The end of the process + End(time: int) // The end of the process /** Another typical log message from a process monitoring */ datatype State2 = diff --git a/Source/DafnyPipeline.Test/FormatterForComments.cs b/Source/DafnyPipeline.Test/FormatterForComments.cs index 47a4a730286..f63c1d5a4fc 100644 --- a/Source/DafnyPipeline.Test/FormatterForComments.cs +++ b/Source/DafnyPipeline.Test/FormatterForComments.cs @@ -102,7 +102,7 @@ await FormatterWorksFor(@" // | ISet(iset
) // This definition is not allowed because Dt appears in a non-strict/lax position // | IMap0(imap) // This definition is not allowed because Dt appears in a non-strict/lax position | IMap1(imap) - // | Last case commented out +// | Last case commented out method M4() { if { @@ -229,8 +229,8 @@ abstract module C { public async Task FormatterWorksForAlignedSingleLineTrailingComments() { var before = @" module RefinedF refines BaseF { - function f(): bool { false } // OK. Local f preferred over imported f - // even if imported into refinement parent + function f(): bool { false } /* OK. Local f preferred over imported f + even if imported into refinement parent */ lemma A() { forall u: int { // regression: the inferred ensures clause used to have // a problem with static const fields @@ -246,11 +246,11 @@ method DeclWithHavoc() }"; var after = @" module RefinedF refines BaseF { - function f(): bool { false } // OK. Local f preferred over imported f - // even if imported into refinement parent + function f(): bool { false } /* OK. Local f preferred over imported f + even if imported into refinement parent */ lemma A() { forall u: int { // regression: the inferred ensures clause used to have - // a problem with static const fields + // a problem with static const fields B(u); } } diff --git a/Source/DafnyPipeline.Test/FormatterForDatatypeDeclarationTest.cs b/Source/DafnyPipeline.Test/FormatterForDatatypeDeclarationTest.cs index 72676b368fc..d84848aad7c 100644 --- a/Source/DafnyPipeline.Test/FormatterForDatatypeDeclarationTest.cs +++ b/Source/DafnyPipeline.Test/FormatterForDatatypeDeclarationTest.cs @@ -29,11 +29,11 @@ await FormatterWorksFor(@" datatype Color2 = Red - // Comment1 + // Comment not docstring | Green | - // Comment2 + // Comment not docstring Blue - // Blue docstring +// Not blue docstring // Comment here datatype T = @@ -128,7 +128,7 @@ await FormatterWorksFor(@" | MOne /* -1 */ // Minus one | Both /* 2 */ - /* Two */ +/* Two */ "); } [Fact] diff --git a/Source/DafnyPipeline.Test/FormatterForStatements.cs b/Source/DafnyPipeline.Test/FormatterForStatements.cs index 575d9611c77..d34ce8f5f48 100644 --- a/Source/DafnyPipeline.Test/FormatterForStatements.cs +++ b/Source/DafnyPipeline.Test/FormatterForStatements.cs @@ -66,14 +66,14 @@ method AlternativeStmt() { print ""odd""; case x % 2 == 0 => print ""even""; - // That's the last case + // That's the last case } if case x % 2 == 1 => print ""odd1""; case x % 2 == 0 => print ""even1""; - // That's the last case + // That's the last case } method AlternativeLoopStmt() { @@ -84,7 +84,7 @@ method AlternativeLoopStmt() { print ""odd2""; case x % 2 == 0 => print ""even2""; - // That's the last case + // That's the last case } while invariant x >= 0 @@ -92,7 +92,7 @@ method AlternativeLoopStmt() { print ""odd3""; case x % 2 == 0 => print ""even3""; - // That's the last case + // That's the last case } "); } @@ -185,6 +185,9 @@ match s { } case 2 => + var b := 3 by { + LemmaCall(); + } case 3 => { } } diff --git a/Source/DafnyPipeline.Test/FormatterForTopLevelDeclarations.cs b/Source/DafnyPipeline.Test/FormatterForTopLevelDeclarations.cs index b24685d8597..4b7ab482c7b 100644 --- a/Source/DafnyPipeline.Test/FormatterForTopLevelDeclarations.cs +++ b/Source/DafnyPipeline.Test/FormatterForTopLevelDeclarations.cs @@ -170,7 +170,7 @@ export X L4 provides L5 , L6 - // Comment + // Comment provides L7, L8 provides @@ -187,7 +187,7 @@ extends A1 M4 reveals M5 , M6 - // Comment + // Comment reveals M7, M8 reveals diff --git a/Source/DafnyPipeline.Test/InterMethodVerificationStability.cs b/Source/DafnyPipeline.Test/InterMethodVerificationStability.cs index 0c42611401a..1af428485c3 100644 --- a/Source/DafnyPipeline.Test/InterMethodVerificationStability.cs +++ b/Source/DafnyPipeline.Test/InterMethodVerificationStability.cs @@ -191,7 +191,7 @@ public InterMethodVerificationStability(ITestOutputHelper output) { } private static string DafnyProjectFile => Path.Combine(dafnyDirectory, "Source", "Dafny", "Dafny.csproj"); - private static string DefaultDafnyArgs => $"run --no-build --project {DafnyProjectFile} -- -useBaseNameForFileName -compileVerbose:0 /errorTrace:0"; + private static string DefaultDafnyArgs => $"run --no-build --project \"{DafnyProjectFile}\" -- -useBaseNameForFileName -compileVerbose:0 /errorTrace:0"; string GetBoogie(string dafnyProgram, string optionalFileName = null) { string fileName = optionalFileName ?? Path.GetTempFileName() + ".dfy"; diff --git a/Source/DafnyPipeline.Test/Trivia.cs b/Source/DafnyPipeline.Test/Trivia.cs index fc960947935..0585a21ef1f 100644 --- a/Source/DafnyPipeline.Test/Trivia.cs +++ b/Source/DafnyPipeline.Test/Trivia.cs @@ -42,33 +42,28 @@ trait Trait1 { } // Just a comment trait Trait2 extends Trait1 // Trait docstring -{ } -// This is attached to trait2 -// This is also attached to trait2 +{ } /* +This is attached to trait2 +This is also attached to trait2 */ // This is attached to n -type n = x: int | x % 2 == 0 -// This is attached to n as well +type n = x: int | x % 2 == 0 // This docstring is attached to n // Just a comment class Class1 extends Trait1 // Class docstring -{ } -// This is attached to the class +{ } // This is attached to the class // Comment attached to c -const c := 2; -// Docstring attached to c +const c := 2 // Docstring attached to c // This is attached to f -function f(): int -// This is f docstring +function f(): int // This is f docstring ensures true { 1 } /** This is the docstring */ -function g(): int -// This is not the docstring +function g(): int // This is not the docstring ensures true { 1 } @@ -102,15 +97,15 @@ ensures true Assert.NotNull(trait1.StartToken.Next); Assert.Equal("Trait1", trait1.StartToken.Next.val); - AssertTrivia(moduleTest, "\n// Comment ∈ before\n", " // Module docstring\n"); - AssertTrivia(trait1, "/** Trait docstring */\n", " "); - AssertTrivia(trait2, "// Just a comment\n", "\n// Trait docstring\n"); - AssertTrivia(subsetType, "// This is attached to n\n", "\n// This is attached to n as well\n\n"); - AssertTrivia(class1, "// Just a comment\n", "\n// Class docstring\n"); - AssertTrivia(c, "// Comment attached to c\n", "\n// Docstring attached to c\n\n"); - AssertTrivia(f, "// This is attached to f\n", "\n// This is f docstring\n"); - AssertTrivia(g, "/** This is the docstring */\n", "\n// This is not the docstring\n"); - AssertTrivia(m, "// Just a regular comment\n", "\n// This is the docstring\n"); + AssertTrivia(moduleTest, "\n// Comment ∈ before\n", "// Module docstring"); + AssertTrivia(trait1, "\n/** Trait docstring */\n", "/** Trait docstring */"); + AssertTrivia(trait2, "\n// Just a comment\n", "// Trait docstring"); + AssertTrivia(subsetType, "\n\n// This is attached to n\n", "// This docstring is attached to n"); + AssertTrivia(class1, "\n// Just a comment\n", "// Class docstring"); + AssertTrivia(c, "\n// Comment attached to c\n", "// Docstring attached to c"); + AssertTrivia(f, "\n// This is attached to f\n", "// This is f docstring"); + AssertTrivia(g, "\n/** This is the docstring */\n", "/** This is the docstring */"); + AssertTrivia(m, "\n// Just a regular comment\n", "// This is the docstring"); TestTokens(dafnyProgram); } @@ -159,14 +154,13 @@ private string AdjustNewlines(string programString) { }; } - private void AssertTrivia(TopLevelDecl topLevelDecl, string triviaBefore, string triviaDoc) { + private void AssertTrivia(Node topLevelDecl, string triviaBefore, string triviaDoc) { Assert.Equal(AdjustNewlines(triviaBefore), topLevelDecl.StartToken.LeadingTrivia); - Assert.Equal(AdjustNewlines(triviaDoc), topLevelDecl.TokenWithTrailingDocString.TrailingTrivia); - } - - private void AssertTrivia(MemberDecl topLevelDecl, string triviaBefore, string triviaDoc) { - Assert.Equal(AdjustNewlines(triviaBefore), topLevelDecl.StartToken.LeadingTrivia); - Assert.Equal(AdjustNewlines(triviaDoc), topLevelDecl.TokenWithTrailingDocString.TrailingTrivia); + if (topLevelDecl is IHasDocstring hasDocstring) { + Assert.Equal(AdjustNewlines(triviaDoc), hasDocstring.GetTriviaContainingDocstring()); + } else { + Assert.True(false); + } } } } diff --git a/Source/DafnyRuntime/DafnyRuntimeDafny/src/dafnyRuntime.dfy b/Source/DafnyRuntime/DafnyRuntimeDafny/src/dafnyRuntime.dfy index 75d93f5348a..626efd4a111 100644 --- a/Source/DafnyRuntime/DafnyRuntimeDafny/src/dafnyRuntime.dfy +++ b/Source/DafnyRuntime/DafnyRuntimeDafny/src/dafnyRuntime.dfy @@ -222,9 +222,9 @@ abstract module {:options "/functionSyntax:4"} Dafny { && storage.Repr <= Repr && this !in storage.Repr && storage.Valid() - // TODO: This is equivalent to the above four clauses - // but I believe it doesn't get unrolled enough. - // && ValidComponent(storage) + // TODO: This is equivalent to the above four clauses + // but I believe it doesn't get unrolled enough. + // && ValidComponent(storage) && 0 <= size <= storage.Length() && forall i | 0 <= i < size :: storage.values[i].Set? } diff --git a/Source/DafnyRuntime/DafnyRuntimeRust/src/system/mod.rs b/Source/DafnyRuntime/DafnyRuntimeRust/src/system/mod.rs index c530be0a578..c113ca25594 100644 --- a/Source/DafnyRuntime/DafnyRuntimeRust/src/system/mod.rs +++ b/Source/DafnyRuntime/DafnyRuntimeRust/src/system/mod.rs @@ -28,11 +28,13 @@ pub mod _System { } impl Tuple2 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple2::_T2{_0, _1, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple2::_T2{_0, _1, } => _1, @@ -64,6 +66,7 @@ pub mod _System { } impl Tuple2 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>) -> Rc) -> Tuple2> { Rc::new(move |this: Self| -> Tuple2{ match this { @@ -137,6 +140,7 @@ pub mod _System { } impl Tuple0 { + /// Enumerates all possible values of Tuple0 pub fn _AllSingletonConstructors() -> SequenceIter> { seq![Rc::new(Tuple0::_T0 {})].iter() } @@ -178,6 +182,7 @@ pub mod _System { } impl Tuple1 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple1::_T1{_0, } => _0, @@ -207,6 +212,7 @@ pub mod _System { } impl Tuple1 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>) -> Rc) -> Tuple1> { Rc::new(move |this: Self| -> Tuple1{ match this { @@ -260,16 +266,19 @@ pub mod _System { } impl Tuple3 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple3::_T3{_0, _1, _2, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple3::_T3{_0, _1, _2, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple3::_T3{_0, _1, _2, } => _2, @@ -303,6 +312,7 @@ pub mod _System { } impl Tuple3 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>) -> Rc) -> Tuple3> { Rc::new(move |this: Self| -> Tuple3{ match this { @@ -363,21 +373,25 @@ pub mod _System { } impl Tuple4 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple4::_T4{_0, _1, _2, _3, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple4::_T4{_0, _1, _2, _3, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple4::_T4{_0, _1, _2, _3, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple4::_T4{_0, _1, _2, _3, } => _3, @@ -413,6 +427,7 @@ pub mod _System { } impl Tuple4 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>) -> Rc) -> Tuple4> { Rc::new(move |this: Self| -> Tuple4{ match this { @@ -477,26 +492,31 @@ pub mod _System { } impl Tuple5 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple5::_T5{_0, _1, _2, _3, _4, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple5::_T5{_0, _1, _2, _3, _4, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple5::_T5{_0, _1, _2, _3, _4, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple5::_T5{_0, _1, _2, _3, _4, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple5::_T5{_0, _1, _2, _3, _4, } => _4, @@ -534,6 +554,7 @@ pub mod _System { } impl Tuple5 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>) -> Rc) -> Tuple5> { Rc::new(move |this: Self| -> Tuple5{ match this { @@ -602,31 +623,37 @@ pub mod _System { } impl Tuple6 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple6::_T6{_0, _1, _2, _3, _4, _5, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple6::_T6{_0, _1, _2, _3, _4, _5, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple6::_T6{_0, _1, _2, _3, _4, _5, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple6::_T6{_0, _1, _2, _3, _4, _5, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple6::_T6{_0, _1, _2, _3, _4, _5, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple6::_T6{_0, _1, _2, _3, _4, _5, } => _5, @@ -666,6 +693,7 @@ pub mod _System { } impl Tuple6 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>) -> Rc) -> Tuple6> { Rc::new(move |this: Self| -> Tuple6{ match this { @@ -738,36 +766,43 @@ pub mod _System { } impl Tuple7 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => _6, @@ -809,6 +844,7 @@ pub mod _System { } impl Tuple7 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>) -> Rc) -> Tuple7> { Rc::new(move |this: Self| -> Tuple7{ match this { @@ -885,41 +921,49 @@ pub mod _System { } impl Tuple8 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => _7, @@ -963,6 +1007,7 @@ pub mod _System { } impl Tuple8 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>) -> Rc) -> Tuple8> { Rc::new(move |this: Self| -> Tuple8{ match this { @@ -1043,46 +1088,55 @@ pub mod _System { } impl Tuple9 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => _8, @@ -1128,6 +1182,7 @@ pub mod _System { } impl Tuple9 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>) -> Rc) -> Tuple9> { Rc::new(move |this: Self| -> Tuple9{ match this { @@ -1212,51 +1267,61 @@ pub mod _System { } impl Tuple10 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => _9, @@ -1304,6 +1369,7 @@ pub mod _System { } impl Tuple10 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>) -> Rc) -> Tuple10> { Rc::new(move |this: Self| -> Tuple10{ match this { @@ -1392,56 +1458,67 @@ pub mod _System { } impl Tuple11 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => _10, @@ -1491,6 +1568,7 @@ pub mod _System { } impl Tuple11 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>) -> Rc) -> Tuple11> { Rc::new(move |this: Self| -> Tuple11{ match this { @@ -1583,61 +1661,73 @@ pub mod _System { } impl Tuple12 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _10, } } + /// Returns a borrow of the field _11 pub fn _11(&self) -> &T11 { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => _11, @@ -1689,6 +1779,7 @@ pub mod _System { } impl Tuple12 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>, f_11: Rc r#__T11 + 'static>) -> Rc) -> Tuple12> { Rc::new(move |this: Self| -> Tuple12{ match this { @@ -1785,66 +1876,79 @@ pub mod _System { } impl Tuple13 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _10, } } + /// Returns a borrow of the field _11 pub fn _11(&self) -> &T11 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _11, } } + /// Returns a borrow of the field _12 pub fn _12(&self) -> &T12 { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => _12, @@ -1898,6 +2002,7 @@ pub mod _System { } impl Tuple13 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>, f_11: Rc r#__T11 + 'static>, f_12: Rc r#__T12 + 'static>) -> Rc) -> Tuple13> { Rc::new(move |this: Self| -> Tuple13{ match this { @@ -1998,71 +2103,85 @@ pub mod _System { } impl Tuple14 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _10, } } + /// Returns a borrow of the field _11 pub fn _11(&self) -> &T11 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _11, } } + /// Returns a borrow of the field _12 pub fn _12(&self) -> &T12 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _12, } } + /// Returns a borrow of the field _13 pub fn _13(&self) -> &T13 { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => _13, @@ -2118,6 +2237,7 @@ pub mod _System { } impl Tuple14 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>, f_11: Rc r#__T11 + 'static>, f_12: Rc r#__T12 + 'static>, f_13: Rc r#__T13 + 'static>) -> Rc) -> Tuple14> { Rc::new(move |this: Self| -> Tuple14{ match this { @@ -2222,76 +2342,91 @@ pub mod _System { } impl Tuple15 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _10, } } + /// Returns a borrow of the field _11 pub fn _11(&self) -> &T11 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _11, } } + /// Returns a borrow of the field _12 pub fn _12(&self) -> &T12 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _12, } } + /// Returns a borrow of the field _13 pub fn _13(&self) -> &T13 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _13, } } + /// Returns a borrow of the field _14 pub fn _14(&self) -> &T14 { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => _14, @@ -2349,6 +2484,7 @@ pub mod _System { } impl Tuple15 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>, f_11: Rc r#__T11 + 'static>, f_12: Rc r#__T12 + 'static>, f_13: Rc r#__T13 + 'static>, f_14: Rc r#__T14 + 'static>) -> Rc) -> Tuple15> { Rc::new(move |this: Self| -> Tuple15{ match this { @@ -2457,81 +2593,97 @@ pub mod _System { } impl Tuple16 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _10, } } + /// Returns a borrow of the field _11 pub fn _11(&self) -> &T11 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _11, } } + /// Returns a borrow of the field _12 pub fn _12(&self) -> &T12 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _12, } } + /// Returns a borrow of the field _13 pub fn _13(&self) -> &T13 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _13, } } + /// Returns a borrow of the field _14 pub fn _14(&self) -> &T14 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _14, } } + /// Returns a borrow of the field _15 pub fn _15(&self) -> &T15 { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => _15, @@ -2591,6 +2743,7 @@ pub mod _System { } impl Tuple16 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>, f_11: Rc r#__T11 + 'static>, f_12: Rc r#__T12 + 'static>, f_13: Rc r#__T13 + 'static>, f_14: Rc r#__T14 + 'static>, f_15: Rc r#__T15 + 'static>) -> Rc) -> Tuple16> { Rc::new(move |this: Self| -> Tuple16{ match this { @@ -2703,86 +2856,103 @@ pub mod _System { } impl Tuple17 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _10, } } + /// Returns a borrow of the field _11 pub fn _11(&self) -> &T11 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _11, } } + /// Returns a borrow of the field _12 pub fn _12(&self) -> &T12 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _12, } } + /// Returns a borrow of the field _13 pub fn _13(&self) -> &T13 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _13, } } + /// Returns a borrow of the field _14 pub fn _14(&self) -> &T14 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _14, } } + /// Returns a borrow of the field _15 pub fn _15(&self) -> &T15 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _15, } } + /// Returns a borrow of the field _16 pub fn _16(&self) -> &T16 { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => _16, @@ -2844,6 +3014,7 @@ pub mod _System { } impl Tuple17 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>, f_11: Rc r#__T11 + 'static>, f_12: Rc r#__T12 + 'static>, f_13: Rc r#__T13 + 'static>, f_14: Rc r#__T14 + 'static>, f_15: Rc r#__T15 + 'static>, f_16: Rc r#__T16 + 'static>) -> Rc) -> Tuple17> { Rc::new(move |this: Self| -> Tuple17{ match this { @@ -2960,91 +3131,109 @@ pub mod _System { } impl Tuple18 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _10, } } + /// Returns a borrow of the field _11 pub fn _11(&self) -> &T11 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _11, } } + /// Returns a borrow of the field _12 pub fn _12(&self) -> &T12 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _12, } } + /// Returns a borrow of the field _13 pub fn _13(&self) -> &T13 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _13, } } + /// Returns a borrow of the field _14 pub fn _14(&self) -> &T14 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _14, } } + /// Returns a borrow of the field _15 pub fn _15(&self) -> &T15 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _15, } } + /// Returns a borrow of the field _16 pub fn _16(&self) -> &T16 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _16, } } + /// Returns a borrow of the field _17 pub fn _17(&self) -> &T17 { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => _17, @@ -3108,6 +3297,7 @@ pub mod _System { } impl Tuple18 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>, f_11: Rc r#__T11 + 'static>, f_12: Rc r#__T12 + 'static>, f_13: Rc r#__T13 + 'static>, f_14: Rc r#__T14 + 'static>, f_15: Rc r#__T15 + 'static>, f_16: Rc r#__T16 + 'static>, f_17: Rc r#__T17 + 'static>) -> Rc) -> Tuple18> { Rc::new(move |this: Self| -> Tuple18{ match this { @@ -3228,96 +3418,115 @@ pub mod _System { } impl Tuple19 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _10, } } + /// Returns a borrow of the field _11 pub fn _11(&self) -> &T11 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _11, } } + /// Returns a borrow of the field _12 pub fn _12(&self) -> &T12 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _12, } } + /// Returns a borrow of the field _13 pub fn _13(&self) -> &T13 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _13, } } + /// Returns a borrow of the field _14 pub fn _14(&self) -> &T14 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _14, } } + /// Returns a borrow of the field _15 pub fn _15(&self) -> &T15 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _15, } } + /// Returns a borrow of the field _16 pub fn _16(&self) -> &T16 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _16, } } + /// Returns a borrow of the field _17 pub fn _17(&self) -> &T17 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _17, } } + /// Returns a borrow of the field _18 pub fn _18(&self) -> &T18 { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => _18, @@ -3383,6 +3592,7 @@ pub mod _System { } impl Tuple19 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>, f_11: Rc r#__T11 + 'static>, f_12: Rc r#__T12 + 'static>, f_13: Rc r#__T13 + 'static>, f_14: Rc r#__T14 + 'static>, f_15: Rc r#__T15 + 'static>, f_16: Rc r#__T16 + 'static>, f_17: Rc r#__T17 + 'static>, f_18: Rc r#__T18 + 'static>) -> Rc) -> Tuple19> { Rc::new(move |this: Self| -> Tuple19{ match this { @@ -3507,101 +3717,121 @@ pub mod _System { } impl Tuple20 { + /// Returns a borrow of the field _0 pub fn _0(&self) -> &T0 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _0, } } + /// Returns a borrow of the field _1 pub fn _1(&self) -> &T1 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _1, } } + /// Returns a borrow of the field _2 pub fn _2(&self) -> &T2 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _2, } } + /// Returns a borrow of the field _3 pub fn _3(&self) -> &T3 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _3, } } + /// Returns a borrow of the field _4 pub fn _4(&self) -> &T4 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _4, } } + /// Returns a borrow of the field _5 pub fn _5(&self) -> &T5 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _5, } } + /// Returns a borrow of the field _6 pub fn _6(&self) -> &T6 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _6, } } + /// Returns a borrow of the field _7 pub fn _7(&self) -> &T7 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _7, } } + /// Returns a borrow of the field _8 pub fn _8(&self) -> &T8 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _8, } } + /// Returns a borrow of the field _9 pub fn _9(&self) -> &T9 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _9, } } + /// Returns a borrow of the field _10 pub fn _10(&self) -> &T10 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _10, } } + /// Returns a borrow of the field _11 pub fn _11(&self) -> &T11 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _11, } } + /// Returns a borrow of the field _12 pub fn _12(&self) -> &T12 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _12, } } + /// Returns a borrow of the field _13 pub fn _13(&self) -> &T13 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _13, } } + /// Returns a borrow of the field _14 pub fn _14(&self) -> &T14 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _14, } } + /// Returns a borrow of the field _15 pub fn _15(&self) -> &T15 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _15, } } + /// Returns a borrow of the field _16 pub fn _16(&self) -> &T16 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _16, } } + /// Returns a borrow of the field _17 pub fn _17(&self) -> &T17 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _17, } } + /// Returns a borrow of the field _18 pub fn _18(&self) -> &T18 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _18, } } + /// Returns a borrow of the field _19 pub fn _19(&self) -> &T19 { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => _19, @@ -3669,6 +3899,7 @@ pub mod _System { } impl Tuple20 { + /// Given type parameter conversions, returns a lambda to convert this structure pub fn coerce(f_0: Rc r#__T0 + 'static>, f_1: Rc r#__T1 + 'static>, f_2: Rc r#__T2 + 'static>, f_3: Rc r#__T3 + 'static>, f_4: Rc r#__T4 + 'static>, f_5: Rc r#__T5 + 'static>, f_6: Rc r#__T6 + 'static>, f_7: Rc r#__T7 + 'static>, f_8: Rc r#__T8 + 'static>, f_9: Rc r#__T9 + 'static>, f_10: Rc r#__T10 + 'static>, f_11: Rc r#__T11 + 'static>, f_12: Rc r#__T12 + 'static>, f_13: Rc r#__T13 + 'static>, f_14: Rc r#__T14 + 'static>, f_15: Rc r#__T15 + 'static>, f_16: Rc r#__T16 + 'static>, f_17: Rc r#__T17 + 'static>, f_18: Rc r#__T18 + 'static>, f_19: Rc r#__T19 + 'static>) -> Rc) -> Tuple20> { Rc::new(move |this: Self| -> Tuple20{ match this { diff --git a/Source/DafnyStandardLibraries/examples/FileIO/WriteBytesToFile.dfy b/Source/DafnyStandardLibraries/examples/FileIO/WriteBytesToFile.dfy index a8edfac45bf..7f0bf61a6ba 100644 --- a/Source/DafnyStandardLibraries/examples/FileIO/WriteBytesToFile.dfy +++ b/Source/DafnyStandardLibraries/examples/FileIO/WriteBytesToFile.dfy @@ -36,12 +36,12 @@ module WriteBytesToFile { var res := FileIO.WriteBytesToFile(outputDir + "/output_plain", bytes); expect res.Success?, "unexpected failure writing to output_plain: " + res.error; } - // Ensure that nonexistent parent directories are created as necessary + // Ensure that nonexistent parent directories are created as necessary { var res := FileIO.WriteBytesToFile(outputDir + "/foo/bar/output_nested", bytes); expect res.Success?, "unexpected failure writing to output_nested: " + res.error; } - // Ensure that file paths with .. are handled correctly + // Ensure that file paths with .. are handled correctly { var res := FileIO.WriteBytesToFile(outputDir + "/foo/bar/../output_up", bytes); expect res.Success?, "unexpected failure writing to output_up: " + res.error; diff --git a/Source/DafnyStandardLibraries/examples/Helpers.dfy b/Source/DafnyStandardLibraries/examples/Helpers.dfy index b8521b9fef0..1ad507cc477 100644 --- a/Source/DafnyStandardLibraries/examples/Helpers.dfy +++ b/Source/DafnyStandardLibraries/examples/Helpers.dfy @@ -5,7 +5,7 @@ module Helpers { import opened Std.Wrappers - // TODO: consider tweaking /testContracts to support this use case better. + // TODO: consider tweaking /testContracts to support this use case better. method AssertAndExpect(p: bool, maybeMsg: Option := None) requires p { match maybeMsg { case None => { diff --git a/Source/DafnyStandardLibraries/src/Std/JSON/Utils/Views.dfy b/Source/DafnyStandardLibraries/src/Std/JSON/Utils/Views.dfy index bef9530e2e8..d324a9dafee 100644 --- a/Source/DafnyStandardLibraries/src/Std/JSON/Utils/Views.dfy +++ b/Source/DafnyStandardLibraries/src/Std/JSON/Utils/Views.dfy @@ -109,12 +109,12 @@ module Std.JSON.Utils.Views.Core { // Compare endpoints first to short-circuit the potentially-costly string // comparison && lv.end == rv.beg - // We would prefer to use reference equality here, but doing so in a sound - // way is tricky (see chapter 9 of ‘Verasco: a Formally Verified C Static - // Analyzer’ by Jacques-Henri Jourdan for details). The runtime optimizes - // the common case of physical equality and otherwise performs a length - // check, so the worst case (checking for adjacency in two slices that have - // equal but not physically-equal contents) is hopefully not too common. + // We would prefer to use reference equality here, but doing so in a sound + // way is tricky (see chapter 9 of ‘Verasco: a Formally Verified C Static + // Analyzer’ by Jacques-Henri Jourdan for details). The runtime optimizes + // the common case of physical equality and otherwise performs a length + // check, so the worst case (checking for adjacency in two slices that have + // equal but not physically-equal contents) is hopefully not too common. && lv.s == rv.s } diff --git a/Source/DafnyStandardLibraries/src/Std/JSON/ZeroCopy/Serializer.dfy b/Source/DafnyStandardLibraries/src/Std/JSON/ZeroCopy/Serializer.dfy index f9a9743f1d9..597e19a446a 100644 --- a/Source/DafnyStandardLibraries/src/Std/JSON/ZeroCopy/Serializer.dfy +++ b/Source/DafnyStandardLibraries/src/Std/JSON/ZeroCopy/Serializer.dfy @@ -389,8 +389,8 @@ module Std.JSON.ZeroCopy.Serializer { SpecProperties.ConcatBytes_Linear(butLast, [last], Spec.Member); wr } // No by method block here, because the loop invariant in the method version - // needs to call MembersSpec and the termination checker gets confused by - // that. Instead, see Members above. // DISCUSS + // needs to call MembersSpec and the termination checker gets confused by + // that. Instead, see Members above. // DISCUSS // DISCUSS: Is there a way to avoid passing the ghost `v` around while // maintaining the termination argument? Maybe the lambda for elements will be enough? @@ -457,8 +457,8 @@ module Std.JSON.ZeroCopy.Serializer { } wr } // No by method block here, because the loop invariant in the method version - // needs to call `SequenceSpec` and the termination checker gets confused by - // that. Instead, see `Sequence`Items above. // DISCUSS + // needs to call `SequenceSpec` and the termination checker gets confused by + // that. Instead, see `Sequence`Items above. // DISCUSS ghost function ItemsSpec(arr: jarray, items: seq, writer: Writer) : (wr: Writer) @@ -479,8 +479,8 @@ module Std.JSON.ZeroCopy.Serializer { SpecProperties.ConcatBytes_Linear(butLast, [last], Spec.Item); wr } // No by method block here, because the loop invariant in the method version - // needs to call ItemsSpec and the termination checker gets confused by - // that. Instead, see Items above. // DISCUSS + // needs to call ItemsSpec and the termination checker gets confused by + // that. Instead, see Items above. // DISCUSS @IsolateAssertions method MembersImpl(obj: jobject, writer: Writer) returns (wr: Writer) diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/docstring.check b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/docstring.check new file mode 100644 index 00000000000..c34d07c3e91 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/docstring.check @@ -0,0 +1,15 @@ +// CHECK: .*/// Docstring for test method.* +// CHECK: .*/// Multi-line.* +// CHECK: .*docstring\.dfy\(7,1\).* +// CHECK: .*/// Docstring for functions.* +// CHECK: .*/// Docstring for classes 1.* +// CHECK: .*/// Docstring for datatype.* +// CHECK: .*/// Docstring for Constructor1.* +// CHECK: .*/// Docstring for Constructor2.* +// CHECK: .*/// Enumerates all possible values of TestDatatype.* +// CHECK: .*/// Docstring for synonym type.* +// CHECK: .*/// Docstring for module.* +// CHECK: .*/// Docstring for classes 2.* +// CHECK: .*/// Allocates an UNINITIALIZED instance. Only the Dafny compiler should use that.* +// CHECK: .*/// Docstring for predicate.* +// CHECK: .*/// Docstring for const.* diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/docstring.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/docstring.dfy new file mode 100644 index 00000000000..507d04e8c14 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/docstring.dfy @@ -0,0 +1,28 @@ +// NONUNIFORM: Test that the Rust generated code contains docstrings +// RUN: %baredafny translate rs "%s" > "%t" +// RUN: %OutputCheck --file-to-check "%S/docstring-rust/src/docstring.rs" "%S/docstring.check" + +/** Docstring for test method + * Multi-line */ +method TestMethod() { } +/** Docstring for functions */ +function TestFn(): SynonymType { 1 } +/** Docstring for classes 1 */ +class TestClass {} +/** Docstring for datatype */ +datatype TestDatatype = + | Constructor1() // Docstring for Constructor1 + | Constructor2() // Docstring for Constructor2 + +/** Docstring for synonym type */ +type SynonymType = x: int | true + +/** Docstring for module */ +module SubModule { + /** Docstring for classes 2 */ + class TestClass { + /** Docstring for const */ + const testConst: bool + predicate SingleLineFunction() { true } // Docstring for predicate + } +} \ No newline at end of file diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafnydoc/doc1/TestDafnyDoc.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafnydoc/doc1/TestDafnyDoc.dfy index d3a10a64137..7ed16d8f7c7 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafnydoc/doc1/TestDafnyDoc.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/dafnydoc/doc1/TestDafnyDoc.dfy @@ -8,12 +8,9 @@ module {:options "--function-syntax:4"} TestModule { const c := 7 + if true then 8 else 9*1 /** Number of items. All of them. */ - const {:myattribute} cc: real - // The distance. - const ccc: bool - /** Valid or not. */ - const {:myattribute}{:otherattribute 5,6} cccc: A? - // The internal state. + const {:myattribute} cc: real // The distance. + const ccc: bool // Valid or not. + const {:myattribute}{:otherattribute 5,6} cccc: A? // The internal state. const f1: int -> int const f2: set ~> seq diff --git a/docs/DafnyRef/Grammar.md b/docs/DafnyRef/Grammar.md index a7b7662ca4a..127ab70bfe8 100644 --- a/docs/DafnyRef/Grammar.md +++ b/docs/DafnyRef/Grammar.md @@ -183,17 +183,12 @@ by IDEs and documentation generation tools to present information to users. In Dafny programs. * Documentation comments (a) either begin with `/**` or (b) begin with `//` or /*` in specific locations -* Doc-comments may be associated with any declaration, including type definitions, export declarations, and datatype constructors. -* They may be placed before or after the declaration. - * If before, it must be a `/**` comment and may not have any blank or white-space lines between the comment - and the declaration. - * If after, any comments are placed after the signature (with no intervening lines), but before any - specifications or left-brace that starts a body, and may be `//` or `/**` or `/*` comments. - * If doc-comments are in both places, only the comments after the declaration are used. -* Doc-comments after the declaration are preferred. -* If the first of a series of single-line or multi-line comments is interpreted as a doc-string, then any subsequent comments - are appended to it, so long as there are no intervening lines, whether blank, all white-space or containing program text. -* The extraction of the doc-string from a multiline comment follow these rules +* Documentation comments may be associated with any declaration, including type definitions, export declarations, and datatype constructors. +* They may be placed before the declaration, between the declaration and the definition or after the definition. The priority of these comments is the following: + * If there is a comment starting with `/**` right before the definition, it's the documentation comment. + * Otherwise, if one or more comments appear between a declaration and its definition — which is uncommon in other programming languages — they are treated as documentation comments, regardless of whether they start with //, /**, or /*. This is because there is no other plausible reason for a comment to be placed in this position. + * Otherwise, if there is a single comment starting with `//` or `/**` or `/*` at the end of the definition, it's the documentation comment. In this case, multi-line documentation comments must be starting with `/*` +* The extraction of the doc-string from a documentation comment follows the following rules * On the first line, an optional `*` right after `/*` and an optional space are removed, if present * On other lines, the indentation space (with possibly one star in it) is removed, as if the content was supposed to align with A if the comment started with `/** A` for example. * The documentation string is interpreted as plain text, but it is possible to provide a user-written @@ -203,40 +198,32 @@ In Dafny programs. Here are examples: ```dafny -const c0 := 8 -/** docstring about c0 */ +/* Just a comment */ +const c0: int := 8 // docstring about c0 +// Just a comment /** docstring about c1 */ -const c1 := 8 - -/** first line of docstring */ -const c2 := 8 -/** second line of docstring */ - -const c3 := 8 -// docstring about c3 -// on two lines - -const c4 := 8 - -// just a comment +newtype c1 = x : int | x > 8 // Just a comment +/* Just a comment */ +function c2(): (r: int) // Docstring about c2 + ensures r > 0 +{ 8 } // Just a comment // just a comment const c5 := 8 - ``` Datatype constructors may also have comments: ```dafny -datatype T = // Docstring for T - | A(x: int, +datatype T // Docstring for T += | A(x: int, y: int) // Docstring for A | B() /* Docstring for B */ | C() // Docstring for C -/** Docstring for T0*/ +/** Docstring for T0 */ datatype T0 = | /** Docstring for A */ A(x: int, @@ -251,21 +238,23 @@ As can `export` declarations: ```dafny module M { -const A: int -const B: int -const C: int -const D: int - -export - // This is the eponymous export set intended for most clients - provides A, B, C - - -export Friends extends M - // This export set is for clients who need to know more of the - // details of the module's definitions. - reveals A - provides D + const A: int + const B: int + const C: int + const D: int + + export + // This is the docstring of the eponymous export set intended for most clients + provides A, B, C + + /** This is the docstring */ + export AB provides A, B + + export Friends extends AB + // This is the docstring of the export set is for clients who need to know more of the + // details of the module's definitions. + reveals A + provides D } ```