diff --git a/Source/DafnyCore.Test/GeneratedDafnyTest.cs b/Source/DafnyCore.Test/GeneratedDafnyTest.cs index 72600e6f7c6..58e73d0e958 100644 --- a/Source/DafnyCore.Test/GeneratedDafnyTest.cs +++ b/Source/DafnyCore.Test/GeneratedDafnyTest.cs @@ -5,7 +5,12 @@ namespace DafnyCore.Test; public class GeneratedDafnyTest { [Fact] - public void TestDafnyGeneratedCode() { + public void TestDafnyCoverage() { DafnyToRustCompilerCoverage.RASTCoverage.__default.TestExpr(); } + + [Fact] + public void TestPathSimplification() { + FactorPathsOptimizationTest.__default.TestApply(); + } } \ No newline at end of file diff --git a/Source/DafnyCore.Test/GeneratedFromDafny/DafnyToRustCompilerCoverage_RASTCoverage.cs b/Source/DafnyCore.Test/GeneratedFromDafny/DafnyToRustCompilerCoverage_RASTCoverage.cs index 8319b008012..9f23566b7a1 100644 --- a/Source/DafnyCore.Test/GeneratedFromDafny/DafnyToRustCompilerCoverage_RASTCoverage.cs +++ b/Source/DafnyCore.Test/GeneratedFromDafny/DafnyToRustCompilerCoverage_RASTCoverage.cs @@ -15,12 +15,16 @@ namespace DafnyToRustCompilerCoverage.RASTCoverage { public partial class __default { + public static void AssertCoverage(bool x) + { + if (!(x)) { + throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-coverage.dfy(13,6): " + Dafny.Sequence.UnicodeFromString("expectation violation").ToVerbatimString(false));} + } public static void TestExpr() { DafnyToRustCompilerCoverage.RASTCoverage.__default.TestOptimizeToString(); DafnyToRustCompilerCoverage.RASTCoverage.__default.TestPrintingInfo(); DafnyToRustCompilerCoverage.RASTCoverage.__default.TestNoExtraSemicolonAfter(); - FactorPathsOptimizationTest.__default.TestApply(); } public static void TestNoOptimize(RAST._IExpr e) { @@ -32,20 +36,22 @@ public static RAST._IExpr ConversionNum(RAST._IType t, RAST._IExpr x) public static RAST._IExpr DafnyIntLiteral(Dafny.ISequence s) { return RAST.Expr.create_Call(RAST.Expr.create_ExprFromPath(RAST.Path.create_PMemberSelect(RAST.__default.dafny__runtime, Dafny.Sequence.UnicodeFromString("int!"))), Dafny.Sequence.FromElements(RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("1")))); } + public static RAST._IExpr Optimize(RAST._IExpr e) { + return (ExpressionOptimization.__default.ExprSimplifier()).ReplaceExpr(e); + } public static void TestOptimizeToString() { RAST._IExpr _0_x; _0_x = RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")); RAST._IExpr _1_y; _1_y = RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("y")); - DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals((RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("&"), RAST.Expr.create_Call(RAST.Expr.create_Select(_0_x, Dafny.Sequence.UnicodeFromString("clone")), Dafny.Sequence.FromElements()), DAST.Format.UnaryOpFormat.create_NoFormat())).Optimize(), RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("&"), _0_x, DAST.Format.UnaryOpFormat.create_NoFormat()))); DafnyToRustCompilerCoverage.RASTCoverage.__default.TestNoOptimize(RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("&"), RAST.Expr.create_Call(RAST.Expr.create_Select(_0_x, Dafny.Sequence.UnicodeFromString("clone")), Dafny.Sequence.FromElements(_1_y)), DAST.Format.UnaryOpFormat.create_NoFormat())); - DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals((RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=="), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_NoFormat()), DAST.Format.UnaryOpFormat.create_CombineFormat())).Optimize(), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("!="), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_NoFormat()))); - DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals((RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<"), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_NoFormat()), DAST.Format.UnaryOpFormat.create_CombineFormat())).Optimize(), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString(">="), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_NoFormat()))); - DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals((RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<"), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_ReverseFormat()), DAST.Format.UnaryOpFormat.create_CombineFormat())).Optimize(), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<="), _1_y, _0_x, DAST.Format.BinaryOpFormat.create_NoFormat()))); - DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals((DafnyToRustCompilerCoverage.RASTCoverage.__default.ConversionNum(RAST.Type.create_I128(), DafnyToRustCompilerCoverage.RASTCoverage.__default.DafnyIntLiteral(Dafny.Sequence.UnicodeFromString("1")))).Optimize(), RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("1")))); + DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals(DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=="), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_NoFormat()), DAST.Format.UnaryOpFormat.create_CombineFormat())), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("!="), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_NoFormat()))); + DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals(DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<"), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_NoFormat()), DAST.Format.UnaryOpFormat.create_CombineFormat())), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString(">="), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_NoFormat()))); + DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals(DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<"), _0_x, _1_y, DAST.Format.BinaryOpFormat.create_ReverseFormat()), DAST.Format.UnaryOpFormat.create_CombineFormat())), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<="), _1_y, _0_x, DAST.Format.BinaryOpFormat.create_NoFormat()))); + DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals(DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(DafnyToRustCompilerCoverage.RASTCoverage.__default.ConversionNum(RAST.Type.create_I128(), DafnyToRustCompilerCoverage.RASTCoverage.__default.DafnyIntLiteral(Dafny.Sequence.UnicodeFromString("1")))), RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("1")))); DafnyToRustCompilerCoverage.RASTCoverage.__default.TestNoOptimize(DafnyToRustCompilerCoverage.RASTCoverage.__default.ConversionNum(RAST.Type.create_I128(), _0_x)); - DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals((RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("z"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), RAST.Expr.create_StmtExpr(RAST.__default.AssignVar(Dafny.Sequence.UnicodeFromString("z"), _1_y), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("return"))))).Optimize(), RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("z"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_Some(_1_y)), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("return"))))); + DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals(DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("z"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), RAST.Expr.create_StmtExpr(RAST.__default.AssignVar(Dafny.Sequence.UnicodeFromString("z"), _1_y), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("return"))))), RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("z"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_Some(_1_y)), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("return"))))); DafnyToRustCompilerCoverage.RASTCoverage.__default.TestNoOptimize(RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("z"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), RAST.Expr.create_StmtExpr(RAST.__default.AssignVar(Dafny.Sequence.UnicodeFromString("w"), _1_y), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("return"))))); DafnyToRustCompilerCoverage.RASTCoverage.__default.TestNoOptimize(_0_x); DafnyToRustCompilerCoverage.RASTCoverage.__default.TestNoOptimize(RAST.Expr.create_StmtExpr(_0_x, _0_x)); @@ -58,7 +64,7 @@ public static void TestOptimizeToString() DafnyToRustCompilerCoverage.RASTCoverage.__default.TestNoOptimize(RAST.Expr.create_StmtExpr(RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("1")), _0_x)); DafnyToRustCompilerCoverage.RASTCoverage.__default.TestNoOptimize(RAST.Expr.create_StmtExpr(RAST.Expr.create_LiteralString(Dafny.Sequence.UnicodeFromString("2"), true, false), _0_x)); DafnyToRustCompilerCoverage.RASTCoverage.__default.TestNoOptimize(RAST.Expr.create_StmtExpr(RAST.Expr.create_LiteralString(Dafny.Sequence.UnicodeFromString("3"), false, true), _0_x)); - DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals((RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("z"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), RAST.Expr.create_StmtExpr(RAST.__default.AssignVar(Dafny.Sequence.UnicodeFromString("z"), _1_y), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("return"))))).Optimize(), RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("z"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_Some(_1_y)), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("return"))))); + DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals(DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("z"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), RAST.Expr.create_StmtExpr(RAST.__default.AssignVar(Dafny.Sequence.UnicodeFromString("z"), _1_y), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("return"))))), RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("z"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_Some(_1_y)), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("return"))))); Dafny.ISequence _2_coverageExpression; _2_coverageExpression = Dafny.Sequence.FromElements(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("abc")), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), RAST.Expr.create_Match(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), Dafny.Sequence.FromElements(RAST.MatchCase.create(Dafny.Sequence.UnicodeFromString("abc"), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x"))))), RAST.Expr.create_StmtExpr(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("panic!()")), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("a"))), RAST.Expr.create_Block(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("abc"))), RAST.Expr.create_StructBuild(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("dummy")), Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(Dafny.Sequence.UnicodeFromString("foo"), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("bar"))))), RAST.Expr.create_StructBuild(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("dummy")), Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(Dafny.Sequence.UnicodeFromString("foo"), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("bar"))), RAST.AssignIdentifier.create(Dafny.Sequence.UnicodeFromString("foo2"), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("bar"))))), RAST.Expr.create_Tuple(Dafny.Sequence.FromElements(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")))), RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("-"), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), DAST.Format.UnaryOpFormat.create_NoFormat()), RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("+"), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("y")), DAST.Format.BinaryOpFormat.create_NoFormat()), RAST.Expr.create_TypeAscription(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), RAST.Type.create_I128()), RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("322")), RAST.Expr.create_LiteralString(Dafny.Sequence.UnicodeFromString("abc"), true, false), RAST.Expr.create_LiteralString(Dafny.Sequence.UnicodeFromString("abc"), false, true), RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("abc"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), RAST.Expr.create_DeclareVar(RAST.DeclareType.create_CONST(), Dafny.Sequence.UnicodeFromString("abc"), Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")))), RAST.__default.AssignVar(Dafny.Sequence.UnicodeFromString("abc"), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x"))), RAST.Expr.create_IfExpr(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x"))), RAST.Expr.create_Loop(Std.Wrappers.Option.create_Some(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x"))), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x"))), RAST.Expr.create_For(Dafny.Sequence.UnicodeFromString("abc"), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x"))), RAST.Expr.create_Labelled(Dafny.Sequence.UnicodeFromString("abc"), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x"))), RAST.Expr.create_Break(Std.Wrappers.Option>.create_None()), RAST.Expr.create_Break(Std.Wrappers.Option>.create_Some(Dafny.Sequence.UnicodeFromString("l"))), RAST.Expr.create_Continue(Std.Wrappers.Option>.create_None()), RAST.Expr.create_Continue(Std.Wrappers.Option>.create_Some(Dafny.Sequence.UnicodeFromString("l"))), RAST.Expr.create_Return(Std.Wrappers.Option.create_None()), RAST.Expr.create_Return(Std.Wrappers.Option.create_Some(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")))), RAST.Expr.create_Call(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), Dafny.Sequence.FromElements()), RAST.Expr.create_Call(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), Dafny.Sequence.FromElements(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("y")))), RAST.Expr.create_CallType(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), Dafny.Sequence.FromElements(RAST.Type.create_I128(), RAST.Type.create_U32())), RAST.Expr.create_Select(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("x")), Dafny.Sequence.UnicodeFromString("abc")), RAST.Expr.create_ExprFromPath(RAST.Path.create_PMemberSelect(RAST.Path.create_Crate(), Dafny.Sequence.UnicodeFromString("abc"))), RAST.Expr.create_ExprFromPath(RAST.Path.create_PMemberSelect(RAST.Path.create_Global(), Dafny.Sequence.UnicodeFromString("abc")))); BigInteger _hi0 = new BigInteger((_2_coverageExpression).Count); @@ -68,21 +74,21 @@ public static void TestOptimizeToString() RAST._IPrintingInfo _5___v0; _5___v0 = (_4_c).printingInfo; RAST._IExpr _6___v1; - _6___v1 = (_4_c).Optimize(); + _6___v1 = DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(_4_c); Dafny.IMap> _7___v2; _7___v2 = Dafny.Map>.FromElements(new Dafny.Pair>(_4_c, (_4_c)._ToString(Dafny.Sequence.UnicodeFromString("")))); RAST._IExpr _8___v3; - _8___v3 = (RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("abc"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), _4_c)).Optimize(); + _8___v3 = DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("abc"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), _4_c)); RAST._IExpr _9___v4; - _9___v4 = (RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("abc"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), RAST.Expr.create_StmtExpr(RAST.__default.AssignVar(Dafny.Sequence.UnicodeFromString("abc"), _4_c), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString(""))))).Optimize(); + _9___v4 = DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("abc"), Std.Wrappers.Option.create_Some(RAST.Type.create_I128()), Std.Wrappers.Option.create_None()), RAST.Expr.create_StmtExpr(RAST.__default.AssignVar(Dafny.Sequence.UnicodeFromString("abc"), _4_c), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString(""))))); RAST._IExpr _10___v5; - _10___v5 = (RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("&"), _4_c, DAST.Format.UnaryOpFormat.create_NoFormat())).Optimize(); + _10___v5 = DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("&"), _4_c, DAST.Format.UnaryOpFormat.create_NoFormat())); RAST._IExpr _11___v6; - _11___v6 = (RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), _4_c, DAST.Format.UnaryOpFormat.create_NoFormat())).Optimize(); + _11___v6 = DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), _4_c, DAST.Format.UnaryOpFormat.create_NoFormat())); RAST._IExpr _12___v7; - _12___v7 = (DafnyToRustCompilerCoverage.RASTCoverage.__default.ConversionNum(RAST.Type.create_U8(), _4_c)).Optimize(); + _12___v7 = DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(DafnyToRustCompilerCoverage.RASTCoverage.__default.ConversionNum(RAST.Type.create_U8(), _4_c)); RAST._IExpr _13___v8; - _13___v8 = (DafnyToRustCompilerCoverage.RASTCoverage.__default.ConversionNum(RAST.Type.create_U8(), RAST.Expr.create_Call(_4_c, Dafny.Sequence.FromElements()))).Optimize(); + _13___v8 = DafnyToRustCompilerCoverage.RASTCoverage.__default.Optimize(DafnyToRustCompilerCoverage.RASTCoverage.__default.ConversionNum(RAST.Type.create_U8(), RAST.Expr.create_Call(_4_c, Dafny.Sequence.FromElements()))); Std.Wrappers._IOption> _14___v9; _14___v9 = (_4_c).RightMostIdentifier(); } @@ -144,9 +150,6 @@ public static void TestPrintingInfo() DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals((RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("?!?"), _0_x, _1_y, _2_bnf)).printingInfo, RAST.PrintingInfo.create_PrecedenceAssociativity(BigInteger.Zero, RAST.Associativity.create_RequiresParentheses()))); DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage(object.Equals((RAST.Expr.create_Break(Std.Wrappers.Option>.create_None())).printingInfo, RAST.PrintingInfo.create_UnknownPrecedence())); } - public static void AssertCoverage(bool x) - { - } public static void TestNoExtraSemicolonAfter() { DafnyToRustCompilerCoverage.RASTCoverage.__default.AssertCoverage((RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString(";"))).NoExtraSemicolonAfter()); diff --git a/Source/DafnyCore.Test/GeneratedFromDafny/FactorPathsOptimizationTest.cs b/Source/DafnyCore.Test/GeneratedFromDafny/FactorPathsOptimizationTest.cs index 619b9656ad7..5d1211e0dae 100644 --- a/Source/DafnyCore.Test/GeneratedFromDafny/FactorPathsOptimizationTest.cs +++ b/Source/DafnyCore.Test/GeneratedFromDafny/FactorPathsOptimizationTest.cs @@ -25,7 +25,7 @@ public static void ShouldBeEqual(RAST._IMod a, RAST._IMod b) Dafny.Helpers.Print((Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Got:\n"), _0_sA), Dafny.Sequence.UnicodeFromString("\n"))).ToVerbatimString(false)); Dafny.Helpers.Print((Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Expected:\n"), _1_sB), Dafny.Sequence.UnicodeFromString("\n"))).ToVerbatimString(false)); if (!((_0_sA).Equals(_1_sB))) { - throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-path-simplification.dfy(12,6): " + Dafny.Sequence.UnicodeFromString("expectation violation").ToVerbatimString(false));} + throw new Dafny.HaltException("Backends/Rust/Dafny-compiler-rust-path-simplification.dfy(13,6): " + Dafny.Sequence.UnicodeFromString("expectation violation").ToVerbatimString(false));} } } public static void TestApply() @@ -42,6 +42,8 @@ public static void TestApply() _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.UnicodeFromString(""), 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.UnicodeFromString(""), 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.UnicodeFromString(""), 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.UnicodeFromString(""), 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.UnicodeFromString(""), 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.UnicodeFromString(""), 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"))))))); } } } // end of namespace FactorPathsOptimizationTest \ No newline at end of file diff --git a/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs b/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs index 5e3ee5c8db5..430eb8cc3c2 100644 --- a/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs +++ b/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs @@ -185,9 +185,15 @@ protected override void EmitBuiltInDecls(SystemModuleManager systemModuleManager // } // They aren't in any namespace to make them universally accessible. private void EmitFuncExtensions(SystemModuleManager systemModuleManager, ConcreteSyntaxTree wr) { - var funcExtensions = wr.NewNamedBlock("internal static class FuncExtensions"); + // An extension for this arity will be provided in the Runtime which has to be linked. + var omitAritiesBefore16 = !Options.IncludeRuntime && Options.SystemModuleTranslationMode is not CommonOptionBag.SystemModuleMode.OmitAllOtherModules; + var name = omitAritiesBefore16 ? "FuncExtensionsAfterArity16" : "FuncExtensions"; + var funcExtensions = wr.NewNamedBlock("public static class " + name); foreach (var kv in systemModuleManager.ArrowTypeDecls) { int arity = kv.Key; + if (omitAritiesBefore16 && arity <= 16) { + continue; + } List TypeParameterList(string prefix) { var l = arity switch { diff --git a/Source/DafnyCore/Backends/Dafny/AST.dfy b/Source/DafnyCore/Backends/Dafny/AST.dfy index a4998f529f4..ff7fa674b28 100644 --- a/Source/DafnyCore/Backends/Dafny/AST.dfy +++ b/Source/DafnyCore/Backends/Dafny/AST.dfy @@ -128,10 +128,11 @@ module {:extern "DAST"} DAST { | SupportsEquality | SupportsDefault - datatype Primitive = Int | Real | String | Bool | Char + datatype Primitive = Int | Real | String | Bool | Char | Native + // USIZE is for whatever target considers that native arrays can be indexed with datatype NewtypeRange = - | U8 | I8 | U16 | I16 | U32 | I32 | U64 | I64 | U128 | I128 | BigInt + | U8 | I8 | U16 | I16 | U32 | I32 | U64 | I64 | U128 | I128 | USIZE | BigInt | NoRange datatype Attribute = Attribute(name: string, args: seq) diff --git a/Source/DafnyCore/Backends/Dafny/ASTBuilder.cs b/Source/DafnyCore/Backends/Dafny/ASTBuilder.cs index 51eec419470..e00b0adaa52 100644 --- a/Source/DafnyCore/Backends/Dafny/ASTBuilder.cs +++ b/Source/DafnyCore/Backends/Dafny/ASTBuilder.cs @@ -1806,7 +1806,7 @@ public void AddBuildable(BuildableExpr item) { } } - public static DAST.Expression ToNativeU64(int number) { + public static DAST.Expression ToNativeUsize(int number) { var origType = DAST.Type.create_Primitive(DAST.Primitive.create_Int()); var numberExpr = (DAST.Expression)DAST.Expression.create_Literal( DAST.Literal.create_IntLiteral(Sequence.UnicodeFromString($"{number}"), @@ -1814,9 +1814,9 @@ public static DAST.Expression ToNativeU64(int number) { ); return (DAST.Expression)DAST.Expression.create_Convert(numberExpr, origType, DAST.Type.create_UserDefined( DAST.ResolvedType.create_ResolvedType( - Sequence>.FromElements((Sequence)Sequence.UnicodeFromString("u64")), + Sequence>.FromElements((Sequence)Sequence.UnicodeFromString("usize")), Sequence<_IType>.Empty, - DAST.ResolvedTypeBase.create_Newtype(origType, DAST.NewtypeRange.create_U64(), true), Sequence<_IAttribute>.Empty, + DAST.ResolvedTypeBase.create_Newtype(origType, DAST.NewtypeRange.create_USIZE(), true), Sequence<_IAttribute>.Empty, Sequence>.Empty, Sequence<_IType>.Empty) )); } @@ -1833,14 +1833,14 @@ public DAST.Expression Build() { DAST.Expression startExpr; if (start == null) { - startExpr = ToNativeU64(0); + startExpr = ToNativeUsize(0); } else { startExpr = (DAST.Expression)DAST.Expression.create_Ident( Sequence.UnicodeFromString(start)); } return (DAST.Expression)DAST.Expression.create_IntRange( - DAST.Type.create_Primitive(DAST.Primitive.create_Int()), + DAST.Type.create_Primitive(DAST.Primitive.create_Native()), startExpr, endExpr, true); } diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-coverage.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-coverage.dfy index 10177703d1e..c2d94f0d3db 100644 --- a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-coverage.dfy +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-coverage.dfy @@ -6,13 +6,17 @@ module DafnyToRustCompilerCoverage { import opened Std.Wrappers import opened DAST.Format import Strings = Std.Strings - import FactorPathsOptimizationTest + import ExpressionOptimization + + method AssertCoverage(x: bool) + { + expect x; + } method TestExpr() { TestOptimizeToString(); TestPrintingInfo(); TestNoExtraSemicolonAfter(); - FactorPathsOptimizationTest.TestApply(); } method TestNoOptimize(e: Expr) @@ -35,21 +39,23 @@ module DafnyToRustCompilerCoverage { Call(ExprFromPath(PMemberSelect(dafny_runtime, "int!")), [LiteralInt("1")]) } + function Optimize(e: Expr): Expr { + ExpressionOptimization.ExprSimplifier().ReplaceExpr(e) + } + method TestOptimizeToString() { var x := Identifier("x"); var y := Identifier("y"); - AssertCoverage(UnaryOp("&", Call(Select(x, "clone"), []), UnaryOpFormat.NoFormat).Optimize() - == UnaryOp("&", x, UnaryOpFormat.NoFormat)); TestNoOptimize(UnaryOp("&", Call(Select(x, "clone"), [y]), UnaryOpFormat.NoFormat)); - AssertCoverage(UnaryOp("!", BinaryOp("==", x, y, BinaryOpFormat.NoFormat), - CombineFormat()).Optimize() == BinaryOp("!=", x, y, BinaryOpFormat.NoFormat)); - AssertCoverage(UnaryOp("!", BinaryOp("<", x, y, BinaryOpFormat.NoFormat), - CombineFormat()).Optimize() == BinaryOp(">=", x, y, BinaryOpFormat.NoFormat())); - AssertCoverage(UnaryOp("!", BinaryOp("<", x, y, ReverseFormat()), - CombineFormat()).Optimize() == BinaryOp("<=", y, x, BinaryOpFormat.NoFormat())); - AssertCoverage(ConversionNum(I128, DafnyIntLiteral("1")).Optimize() == LiteralInt("1")); + AssertCoverage(Optimize(UnaryOp("!", BinaryOp("==", x, y, BinaryOpFormat.NoFormat), + CombineFormat())) == BinaryOp("!=", x, y, BinaryOpFormat.NoFormat)); + AssertCoverage(Optimize(UnaryOp("!", BinaryOp("<", x, y, BinaryOpFormat.NoFormat), + CombineFormat())) == BinaryOp(">=", x, y, BinaryOpFormat.NoFormat())); + AssertCoverage(Optimize(UnaryOp("!", BinaryOp("<", x, y, ReverseFormat()), + CombineFormat())) == BinaryOp("<=", y, x, BinaryOpFormat.NoFormat())); + AssertCoverage(Optimize(ConversionNum(I128, DafnyIntLiteral("1"))) == LiteralInt("1")); TestNoOptimize(ConversionNum(I128, x)); - AssertCoverage(StmtExpr(DeclareVar(MUT, "z", Some(I128), None), StmtExpr(AssignVar("z", y), RawExpr("return"))).Optimize() + AssertCoverage(Optimize(StmtExpr(DeclareVar(MUT, "z", Some(I128), None), StmtExpr(AssignVar("z", y), RawExpr("return")))) == StmtExpr(DeclareVar(MUT, "z", Some(I128), Some(y)), RawExpr("return"))); TestNoOptimize(StmtExpr(DeclareVar(MUT, "z", Some(I128), None), StmtExpr(AssignVar("w", y), RawExpr("return")))); @@ -64,7 +70,7 @@ module DafnyToRustCompilerCoverage { TestNoOptimize(StmtExpr(LiteralInt("1"), x)); TestNoOptimize(StmtExpr(LiteralString("2", true, false), x)); TestNoOptimize(StmtExpr(LiteralString("3", false, true), x)); - AssertCoverage(StmtExpr(DeclareVar(MUT, "z", Some(I128), None), StmtExpr(AssignVar("z", y), RawExpr("return"))).Optimize() + AssertCoverage(Optimize(StmtExpr(DeclareVar(MUT, "z", Some(I128), None), StmtExpr(AssignVar("z", y), RawExpr("return")))) == StmtExpr(DeclareVar(MUT, "z", Some(I128), Some(y)), RawExpr("return"))); var coverageExpression := [ @@ -105,14 +111,14 @@ module DafnyToRustCompilerCoverage { for i := 0 to |coverageExpression| { var c := coverageExpression[i]; var _ := c.printingInfo; - var _ := c.Optimize(); + var _ := Optimize(c); var _ := map[c := c.ToString("")]; - var _ := StmtExpr(DeclareVar(MUT, "abc", Some(I128), None), c).Optimize(); - var _ := StmtExpr(DeclareVar(MUT, "abc", Some(I128), None), StmtExpr(AssignVar("abc", c), RawExpr(""))).Optimize(); - var _ := UnaryOp("&", c, UnaryOpFormat.NoFormat()).Optimize(); - var _ := UnaryOp("!", c, UnaryOpFormat.NoFormat()).Optimize(); - var _ := ConversionNum(U8, c).Optimize(); - var _ := ConversionNum(U8, Call(c, [])).Optimize(); + var _ := Optimize(StmtExpr(DeclareVar(MUT, "abc", Some(I128), None), c)); + var _ := Optimize(StmtExpr(DeclareVar(MUT, "abc", Some(I128), None), StmtExpr(AssignVar("abc", c), RawExpr("")))); + var _ := Optimize(UnaryOp("&", c, UnaryOpFormat.NoFormat())); + var _ := Optimize(UnaryOp("!", c, UnaryOpFormat.NoFormat())); + var _ := Optimize(ConversionNum(U8, c)); + var _ := Optimize(ConversionNum(U8, Call(c, []))); var _ := c.RightMostIdentifier(); } @@ -172,11 +178,6 @@ module DafnyToRustCompilerCoverage { AssertCoverage(Break(None).printingInfo == UnknownPrecedence()); } - method AssertCoverage(x: bool) - //requires x // Too expensive - { - } - method TestNoExtraSemicolonAfter() { AssertCoverage(RawExpr(";").NoExtraSemicolonAfter()); AssertCoverage(!RawExpr("a").NoExtraSemicolonAfter()); diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-expression-optimization.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-expression-optimization.dfy new file mode 100644 index 00000000000..2c569966437 --- /dev/null +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-expression-optimization.dfy @@ -0,0 +1,66 @@ +// Tests in Dafny-compiler-rust-coverage +module ExpressionOptimization { + import Std + import opened RAST + import opened DAST.Format + import opened Std.Wrappers + + function apply(mod: Mod): Mod { + ExprSimplifier().ReplaceMod(mod, crate.MSel(mod.name)) + } + + function ExprSimplifier(): RASTBottomUpReplacer + { + RASTBottomUpReplacer( + ReplaceModSingle := + (m: Mod, SelfPath: Path) => m, + ReplaceTypeSingle := (t: Type) => t, + ReplaceExprSingle := + (e: Expr) => + match e { + case UnaryOp("!", BinaryOp(op, left, right, format), + CombineFormat()) => + match op { + case "==" => BinaryOp("!=", left, right, BinaryOpFormat.NoFormat()) + case "<" => + if format.NoFormat? then + BinaryOp(">=", left, right, BinaryOpFormat.NoFormat()) + else if format.ReverseFormat? then + BinaryOp("<=", right, left, BinaryOpFormat.NoFormat()) + else + e + case _ => e + } + case Call(ExprFromPath(PMemberSelect(r, "truncate!")), args) => + if (r != dafny_runtime && r != global) || |args| != 2 then + e + else + var expr := args[0]; + var tpeExpr := args[1]; + if !tpeExpr.ExprFromType? then e else + var tpe := tpeExpr.tpe; + if || tpe.U8? || tpe.U16? || tpe.U32? || tpe.U64? || tpe.U128? + || tpe.I8? || tpe.I16? || tpe.I32? || tpe.I64? || tpe.I128? || tpe.USIZE? then + match expr { + case Call(ExprFromPath(PMemberSelect(base, "int!")), args) => + if |args| == 1 && (base == dafny_runtime || base == global) then + match args[0] { + case LiteralInt(number) => LiteralInt(number) + case LiteralString(number, _, _) => LiteralInt(number) + case _ => e + } + else e + case _ => e + } + else + e + case StmtExpr(DeclareVar(mod, name, Some(tpe), None), StmtExpr(Assign(name2, rhs), last)) => + if name2 == Some(LocalVar(name)) then + StmtExpr(DeclareVar(mod, name, Some(tpe), Some(rhs)), last) + else + e + case _ => e + } + ) + } +} 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 4956c4d01e7..54b947ad870 100644 --- a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-path-simplification.dfy +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust-path-simplification.dfy @@ -2,6 +2,7 @@ module FactorPathsOptimizationTest { export provides TestApply import opened RAST import opened FactorPathsOptimization + import opened Std.Wrappers method ShouldBeEqual(a: Mod, b: Mod) { var sA := a.ToString(""); @@ -19,42 +20,139 @@ module FactorPathsOptimizationTest { var T := TIdentifier("T"); var std_any_Any := global.MSel("std").MSel("any").MSel("Any"); var Any := TIdentifier("Any"); - ShouldBeEqual(apply(crate)( - Mod("onemodule", [], [ - StructDecl( - Struct([], "test", [T_Decl], - NamedFields([Field(PUB, Formal("a", std_any_Any.AsType()))]))), - // ::std::any::Any ==> Any - ImplDecl(Impl([T_Decl], TIdentifier("test").Apply([T]), "", [])), - ImplDecl( - ImplFor( - [T_Decl], std_any_Any.AsType(), crate.MSel("onemodule").MSel("test").AsType().Apply([T]), "", [])) - // ::std::any::Any ==> Any crate::onemodule::test ==> test - ])), - Mod("onemodule", [], [ - UseDecl(Use(PUB, dafny_runtime.MSel("DafnyType"))), - UseDecl(Use(PUB, std_any_Any)), - StructDecl( - Struct([], "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]), "", [])) - ])); - ShouldBeEqual(apply(crate)( - Mod("onemodule", [], [ - ImplDecl( - ImplFor( - [T_Decl], dafny_runtime.MSel("UpcastObject").AsType().Apply([TIdentifier("x")]), - TIdentifier("test").Apply([T]), "", [])) - ])), - Mod("onemodule", [], [ - UseDecl(Use(PUB, dafny_runtime.MSel("DafnyType"))), - UseDecl(Use(PUB, dafny_runtime.MSel("UpcastObject"))), - ImplDecl( - ImplFor( - [T_Decl_simp], TIdentifier("UpcastObject").Apply([TIdentifier("x")]), - TIdentifier("test").Apply([T]), "", [])) - ])); + ShouldBeEqual( + apply(crate)( + Mod( + "onemodule", [], [ + StructDecl( + Struct([], "test", [T_Decl], + NamedFields([Field(PUB, Formal("a", std_any_Any.AsType()))]))), + // ::std::any::Any ==> Any + ImplDecl(Impl([T_Decl], TIdentifier("test").Apply([T]), "", [])), + ImplDecl( + ImplFor( + [T_Decl], std_any_Any.AsType(), crate.MSel("onemodule").MSel("test").AsType().Apply([T]), "", [])) + // ::std::any::Any ==> Any crate::onemodule::test ==> test + ])), + Mod( + "onemodule", [], [ + UseDecl(Use(PUB, dafny_runtime.MSel("DafnyType"))), + UseDecl(Use(PUB, std_any_Any)), + StructDecl( + Struct([], "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]), "", [])) + ])); + ShouldBeEqual( + apply(crate)( + Mod( + "onemodule", [], [ + ImplDecl( + ImplFor( + [T_Decl], dafny_runtime.MSel("UpcastObject").AsType().Apply([TIdentifier("x")]), + TIdentifier("test").Apply([T]), "", [])) + ])), + Mod( + "onemodule", [], [ + UseDecl(Use(PUB, dafny_runtime.MSel("DafnyType"))), + UseDecl(Use(PUB, dafny_runtime.MSel("UpcastObject"))), + ImplDecl( + ImplFor( + [T_Decl_simp], TIdentifier("UpcastObject").Apply([TIdentifier("x")]), + TIdentifier("test").Apply([T]), "", [])) + ])); + ShouldBeEqual( + apply(crate)( + Mod( + "onemodule", [], [ + ConstDecl( + Constant( + [], + "dummy", std_any_Any.AsType(), + StmtExpr( + DeclareVar( + MUT, "doit", Some(std_rc_Rc.AsType().Apply1(TIdentifier("unknown"))), + Some( + Identifier("something").ApplyType( + [ DynType(std_default_Default.AsType()) + ]).Apply([ + std_default_Default_default, + dafny_runtime.MSel("rd!").AsExpr().Apply1(Identifier("obj")) + ]) + )), + TypeAscription( + ExprFromType( + dafny_runtime.MSel("DafnyString").AsType()), + dafny_runtime.MSel("DafnyType").AsType())))) + ])), + Mod( + "onemodule", [], [ + UseDecl(Use(PUB, std_any_Any)), + UseDecl(Use(PUB, std_rc_Rc)), + UseDecl(Use(PUB, std_default_Default)), + UseDecl(Use(PUB, dafny_runtime.MSel("rd"))), + UseDecl(Use(PUB, dafny_runtime.MSel("DafnyString"))), + UseDecl(Use(PUB, dafny_runtime.MSel("DafnyType"))), + ConstDecl( + Constant( + [], + "dummy", TIdentifier("Any"), + StmtExpr( + DeclareVar( + MUT, "doit", Some(TIdentifier("Rc").Apply1(TIdentifier("unknown"))), + Some( + Identifier("something").ApplyType( + [ DynType(TIdentifier("Default")) + ]).Apply([ + Identifier("Default").FSel("default").Apply([]), + Identifier("rd!").Apply1(Identifier("obj")) + ]) + )), + TypeAscription( + ExprFromType( + TIdentifier("DafnyString")), + TIdentifier("DafnyType"))))) + ])); + + // Edge case: There is a trait in the current module + // And we have a constant of the type of this trait + // and another the type of another trait in another module but with the same name. + ShouldBeEqual( + apply(crate)( + Mod( + "onemodule", [], [ + TraitDecl( + Trait([], TIdentifier("Something"), [], []) + ), + ConstDecl( + Constant( + [], + "dummyExtern", crate.MSel("anothermodule").MSel("Something").AsType(), + RawExpr("nothing"))), + ConstDecl( + Constant( + [], + "dummyIntern", crate.MSel("onemodule").MSel("Something").AsType(), + RawExpr("nothing"))) + ])), + Mod( + "onemodule", [], [ + TraitDecl( + Trait([], TIdentifier("Something"), [], []) + ), + ConstDecl( + Constant( + [], + "dummyExtern", crate.MSel("anothermodule").MSel("Something").AsType(), // No simplification + RawExpr("nothing"))), + ConstDecl( + Constant( + [], + "dummyIntern", TIdentifier("Something"), + RawExpr("nothing"))) + ]) + ); } } @@ -64,32 +162,22 @@ module FactorPathsOptimization { import opened RAST export Std - /*function Debug(s: T, msg: string): T { - s - } by method { - print msg, ":", s, "\n"; - return s; - }*/ - - function apply(thisFile: Path): (Mod -> Mod) { - (mod: Mod) => applyPrefix(mod, thisFile.MSel(mod.name)) + function apply(root: Path): Mod -> Mod { + (mod: Mod) => applyPrefix(mod, root.MSel(mod.name)) } - function applyPrefix(mod: Mod, SelfPath: Path): Mod { + function applyPrefix(mod: Mod, SelfPath: Path): Mod + decreases mod, 1 + { if mod.ExternMod? then mod else - var initialMapping: Mapping := Mapping(map[], []); - var mappings: Mapping := - mod.Fold(initialMapping, (current, modDecl) => GatherModMapping(SelfPath, modDecl, current)); - //var _ := Debug(mappings, "Mappings"); - var pathsToRemove := mappings.ToFinalReplacement(); + var mappings: Mapping := PathsVisitor().VisitMod(Mapping(map[], []), mod, SelfPath); + var pathsToRemove := mappings.ToFinalReplacement(SelfPath); var imports := mappings.ToUseStatements(pathsToRemove, SelfPath); - var rewrittenDeclarations := - mod.Fold([], (current, modDecl) requires modDecl < mod => - current + [ReplaceModDecl(modDecl, SelfPath, pathsToRemove)] - ); - mod.(body := imports + rewrittenDeclarations) + var mod := PathSimplifier(mod, pathsToRemove).ReplaceMod(mod, SelfPath); + mod.(body := imports + mod.body) } + // Retrieves the unique element of a singleton set opaque function UniqueElementOf(s: set): (r: T) requires |s| == 1 ensures r in s @@ -106,6 +194,8 @@ module FactorPathsOptimization { e } + type FinalReplacement = map + datatype Mapping = Mapping( provenance: map>, keys: seq @@ -117,159 +207,115 @@ module FactorPathsOptimization { this.(provenance := provenance[k := {path}], keys := keys + [k]) } - function ToFinalReplacement(): FinalReplacement { + // For any mapping identifier -> full paths, + // we will perform the replacement either if there is exactly one full path, + // or if the path is the dafny runtime (in which cases, all other homonyms remain fully prefixed) + function ToFinalReplacement(SelfPath: Path): FinalReplacement { map identifier <- provenance, paths | paths == provenance[identifier] && (|| |paths| == 1 - || exists p <- paths :: p == dafny_runtime) + || SelfPath in paths + || dafny_runtime in paths) :: - identifier := if |paths| == 1 then UniqueElementOf(paths) else dafny_runtime + identifier := if |paths| == 1 then UniqueElementOf(paths) else + if SelfPath in paths then SelfPath else dafny_runtime } + // Given a final replacement map, + // creates a sequence of use statements to be inserted at the beginning of the module function ToUseStatements(finalReplacement: FinalReplacement, SelfPath: Path): seq - requires finalReplacement == ToFinalReplacement() + requires finalReplacement == ToFinalReplacement(SelfPath) { - var toUse := Std.Collections.Seq.Filter( - (key: string) => key in finalReplacement && finalReplacement[key] != SelfPath, keys); + var toUse := + Std.Collections.Seq.Filter( + (key: string) => key in finalReplacement && finalReplacement[key] != SelfPath, + keys); seq(|toUse|, i requires 0 <= i < |toUse| => UseDecl(Use(PUB, finalReplacement[toUse[i]].MSel(toUse[i])))) } } - type FinalReplacement = map - - function GatherTypeParams(typeParams: seq, current: Mapping): Mapping { - FoldLeft( (current: Mapping, t: TypeParamDecl) => - FoldLeft( (current: Mapping, t: Type) => - GatherTypeMapping(t, current), - current, t.constraints), - current, typeParams) - } - - function GatherFields(fields: Fields, current: Mapping): Mapping { - match fields { - case NamedFields(sFields) => - FoldLeft( (current: Mapping, f: Field) => - GatherTypeMapping(f.formal.tpe, current), - current, sFields) - case NamelessFields(sFields) => - FoldLeft( (current: Mapping, f: NamelessField) => - GatherTypeMapping(f.tpe, current), - current, sFields) - } - } - - function GatherModMapping(prefix: Path, modDecl: ModDecl, current: Mapping): Mapping { - match modDecl { - case ModDecl(mod) => - current.Add(mod.name, prefix) // Modules must be handled independently - case StructDecl(struct) => - GatherStructMapping(struct, current.Add(struct.name, prefix)) - case TypeDecl(tpe) => - current.Add(tpe.name, prefix) - case ConstDecl(c) => - current.Add(c.name, prefix) - case EnumDecl(enum) => - current.Add(enum.name, prefix) - case ImplDecl(impl) => - GatherImplMapping(impl, current) - case TraitDecl(tr) => - current - case TopFnDecl(fn) => - current.Add(fn.fn.name, prefix) - case UseDecl(use) => // Used for externs with *, we can't extract any name - current - } - } - - function GatherStructMapping(struct: Struct, current: Mapping): Mapping { - GatherTypeParams(struct.typeParams, current) - } - - function GatherTypeMapping(tpe: Type, current: Mapping): Mapping { - tpe.Fold(current, (current: Mapping, t: Type) => - match t { - case TypeFromPath(PMemberSelect(base, name)) => current.Add(name, base) - case _ => current - } + function PathsVisitor(): RASTTopDownVisitor { + RASTTopDownVisitor( + VisitTypeSingle := (current: Mapping, t: Type) => + match t { + case TypeFromPath(PMemberSelect(base, name)) => + if base == Self() then current else current.Add(name, base) + case _ => current + }, + VisitExprSingle := (current: Mapping, e: Expr) => + match e { + case ExprFromPath(PMemberSelect(base, id)) => + if base == Self() then current else + if |id| > 0 && id[|id|-1] == '!' then + current.Add(id[..|id|-1], base) + else + current.Add(id, base) + case _ => current + } + , + VisitModDeclSingle := (current: Mapping, modDecl: ModDecl, prefix: Path) => + match modDecl { + case ModDecl(mod) => + current.Add(mod.name, prefix) // Modules must be handled independently + case StructDecl(struct) => + current.Add(struct.name, prefix) + case TypeDecl(tpe) => + current.Add(tpe.name, prefix) + case ConstDecl(c) => + current.Add(c.name, prefix) + case EnumDecl(enum) => + current.Add(enum.name, prefix) + case ImplDecl(impl) => + current + case TraitDecl(tr) => + match tr.tpe { + case TypeApp(TIdentifier(name), _) => + current.Add(name, prefix) + case TIdentifier(name) => + current.Add(name, prefix) + case _ => + current + } + case TopFnDecl(fn) => + current.Add(fn.fn.name, prefix) + case UseDecl(use) => // Used for externs with *, we can't extract any name + current + }, + recurseSubmodules := false // Recursion is done manually ) } - function GatherImplMapping(impl: Impl, current: Mapping): Mapping { - match impl { - case ImplFor(typeParams, tpe, forType, where, body) => - var current := GatherTypeParams(typeParams, current); - var current := GatherTypeMapping(tpe, current); - GatherTypeMapping(forType, current) - // TODO: Add body - case Impl(typeParams, tpe, where, body) => - GatherTypeMapping(tpe, current) - } - } - - function ReplaceModDecl(modDecl: ModDecl, SelfPath: Path, replacement: FinalReplacement): ModDecl { - match modDecl { - case ModDecl(mod) => - ModDecl(applyPrefix(mod, SelfPath.MSel(mod.name))) // We optimize independently submodules - case StructDecl(struct) => StructDecl(ReplaceStruct(struct, replacement)) - case TypeDecl(tpe) => modDecl // TODO - case ConstDecl(c) => modDecl // TODO - case EnumDecl(enum) => modDecl // TODO - case ImplDecl(impl) => ImplDecl(ReplaceImplDecl(impl, replacement)) - case TraitDecl(tr) => modDecl // TODO - case TopFnDecl(fn) => modDecl // TODO - case UseDecl(use) => modDecl - } - } - - function ReplaceType(t: Type, replacement: FinalReplacement): Type { - match t { - case TypeFromPath(PMemberSelect(base, id)) => - if id in replacement && replacement[id] == base then - TSynonym(TIdentifier(id), t) - else - t - case _ => t - } - } - - const typeReplacer: FinalReplacement -> Type -> Type := - (replacement: FinalReplacement) => (t: Type) => ReplaceType(t, replacement) - - function ReplaceTypeParams(typeParams: seq, replacement: FinalReplacement): seq { - Std.Collections.Seq.Map((t: TypeParamDecl) => - t.(constraints := Std.Collections.Seq.Map((constraint: Type) => - ReplaceType(constraint, replacement), t.constraints)), - typeParams) - } - - function ReplaceImplDecl(impl: Impl, replacement: FinalReplacement): Impl { - match impl { - case ImplFor(typeParams, tpe, forType, where, body) => - ImplFor(ReplaceTypeParams(typeParams, replacement), tpe.Replace(typeReplacer(replacement)), forType.Replace(typeReplacer(replacement)), where, body) - // TODO: Replace body - case Impl(typeParams, tpe, where, body) => - Impl(ReplaceTypeParams(typeParams, replacement), tpe.Replace(typeReplacer(replacement)), where, body) - } - } + function PathSimplifier(ghost mParent: Mod, replacement: FinalReplacement): RASTBottomUpReplacer + decreases mParent, 0 + { + RASTBottomUpReplacer( + ReplaceModSingle := + (m: Mod, SelfPath: Path) requires m < mParent => + applyPrefix(m, SelfPath.MSel(m.name)), + ReplaceTypeSingle := (t: Type) => + match t { + case TypeFromPath(PMemberSelect(base, id)) => + if id in replacement && replacement[id] == base then + TSynonym(TIdentifier(id), t) + else + t + case _ => t + }, + ReplaceExprSingle := + (e: Expr) => + match e { + case ExprFromPath(PMemberSelect(base, id)) => + if id in replacement && replacement[id] == base then + Identifier(id) + else if |id| > 0 && id[|id|-1] == '!' then + var macro_id := id[..|id|-1]; + if macro_id in replacement && replacement[macro_id] == base then + Identifier(id) + else e + else e + case _ => e + } - function ReplaceStruct(struct: Struct, replacement: FinalReplacement): Struct { - match struct { - case Struct(attributes, name, typeParams, fields) => - Struct(attributes, name, - ReplaceTypeParams(typeParams, replacement), - ReplaceFields(fields, replacement) - ) - } - } - function ReplaceFields(fields: Fields, replacement: FinalReplacement): Fields { - match fields { - case NamedFields(sFields) => - NamedFields(Std.Collections.Seq.Map((f: Field) => - f.(formal := f.formal.(tpe := ReplaceType(f.formal.tpe, replacement))), sFields - )) - case NamelessFields(sFields) => - NamelessFields(Std.Collections.Seq.Map((f: NamelessField) => - f.(tpe := ReplaceType(f.tpe, replacement)), sFields)) - } + ) } } diff --git a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust.dfy b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust.dfy index f406fb0fc09..3e1d87bed74 100644 --- a/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust.dfy +++ b/Source/DafnyCore/Backends/Rust/Dafny-compiler-rust.dfy @@ -19,6 +19,331 @@ module RAST // Default Indentation const IND := " " + datatype RASTTopDownVisitor = + RASTTopDownVisitor( + nameonly VisitTypeSingle: (T, Type) -> T, + nameonly VisitExprSingle: (T, Expr) -> T, + nameonly VisitModDeclSingle: (T, ModDecl, Path) -> T, + nameonly recurseSubmodules: bool := false + ) + { + function VisitMod(acc: T, mod: Mod, SelfPath: Path): T { + mod.Fold(acc, (acc, modDecl) requires modDecl < mod => VisitModMapping(acc, modDecl, SelfPath)) + } + function VisitTypeParams(acc: T, typeParams: seq): T { + FoldLeft( (acc: T, t: TypeParamDecl) => + FoldLeft( (acc: T, t: Type) => + VisitType(acc, t), + acc, t.constraints), + acc, typeParams) + } + function VisitFields(acc: T, fields: Fields): T { + match fields { + case NamedFields(sFields) => + FoldLeft( (acc: T, f: Field) => + VisitType(acc, f.formal.tpe), + acc, sFields) + case NamelessFields(sFields) => + FoldLeft( (acc: T, f: NamelessField) => + VisitType(acc, f.tpe), + acc, sFields) + } + } + + function VisitModMapping(acc: T, modDecl: ModDecl, SelfPath: Path): T { + var acc := VisitModDeclSingle(acc, modDecl, SelfPath); + match modDecl { + case ModDecl(mod) => + 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)) => + var acc := VisitTypeParams(acc, typeParams); + var acc := VisitType(acc, tpe); + acc + 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)) => + FoldLeft( + (acc: T, enumCase: EnumCase) requires enumCase in variants => + VisitFields(acc, enumCase.fields), + VisitTypeParams(acc, typeParams), + variants + ) + case ImplDecl(impl) => VisitImplMapping(acc, impl) + case TraitDecl(tr) => VisitTraitDecl(acc, tr) + case TopFnDecl(fn) => VisitTopFn(acc, fn) + case UseDecl(use) => VisitUse(acc, use) + } + } + + function VisitStructMapping(acc: T, struct: Struct): T { + VisitTypeParams(acc, struct.typeParams) + } + + function VisitTraitDecl(acc: T, tr: Trait): T { + match tr { + case Trait(typeParams, tpe, parents, body) => + var acc := VisitTypeParams(acc, typeParams); + var acc := tpe.Fold(acc, VisitTypeSingle); + var acc := + FoldLeft( + (acc: T, parent: Type) => + parent.Fold(acc, VisitTypeSingle), + acc, + parents + ); + VisitBody(acc, body) + } + } + + function VisitTopFn(acc: T, t: TopFnDecl): T { + match t { + case TopFn(attributes, visibility, fn) => + VisitFn(acc, fn) + } + } + + function VisitUse(acc: T, u: Use): T { + acc // Nothing to visit for now + } + + function VisitType(acc: T, tpe: Type): T { + tpe.Fold(acc, (acc: T, t: Type) => VisitTypeSingle(acc, t)) + } + + function VisitImplMapping(acc: T, impl: Impl): T { + match impl { + case ImplFor(typeParams, tpe, forType, where, body) => + var acc := VisitTypeParams(acc, typeParams); + var acc := VisitType(acc, tpe); + var acc := VisitType(acc, forType); + VisitBody(acc, body) + // TODO: Add body + case Impl(typeParams, tpe, where, body) => + var acc := VisitType(acc, tpe); + VisitBody(acc, body) + } + } + function VisitBody(acc: T, members: seq): T { + FoldLeft( + (acc: T, member: ImplMember) requires member in members => + VisitMember(acc, member), + acc, + members + ) + } + function VisitMember(acc: T, member: ImplMember): T { + match member { + case RawImplMember(content) => acc + case FnDecl(pub, fun) => + VisitFn(acc, fun) + case ImplMemberMacro(expr: Expr) => + expr.Fold(acc, VisitExprSingle, VisitTypeSingle) + } + } + function VisitFn(acc: T, fn: Fn): T { + match fn { + case Fn(name, typeParams, formals, returnType, where, body) => + var acc := VisitTypeParams(acc, typeParams); + var acc := FoldLeft( + (acc: T, f: Formal) requires f in formals => f.tpe.Fold(acc, VisitTypeSingle), + acc, formals + ); + var acc := if returnType.None? then acc else returnType.value.Fold(acc, VisitTypeSingle); + var acc := if body.None? then acc else body.value.Fold(acc, VisitExprSingle, VisitTypeSingle); + acc + } + } + } + + datatype RASTBottomUpReplacer = + RASTBottomUpReplacer( + nameonly ReplaceModSingle: (Mod, Path) --> Mod := (m: Mod, p: Path) => m, + nameonly ReplaceTypeSingle: Type -> Type := (t: Type) => t, + nameonly ReplaceExprSingle: Expr -> Expr := (e: Expr) => e + ) { + function ReplaceMod(mod: Mod, SelfPath: Path): Mod + requires forall m: Mod, p: Path | m < mod :: + ReplaceModSingle.requires(m, p) + { + if mod.ExternMod? then mod else + var newModDeclarations := mod.Fold([], (current, modDecl) requires modDecl < mod => + assert forall mod: Mod, p: Path | mod < modDecl :: this.ReplaceModSingle.requires(mod, p); + current + [ReplaceModDecl(modDecl, SelfPath)] + ); + mod.(body := newModDeclarations) + } + function ReplaceModDecl(modDecl: ModDecl, SelfPath: Path): ModDecl + requires forall mod: Mod, p: Path | mod < modDecl :: + ReplaceModSingle.requires(mod, p) + { + match modDecl { + case ModDecl(mod) => + ModDecl(ReplaceModSingle(mod, SelfPath.MSel(mod.name))) // We optimize independently submodules + case StructDecl(struct) => + StructDecl(ReplaceStruct(struct)) + case TypeDecl(tpe) => + TypeDecl(ReplaceTypeDecl(tpe)) + case ConstDecl(c) => + ConstDecl(ReplaceConst(c)) + case EnumDecl(enum) => + EnumDecl(ReplaceEnum(enum)) + case ImplDecl(impl) => + ImplDecl(ReplaceImplDecl(impl)) + case TraitDecl(tr) => + TraitDecl(ReplaceTrait(tr)) + case TopFnDecl(fn) => + TopFnDecl(ReplaceTopFn(fn)) + case UseDecl(use) => + UseDecl(ReplaceUse(use)) + } + } + + function ReplaceStruct(struct: Struct): Struct { + match struct { + case Struct(attributes, name, typeParams, fields) => + Struct(attributes, name, + ReplaceTypeParams(typeParams), + ReplaceFields(fields) + ) + } + } + + function ReplaceTypeDecl(t: TypeSynonym): TypeSynonym { + match t { + case TypeSynonym(attributes, name, typeParams, tpe) => + TypeSynonym(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)) + } + } + + function ReplaceEnum(enum: Enum): Enum { + match enum { + case Enum(attributes, name, typeParams, variants) => + Enum(attributes, name, + ReplaceTypeParams(typeParams), + Std.Collections.Seq.Map( + (t: EnumCase) => ReplaceEnumCase(t), variants)) + } + } + + function ReplaceEnumCase(enumCase: EnumCase): EnumCase { + match enumCase { + case EnumCase(name, fields) => + EnumCase(name, ReplaceFields(fields)) + } + } + + function ReplaceImplDecl(impl: Impl): Impl { + match impl { + case ImplFor(typeParams, tpe, forType, where, body) => + ImplFor( + ReplaceTypeParams(typeParams), + ReplaceType(tpe), + ReplaceType(forType), + where, + ReplaceBody(body)) + case Impl(typeParams, tpe, where, body) => + Impl(ReplaceTypeParams(typeParams), ReplaceType(tpe), where, ReplaceBody(body)) + } + } + + function ReplaceTrait(tr: Trait): Trait { + match tr { + case Trait(typeParams, tpe, parents, body) => + Trait( + ReplaceTypeParams(typeParams), + ReplaceType(tpe), + Std.Collections.Seq.Map( + (t: Type) => ReplaceType(t), parents), + ReplaceBody(body)) + } + } + + function ReplaceTopFn(t: TopFnDecl): TopFnDecl { + match t { + case TopFn(attributes, visibility, fn) => + TopFn(attributes, visibility, ReplaceFn(fn)) + } + } + + function ReplaceFn(t: Fn): Fn { + match t { + case Fn(name, typeParams, formals, returnType, where, body) => + Fn( + name, + ReplaceTypeParams(typeParams), + Std.Collections.Seq.Map( + (f: Formal) requires f in formals => f.Replace(ReplaceType), + 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)) + ) + } + } + + function ReplaceUse(use: Use): Use { + match use { + case Use(visibility, path) => + Use(visibility, path) + } + } + + function ReplaceBody(decls: seq): seq { + Std.Collections.Seq.Map( + (t: ImplMember) => ReplaceImplMember(t), decls) + } + + function ReplaceImplMember(t: ImplMember): ImplMember { + match t { + case RawImplMember(content) => t + case FnDecl(pub, fun) => + FnDecl(pub, ReplaceFn(fun)) + case ImplMemberMacro(expr: Expr) => + ImplMemberMacro(ReplaceExpr(expr)) + } + } + function ReplaceExpr(e: Expr): Expr { + e.Replace(ReplaceExprSingle, ReplaceTypeSingle) + } + function ReplaceTypeParams(typeParams: seq): seq { + Std.Collections.Seq.Map( + (t: TypeParamDecl) => + t.(constraints := Std.Collections.Seq.Map( + (constraint: Type) => + ReplaceType(constraint), t.constraints)), typeParams) + } + function ReplaceType(t: Type): Type { + t.Replace(this.ReplaceTypeSingle) + } + function ReplaceFields(fields: Fields): Fields { + match fields { + case NamedFields(sFields) => + NamedFields( + Std.Collections.Seq.Map( + (f: Field) => + f.(formal := f.formal.(tpe := ReplaceType(f.formal.tpe))), sFields + )) + case NamelessFields(sFields) => + NamelessFields( + Std.Collections.Seq.Map( + (f: NamelessField) => + f.(tpe := ReplaceType(f.tpe)), sFields)) + } + } + } + opaque function FoldLeft(f: (A, T) --> A, init: A, xs: seq): A requires forall t: T <- xs, a: A :: f.requires(a, t) { @@ -143,7 +468,7 @@ module RAST { function ToString(ind: string): string { Attribute.ToStringMultiple(attributes, ind) + - "pub const " + name + ": " + tpe.ToString(ind) + "=" + + "pub const " + name + ": " + tpe.ToString(ind) + " = " + value.ToString(ind) + ";" } } @@ -314,6 +639,12 @@ module RAST function MSel(name: string): Path { PMemberSelect(this, name) } + function MSels(names: seq): Path + decreases |names| + { + if |names| == 0 then this else + this.MSel(names[0]).MSels(names[1..]) + } function FSel(name: string): Expr { AsExpr().FSel(name) } @@ -344,7 +675,7 @@ module RAST const SelfOwned := Self().AsType() datatype Type = - | U8 | U16 | U32 | U64 | U128 | I8 | I16 | I32 | I64 | I128 + | U8 | U16 | U32 | U64 | U128 | I8 | I16 | I32 | I64 | I128 | USIZE | Bool | TIdentifier(name: string) | TypeFromPath(path: Path) @@ -380,7 +711,7 @@ module RAST function Replace(mapping: Type -> Type): Type { var r := match this { - case U8 | U16 | U32 | U64 | U128 | I8 | I16 | I32 | I64 | I128 | Bool => this + case U8 | U16 | U32 | U64 | U128 | I8 | I16 | I32 | I64 | I128 | USIZE | Bool => this case TIdentifier(_) => this case TypeFromPath(path) => this case TypeApp(baseName, arguments) => @@ -409,31 +740,32 @@ module RAST mapping(r) } - function Fold(acc: T, f: (T, Type) -> T): T + function Fold(acc: T, f: (T, Type) -> T): T // Traverses all types in a random order { var newAcc := f(acc, this); match this { - case U8 | U16 | U32 | U64 | U128 | I8 | I16 | I32 | I64 | I128 | Bool => newAcc + case U8 | U16 | U32 | U64 | U128 | I8 | I16 | I32 | I64 | I128 | USIZE | Bool => newAcc case TIdentifier(_) => newAcc case TypeFromPath(path) => newAcc case TypeApp(baseName, arguments) => - Std.Collections.Seq.FoldLeft( - (acc: T, argType: Type) => assume {:axiom} argType in arguments; argType.Fold(acc, f), - baseName.Fold(newAcc, f), + var newAcc := baseName.Fold(newAcc, f); + FoldLeft( + (acc: T, argType: Type) requires argType in arguments => argType.Fold(acc, f), + newAcc, arguments) case Borrowed(underlying) => underlying.Fold(newAcc, f) case BorrowedMut(underlying) => underlying.Fold(newAcc, f) case ImplType(underlying) => underlying.Fold(newAcc, f) case DynType(underlying) => underlying.Fold(newAcc, f) case TupleType(arguments) => - Std.Collections.Seq.FoldLeft( - (acc: T, argType: Type) => assume {:axiom} argType in arguments; argType.Fold(acc, f), + FoldLeft( + (acc: T, argType: Type) requires argType in arguments => argType.Fold(acc, f), newAcc, arguments) case FnType(arguments, returnType) => returnType.Fold( - Std.Collections.Seq.FoldLeft( - (acc: T, argType: Type) => assume {:axiom} argType in arguments; argType.Fold(acc, f), + FoldLeft( + (acc: T, argType: Type) requires argType in arguments => argType.Fold(acc, f), newAcc, arguments), f) case IntersectionType(left, right) => @@ -444,7 +776,7 @@ module RAST } predicate CanReadWithoutClone() { - U8? || U16? || U32? || U64? || U128? || I8? || I16? || I32? || I64? || I128? || Bool? + U8? || U16? || U32? || U64? || U128? || I8? || I16? || I32? || I64? || I128? || USIZE? || Bool? || (TSynonym? && base.CanReadWithoutClone()) || IsPointer() } predicate IsRcOrBorrowedRc() { @@ -518,6 +850,7 @@ module RAST case I32() => "i32" case I64() => "i64" case I128() => "i128" + case USIZE() => "usize" case Array(underlying, size) => "[" + underlying.ToString(ind) + (if size.Some? then "; " + size.value else "") + "]" case TSynonym(display, base) => display.ToString(ind) } @@ -544,9 +877,9 @@ module RAST { assert Expand().IsObject() || Expand().IsPointer(); if Expand().IsObject() then - Object.FSel("null").Apply([]) + Object.FSel("null").Apply0() else - Ptr.FSel("null").Apply([]) + Ptr.FSel("null").Apply0() } predicate IsMultiArray() { @@ -675,8 +1008,8 @@ module RAST const RefcellType := cell.MSel("RefCell").AsType() const dafny_runtime: Path := global.MSel("dafny_runtime") const CloneTrait := std.MSel("clone").MSel("Clone").AsType() - const DefaultPath := std.MSel("default").MSel("Default") - const DefaultTrait := DefaultPath.AsType() + const std_default_Default := std.MSel("default").MSel("Default") + const DefaultTrait := std_default_Default.AsType() const AnyTrait := std.MSel("any").MSel("Any").AsType() const StaticTrait := RawType("'static") const DafnyType := dafny_runtime.MSel("DafnyType").AsType() @@ -779,10 +1112,21 @@ module RAST datatype Formal = Formal(name: string, tpe: Type) { + static function ImplicitlyTyped(name: string): Formal { + Formal(name, TIdentifier("_")) + } + function Replace(ft: Type -> Type): Formal { + Formal(name, tpe.Replace(ft)) + } + function Fold(acc: T, ft: (T, Type) -> T): T { + tpe.Fold(acc, ft) + } function ToString(ind: string): string { if name == "self" && tpe == SelfOwned then name else if name == "self" && tpe == SelfBorrowed then "&" + name else if name == "self" && tpe == SelfBorrowedMut then "&mut " + name + else if tpe.TIdentifier? && tpe.name == "_" then + name else name + ": " + tpe.ToString(ind) } @@ -802,11 +1146,13 @@ module RAST datatype MatchCase = MatchCase(pattern: Pattern, rhs: Expr) { - ghost function Height(): nat { - 1 + rhs.Height() + function Replace(mapping: Expr -> Expr, mappingType: Type -> Type): MatchCase { + MatchCase(pattern, rhs.Replace(mapping, mappingType)) + } + function Fold(acc: T, f: (T, Expr) -> T, ft: (T, Type) -> T): T { + rhs.Fold(acc, f, ft) } function ToString(ind: string): string - decreases Height() { var newIndent := if rhs.Block? then ind else ind + IND; var rhsString := rhs.ToString(newIndent); @@ -820,12 +1166,13 @@ module RAST datatype AssignIdentifier = AssignIdentifier(identifier: string, rhs: Expr) { - ghost function Height(): nat { - 1 + rhs.Height() + function Replace(f: Expr -> Expr, ft: Type -> Type): AssignIdentifier { + AssignIdentifier(identifier, rhs.Replace(f, ft)) + } + function Fold(acc: T, f: (T, Expr) -> T, ft: (T, Type) -> T): T { + rhs.Fold(acc, f, ft) } - function ToString(ind: string): string - decreases Height() { identifier + ": " + rhs.ToString(ind + IND) } @@ -920,6 +1267,7 @@ module RAST | UnaryOp(op1: string, underlying: Expr, format: Format.UnaryOpFormat) | BinaryOp(op2: string, left: Expr, right: Expr, format2: Format.BinaryOpFormat) | TypeAscription(left: Expr, tpe: Type) // underlying as tpe + | TraitCast(leftTpe: Type, tpe: Type) // < leftTpe as tpe > | LiteralInt(value: string) | LiteralBool(bvalue: bool) | LiteralString(value: string, binary: bool, verbatim: bool) @@ -932,7 +1280,7 @@ module RAST | Break(optLbl: Option) // break lbl; | Continue(optLbl: Option) // continue optLabel; | Return(optExpr: Option) // return optExpr; - | CallType(obj: Expr, typeParameters: seq) // obj::<...type parameters> + | CallType(obj: Expr, typeArguments: seq) // obj::<...type parameters> | Call(obj: Expr, arguments: seq) // obj(...arguments) | Select(obj: Expr, name: string) // obj.name | SelectIndex(obj: Expr, range: Expr) // obj[range] @@ -940,6 +1288,161 @@ module RAST | FunctionSelect(obj: Expr, name: string) // objType::name | Lambda(params: seq, retType: Option, body: Expr) // move || -> retType { body } { + function Replace(f: Expr -> Expr, ft: Type -> Type): Expr { + var r := + match this { + case RawExpr(content) => this + case ExprFromType(tpe) => ExprFromType(tpe.Replace(ft)) + case Identifier(name) => this + case Match(matchee, cases) => + Match(matchee.Replace(f, ft), + Std.Collections.Seq.Map( + c requires c in cases => c.Replace(f, ft), cases)) + case StmtExpr(stmt, rhs) => + StmtExpr(stmt.Replace(f, ft), rhs.Replace(f, ft)) + case Block(underlying) => + Block(underlying.Replace(f, ft)) + case StructBuild(underlying, assignments) => + StructBuild(underlying.Replace(f, ft), Std.Collections.Seq.Map( + a requires a in assignments => + a.Replace(f, ft), + assignments)) + case Tuple(arguments) => + Tuple( + Std.Collections.Seq.Map( + e requires e in arguments => + e.Replace(f, ft), arguments)) + case UnaryOp(op1, underlying, format) => + UnaryOp(op1, underlying.Replace(f, ft), format) + case BinaryOp(op2, left, right, format2) => + BinaryOp(op2, left.Replace(f, ft), right.Replace(f, ft), format2) + case TypeAscription(left, tpe) => TypeAscription(left.Replace(f, ft), tpe.Replace(ft)) + case TraitCast(leftTpe, tpe) => TraitCast(leftTpe.Replace(ft), tpe.Replace(ft)) + case LiteralInt(value) => this + case LiteralBool(bvalue) => this + case LiteralString(value, binary, verbatim) => this + case DeclareVar(declareType, name, optType, optRhs) => + DeclareVar( + declareType, name, + if optType.None? then optType else Some(optType.value.Replace(ft)), + if optRhs.None? then optRhs else Some(optRhs.value.Replace(f, ft))) + case Assign(names, rhs) => Assign(names, rhs.Replace(f, ft)) + case IfExpr(cond, thn, els) => IfExpr(cond.Replace(f, ft), thn.Replace(f, ft), els.Replace(f, ft)) + case Loop(optCond, underlying) => + Loop(if optCond.None? then None else Some(optCond.value.Replace(f, ft)), underlying.Replace(f, ft)) + case For(name, range, body) => + For(name, range.Replace(f, ft), body.Replace(f, ft)) + case Labelled(lbl, underlying) => + Labelled(lbl, underlying.Replace(f, ft)) + case Break(optLbl) => this + case Continue(optLbl) => this + case Return(optExpr) => Return(if optExpr.None? then None else Some(optExpr.value.Replace(f, ft))) + case CallType(obj, typeArguments) => + CallType(obj.Replace(f, ft), Std.Collections.Seq.Map((tp: Type) => tp.Replace(ft), typeArguments)) + case Call(obj, arguments) => + Call( + obj.Replace(f, ft), + Std.Collections.Seq.Map((a: Expr) requires a < this => a.Replace(f, ft), arguments)) + case Select(obj, name) => Select(obj.Replace(f, ft), name) + case SelectIndex(obj, range) => SelectIndex(obj.Replace(f, ft), range.Replace(f, ft)) + case ExprFromPath(path) => ExprFromPath(path) + case FunctionSelect(obj, name) => FunctionSelect(obj.Replace(f, ft), name) + case Lambda(params, retType, body) => + Lambda( + Std.Collections.Seq.Map( + (f: Formal) requires f < this => f.Replace(ft), + params), + if retType.None? then None else Some(retType.value.Replace(ft)), + body.Replace(f, ft)) + }; + f(r) + } + function Fold(acc: T, f: (T, Expr) -> T, ft: (T, Type) -> T): T { + var acc := f(acc, this); + match this { + case RawExpr(content) => acc + case ExprFromType(tpe) => tpe.Fold(acc, ft) + case Identifier(name) => acc + case Match(matchee, cases) => + var acc := matchee.Fold(acc, f, ft); + FoldLeft( + (acc: T, c: MatchCase) requires c in cases => c.Fold(acc, f, ft), + acc, + cases) + case StmtExpr(stmt, rhs) => + rhs.Fold(stmt.Fold(acc, f, ft), f, ft) + case Block(underlying) => underlying.Fold(acc, f, ft) + case StructBuild(underlying, assignments) => + FoldLeft( + (acc: T, c: AssignIdentifier) requires c in assignments => c.Fold(acc, f, ft), + underlying.Fold(acc, f, ft), + assignments + ) + case Tuple(arguments) => + FoldLeft( + (acc: T, e: Expr) requires e in arguments => e.Fold(acc, f, ft), + acc, + arguments + ) + case UnaryOp(op1, underlying, format) => underlying.Fold(acc, f, ft) + case BinaryOp(op2, left, right, format2) => + right.Fold(left.Fold(acc, f, ft), f, ft) + case TypeAscription(left, tpe) => tpe.Fold(left.Fold(acc, f, ft), ft) + case TraitCast(leftTpe, tpe) => tpe.Fold(leftTpe.Fold(acc, ft), ft) + case LiteralInt(value) => acc + case LiteralBool(bvalue) => acc + case LiteralString(value, binary, verbatim) => acc + case DeclareVar(declareType, name, optType, optRhs) => + var acc := if optType.None? then acc else optType.value.Fold(acc, ft); + if optRhs.None? then acc else optRhs.value.Fold(acc, f, ft) + case Assign(names, rhs) => rhs.Fold(acc, f, ft) + case IfExpr(cond, thn, els) => + var acc := cond.Fold(acc, f, ft); + var acc := thn.Fold(acc, f, ft); + els.Fold(acc, f, ft) + case Loop(optCond, underlying) => + var acc := if optCond.None? then acc else optCond.value.Fold(acc, f, ft); + underlying.Fold(acc, f, ft) + case For(name, range, body) => + var acc := range.Fold(acc, f, ft); + body.Fold(acc, f, ft) + case Labelled(lbl, underlying) => underlying.Fold(acc, f, ft) + case Break(optLbl) => acc + case Continue(optLbl) => acc + case Return(optExpr) => if optExpr.None? then acc else optExpr.value.Fold(acc, f, ft) + case CallType(obj, typeArguments) => + var acc := obj.Fold(acc, f, ft); + FoldLeft( + (acc: T, t: Type) requires t in typeArguments => + t.Fold(acc, ft), + acc, + typeArguments + ) + case Call(obj, arguments) => + var acc := obj.Fold(acc, f, ft); + FoldLeft( + (acc: T, e: Expr) requires e in arguments => + e.Fold(acc, f, ft), + acc, + arguments + ) + case Select(obj, name) => + obj.Fold(acc, f, ft) + case SelectIndex(obj, range) => + range.Fold(obj.Fold(acc, f, ft), f, ft) + case ExprFromPath(path) => acc + case FunctionSelect(obj, name) => + obj.Fold(acc, f, ft) + case Lambda(params, retType, body) => + var acc := FoldLeft( + (acc: T, param: Formal) requires param in params => + param.Fold(acc, ft), + acc, params); + var acc := if retType.None? then acc else retType.value.Fold(acc, ft); + body.Fold(acc, f, ft) + } + } + predicate NoExtraSemicolonAfter() { DeclareVar? || Assign? || Break? || Continue? || Return? || For? || (RawExpr? && |content| > 0 && content[|content| - 1] == ';') @@ -971,6 +1474,7 @@ module RAST case Call(_, _) => PrecedenceAssociativity(2, LeftToRight) case TypeAscription(left, tpe) => PrecedenceAssociativity(10, LeftToRight) + case TraitCast(leftTpe, tpe) => Precedence(1) case BinaryOp(op2, left, right, format) => match op2 { case "*" | "/" | "%" => PrecedenceAssociativity(20, LeftToRight) @@ -1003,160 +1507,8 @@ module RAST case _ => UnknownPrecedence() } - ghost function Height(): nat { - match this { - case Identifier(_) => 1 - case ExprFromType(_) => 1 - case LiteralInt(_) => 1 - case LiteralBool(_) => 1 - case LiteralString(_, _, _) => 1 - case Match(matchee, cases) => - 1 + max(matchee.Height(), - SeqToHeight(cases, (oneCase: MatchCase) - requires oneCase < this - => oneCase.Height())) - case StmtExpr(stmt, rhs) => - var default := 1 + max(stmt.Height(), rhs.Height()); - match this { - case StmtExpr(DeclareVar(mod, name, Some(tpe), None), StmtExpr(Assign(name2, rhs), last)) => - if name2 == Some(LocalVar(name)) then - 1 + default - else default - case StmtExpr(IfExpr(UnaryOp("!", BinaryOp("==", a, b, f), of), RawExpr("panic!(\"Halt\");"), RawExpr("")), last) => - 1 + default - case _ => default - } - - case Block(underlying) => - 1 + underlying.Height() - case StructBuild(name, assignments) => - 1 + max(name.Height(), SeqToHeight(assignments, (assignment: AssignIdentifier) - requires assignment < this - => assignment.Height())) - case Tuple(arguments) => - 1 + SeqToHeight(arguments, (argument: Expr) - requires argument < this - => argument.Height()) - // Special cases - case UnaryOp(_, underlying, _) => 1 + underlying.Height() - case TypeAscription(left, tpe) => 1 + left.Height() - case BinaryOp(op, left, right, format) => - 1 + max(left.Height(), right.Height()) - case IfExpr(cond, thn, els) => - 1 + max(cond.Height(), max(thn.Height(), els.Height())) - case DeclareVar(declareType, name, tpe, expr) => - 1 + (match expr { - case Some(e) => e.Height() - case None => 0 - }) - case Assign(names, expr) => - match names { - case Some(SelectMember(on, field)) => 1 + max(on.Height(), expr.Height()) - case Some(Index(arr, indices)) => 1 + max(expr.Height(), max(arr.Height(), SeqToHeight(indices, (index: Expr) requires index < this => index.Height()))) - case _ => 1 + expr.Height() - } - case Loop(optCond, underlying) => - 1 + if optCond.Some? then max(optCond.value.Height(), underlying.Height()) else underlying.Height() - case Labelled(lbl, underlying) => - 1 + underlying.Height() - case Break(_) => 1 - case Continue(_) => 1 - case For(name, range, body) => - 1 + max(range.Height(), body.Height()) - case Return(optExpr) => - if optExpr.Some? then 1 + optExpr.value.Height() else 1 - case CallType(obj, tpes) => - 1 + max(obj.Height(), - SeqToHeight(tpes, (tpe: Type) requires tpe < this => 1)) - case Call(obj, args) => - 1 + max(obj.Height(), - SeqToHeight(args, (arg: Expr) requires arg < this => arg.Height())) - case Select(expression, name) => - 1 + expression.Height() - case SelectIndex(expression, range) => - 1 + max(expression.Height(), range.Height()) - case ExprFromPath(underlying) => - 1 - case FunctionSelect(expression, name) => - 1 + expression.Height() - case Lambda(params, retType, body) => - if body.Block? || retType.None? then 1 + body.Height() - else 2 + body.Height() - case _ => - assert RawExpr?; - 1 - } - } - - // Wish: Prove that Optimize() preserves semantics, if any - // TODO: Ensure that even without Optimize(), tests pass - opaque function Optimize(): (r: Expr) - ensures this == r || r.Height() < this.Height() - { - match this { - case UnaryOp("!", BinaryOp("==", left, right, format), - CombineFormat()) => - assert BinaryOp("==", left, right, format).Height() - == BinaryOp("!=", left, right, BinaryOpFormat.NoFormat()).Height(); - BinaryOp("!=", left, right, BinaryOpFormat.NoFormat()) - - case UnaryOp("!", BinaryOp("<", left, right, NoFormat()), - CombineFormat()) => - assert BinaryOp(">=", left, right, BinaryOpFormat.NoFormat()).Height() - == BinaryOp("<", left, right, BinaryOpFormat.NoFormat()).Height(); - BinaryOp(">=", left, right, BinaryOpFormat.NoFormat()) - - case UnaryOp("!", BinaryOp("<", left, right, ReverseFormat()), - CombineFormat()) => - assert BinaryOp("<=", right, left, BinaryOpFormat.NoFormat()).Height() - == BinaryOp("<", left, right, BinaryOpFormat.ReverseFormat()).Height(); - BinaryOp("<=", right, left, BinaryOpFormat.NoFormat()) - case Call(ExprFromPath(PMemberSelect(r, "truncate!")), args) => - if (r != dafny_runtime && r != global) || |args| != 2 then - this - else - var expr := args[0]; - var tpeExpr := args[1]; - if !tpeExpr.ExprFromType? then this else - var tpe := tpeExpr.tpe; - if || tpe.U8? || tpe.U16? || tpe.U32? || tpe.U64? || tpe.U128? - || tpe.I8? || tpe.I16? || tpe.I32? || tpe.I64? || tpe.I128? then - match expr { - case Call(ExprFromPath(PMemberSelect(base, "int!")), args) => - if |args| == 1 && (base == dafny_runtime || base == global) then - match args[0] { - case LiteralInt(number) => LiteralInt(number) - case LiteralString(number, _, _) => LiteralInt(number) - case _ => this - } - else this - case _ => this - } - else - this - case StmtExpr(DeclareVar(mod, name, Some(tpe), None), StmtExpr(Assign(name2, rhs), last)) => - if name2 == Some(LocalVar(name)) then - var rewriting := StmtExpr(DeclareVar(mod, name, Some(tpe), Some(rhs)), last); - assert rewriting.Height() < this.Height() by { - assert StmtExpr(Assign(name2, rhs), last).Height() == - 1 + max(Assign(name2, rhs).Height(), last.Height()) == - 1 + max(1 + rhs.Height(), last.Height()); - assert this.Height() == 2 + max(1, 1 + max(1 + rhs.Height(), last.Height())); - assert rewriting.Height() == 1 + max(1 + rhs.Height(), last.Height()); - } - rewriting - else - this - case StmtExpr(IfExpr(UnaryOp("!", BinaryOp("==", a, b, f), of), RawExpr("panic!(\"Halt\");"), RawExpr("")), last) => - var rewriting := StmtExpr(Identifier("assert_eq!").Apply([a, b]), last); - assume {:axiom} rewriting.Height() < this.Height(); // TODO: Need to prove formally - rewriting - case _ => this - } - } - predicate LeftRequiresParentheses(left: Expr) { - printingInfo.NeedParenthesesForLeft(left.Optimize().printingInfo) + printingInfo.NeedParenthesesForLeft(left.printingInfo) } function LeftParentheses(left: Expr): (string, string) { if LeftRequiresParentheses(left) then @@ -1166,7 +1518,7 @@ module RAST } predicate RightRequiresParentheses(right: Expr) { - printingInfo.NeedParenthesesForRight(right.Optimize().printingInfo) + printingInfo.NeedParenthesesForRight(right.printingInfo) } @@ -1181,6 +1533,7 @@ module RAST match this { case FunctionSelect(_, id) => Some(id) case ExprFromPath(p) => p.RightMostIdentifier() + case Identifier(id) => Some(id) case _ => None } } @@ -1198,9 +1551,8 @@ module RAST } function ToString(ind: string): string - decreases Height() { - match this.Optimize() { + match this { case Identifier(name) => name case ExprFromType(t) => t.ToString(ind) case LiteralInt(number) => number @@ -1212,7 +1564,7 @@ module RAST case Match(matchee, cases) => "match " + matchee.ToString(ind + IND) + " {" + SeqToString(cases, - (c: MatchCase) requires c.Height() < this.Height() => + (c: MatchCase) requires c in cases => "\n" + ind + IND + c.ToString(ind + IND) + ",", "") + "\n" + ind + "}" case StmtExpr(stmt, rhs) => // They are built like StmtExpr(1, StmtExpr(2, StmtExpr(3, ...))) @@ -1231,38 +1583,45 @@ module RAST // Numeric name.ToString(ind) + " (" + SeqToString(assignments, (assignment: AssignIdentifier) - requires assignment.Height() < this.Height() + requires assignment in assignments => "\n" + ind + IND + assignment.rhs.ToString(ind + IND), ",") + (if |assignments| > 1 then "\n" + ind else "") + ")" else name.ToString(ind) + " {" + SeqToString(assignments, (assignment: AssignIdentifier) - requires assignment.Height() < this.Height() + requires assignment in assignments => "\n" + ind + IND + assignment.ToString(ind + IND), ",") + (if |assignments| > 0 then "\n" + ind else "") + "}" case Tuple(arguments) => "(" + SeqToString(arguments, (arg: Expr) - requires arg.Height() < this.Height() + requires arg in arguments => "\n" + ind + IND + arg.ToString(ind + IND), ",") + (if |arguments| > 0 then "\n" + ind else "") + ")" case UnaryOp(op, underlying, format) => + var isPattern := |op| >= 1 && op[0..1] == "{"; + var isUnsafe := op == "unsafe"; var (leftP, rightP) := - if printingInfo.NeedParenthesesFor(underlying.Optimize().printingInfo) then + if !isPattern && !isUnsafe && printingInfo.NeedParenthesesFor(underlying.printingInfo) then ("(", ")") else ("", ""); - var leftOp := if op == "&mut" && leftP != "(" then op + " " else if op == "?" then "" else op; - var rightOp := if op == "?" then op else ""; - + var opToRight := op == "?" || ( + |op| >= 2 && op[0..2] == "/*" // comment + ) || isPattern; + var leftOp := if opToRight then "" else op; + var leftOp := if (op == "&mut" || isUnsafe) && leftP != "(" then leftOp + " " else leftOp; + var rightOp := if opToRight then op else ""; leftOp + leftP + underlying.ToString(ind) + rightP + rightOp case TypeAscription(left, tpe) => var (leftLeftP, leftRightP) := LeftParentheses(left); leftLeftP + left.ToString(IND) + leftRightP + " as " + tpe.ToString(IND) + case TraitCast(leftTpe, tpe) => + "<" + leftTpe.ToString(IND) + " as " + tpe.ToString(IND) + ">" case BinaryOp(op2, left, right, format) => var (leftLeftP, leftRighP) := LeftParentheses(left); var (rightLeftP, rightRightP) := RightParentheses(right); @@ -1293,7 +1652,7 @@ module RAST case Some(Index(e, indices)) => var (leftP, rightP) := Call(e, indices).LeftParentheses(e); leftP + e.ToString(ind) + rightP + "[" + SeqToString(indices, - (index: Expr) requires index.Height() < this.Height() => index.ToString(ind + IND), "][") + (index: Expr) requires index in indices => index.ToString(ind + IND), "][") + "] = " case None => "_ = " }; @@ -1337,7 +1696,7 @@ module RAST ("(", ")") }; leftP + expr.ToString(ind) + rightP + - leftCallP + SeqToString(args, (arg: Expr) requires arg.Height() < this.Height() => arg.ToString(ind + IND), ", ")+ rightCallP + leftCallP + SeqToString(args, (arg: Expr) requires arg in args => arg.ToString(ind + IND), ", ")+ rightCallP case Select(expression, name) => var (leftP, rightP) := LeftParentheses(expression); leftP + expression.ToString(ind) + rightP + "." + name @@ -1356,7 +1715,7 @@ module RAST "-> " + retType.value.ToString(ind) else "") + (if retType.Some? && !body.Block? then - Block(body).ToString(ind) + "{\n" + ind + IND + body.ToString(ind + IND) + "\n" + ind + "}" else body.ToString(ind)) case r => assert r.RawExpr?; AddIndent(r.content, ind) @@ -1379,12 +1738,12 @@ module RAST function FSel(name: string): Expr { FunctionSelect(this, name) } - function ApplyType(typeParameters: seq): Expr { - if |typeParameters| == 0 then this else - CallType(this, typeParameters) + function ApplyType(typeArguments: seq): Expr { + if |typeArguments| == 0 then this else + CallType(this, typeArguments) } - function ApplyType1(typeParameter: Type): Expr { - CallType(this, [typeParameter]) + function ApplyType1(typeArgument: Type): Expr { + CallType(this, [typeArgument]) } function Apply(arguments: seq): Expr { Call(this, arguments) @@ -1394,6 +1753,10 @@ module RAST Call(this, [argument]) } + function Apply0(): Expr { + Call(this, []) + } + predicate IsLhsIdentifier() { || this.Identifier? || (&& this.Call? @@ -1421,10 +1784,14 @@ module RAST } function Clone(): Expr { - Select(this, "clone").Apply([]) + Select(this, "clone").Apply0() } } + function Unsafe(underlying: Expr): Expr { + UnaryOp("unsafe", underlying, Format.UnaryOpFormat.NoFormat) + } + const self := Identifier("self") @@ -1447,7 +1814,7 @@ module RAST const std_rc_Rc_new := std_rc_Rc.FSel("new") - const std_Default_default := DefaultPath.FSel("default").Apply([]) + const std_default_Default_default := std_default_Default.FSel("default").Apply0() function RcNew(underlying: Expr): Expr { Call(std_rc_Rc_new, [underlying]) @@ -1481,6 +1848,7 @@ module RAST module {:extern "DCOMP"} DafnyToRustCompiler { import FactorPathsOptimization + import ExpressionOptimization import opened DAST import Strings = Std.Strings @@ -1739,7 +2107,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { datatype ExternAttribute = | NoExtern() | SimpleExtern(overrideName: string) - | AdvancedExtern(enclosingModule: string, overrideName: string) + | AdvancedExtern(enclosingModule: seq, overrideName: string) | UnsupportedExtern(reason: string) opaque function OptExtern(attr: Attribute, dafnyName: Name): Option { @@ -1747,7 +2115,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { Some( if |attr.args| == 0 then SimpleExtern(escapeName(dafnyName)) else if |attr.args| == 1 then SimpleExtern(attr.args[0]) else - if |attr.args| == 2 then AdvancedExtern(ReplaceDotByDoubleColon(attr.args[0]), attr.args[1]) else + if |attr.args| == 2 then AdvancedExtern(SplitRustPathElement(ReplaceDotByDoubleColon(attr.args[0])), attr.args[1]) else UnsupportedExtern("{:extern} supports only 0, 1 or 2 attributes, got " + Std.Strings.OfNat(|attr.args|)) ) else @@ -1763,6 +2131,16 @@ module {:extern "DCOMP"} DafnyToRustCompiler { (if s[0] == '.' then "::" else [s[0]]) + ReplaceDotByDoubleColon(s[1..]) } + function SplitRustPathElement(s: string, result: seq := [], acc: string := ""): seq { + if |s| == 0 then + if acc == "" then result else result + [acc] + else + if |s| >= 2 && s[0..2] =="::" then + SplitRustPathElement(s[2..], result + [acc], "") + else + SplitRustPathElement(s[1..], result, acc + [s[0]]) + } + function ExtractExtern(attributes: seq, dafnyName: Name): (res: ExternAttribute) { if |attributes| == 0 then NoExtern() else @@ -1829,9 +2207,13 @@ module {:extern "DCOMP"} DafnyToRustCompiler { const downcast := if pointerType.Raw? then "cast!" else "cast_object!" - function UnreachablePanicIfVerified(optText: string := ""): string { - if pointerType.Raw? then "unsafe { ::std::hint::unreachable_unchecked() }" else - if optText == "" then "panic!()" else "panic!(\"" + optText + "\")" + function UnreachablePanicIfVerified(optText: string := ""): R.Expr { + if pointerType.Raw? then + R.Unsafe(R.Block(R.std.MSel("hint").AsExpr().FSel("unreachable_unchecked").Apply0())) + else if optText == "" then + R.Identifier("panic!").Apply0() + else + R.Identifier("panic!").Apply1(R.LiteralString(optText, binary := false, verbatim := false)) } @@ -1848,7 +2230,9 @@ module {:extern "DCOMP"} DafnyToRustCompiler { this.pointerType := pointerType; this.rootType := rootType; this.error := None; // If error, then the generated code contains Unsupported: .* - this.optimizations := [FactorPathsOptimization.apply(thisFile)]; + this.optimizations := [ + ExpressionOptimization.apply, + FactorPathsOptimization.apply(thisFile)]; new; } @@ -1880,7 +2264,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var body, allmodules := GenModuleBody(mod, mod.body.value, containingPath + [Ident.Ident(innerName)]); if optExtern.SimpleExtern? { if mod.requiresExterns { - body := [R.UseDecl(R.Use(R.PUB, thisFile.MSel(DAFNY_EXTERN_MODULE).MSel(ReplaceDotByDoubleColon(optExtern.overrideName)).MSel("*")))] + body; + body := [R.UseDecl(R.Use(R.PUB, thisFile.MSel(DAFNY_EXTERN_MODULE).MSels(SplitRustPathElement(ReplaceDotByDoubleColon(optExtern.overrideName))).MSel("*")))] + body; } } else if optExtern.AdvancedExtern? { error := Some("Externs on modules can only have 1 string argument"); @@ -2010,7 +2394,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } case None => { // TODO(mikael) Use type descriptors for default values if generics - var default := R.std_Default_default; + var default := R.std_default_Default_default; if fieldType.IsObjectOrPointer() { default := fieldType.ToNullExpr(); } @@ -2036,7 +2420,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { fieldInits := fieldInits + [ R.AssignIdentifier( "_phantom_type_param_" + Strings.OfNat(typeParamI), - R.RawExpr("::std::marker::PhantomData"))]; + R.std.MSel("marker").MSel("PhantomData").AsExpr())]; } var extern := ExtractExtern(c.attributes, c.name); @@ -2077,7 +2461,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { [], [], Some(Object(R.SelfOwned)), "", Some( - R.dafny_runtime.MSel(allocate).AsExpr().ApplyType1(R.SelfOwned).Apply([]) + R.dafny_runtime.MSel(allocate).AsExpr().ApplyType1(R.SelfOwned).Apply0() )) ) ] + implBody; @@ -2087,7 +2471,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if extern.NoExtern? || extern.UnsupportedExtern? { selfTypeForImpl := R.TIdentifier(className); } else if extern.AdvancedExtern? { - selfTypeForImpl := R.crate.MSel(extern.enclosingModule).MSel(extern.overrideName).AsType(); + selfTypeForImpl := R.crate.MSels(extern.enclosingModule).MSel(extern.overrideName).AsType(); } else if extern.SimpleExtern? { selfTypeForImpl := R.TIdentifier(extern.overrideName); } @@ -2285,7 +2669,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { fnBody := fnBody.Apply1(eStr); } case None => { - fnBody := fnBody.Apply1(R.std_Default_default); + fnBody := fnBody.Apply1(R.std_default_Default_default); } } @@ -2338,11 +2722,16 @@ module {:extern "DCOMP"} DafnyToRustCompiler { [R.FnDecl( R.PRIV, R.Fn("fmt_print", [], - [R.Formal.selfBorrowed, R.Formal("_formatter", R.RawType("&mut ::std::fmt::Formatter")), R.Formal("in_seq", R.Type.Bool)], - Some(R.RawType("::std::fmt::Result")), + [ 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.RawExpr("::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq)")) - ))]))]; + Some(R.dafny_runtime.MSel("DafnyPrint").AsExpr().FSel("fmt_print").Apply( + [ R.Borrow(R.self.Sel("0")), + R.Identifier("_formatter"), + R.Identifier("in_seq")]))) + )]))]; s := s + [ R.ImplDecl( R.ImplFor( @@ -2356,7 +2745,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { R.Fn("deref", [], [R.Formal.selfBorrowed], Some(R.Borrowed(R.Self().MSel("Target").AsType())), "", - Some(R.RawExpr("&self.0"))))]))]; + Some(R.Borrow(R.self.Sel("0")))))]))]; } method GenSynonymType(c: SynonymType) returns (s: seq) @@ -2421,6 +2810,21 @@ module {:extern "DCOMP"} DafnyToRustCompiler { !c.isCo && forall ctor <- c.ctors, arg <- ctor.args :: TypeIsEq(arg.formal.typ) } + function write(r: R.Expr, final: bool := false): R.Expr { + var result := + R.Identifier("write!").Apply([ + R.Identifier("_formatter"), + r]); + if final then + result + else + R.UnaryOp("?", result, Format.UnaryOpFormat.NoFormat) + } + + function writeStr(s: string, final: bool := false): R.Expr { + write(R.LiteralString(s, binary := false, verbatim := false)) + } + method GenDatatype(c: Datatype) returns (s: seq) modifies this { @@ -2504,7 +2908,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var ctor2 := c.ctors[k]; var pattern := datatypeName + "::" + escapeName(ctor2.name); - var rhs: string; + var rhs: R.Expr; var hasMatchingField := None; var patternInner := ""; var isNumeric := false; @@ -2531,20 +2935,20 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if hasMatchingField.Some? { if c.isCo { - rhs := "::std::ops::Deref::deref(&" + hasMatchingField.value + ".0)"; + rhs := R.std.MSel("ops").MSel("Deref").AsExpr().FSel("deref").Apply1(R.Borrow(R.Identifier(hasMatchingField.value).Sel("0"))); } else { - rhs := hasMatchingField.value + ""; + rhs := R.Identifier(hasMatchingField.value); } } else { rhs := UnreachablePanicIfVerified("field does not exist on this variant"); } - var ctorMatch := R.MatchCase(R.RawPattern(pattern), R.RawExpr(rhs)); + var ctorMatch := R.MatchCase(R.RawPattern(pattern), rhs); cases := cases + [ctorMatch]; } if |c.typeParams| > 0 && |unusedTypeParams| > 0 { cases := cases + [ - R.MatchCase(R.RawPattern(datatypeName + "::_PhantomVariant(..)"), R.RawExpr(UnreachablePanicIfVerified(""))) + R.MatchCase(R.RawPattern(datatypeName + "::_PhantomVariant(..)"), UnreachablePanicIfVerified("")) ]; } @@ -2646,9 +3050,8 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if |ctorName| >= 13 && ctorName[0..13] == "_System.Tuple" { ctorName := ""; } - var printRhs := - R.RawExpr("write!(_formatter, \"" + ctorName + (if ctor.hasAnyArgs then "(\")?" else "\")?")); - var hashRhs := R.RawExpr(""); + var printRhs := writeStr(ctorName + (if ctor.hasAnyArgs then "(" else "")); + var hashRhs := InitEmptyExpr(); var coerceRhsArgs := []; var isNumeric := false; @@ -2667,21 +3070,25 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if formalType.Arrow? then hashRhs.Then(R.LiteralInt("0").Sel("hash").Apply1(R.Identifier("_state"))) else - hashRhs.Then(R.std.MSel("hash").MSel("Hash").MSel("hash").AsExpr().Apply([R.Identifier(patternName), R.Identifier("_state")])); + hashRhs.Then(R.std.MSel("hash").MSel("Hash").AsExpr().FSel("hash").Apply([R.Identifier(patternName), R.Identifier("_state")])); ctorMatchInner := ctorMatchInner + patternName + ", "; if (j > 0) { - printRhs := printRhs.Then(R.RawExpr("write!(_formatter, \", \")?")); + printRhs := printRhs.Then(writeStr(", ")); } printRhs := printRhs.Then( - R.RawExpr( - if formalType.Arrow? then - "write!(_formatter, \"\")?" - else - "::dafny_runtime::DafnyPrint::fmt_print(" + patternName + ", _formatter, false)?" - )); + if formalType.Arrow? then + writeStr("") + else + R.UnaryOp("?", + R.dafny_runtime.MSel("DafnyPrint").AsExpr().FSel("fmt_print").Apply([ + R.Identifier(patternName), + R.Identifier("_formatter"), + R.LiteralBool(false) + ]), Format.UnaryOpFormat.NoFormat) + ); var coerceRhsArg: R.Expr; @@ -2713,10 +3120,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } if (ctor.hasAnyArgs) { - printRhs := printRhs.Then(R.RawExpr("write!(_formatter, \")\")?")); + printRhs := printRhs.Then(writeStr(")")); } - printRhs := printRhs.Then(R.RawExpr("Ok(())")); + printRhs := printRhs.Then(R.Identifier("Ok").Apply([R.Tuple([])])); printImplBodyCases := printImplBodyCases + [ R.MatchCase(R.RawPattern(datatypeName + "::" + ctorMatch), @@ -2734,7 +3141,9 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if |c.typeParams| > 0 && |unusedTypeParams| > 0 { var extraCases := [ - R.MatchCase(R.RawPattern(datatypeName + "::_PhantomVariant(..)"), R.RawExpr("{"+UnreachablePanicIfVerified()+"}")) + R.MatchCase( + R.RawPattern(datatypeName + "::_PhantomVariant(..)"), + R.Block(UnreachablePanicIfVerified())) ]; printImplBodyCases := printImplBodyCases + extraCases; hashImplBodyCases := hashImplBodyCases + extraCases; @@ -2776,8 +3185,8 @@ module {:extern "DCOMP"} DafnyToRustCompiler { "", Some(R.dafny_runtime .MSel("DafnyPrint") - .MSel("fmt_print") .AsExpr() + .FSel("fmt_print") .Apply( [ R.self, R.Identifier("f"), @@ -2854,7 +3263,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { [], Some(R.dafny_runtime.MSel("SequenceIter").AsType().Apply([instantiationType])), "", - Some(R.dafny_runtime.MSel("seq!").AsExpr().Apply(singletonConstructors).Sel("iter").Apply([])) + Some(R.dafny_runtime.MSel("seq!").AsExpr().Apply(singletonConstructors).Sel("iter").Apply0()) ) )]))]; } @@ -2897,7 +3306,9 @@ module {:extern "DCOMP"} DafnyToRustCompiler { for i := 0 to |c.ctors[0].args| { var dtor := c.ctors[0].args[i]; structAssignments := structAssignments + [ - R.AssignIdentifier(escapeVar(dtor.formal.name), R.RawExpr("::std::default::Default::default()")) + R.AssignIdentifier( + escapeVar(dtor.formal.name), + R.std.MSel("default").MSel("Default").AsExpr().FSel("default").Apply0()) ]; } var defaultConstrainedTypeParams := R.TypeParamDecl.AddConstraintsMultiple( @@ -2950,13 +3361,16 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if |p| == 0 { return R.Self(); } else { - r := - if p[0].id.dafny_name == "std" then - R.Global() - else if p[0].id.dafny_name == "_System" then - R.dafny_runtime - else - thisFile; + var p := p; // Make p mutable + var name := p[0].id.dafny_name; + if |name| >= 2 && name[0..2] == "::" { + r := R.Global(); + p := p[0 := Ident.Ident(Name(name[2..]))]; + } else if p[0].id.dafny_name == "_System" { + r := R.dafny_runtime; + } else { + r := thisFile; + } for i := 0 to |p| { var name := p[i].id; if escape { @@ -2967,7 +3381,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { r := r.MSel(escapeName(finalName)); } else { // TODO: Try removing this else branch and the escape test. - r := r.MSel(ReplaceDotByDoubleColon(name.dafny_name)); + r := r.MSels(SplitRustPathElement(ReplaceDotByDoubleColon(name.dafny_name))); } } } @@ -3133,6 +3547,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { case Real => s := R.dafny_runtime.MSel("BigRational").AsType(); case String => s := R.TypeApp(R.dafny_runtime.MSel("Sequence").AsType(), [R.dafny_runtime.MSel(DafnyChar).AsType()]); + case Native => s := R.Type.USIZE; case Bool => s := R.Type.Bool; case Char => s := R.dafny_runtime.MSel(DafnyChar).AsType(); } @@ -3288,7 +3703,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var fBody: Option; var env: Environment; - var preBody := R.RawExpr(""); + var preBody := InitEmptyExpr(); var preAssignNames: seq := []; var preAssignTypes: map := map[]; @@ -3353,7 +3768,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { decreases stmts, 1, 0 modifies this { - generated := R.RawExpr(""); + generated := InitEmptyExpr(); var declarations := {}; readIdents := {}; var i := 0; @@ -3454,7 +3869,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { onExpr := modify_macro.Apply1(onExpr); - var r := R.RawExpr(""); + var r := InitEmptyExpr(); var indicesExpr := []; for i := 0 to |indices| { @@ -3485,7 +3900,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { { match stmt { case ConstructorNewSeparator(fields) => { - generated := R.RawExpr(""); + generated := InitEmptyExpr(); readIdents := {}; newEnv := env; for i := 0 to |fields| { @@ -3508,7 +3923,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var varName := escapeVar(name); var hasCopySemantics := tpe.CanReadWithoutClone(); if expression.InitializationValue? && !hasCopySemantics { - generated := R.DeclareVar(R.MUT, varName, None, Some(R.MaybePlaceboPath.AsExpr().ApplyType1(tpe).FSel("new").Apply([]))); + generated := R.DeclareVar(R.MUT, varName, None, Some(R.MaybePlaceboPath.AsExpr().ApplyType1(tpe).FSel("new").Apply0())); readIdents := {}; newEnv := env.AddAssigned(varName, R.MaybePlaceboType(tpe)); } else { @@ -3589,7 +4004,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { // Variables are usually owned, so we request OwnershipOwned here although it's for each variable. var over, _, recIdents := GenExpr(overExpr, selfIdent, env, OwnershipOwned); if overExpr.MapBoundedPool? || overExpr.SetBoundedPool? { - over := over.Sel("cloned").Apply([]); + over := over.Sel("cloned").Apply0(); } var boundTpe := GenType(boundType, GenTypeContext.default()); @@ -3615,7 +4030,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } case TailRecursive(body) => { // clone the parameters to make them mutable - generated := R.RawExpr(""); + generated := InitEmptyExpr(); if selfIdent != NoSelf { var selfClone, _, _ := GenIdent(selfIdent.rSelfName, selfIdent, Environment.Empty(), OwnershipOwned); @@ -3669,7 +4084,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { onExpr := modify_macro.Apply1(onExpr); readIdents := readIdents + recIdents; } else { - onExpr, recOwnership, recIdents := GenExpr(on, selfIdent, env, OwnershipBorrowedMut); + onExpr, recOwnership, recIdents := GenExpr(on, selfIdent, env, OwnershipBorrowed); readIdents := readIdents + recIdents; } generated := fullPath.ApplyType(onTypeExprs).FSel(escapeName(name.name)).ApplyType(typeExprs).Apply([onExpr] + argExprs); @@ -3801,12 +4216,14 @@ module {:extern "DCOMP"} DafnyToRustCompiler { case I32() => Some(R.Type.I32) case I64() => Some(R.Type.I64) case I128() => Some(R.Type.I128) + case USIZE() => Some(R.Type.USIZE) case _ => None } } method FromOwned(r: R.Expr, expectedOwnership: Ownership) returns (out: R.Expr, resultingOwnership: Ownership) + modifies this ensures resultingOwnership != OwnershipAutoBorrowed ensures expectedOwnership != OwnershipAutoBorrowed ==> resultingOwnership == expectedOwnership @@ -3823,7 +4240,8 @@ module {:extern "DCOMP"} DafnyToRustCompiler { resultingOwnership := OwnershipBorrowed; } else { assert expectedOwnership == OwnershipBorrowedMut; - out := modify_macro.Apply1(R.RawExpr(r.ToString("") + "/*TODO: Conversion from Borrowed or BorrowedMut to BorrowedMut*/")); + out := Error("Conversion from Borrowed or BorrowedMut to BorrowedMut", r); + out := modify_macro.Apply1(out); resultingOwnership := OwnershipBorrowedMut; } } @@ -3831,6 +4249,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { method FromOwnership(r: R.Expr, ownership: Ownership, expectedOwnership: Ownership) returns (out: R.Expr, resultingOwnership: Ownership) requires ownership != OwnershipAutoBorrowed + modifies this ensures OwnershipGuarantee(expectedOwnership, resultingOwnership) { if ownership == expectedOwnership { @@ -3904,7 +4323,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } case o => { var genType := GenType(o, GenTypeContext.default()); - r := R.TypeAscription(R.RawExpr(i), genType); + r := R.TypeAscription(R.LiteralInt(i), genType); } } r, resultingOwnership := FromOwned(r, expectedOwnership); @@ -3914,11 +4333,23 @@ module {:extern "DCOMP"} DafnyToRustCompiler { case Literal(DecLiteral(n, d, t)) => { match t { case Primitive(Real) => { - r := R.RcNew(R.RawExpr("::dafny_runtime::BigRational::new(::dafny_runtime::BigInt::parse_bytes(b\"" + n + "\", 10).unwrap(), ::dafny_runtime::BigInt::parse_bytes(b\"" + d + "\", 10).unwrap())")); + r := R.dafny_runtime.MSel("BigRational").AsExpr().FSel("new").Apply([ + R.dafny_runtime.MSel("BigInt").AsExpr().FSel("parse_bytes").Apply([ + R.LiteralString(n, binary := true, verbatim := false), + R.LiteralInt("10") + ]).Sel("unwrap").Apply0(), + R.dafny_runtime.MSel("BigInt").AsExpr().FSel("parse_bytes").Apply([ + R.LiteralString(d, binary := true, verbatim := false), + R.LiteralInt("10") + ]).Sel("unwrap").Apply0() + ]); } case o => { var genType := GenType(o, GenTypeContext.default()); - r := R.TypeAscription(R.RawExpr("(" + n + ".0 / " + d + ".0" + ")"), genType); + r := R.TypeAscription( + R.BinaryOp("/", + R.LiteralInt(n).Sel("0"), + R.LiteralInt(d).Sel("0"), Format.BinaryOpFormat.NoFormat), genType); } } @@ -3948,7 +4379,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { r := R.global.MSel("std").MSel("primitive") .MSel("char").FSel("from_u32") - .Apply1(r).Sel("unwrap").Apply([]); + .Apply1(r).Sel("unwrap").Apply0(); } r := R.dafny_runtime.MSel(DafnyChar).AsExpr().Apply1(r); r, resultingOwnership := FromOwned(r, expectedOwnership); @@ -3960,7 +4391,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if pointerType.Raw? { r := R.dafny_runtime.MSel("Ptr").AsExpr().FSel("null").Apply([]); } else { - r := R.TypeAscription(R.dafny_runtime.MSel("Object").AsExpr().Apply1(R.RawExpr("None")), tpeGen); + r := R.TypeAscription(R.dafny_runtime.MSel("Object").AsExpr().Apply1(R.Identifier("None")), tpeGen); } r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := {}; @@ -4092,26 +4523,25 @@ module {:extern "DCOMP"} DafnyToRustCompiler { case Eq(referential) => { if (referential) { if pointerType.Raw? { - error := Some("Cannot compare raw pointers yet - need to wrap them with a structure to ensure they are compared properly"); - r := R.RawExpr(error.value); + r := Error("Cannot compare raw pointers yet - need to wrap them with a structure to ensure they are compared properly"); } else { r := R.BinaryOp("==", left, right, DAST.Format.BinaryOpFormat.NoFormat()); } } else { if rExpr.SeqValue? && |rExpr.elements| == 0 { - r := R.BinaryOp("==", left.Sel("to_array").Apply([]).Sel("len").Apply([]), R.LiteralInt("0"), DAST.Format.BinaryOpFormat.NoFormat()); + r := R.BinaryOp("==", left.Sel("to_array").Apply0().Sel("len").Apply0(), R.LiteralInt("0"), DAST.Format.BinaryOpFormat.NoFormat()); } else if lExpr.SeqValue? && |lExpr.elements| == 0 { - r := R.BinaryOp("==", R.LiteralInt("0"), right.Sel("to_array").Apply([]).Sel("len").Apply([]), DAST.Format.BinaryOpFormat.NoFormat()); + r := R.BinaryOp("==", R.LiteralInt("0"), right.Sel("to_array").Apply0().Sel("len").Apply0(), DAST.Format.BinaryOpFormat.NoFormat()); } else { r := R.BinaryOp("==", left, right, DAST.Format.BinaryOpFormat.NoFormat()); } } } case EuclidianDiv() => { - r := R.RawExpr("::dafny_runtime::euclidian_division").Apply([left, right]); + r := R.dafny_runtime.AsExpr().FSel("euclidian_division").Apply([left, right]); } case EuclidianMod() => { - r := R.RawExpr("::dafny_runtime::euclidian_modulo").Apply([left, right]); + r := R.dafny_runtime.AsExpr().FSel("euclidian_modulo").Apply([left, right]); } case Passthrough(op) => { r := R.Expr.BinaryOp(op, left, right, format); @@ -4153,7 +4583,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { r := recursiveGen; } else { var rhsType := GenType(toTpe, GenTypeContext.default()); - r := R.RawExpr(rhsType.ToString(IND) + "(" + recursiveGen.ToString(IND) + ")"); + r := R.ExprFromType(rhsType).Apply1(recursiveGen); } r, resultingOwnership := FromOwnership(r, recOwned, expectedOwnership); } @@ -4274,12 +4704,12 @@ module {:extern "DCOMP"} DafnyToRustCompiler { function UpcastConversionLambda(fromType: Type, fromTpe: R.Type, toType: Type, toTpe: R.Type, typeParams: map<(R.Type, R.Type), R.Expr>): Result)> { if fromTpe == toTpe then - Success(R.dafny_runtime.MSel("upcast_id").AsExpr().ApplyType([fromTpe]).Apply([])) + Success(R.dafny_runtime.MSel("upcast_id").AsExpr().ApplyType([fromTpe]).Apply0()) else if fromTpe.IsObjectOrPointer() && toTpe.IsObjectOrPointer() then if !toTpe.ObjectOrPointerUnderlying().DynType? then Failure((fromType, fromTpe, toType, toTpe, typeParams)) else var fromTpeUnderlying := fromTpe.ObjectOrPointerUnderlying(); var toTpeUnderlying := toTpe.ObjectOrPointerUnderlying(); - Success(R.dafny_runtime.MSel(upcast).AsExpr().ApplyType([fromTpeUnderlying, toTpeUnderlying]).Apply([])) + Success(R.dafny_runtime.MSel(upcast).AsExpr().ApplyType([fromTpeUnderlying, toTpeUnderlying]).Apply0()) else if (fromTpe, toTpe) in typeParams then Success(typeParams[(fromTpe, toTpe)]) else if fromTpe.IsRc() && toTpe.IsRc() then @@ -4392,9 +4822,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var recursiveGen, recOwned, recIdents := GenExpr(expr, selfIdent, env, expectedOwnership); readIdents := recIdents; var Failure((fromType, fromTpeGen, toType, toTpeGen, m)) := upcastConverter; - var msg := "/* Coercion from " + fromTpeGen.ToString(IND) + " to " + toTpeGen.ToString(IND) + " not yet implemented */"; - error := Some(msg); - r := R.RawExpr(recursiveGen.ToString(IND) + msg); + r := Error("Coercion from " + fromTpeGen.ToString(IND) + " to " + toTpeGen.ToString(IND) + " not yet implemented", recursiveGen); r, resultingOwnership := FromOwnership(r, recOwned, expectedOwnership); } } @@ -4426,34 +4854,44 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } case (Primitive(Int), Primitive(Real)) => { var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipOwned); - r := R.RcNew(R.RawExpr("::dafny_runtime::BigRational::from_integer(" + recursiveGen.ToString(IND) + ")")); + r := R.RcNew(R.dafny_runtime.MSel("BigRational").AsExpr().FSel("from_integer").Apply1(recursiveGen)); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; } case (Primitive(Real), Primitive(Int)) => { var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipBorrowed); - r := R.RawExpr("::dafny_runtime::dafny_rational_to_int(" + recursiveGen.ToString(IND) + ")"); + r := R.dafny_runtime.AsExpr().FSel("dafny_rational_to_int").Apply1(recursiveGen); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; } case (Primitive(Int), Passthrough(_)) => { var rhsType := GenType(toTpe, GenTypeContext.default()); var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipOwned); - r := R.RawExpr("<" + rhsType.ToString(IND) + " as ::dafny_runtime::NumCast>::from(" + recursiveGen.ToString(IND) + ").unwrap()"); + r := R.TraitCast(rhsType, R.dafny_runtime.MSel("NumCast").AsType()).FSel("from").Apply1(recursiveGen).Sel("unwrap").Apply0(); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; } case (Passthrough(_), Primitive(Int)) => { var rhsType := GenType(fromTpe, GenTypeContext.default()); var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipOwned); - r := R.RawExpr("::dafny_runtime::DafnyInt::new(::std::rc::Rc::new(::dafny_runtime::BigInt::from(" + recursiveGen.ToString(IND) + ")))"); + r := R.dafny_runtime.MSel("DafnyInt").AsExpr().FSel("new") + .Apply1(R.std.MSel("rc").MSel("Rc").AsExpr().FSel("new") + .Apply1(R.dafny_runtime.MSel("BigInt").AsExpr().FSel("from").Apply1(recursiveGen))); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; } case (Primitive(Int), Primitive(Char)) => { var rhsType := GenType(toTpe, GenTypeContext.default()); var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipOwned); - r := R.RawExpr("::dafny_runtime::" + DafnyChar + "(" + (if charType.UTF32? then "char::from_u32(::from(" + recursiveGen.ToString(IND) + ").unwrap())" + if charType.UTF32? then ".unwrap())" else ""); + var uType := if charType.UTF32? then R.U32 else R.U16; + r := R.TraitCast(uType, R.dafny_runtime.MSel("NumCast").AsType()); + r := r.FSel("from").Apply1( + recursiveGen + ).Sel("unwrap").Apply0(); + if charType.UTF32? { + r := R.Identifier("char").FSel("from_u32").Apply1(r.Sel("unwrap").Apply0()); + } + r := R.dafny_runtime.MSel(DafnyChar).AsExpr().Apply1(r); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; } @@ -4468,7 +4906,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipOwned); var toTpeGen := GenType(toTpe, GenTypeContext.default()); - r := R.RawExpr("((" + recursiveGen.ToString(IND) + ") as " + toTpeGen.ToString(IND) + ")"); + r := R.TypeAscription(recursiveGen, toTpeGen); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; @@ -4497,7 +4935,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var currentlyBorrowed := env.IsBorrowed(rName); // Otherwise names are owned var noNeedOfClone := env.CanReadWithoutClone(rName); if placeboOpt.Some? { - r := r.Sel("read").Apply([]); + r := r.Sel("read").Apply0(); currentlyBorrowed := false; noNeedOfClone := true; // No need to clone it, it's already owned tpe := Some(placeboOpt.value); @@ -4692,7 +5130,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if typExpr.IsObjectOrPointer() { r := typExpr.ToNullExpr(); } else { - r := R.RawExpr("<" + typExpr.ToString(IND) + " as std::default::Default>::default()"); + r := R.TraitCast(typExpr, R.DefaultTrait).FSel("default").Apply0(); } r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := {}; @@ -4738,14 +5176,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } case NewUninitArray(dims, typ) => { if 16 < |dims| { - var msg := "Unsupported: Creation of arrays of more than 16 dimensions"; - if this.error.None? { - this.error := Some(msg); - } - r := R.RawExpr(msg); + r := Error("Unsupported: Creation of arrays of more than 16 dimensions"); readIdents := {}; } else { - r := R.RawExpr(""); + r := InitEmptyExpr(); var typeGen := GenType(typ, GenTypeContext.default()); readIdents := {}; var dimExprs := []; @@ -4781,12 +5215,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var c := t.MultiArrayClass(); r := R.dafny_runtime.MSel(c).AsExpr().FSel(array_construct).Apply1(recursiveGen); } else { - error := Some("Finalize New Array with a pointer or object type to something that is not an array or a multi array: " + tpe.ToString(IND)); - r := R.RawExpr(error.value); + r := Error("Finalize New Array with a pointer or object type to something that is not an array or a multi array: " + tpe.ToString(IND)); } } else { - error := Some("Finalize New Array with a type that is not a pointer or an object: " + tpe.ToString(IND)); - r := R.RawExpr(error.value); + r := Error("Finalize New Array with a type that is not a pointer or an object: " + tpe.ToString(IND)); } r, resultingOwnership := FromOwned(r, expectedOwnership); } @@ -4811,14 +5243,21 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var recursiveGen, _, recIdents := GenExpr(value, selfIdent, Environment.Empty(), OwnershipOwned); readIdents := readIdents + recIdents; - var allReadCloned := ""; + var allReadCloned := InitEmptyExpr(); while recIdents != {} decreases recIdents { var next: string :| next in recIdents; - allReadCloned := allReadCloned + "let " + next + " = " + next + ".clone();\n"; + allReadCloned := allReadCloned.Then( + R.DeclareVar(R.CONST, next, None, Some(R.Identifier(next).Clone())) + ); recIdents := recIdents - {next}; } - var wasAssigned: string := "::dafny_runtime::LazyFieldWrapper(::dafny_runtime::Lazy::new(::std::boxed::Box::new({\n" + allReadCloned + "move || (" + recursiveGen.ToString(IND) + ")})))"; - assignments := assignments + [R.AssignIdentifier(escapeVar(name), R.RawExpr(wasAssigned))]; + var wasAssigned := R.dafny_runtime.MSel("LazyFieldWrapper").AsExpr().Apply1( + R.dafny_runtime.MSel("Lazy").AsExpr().FSel("new").Apply1( + R.std.MSel("boxed").MSel("Box").AsExpr().FSel("new").Apply1( + allReadCloned.Then( + R.Lambda([], None, recursiveGen) + )))); + assignments := assignments + [R.AssignIdentifier(escapeVar(name), wasAssigned)]; } else { var recursiveGen, _, recIdents := GenExpr(value, selfIdent, env, OwnershipOwned); @@ -4838,10 +5277,32 @@ module {:extern "DCOMP"} DafnyToRustCompiler { GenExprConvert(e, selfIdent, env, expectedOwnership); } case SeqConstruct(length, expr) => { + // seq(length, elemFromIndex) var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipOwned); var lengthGen, _, lengthIdents := GenExpr(length, selfIdent, env, OwnershipOwned); - - r := R.RawExpr("{\nlet _initializer = " + recursiveGen.ToString(IND) + ";\n::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), " + lengthGen.ToString(IND) + ").map(|i| _initializer(&i)).collect::<::dafny_runtime::Sequence<_>>()\n}"); + /* We will generate this + { + let _initializer = Some(elemFromIndex); + integer_range(Zero::zero(), length).map( + move |i| => _initializer(&i) + ).collect::>() + } + */ + r := R.DeclareVar(R.CONST, "_initializer", None, Some(recursiveGen)); + var range := R.dafny_runtime.MSel("integer_range").AsExpr(); + range := range.Apply([ + R.dafny_runtime.MSel("Zero").AsExpr().FSel("zero").Apply0(), + lengthGen + ]); + range := range.Sel("map"); + var rangeMap := R.Lambda([R.Formal.ImplicitlyTyped("i")], None, R.Identifier("_initializer").Apply1(R.Borrow(R.Identifier("i")))); + range := range.Apply1( + rangeMap + ); + range := range.Sel("collect").ApplyType([ + R.dafny_runtime.MSel("Sequence").AsType().Apply([R.TIdentifier("_")]) + ]).Apply0(); + r := R.Block(r.Then(range)); readIdents := recIdents + lengthIdents; r, resultingOwnership := FromOwned(r, expectedOwnership); @@ -4901,7 +5362,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } case ToMultiset(expr) => { var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipAutoBorrowed); - r := recursiveGen.Sel("as_dafny_multiset").Apply([]); + r := recursiveGen.Sel("as_dafny_multiset").Apply0(); readIdents := recIdents; r, resultingOwnership := FromOwned(r, expectedOwnership); return; @@ -4956,7 +5417,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { r, resultingOwnership, readIdents := GenIdent(id, selfIdent, env, expectedOwnership); } case None => { - r := R.RawExpr("panic!(\"this outside of a method\")"); + r := Error("this outside of a method"); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := {}; } @@ -4998,7 +5459,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { case UnOp(Cardinality, e, format) => { var recursiveGen, recOwned, recIdents := GenExpr(e, selfIdent, env, OwnershipAutoBorrowed); - r := recursiveGen.Sel("cardinality").Apply([]); + r := recursiveGen.Sel("cardinality").Apply0(); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; return; @@ -5011,18 +5472,16 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var arrayType := GenType(exprType, GenTypeContext.default()); if !arrayType.IsObjectOrPointer() { - var msg := "Array length of something not an array but " + arrayType.ToString(IND); - this.error := Some(msg); - r := R.RawExpr(msg); + r := Error("Array length of something not an array but " + arrayType.ToString(IND)); } else { var underlying := arrayType.ObjectOrPointerUnderlying(); if dim == 0 && underlying.Array? { - r := read_macro.Apply1(recursiveGen).Sel("len").Apply([]); + r := read_macro.Apply1(recursiveGen).Sel("len").Apply0(); } else { if dim == 0 { - r := read_macro.Apply1(recursiveGen).Sel("data").Sel("len").Apply([]); + r := read_macro.Apply1(recursiveGen).Sel("data").Sel("len").Apply0(); } else { - r := read_macro.Apply1(recursiveGen).Sel("length" + Strings.OfNat(dim) + "_usize").Apply([]); + r := read_macro.Apply1(recursiveGen).Sel("length" + Strings.OfNat(dim) + "_usize").Apply0(); } } if !native { @@ -5036,97 +5495,81 @@ module {:extern "DCOMP"} DafnyToRustCompiler { case MapKeys(expr) => { var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipAutoBorrowed); readIdents := recIdents; - r := recursiveGen.Sel("keys").Apply([]); + r := recursiveGen.Sel("keys").Apply0(); r, resultingOwnership := FromOwned(r, expectedOwnership); return; } case MapValues(expr) => { var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipAutoBorrowed); readIdents := recIdents; - r := recursiveGen.Sel("values").Apply([]); + r := recursiveGen.Sel("values").Apply0(); r, resultingOwnership := FromOwned(r, expectedOwnership); return; } case MapItems(expr) => { var recursiveGen, _, recIdents := GenExpr(expr, selfIdent, env, OwnershipAutoBorrowed); readIdents := recIdents; - r := recursiveGen.Sel("items").Apply([]); + r := recursiveGen.Sel("items").Apply0(); r, resultingOwnership := FromOwned(r, expectedOwnership); return; } case SelectFn(on, field, isDatatype, isStatic, isConstant, arguments) => { // Transforms a function member into a lambda var onExpr, onOwned, recIdents := GenExpr(on, selfIdent, env, OwnershipBorrowed); - var s: string; var onString := onExpr.ToString(IND); + var lEnv := env; + var args := []; + var parameters := []; + for i := 0 to |arguments| { + var ty := GenType(arguments[i], GenTypeContext.default()); + var bTy := R.Borrowed(ty); + var name := "x" + Strings.OfInt(i); + lEnv := lEnv.AddAssigned(name, bTy); + parameters := parameters + [R.Formal(name, bTy)]; + args := args + [(name, ty)]; + } + var body := + if isStatic then + onExpr.FSel(escapeVar(field)) + else + R.Identifier("callTarget").Sel(escapeVar(field)); + if isConstant { + body := body.Apply0(); + } + var onExprArgs := []; + for i := 0 to |args| { + var (name, ty) := args[i]; + var rIdent, _, _ := GenIdent(name, selfIdent, lEnv, if ty.CanReadWithoutClone() then OwnershipOwned else OwnershipBorrowed); + onExprArgs := onExprArgs + [rIdent]; + } + body := body.Apply(onExprArgs); + r := R.Lambda(parameters, None, body); if isStatic { // Generates |x0: &tp0, ...xn: &tpn| on::field(x0, .... xn) (possibly with some .clone()) - var lEnv := env; - var args := []; - s := "|"; - for i := 0 to |arguments| { - if i > 0 { - s := s + ", "; - } - var ty := GenType(arguments[i], GenTypeContext.default()); - var bTy := R.Borrowed(ty); - var name := "x" + Strings.OfInt(i); - lEnv := lEnv.AddAssigned(name, bTy); - - args := args + [(name, ty)]; - s := s + name + ": " + bTy.ToString(IND); - } - s := s + "| " + onString + "::" + escapeVar(field) + (if isConstant then "()" else "") + "("; - for i := 0 to |args| { - if i > 0 { - s := s + ", "; - } - var (name, ty) := args[i]; - var rIdent, _, _ := GenIdent(name, selfIdent, lEnv, if ty.CanReadWithoutClone() then OwnershipOwned else OwnershipBorrowed); - s := s + rIdent.ToString(IND); - } - s := s + ")"; } else { // Generates // { // let callTarget = (on); //or (on.clone()) if it was owned. - // move |arg0, ...argn| { - // callTarget.field(arg0, .... argn) (possibly with some .clone()) - // } + // move |x0, ...xn| callTarget.field(x0, .... xn) (possibly with some .clone()) // } - s := "{\n"; - s := s + "let callTarget = (" + onString + (if onOwned == OwnershipOwned then ")" else ").clone()") + ";\n"; - var args := ""; - var i := 0; - while i < |arguments| { - if i > 0 { - args := args + ", "; - } - args := args + "arg" + Strings.OfNat(i); - i := i + 1; - } - s := s + "move |" + args + "| {\n"; - s := s + "callTarget." + escapeVar(field) + - (if isConstant then "()" else "") + "(" + args + ")\n"; - s := s + "}\n"; - s := s + "}"; + var target := if onOwned == OwnershipOwned then onExpr else onExpr.Clone(); + r := R.Block( + R.DeclareVar(R.CONST, "callTarget", None, Some(target)).Then( + r)); } - var typeShape := "dyn ::std::ops::Fn("; - var i := 0; - while i < |arguments| { - if i > 0 { - typeShape := typeShape + ", "; - } - typeShape := typeShape + "&_"; - i := i + 1; + // as dyn ::std::ops::Fn(&_, ... &_) -> _ + var typeShapeArgs := []; + for i := 0 to |arguments| { + typeShapeArgs := typeShapeArgs + [R.Borrowed(R.TIdentifier("_"))]; } - typeShape := typeShape + ") -> _"; + var typeShape := R.DynType(R.FnType(typeShapeArgs, R.TIdentifier("_"))); - s := "::std::rc::Rc::new(" + s + ") as ::std::rc::Rc<" + typeShape + ">"; - r := R.RawExpr(s); + r := R.TypeAscription( + R.std_rc_Rc_new.Apply1(r), + R.std_rc_Rc.AsType().Apply([typeShape])); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; return; @@ -5135,14 +5578,16 @@ module {:extern "DCOMP"} DafnyToRustCompiler { if on.Companion? || on.ExternCompanion? { var onExpr, onOwned, recIdents := GenExpr(on, selfIdent, env, OwnershipAutoBorrowed); - r := onExpr.FSel(escapeVar(field)).Apply([]); + // onExpr::field() + r := onExpr.FSel(escapeVar(field)).Apply0(); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; return; } else if isDatatype { var onExpr, onOwned, recIdents := GenExpr(on, selfIdent, env, OwnershipAutoBorrowed); - r := onExpr.Sel(escapeVar(field)).Apply([]); + // onExpr.field() + r := onExpr.Sel(escapeVar(field)).Apply0(); var typ := GenType(fieldType, GenTypeContext.default()); // All fields are returned as addresses for now until we have something more clever r, resultingOwnership := FromOwnership(r, OwnershipBorrowed, expectedOwnership); @@ -5163,7 +5608,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } r := r.Sel(escapeVar(field)); if isConstant { - r := r.Apply([]); + r := r.Apply0(); } r := r.Clone(); // self could be &mut, so to avoid any borrow checker problem, we clone the value. r, resultingOwnership := FromOwned(r, expectedOwnership); @@ -5334,7 +5779,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var recursiveGen, recIdents, _ := GenStmts(body, if selfIdent != NoSelf then ThisTyped("_this", selfIdent.dafnyType) else NoSelf, subEnv, true, None); readIdents := {}; recIdents := recIdents - (set name <- paramNames); - var allReadCloned := R.RawExpr(""); + var allReadCloned := InitEmptyExpr(); while recIdents != {} decreases recIdents { var next: string :| next in recIdents; @@ -5377,7 +5822,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } readIdents := {}; - r := R.RawExpr(""); + r := InitEmptyExpr(); for i := 0 to |values| { var typeGen := GenType(values[i].0.typ, GenTypeContext.default()); @@ -5426,8 +5871,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } case TypeTest(on, dType, variant) => { var exprGen, _, recIdents := GenExpr(on, selfIdent, env, OwnershipBorrowed); - var dTypePath := GenPathType(dType + [Ident.Ident(variant)]); - r := R.Identifier("matches!").Apply([exprGen.Sel("as_ref").Apply([]), R.RawExpr(dTypePath.ToString(IND) + "{ .. }")]); + var variantExprPath := GenPathExpr(dType + [Ident.Ident(variant)]); + r := R.Identifier("matches!").Apply( + [ exprGen.Sel("as_ref").Apply0(), + R.UnaryOp("{ .. }", variantExprPath, Format.UnaryOpFormat.NoFormat)]); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; return; @@ -5437,10 +5884,9 @@ module {:extern "DCOMP"} DafnyToRustCompiler { var fromType := GenType(fromType, GenTypeContext.default()); var toType := GenType(toType, GenTypeContext.default()); if fromType.IsObjectOrPointer() && toType.IsObjectOrPointer() { - r := expr.Sel("is_instance_of").ApplyType([toType.ObjectOrPointerUnderlying()]).Apply([]); + r := expr.Sel("is_instance_of").ApplyType([toType.ObjectOrPointerUnderlying()]).Apply0(); } else { - error := Some("Source and/or target types of type test is/are not Object or Ptr"); - r := R.RawExpr(error.value); + r := Error("Source and/or target types of type test is/are not Object or Ptr"); readIdents := {}; } r, resultingOwnership := FromOwnership(r, recOwned, expectedOwnership); @@ -5455,16 +5901,16 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } case SetBoundedPool(of) => { var exprGen, _, recIdents := GenExpr(of, selfIdent, env, OwnershipBorrowed); - r := exprGen.Sel("iter").Apply([]); + r := exprGen.Sel("iter").Apply0(); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; return; } case SeqBoundedPool(of, includeDuplicates) => { var exprGen, _, recIdents := GenExpr(of, selfIdent, env, OwnershipBorrowed); - r := exprGen.Sel("iter").Apply([]); + r := exprGen.Sel("iter").Apply0(); if !includeDuplicates { - r := R.dafny_runtime.MSel("itertools").MSel("Itertools").MSel("unique").AsExpr().Apply1(r); + r := R.dafny_runtime.MSel("itertools").MSel("Itertools").AsExpr().FSel("unique").Apply1(r); } r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := recIdents; @@ -5472,7 +5918,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } case MapBoundedPool(of) => { var exprGen, _, recIdents := GenExpr(of, selfIdent, env, OwnershipBorrowed); - r := exprGen.Sel("keys").Apply([]).Sel("iter").Apply([]); + r := exprGen.Sel("keys").Apply0().Sel("iter").Apply0(); readIdents := recIdents; r, resultingOwnership := FromOwned(r, expectedOwnership); } @@ -5512,7 +5958,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { case MapBuilder(keyType, valueType) => { var kType := GenType(keyType, GenTypeContext.default()); var vType := GenType(valueType, GenTypeContext.default()); - r := R.dafny_runtime.MSel("MapBuilder").AsExpr().ApplyType([kType, vType]).FSel("new").Apply([]); + r := R.dafny_runtime.MSel("MapBuilder").AsExpr().ApplyType([kType, vType]).FSel("new").Apply0(); r, resultingOwnership := FromOwned(r, expectedOwnership); readIdents := {}; return; @@ -5520,7 +5966,7 @@ module {:extern "DCOMP"} DafnyToRustCompiler { case SetBuilder(elemType) => { var eType := GenType(elemType, GenTypeContext.default()); readIdents := {}; - r := R.dafny_runtime.MSel("SetBuilder").AsExpr().ApplyType([eType]).FSel("new").Apply([]); + r := R.dafny_runtime.MSel("SetBuilder").AsExpr().ApplyType([eType]).FSel("new").Apply0(); r, resultingOwnership := FromOwned(r, expectedOwnership); return; } @@ -5548,11 +5994,10 @@ module {:extern "DCOMP"} DafnyToRustCompiler { assume {:axiom} newLambda < lambda; var lambdaGen, _, recLambdaIdents := GenExpr(newLambda, selfIdent, env, OwnershipOwned); var fn := if is_forall then "all" else "any"; - r := collectionGen.Sel(fn).Apply1(lambdaGen.Sel("as_ref").Apply([])); + r := collectionGen.Sel(fn).Apply1(lambdaGen.Sel("as_ref").Apply0()); readIdents := recIdents + recLambdaIdents; } else { - error := Some("Quantifier without an inline lambda"); - r := R.RawExpr(error.value); + r := Error("Quantifier without an inline lambda"); readIdents := {}; } r, resultingOwnership := FromOwned(r, expectedOwnership); @@ -5560,6 +6005,19 @@ module {:extern "DCOMP"} DafnyToRustCompiler { } } + function InitEmptyExpr(): R.Expr { + R.RawExpr("") + } + + method Error(message: string, defaultExpr: R.Expr := InitEmptyExpr()) returns (r: R.Expr) + modifies this + { + if error.None? { + error := Some(message); + } + r := R.UnaryOp("/*" + message + "*/", defaultExpr, Format.UnaryOpFormat.NoFormat); + } + method Compile(p: seq, externalFiles: seq) returns (s: string) modifies this { diff --git a/Source/DafnyCore/DafnyGeneratedFromDafnyPost.py b/Source/DafnyCore/DafnyGeneratedFromDafnyPost.py index 5fb5b857544..f493acfaea3 100644 --- a/Source/DafnyCore/DafnyGeneratedFromDafnyPost.py +++ b/Source/DafnyCore/DafnyGeneratedFromDafnyPost.py @@ -20,7 +20,7 @@ print(f"File {output} was not generated. Fix issues and re-run ./DafnyGeneratedFromDafny.sh") exit() -with open (output + '.cs', 'r' ) as f: +with open(output + '.cs', 'r' ) as f: content = f.read() content_trimmed = re.sub('\[assembly[\s\S]*?(?=namespace Formatting)|namespace\s+\w+\s*\{\s*\}\s*//.*', '', content, flags = re.M) content_new = re.sub('\r?\nnamespace\s+(Std\.(?!Wrappers)(?!Strings)(?!Collections.Seq)(?!Arithmetic)(?!Math)\S+)\s*\{[\s\S]*?\}\s*// end of namespace \\1', '', content_trimmed, flags = re.M) @@ -69,4 +69,4 @@ # Now delete the file output.cs os.remove(output + '.cs') -print("File deleted: " + output + '.cs') \ No newline at end of file +print("File deleted: " + output + '.cs') diff --git a/Source/DafnyCore/GeneratedFromDafny/DAST.cs b/Source/DafnyCore/GeneratedFromDafny/DAST.cs index b9c3d448263..1179a0a0174 100644 --- a/Source/DafnyCore/GeneratedFromDafny/DAST.cs +++ b/Source/DafnyCore/GeneratedFromDafny/DAST.cs @@ -1429,6 +1429,7 @@ public interface _IPrimitive { bool is_String { get; } bool is_Bool { get; } bool is_Char { get; } + bool is_Native { get; } _IPrimitive DowncastClone(); } public abstract class Primitive : _IPrimitive { @@ -1457,11 +1458,15 @@ public static _IPrimitive create_Bool() { public static _IPrimitive create_Char() { return new Primitive_Char(); } + public static _IPrimitive create_Native() { + return new Primitive_Native(); + } public bool is_Int { get { return this is Primitive_Int; } } public bool is_Real { get { return this is Primitive_Real; } } public bool is_String { get { return this is Primitive_String; } } public bool is_Bool { get { return this is Primitive_Bool; } } public bool is_Char { get { return this is Primitive_Char; } } + public bool is_Native { get { return this is Primitive_Native; } } public static System.Collections.Generic.IEnumerable<_IPrimitive> AllSingletonConstructors { get { yield return Primitive.create_Int(); @@ -1469,6 +1474,7 @@ public static System.Collections.Generic.IEnumerable<_IPrimitive> AllSingletonCo yield return Primitive.create_String(); yield return Primitive.create_Bool(); yield return Primitive.create_Char(); + yield return Primitive.create_Native(); } } public abstract _IPrimitive DowncastClone(); @@ -1578,6 +1584,27 @@ public override string ToString() { return s; } } + public class Primitive_Native : Primitive { + public Primitive_Native() : base() { + } + public override _IPrimitive DowncastClone() { + if (this is _IPrimitive dt) { return dt; } + return new Primitive_Native(); + } + public override bool Equals(object other) { + var oth = other as DAST.Primitive_Native; + return oth != null; + } + public override int GetHashCode() { + ulong hash = 5381; + hash = ((hash << 5) + hash) + 5; + return (int) hash; + } + public override string ToString() { + string s = "DAST.Primitive.Native"; + return s; + } + } public interface _INewtypeRange { bool is_U8 { get; } @@ -1590,6 +1617,7 @@ public interface _INewtypeRange { bool is_I64 { get; } bool is_U128 { get; } bool is_I128 { get; } + bool is_USIZE { get; } bool is_BigInt { get; } bool is_NoRange { get; } _INewtypeRange DowncastClone(); @@ -1635,6 +1663,9 @@ public static _INewtypeRange create_U128() { public static _INewtypeRange create_I128() { return new NewtypeRange_I128(); } + public static _INewtypeRange create_USIZE() { + return new NewtypeRange_USIZE(); + } public static _INewtypeRange create_BigInt() { return new NewtypeRange_BigInt(); } @@ -1651,6 +1682,7 @@ public static _INewtypeRange create_NoRange() { public bool is_I64 { get { return this is NewtypeRange_I64; } } public bool is_U128 { get { return this is NewtypeRange_U128; } } public bool is_I128 { get { return this is NewtypeRange_I128; } } + public bool is_USIZE { get { return this is NewtypeRange_USIZE; } } public bool is_BigInt { get { return this is NewtypeRange_BigInt; } } public bool is_NoRange { get { return this is NewtypeRange_NoRange; } } public static System.Collections.Generic.IEnumerable<_INewtypeRange> AllSingletonConstructors { @@ -1665,6 +1697,7 @@ public static System.Collections.Generic.IEnumerable<_INewtypeRange> AllSingleto yield return NewtypeRange.create_I64(); yield return NewtypeRange.create_U128(); yield return NewtypeRange.create_I128(); + yield return NewtypeRange.create_USIZE(); yield return NewtypeRange.create_BigInt(); yield return NewtypeRange.create_NoRange(); } @@ -1881,6 +1914,27 @@ public override string ToString() { return s; } } + public class NewtypeRange_USIZE : NewtypeRange { + public NewtypeRange_USIZE() : base() { + } + public override _INewtypeRange DowncastClone() { + if (this is _INewtypeRange dt) { return dt; } + return new NewtypeRange_USIZE(); + } + public override bool Equals(object other) { + var oth = other as DAST.NewtypeRange_USIZE; + return oth != null; + } + public override int GetHashCode() { + ulong hash = 5381; + hash = ((hash << 5) + hash) + 10; + return (int) hash; + } + public override string ToString() { + string s = "DAST.NewtypeRange.USIZE"; + return s; + } + } public class NewtypeRange_BigInt : NewtypeRange { public NewtypeRange_BigInt() : base() { } @@ -1894,7 +1948,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 10; + hash = ((hash << 5) + hash) + 11; return (int) hash; } public override string ToString() { @@ -1915,7 +1969,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 11; + hash = ((hash << 5) + hash) + 12; return (int) hash; } public override string ToString() { diff --git a/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs b/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs index 2065fe2f254..ce265579fcb 100644 --- a/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs +++ b/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs @@ -172,7 +172,7 @@ public static bool is__idiomatic__rust__id(Dafny.ISequence i) { public static Std.Wrappers._IOption OptExtern(DAST._IAttribute attr, Dafny.ISequence dafnyName) { if (((attr).dtor_name).Equals(Dafny.Sequence.UnicodeFromString("extern"))) { - return Std.Wrappers.Option.create_Some((((new BigInteger(((attr).dtor_args).Count)).Sign == 0) ? (DCOMP.ExternAttribute.create_SimpleExtern(DCOMP.__default.escapeName(dafnyName))) : ((((new BigInteger(((attr).dtor_args).Count)) == (BigInteger.One)) ? (DCOMP.ExternAttribute.create_SimpleExtern(((attr).dtor_args).Select(BigInteger.Zero))) : ((((new BigInteger(((attr).dtor_args).Count)) == (new BigInteger(2))) ? (DCOMP.ExternAttribute.create_AdvancedExtern(DCOMP.__default.ReplaceDotByDoubleColon(((attr).dtor_args).Select(BigInteger.Zero)), ((attr).dtor_args).Select(BigInteger.One))) : (DCOMP.ExternAttribute.create_UnsupportedExtern(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("{:extern} supports only 0, 1 or 2 attributes, got "), Std.Strings.__default.OfNat(new BigInteger(((attr).dtor_args).Count))))))))))); + return Std.Wrappers.Option.create_Some((((new BigInteger(((attr).dtor_args).Count)).Sign == 0) ? (DCOMP.ExternAttribute.create_SimpleExtern(DCOMP.__default.escapeName(dafnyName))) : ((((new BigInteger(((attr).dtor_args).Count)) == (BigInteger.One)) ? (DCOMP.ExternAttribute.create_SimpleExtern(((attr).dtor_args).Select(BigInteger.Zero))) : ((((new BigInteger(((attr).dtor_args).Count)) == (new BigInteger(2))) ? (DCOMP.ExternAttribute.create_AdvancedExtern(DCOMP.__default.SplitRustPathElement(DCOMP.__default.ReplaceDotByDoubleColon(((attr).dtor_args).Select(BigInteger.Zero)), Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("")), ((attr).dtor_args).Select(BigInteger.One))) : (DCOMP.ExternAttribute.create_UnsupportedExtern(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("{:extern} supports only 0, 1 or 2 attributes, got "), Std.Strings.__default.OfNat(new BigInteger(((attr).dtor_args).Count))))))))))); } else { return Std.Wrappers.Option.create_None(); } @@ -191,6 +191,33 @@ public static bool is__idiomatic__rust__id(Dafny.ISequence i) { goto TAIL_CALL_START; } } + public static Dafny.ISequence> SplitRustPathElement(Dafny.ISequence s, Dafny.ISequence> result, Dafny.ISequence acc) + { + TAIL_CALL_START: ; + if ((new BigInteger((s).Count)).Sign == 0) { + if ((acc).Equals(Dafny.Sequence.UnicodeFromString(""))) { + return result; + } else { + return Dafny.Sequence>.Concat(result, Dafny.Sequence>.FromElements(acc)); + } + } else if (((new BigInteger((s).Count)) >= (new BigInteger(2))) && (((s).Subsequence(BigInteger.Zero, new BigInteger(2))).Equals(Dafny.Sequence.UnicodeFromString("::")))) { + Dafny.ISequence _in0 = (s).Drop(new BigInteger(2)); + Dafny.ISequence> _in1 = Dafny.Sequence>.Concat(result, Dafny.Sequence>.FromElements(acc)); + Dafny.ISequence _in2 = Dafny.Sequence.UnicodeFromString(""); + s = _in0; + result = _in1; + acc = _in2; + goto TAIL_CALL_START; + } else { + Dafny.ISequence _in3 = (s).Drop(BigInteger.One); + Dafny.ISequence> _in4 = result; + Dafny.ISequence _in5 = Dafny.Sequence.Concat(acc, Dafny.Sequence.FromElements((s).Select(BigInteger.Zero))); + s = _in3; + result = _in4; + acc = _in5; + goto TAIL_CALL_START; + } + } public static DCOMP._IExternAttribute ExtractExtern(Dafny.ISequence attributes, Dafny.ISequence dafnyName) { DCOMP._IExternAttribute res = DCOMP.ExternAttribute.Default(); @@ -906,7 +933,7 @@ public interface _IExternAttribute { bool is_AdvancedExtern { get; } bool is_UnsupportedExtern { get; } Dafny.ISequence dtor_overrideName { get; } - Dafny.ISequence dtor_enclosingModule { get; } + Dafny.ISequence> dtor_enclosingModule { get; } Dafny.ISequence dtor_reason { get; } _IExternAttribute DowncastClone(); } @@ -927,7 +954,7 @@ public static _IExternAttribute create_NoExtern() { public static _IExternAttribute create_SimpleExtern(Dafny.ISequence overrideName) { return new ExternAttribute_SimpleExtern(overrideName); } - public static _IExternAttribute create_AdvancedExtern(Dafny.ISequence enclosingModule, Dafny.ISequence overrideName) { + public static _IExternAttribute create_AdvancedExtern(Dafny.ISequence> enclosingModule, Dafny.ISequence overrideName) { return new ExternAttribute_AdvancedExtern(enclosingModule, overrideName); } public static _IExternAttribute create_UnsupportedExtern(Dafny.ISequence reason) { @@ -944,7 +971,7 @@ public Dafny.ISequence dtor_overrideName { return ((ExternAttribute_AdvancedExtern)d)._overrideName; } } - public Dafny.ISequence dtor_enclosingModule { + public Dafny.ISequence> dtor_enclosingModule { get { var d = this; return ((ExternAttribute_AdvancedExtern)d)._enclosingModule; @@ -1007,9 +1034,9 @@ public override string ToString() { } } public class ExternAttribute_AdvancedExtern : ExternAttribute { - public readonly Dafny.ISequence _enclosingModule; + public readonly Dafny.ISequence> _enclosingModule; public readonly Dafny.ISequence _overrideName; - public ExternAttribute_AdvancedExtern(Dafny.ISequence enclosingModule, Dafny.ISequence overrideName) : base() { + public ExternAttribute_AdvancedExtern(Dafny.ISequence> enclosingModule, Dafny.ISequence overrideName) : base() { this._enclosingModule = enclosingModule; this._overrideName = overrideName; } @@ -1031,7 +1058,7 @@ public override int GetHashCode() { public override string ToString() { string s = "DafnyToRustCompiler.ExternAttribute.AdvancedExtern"; s += "("; - s += this._enclosingModule.ToVerbatimString(true); + s += Dafny.Helpers.ToString(this._enclosingModule); s += ", "; s += this._overrideName.ToVerbatimString(true); s += ")"; @@ -1081,13 +1108,13 @@ public RAST._IType Object(RAST._IType underlying) { return RAST.__default.ObjectType(underlying); } } - public Dafny.ISequence UnreachablePanicIfVerified(Dafny.ISequence optText) { + public RAST._IExpr UnreachablePanicIfVerified(Dafny.ISequence optText) { if (((this).pointerType).is_Raw) { - return Dafny.Sequence.UnicodeFromString("unsafe { ::std::hint::unreachable_unchecked() }"); + return RAST.__default.Unsafe(RAST.Expr.create_Block(((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("hint"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("unreachable_unchecked"))).Apply0())); } else if ((optText).Equals(Dafny.Sequence.UnicodeFromString(""))) { - return Dafny.Sequence.UnicodeFromString("panic!()"); + return (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("panic!"))).Apply0(); } else { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("panic!(\""), optText), Dafny.Sequence.UnicodeFromString("\")")); + return (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("panic!"))).Apply1(RAST.Expr.create_LiteralString(optText, false, false)); } } public Std.Wrappers._IOption> error {get; set;} @@ -1098,7 +1125,7 @@ public void __ctor(DCOMP._ICharType charType, DCOMP._IPointerType pointerType, D (this)._pointerType = pointerType; (this)._rootType = rootType; (this).error = Std.Wrappers.Option>.create_None(); - (this).optimizations = Dafny.Sequence>.FromElements(FactorPathsOptimization.__default.apply((this).thisFile)); + (this).optimizations = Dafny.Sequence>.FromElements(ExpressionOptimization.__default.apply, FactorPathsOptimization.__default.apply((this).thisFile)); } public static Dafny.ISequence> ContainingPathToRust(Dafny.ISequence> containingPath) { return Std.Collections.Seq.__default.Map, Dafny.ISequence>(((System.Func, Dafny.ISequence>)((_0_i) => { @@ -1141,7 +1168,7 @@ public bool HasAttribute(Dafny.ISequence attributes, Dafny.ISe _7_allmodules = _out1; if ((_4_optExtern).is_SimpleExtern) { if ((mod).dtor_requiresExterns) { - _6_body = Dafny.Sequence.Concat(Dafny.Sequence.FromElements(RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), ((((this).thisFile).MSel(DCOMP.COMP.DAFNY__EXTERN__MODULE)).MSel(DCOMP.__default.ReplaceDotByDoubleColon((_4_optExtern).dtor_overrideName))).MSel(Dafny.Sequence.UnicodeFromString("*"))))), _6_body); + _6_body = Dafny.Sequence.Concat(Dafny.Sequence.FromElements(RAST.ModDecl.create_UseDecl(RAST.Use.create(RAST.Visibility.create_PUB(), ((((this).thisFile).MSel(DCOMP.COMP.DAFNY__EXTERN__MODULE)).MSels(DCOMP.__default.SplitRustPathElement(DCOMP.__default.ReplaceDotByDoubleColon((_4_optExtern).dtor_overrideName), Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString("")))).MSel(Dafny.Sequence.UnicodeFromString("*"))))), _6_body); } } else if ((_4_optExtern).is_AdvancedExtern) { (this).error = Std.Wrappers.Option>.create_Some(Dafny.Sequence.UnicodeFromString("Externs on modules can only have 1 string argument")); @@ -1324,15 +1351,15 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) DAST._IExpression _12_e = _source0.dtor_value; { RAST._IExpr _13_expr; - DCOMP._IOwnership _14___v51; - Dafny.ISet> _15___v52; + DCOMP._IOwnership _14___v32; + Dafny.ISet> _15___v33; RAST._IExpr _out5; DCOMP._IOwnership _out6; Dafny.ISet> _out7; (this).GenExpr(_12_e, DCOMP.SelfInfo.create_NoSelf(), DCOMP.Environment.Empty(), DCOMP.Ownership.create_OwnershipOwned(), out _out5, out _out6, out _out7); _13_expr = _out5; - _14___v51 = _out6; - _15___v52 = _out7; + _14___v32 = _out6; + _15___v33 = _out7; _6_fieldInits = Dafny.Sequence.Concat(_6_fieldInits, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(_11_fieldRustName, _13_expr))); } goto after_match0; @@ -1341,7 +1368,7 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) { { RAST._IExpr _16_default; - _16_default = RAST.__default.std__Default__default; + _16_default = RAST.__default.std__default__Default__default; if ((_10_fieldType).IsObjectOrPointer()) { _16_default = (_10_fieldType).ToNullExpr(); } @@ -1367,7 +1394,7 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) goto continue_0; } _5_fields = Dafny.Sequence.Concat(_5_fields, Dafny.Sequence.FromElements(RAST.Field.create(RAST.Visibility.create_PRIV(), RAST.Formal.create(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_phantom_type_param_"), Std.Strings.__default.OfNat(_17_typeParamI)), RAST.Type.create_TypeApp((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("marker"))).MSel(Dafny.Sequence.UnicodeFromString("PhantomData"))).AsType(), Dafny.Sequence.FromElements(_20_rTypeArg)))))); - _6_fieldInits = Dafny.Sequence.Concat(_6_fieldInits, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_phantom_type_param_"), Std.Strings.__default.OfNat(_17_typeParamI)), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("::std::marker::PhantomData"))))); + _6_fieldInits = Dafny.Sequence.Concat(_6_fieldInits, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_phantom_type_param_"), Std.Strings.__default.OfNat(_17_typeParamI)), (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("marker"))).MSel(Dafny.Sequence.UnicodeFromString("PhantomData"))).AsExpr()))); continue_0: ; } after_0: ; @@ -1396,13 +1423,13 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _24_implBody = _out11; _25_traitBodies = _out12; if (((_21_extern).is_NoExtern) && (!(_22_className).Equals(Dafny.Sequence.UnicodeFromString("_default")))) { - _24_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)).Apply(Dafny.Sequence.FromElements()))))), _24_implBody); + _24_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())))), _24_implBody); } RAST._IType _26_selfTypeForImpl = RAST.Type.Default(); if (((_21_extern).is_NoExtern) || ((_21_extern).is_UnsupportedExtern)) { _26_selfTypeForImpl = RAST.Type.create_TIdentifier(_22_className); } else if ((_21_extern).is_AdvancedExtern) { - _26_selfTypeForImpl = (((RAST.__default.crate).MSel((_21_extern).dtor_enclosingModule)).MSel((_21_extern).dtor_overrideName)).AsType(); + _26_selfTypeForImpl = (((RAST.__default.crate).MSels((_21_extern).dtor_enclosingModule)).MSel((_21_extern).dtor_overrideName)).AsType(); } else if ((_21_extern).is_SimpleExtern) { _26_selfTypeForImpl = RAST.Type.create_TIdentifier((_21_extern).dtor_overrideName); } @@ -1535,12 +1562,12 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) Dafny.ISequence> _8_fullPath; _8_fullPath = Dafny.Sequence>.Concat(containingPath, Dafny.Sequence>.FromElements((t).dtor_name)); Dafny.ISequence _9_implBody; - Dafny.IMap>,Dafny.ISequence> _10___v56; + Dafny.IMap>,Dafny.ISequence> _10___v37; Dafny.ISequence _out3; Dafny.IMap>,Dafny.ISequence> _out4; (this).GenClassImplBody((t).dtor_body, true, DAST.Type.create_UserDefined(DAST.ResolvedType.create(_8_fullPath, Dafny.Sequence.FromElements(), DAST.ResolvedTypeBase.create_Trait(), (t).dtor_attributes, Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements())), _0_typeParamsSeq, out _out3, out _out4); _9_implBody = _out3; - _10___v56 = _out4; + _10___v37 = _out4; Dafny.ISequence _11_parents; _11_parents = Dafny.Sequence.FromElements(); BigInteger _hi1 = new BigInteger(((t).dtor_parents).Count); @@ -1606,15 +1633,15 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _11_e = DAST.Expression.create_Convert(_10_e, (c).dtor_base, _7_resultingType); } RAST._IExpr _12_eStr; - DCOMP._IOwnership _13___v57; - Dafny.ISet> _14___v58; + DCOMP._IOwnership _13___v38; + Dafny.ISet> _14___v39; RAST._IExpr _out5; DCOMP._IOwnership _out6; Dafny.ISet> _out7; (this).GenExpr(_11_e, DCOMP.SelfInfo.create_NoSelf(), DCOMP.Environment.Empty(), DCOMP.Ownership.create_OwnershipOwned(), out _out5, out _out6, out _out7); _12_eStr = _out5; - _13___v57 = _out6; - _14___v58 = _out7; + _13___v38 = _out6; + _14___v39 = _out7; _9_fnBody = (_9_fnBody).Apply1(_12_eStr); } goto after_match1; @@ -1622,7 +1649,7 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) } { { - _9_fnBody = (_9_fnBody).Apply1(RAST.__default.std__Default__default); + _9_fnBody = (_9_fnBody).Apply1(RAST.__default.std__default__Default__default); } } after_match1: ; @@ -1639,14 +1666,14 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) DAST._IFormal _16_formal = value0.dtor_variable; Dafny.ISequence _17_constraintStmts = value0.dtor_constraintStmts; RAST._IExpr _18_rStmts; - Dafny.ISet> _19___v59; + Dafny.ISet> _19___v40; DCOMP._IEnvironment _20_newEnv; RAST._IExpr _out8; Dafny.ISet> _out9; DCOMP._IEnvironment _out10; (this).GenStmts(_17_constraintStmts, DCOMP.SelfInfo.create_NoSelf(), DCOMP.Environment.Empty(), false, Std.Wrappers.Option>>.create_None(), out _out8, out _out9, out _out10); _18_rStmts = _out8; - _19___v59 = _out9; + _19___v40 = _out9; _20_newEnv = _out10; Dafny.ISequence _21_rFormals; Dafny.ISequence _out11; @@ -1656,8 +1683,8 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) } after_match2: ; s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, RAST.__default.DefaultTrait, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_8_newtypeName), _1_rTypeParams), _3_whereConstraints, Dafny.Sequence.FromElements(_15_body))))); - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, RAST.__default.DafnyPrint, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_8_newtypeName), _1_rTypeParams), Dafny.Sequence.UnicodeFromString(""), 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.__default.RawType(Dafny.Sequence.UnicodeFromString("&mut ::std::fmt::Formatter"))), 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(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("::dafny_runtime::DafnyPrint::fmt_print(&self.0, _formatter, in_seq)")))))))))); - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, RAST.__default.RawType(Dafny.Sequence.UnicodeFromString("::std::ops::Deref")), RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_8_newtypeName), _1_rTypeParams), Dafny.Sequence.UnicodeFromString(""), Dafny.Sequence.FromElements(RAST.ImplMember.create_RawImplMember(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("type Target = "), (_5_underlyingType)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(";"))), 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.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("&self.0")))))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, RAST.__default.DafnyPrint, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_8_newtypeName), _1_rTypeParams), Dafny.Sequence.UnicodeFromString(""), 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.RawType(Dafny.Sequence.UnicodeFromString("::std::ops::Deref")), RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_8_newtypeName), _1_rTypeParams), Dafny.Sequence.UnicodeFromString(""), Dafny.Sequence.FromElements(RAST.ImplMember.create_RawImplMember(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("type Target = "), (_5_underlyingType)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(";"))), 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"))))))))))); return s; } public Dafny.ISequence GenSynonymType(DAST._ISynonymType c) @@ -1691,25 +1718,25 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) DAST._IExpression _7_e = _source0.dtor_value; { RAST._IExpr _8_rStmts; - Dafny.ISet> _9___v60; + Dafny.ISet> _9___v41; DCOMP._IEnvironment _10_newEnv; RAST._IExpr _out5; Dafny.ISet> _out6; DCOMP._IEnvironment _out7; (this).GenStmts((c).dtor_witnessStmts, DCOMP.SelfInfo.create_NoSelf(), DCOMP.Environment.Empty(), false, Std.Wrappers.Option>>.create_None(), out _out5, out _out6, out _out7); _8_rStmts = _out5; - _9___v60 = _out6; + _9___v41 = _out6; _10_newEnv = _out7; RAST._IExpr _11_rExpr; - DCOMP._IOwnership _12___v61; - Dafny.ISet> _13___v62; + DCOMP._IOwnership _12___v42; + Dafny.ISet> _13___v43; RAST._IExpr _out8; DCOMP._IOwnership _out9; Dafny.ISet> _out10; (this).GenExpr(_7_e, DCOMP.SelfInfo.create_NoSelf(), _10_newEnv, DCOMP.Ownership.create_OwnershipOwned(), out _out8, out _out9, out _out10); _11_rExpr = _out8; - _12___v61 = _out9; - _13___v62 = _out10; + _12___v42 = _out9; + _13___v43 = _out10; Dafny.ISequence _14_constantName; _14_constantName = DCOMP.__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(_14_constantName, _6_defaultConstrainedTypeParams, Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some(_5_resultingType), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((_8_rStmts).Then(_11_rExpr))))))); @@ -1816,6 +1843,19 @@ public bool DatatypeIsEq(DAST._IDatatype c) { }))); }))))(c)); } + public RAST._IExpr write(RAST._IExpr r, bool final) + { + RAST._IExpr _0_result = (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("write!"))).Apply(Dafny.Sequence.FromElements(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_formatter")), r)); + if (final) { + return _0_result; + } else { + return RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("?"), _0_result, DAST.Format.UnaryOpFormat.create_NoFormat()); + } + } + public RAST._IExpr writeStr(Dafny.ISequence s, bool final) + { + return (this).write(RAST.Expr.create_LiteralString(s, false, false), false); + } public Dafny.ISequence GenDatatype(DAST._IDatatype c) { Dafny.ISequence s = Dafny.Sequence.Empty; @@ -1939,7 +1979,7 @@ public bool DatatypeIsEq(DAST._IDatatype c) { _36_ctor2 = ((c).dtor_ctors).Select(_35_k); Dafny.ISequence _37_pattern; _37_pattern = Dafny.Sequence.Concat(Dafny.Sequence.Concat(_4_datatypeName, Dafny.Sequence.UnicodeFromString("::")), DCOMP.__default.escapeName((_36_ctor2).dtor_name)); - Dafny.ISequence _38_rhs = Dafny.Sequence.Empty; + RAST._IExpr _38_rhs = RAST.Expr.Default(); Std.Wrappers._IOption> _39_hasMatchingField; _39_hasMatchingField = Std.Wrappers.Option>.create_None(); Dafny.ISequence _40_patternInner; @@ -1970,19 +2010,19 @@ public bool DatatypeIsEq(DAST._IDatatype c) { } if ((_39_hasMatchingField).is_Some) { if ((c).dtor_isCo) { - _38_rhs = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::std::ops::Deref::deref(&"), (_39_hasMatchingField).dtor_value), Dafny.Sequence.UnicodeFromString(".0)")); + _38_rhs = (((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("ops"))).MSel(Dafny.Sequence.UnicodeFromString("Deref"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("deref"))).Apply1(RAST.__default.Borrow((RAST.Expr.create_Identifier((_39_hasMatchingField).dtor_value)).Sel(Dafny.Sequence.UnicodeFromString("0")))); } else { - _38_rhs = Dafny.Sequence.Concat((_39_hasMatchingField).dtor_value, Dafny.Sequence.UnicodeFromString("")); + _38_rhs = RAST.Expr.create_Identifier((_39_hasMatchingField).dtor_value); } } else { _38_rhs = (this).UnreachablePanicIfVerified(Dafny.Sequence.UnicodeFromString("field does not exist on this variant")); } RAST._IMatchCase _45_ctorMatch; - _45_ctorMatch = RAST.MatchCase.create(_37_pattern, RAST.Expr.create_RawExpr(_38_rhs)); + _45_ctorMatch = RAST.MatchCase.create(_37_pattern, _38_rhs); _34_cases = Dafny.Sequence.Concat(_34_cases, Dafny.Sequence.FromElements(_45_ctorMatch)); } if (((new BigInteger(((c).dtor_typeParams).Count)).Sign == 1) && ((new BigInteger((_20_unusedTypeParams).Count)).Sign == 1)) { - _34_cases = Dafny.Sequence.Concat(_34_cases, Dafny.Sequence.FromElements(RAST.MatchCase.create(Dafny.Sequence.Concat(_4_datatypeName, Dafny.Sequence.UnicodeFromString("::_PhantomVariant(..)")), RAST.Expr.create_RawExpr((this).UnreachablePanicIfVerified(Dafny.Sequence.UnicodeFromString("")))))); + _34_cases = Dafny.Sequence.Concat(_34_cases, Dafny.Sequence.FromElements(RAST.MatchCase.create(Dafny.Sequence.Concat(_4_datatypeName, Dafny.Sequence.UnicodeFromString("::_PhantomVariant(..)")), (this).UnreachablePanicIfVerified(Dafny.Sequence.UnicodeFromString(""))))); } RAST._IExpr _46_methodBody; _46_methodBody = RAST.Expr.create_Match(RAST.__default.self, _34_cases); @@ -2084,9 +2124,9 @@ public bool DatatypeIsEq(DAST._IDatatype c) { _75_ctorName = Dafny.Sequence.UnicodeFromString(""); } RAST._IExpr _76_printRhs; - _76_printRhs = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("write!(_formatter, \""), _75_ctorName), (((_72_ctor).dtor_hasAnyArgs) ? (Dafny.Sequence.UnicodeFromString("(\")?")) : (Dafny.Sequence.UnicodeFromString("\")?"))))); + _76_printRhs = (this).writeStr(Dafny.Sequence.Concat(_75_ctorName, (((_72_ctor).dtor_hasAnyArgs) ? (Dafny.Sequence.UnicodeFromString("(")) : (Dafny.Sequence.UnicodeFromString("")))), false); RAST._IExpr _77_hashRhs; - _77_hashRhs = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); + _77_hashRhs = (this).InitEmptyExpr(); Dafny.ISequence _78_coerceRhsArgs; _78_coerceRhsArgs = Dafny.Sequence.FromElements(); bool _79_isNumeric; @@ -2110,13 +2150,13 @@ public bool DatatypeIsEq(DAST._IDatatype c) { if ((_84_formalType).is_Arrow) { _77_hashRhs = (_77_hashRhs).Then(((RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("0"))).Sel(Dafny.Sequence.UnicodeFromString("hash"))).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_state")))); } else { - _77_hashRhs = (_77_hashRhs).Then((((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("hash"))).MSel(Dafny.Sequence.UnicodeFromString("Hash"))).MSel(Dafny.Sequence.UnicodeFromString("hash"))).AsExpr()).Apply(Dafny.Sequence.FromElements(RAST.Expr.create_Identifier(_83_patternName), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_state"))))); + _77_hashRhs = (_77_hashRhs).Then((((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("hash"))).MSel(Dafny.Sequence.UnicodeFromString("Hash"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("hash"))).Apply(Dafny.Sequence.FromElements(RAST.Expr.create_Identifier(_83_patternName), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_state"))))); } _80_ctorMatchInner = Dafny.Sequence.Concat(Dafny.Sequence.Concat(_80_ctorMatchInner, _83_patternName), Dafny.Sequence.UnicodeFromString(", ")); if ((_81_j).Sign == 1) { - _76_printRhs = (_76_printRhs).Then(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("write!(_formatter, \", \")?"))); + _76_printRhs = (_76_printRhs).Then((this).writeStr(Dafny.Sequence.UnicodeFromString(", "), false)); } - _76_printRhs = (_76_printRhs).Then(RAST.Expr.create_RawExpr((((_84_formalType).is_Arrow) ? (Dafny.Sequence.UnicodeFromString("write!(_formatter, \"\")?")) : (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::dafny_runtime::DafnyPrint::fmt_print("), _83_patternName), Dafny.Sequence.UnicodeFromString(", _formatter, false)?")))))); + _76_printRhs = (_76_printRhs).Then((((_84_formalType).is_Arrow) ? ((this).writeStr(Dafny.Sequence.UnicodeFromString(""), false)) : (RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("?"), ((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyPrint"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("fmt_print"))).Apply(Dafny.Sequence.FromElements(RAST.Expr.create_Identifier(_83_patternName), RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_formatter")), RAST.Expr.create_LiteralBool(false))), DAST.Format.UnaryOpFormat.create_NoFormat())))); RAST._IExpr _85_coerceRhsArg = RAST.Expr.Default(); RAST._IType _86_formalTpe; RAST._IType _out14; @@ -2146,16 +2186,16 @@ public bool DatatypeIsEq(DAST._IDatatype c) { _73_ctorMatch = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_73_ctorMatch, Dafny.Sequence.UnicodeFromString("{")), _80_ctorMatchInner), Dafny.Sequence.UnicodeFromString("}")); } if ((_72_ctor).dtor_hasAnyArgs) { - _76_printRhs = (_76_printRhs).Then(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("write!(_formatter, \")\")?"))); + _76_printRhs = (_76_printRhs).Then((this).writeStr(Dafny.Sequence.UnicodeFromString(")"), false)); } - _76_printRhs = (_76_printRhs).Then(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("Ok(())"))); + _76_printRhs = (_76_printRhs).Then((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("Ok"))).Apply(Dafny.Sequence.FromElements(RAST.Expr.create_Tuple(Dafny.Sequence.FromElements())))); _68_printImplBodyCases = Dafny.Sequence.Concat(_68_printImplBodyCases, Dafny.Sequence.FromElements(RAST.MatchCase.create(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_4_datatypeName, Dafny.Sequence.UnicodeFromString("::")), _73_ctorMatch), RAST.Expr.create_Block(_76_printRhs)))); _69_hashImplBodyCases = Dafny.Sequence.Concat(_69_hashImplBodyCases, Dafny.Sequence.FromElements(RAST.MatchCase.create(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_4_datatypeName, Dafny.Sequence.UnicodeFromString("::")), _73_ctorMatch), RAST.Expr.create_Block(_77_hashRhs)))); _70_coerceImplBodyCases = Dafny.Sequence.Concat(_70_coerceImplBodyCases, Dafny.Sequence.FromElements(RAST.MatchCase.create(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_4_datatypeName, Dafny.Sequence.UnicodeFromString("::")), _73_ctorMatch), RAST.Expr.create_Block(_91_coerceRhs)))); } if (((new BigInteger(((c).dtor_typeParams).Count)).Sign == 1) && ((new BigInteger((_20_unusedTypeParams).Count)).Sign == 1)) { Dafny.ISequence _92_extraCases; - _92_extraCases = Dafny.Sequence.FromElements(RAST.MatchCase.create(Dafny.Sequence.Concat(_4_datatypeName, Dafny.Sequence.UnicodeFromString("::_PhantomVariant(..)")), RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("{"), (this).UnreachablePanicIfVerified(Dafny.Sequence.UnicodeFromString(""))), Dafny.Sequence.UnicodeFromString("}"))))); + _92_extraCases = Dafny.Sequence.FromElements(RAST.MatchCase.create(Dafny.Sequence.Concat(_4_datatypeName, Dafny.Sequence.UnicodeFromString("::_PhantomVariant(..)")), RAST.Expr.create_Block((this).UnreachablePanicIfVerified(Dafny.Sequence.UnicodeFromString(""))))); _68_printImplBodyCases = Dafny.Sequence.Concat(_68_printImplBodyCases, _92_extraCases); _69_hashImplBodyCases = Dafny.Sequence.Concat(_69_hashImplBodyCases, _92_extraCases); _70_coerceImplBodyCases = Dafny.Sequence.Concat(_70_coerceImplBodyCases, _92_extraCases); @@ -2170,7 +2210,7 @@ public bool DatatypeIsEq(DAST._IDatatype c) { _96_printImplBody = RAST.Expr.create_Match(RAST.__default.self, _68_printImplBodyCases); RAST._IExpr _97_hashImplBody; _97_hashImplBody = RAST.Expr.create_Match(RAST.__default.self, _69_hashImplBodyCases); - 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("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Debug"))).AsType(), RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_4_datatypeName), _1_rTypeParams), Dafny.Sequence.UnicodeFromString(""), 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"))).MSel(Dafny.Sequence.UnicodeFromString("fmt_print"))).AsExpr()).Apply(Dafny.Sequence.FromElements(RAST.__default.self, RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("f")), RAST.Expr.create_LiteralBool(true))))))))), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, RAST.__default.DafnyPrint, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_4_datatypeName), _1_rTypeParams), Dafny.Sequence.UnicodeFromString(""), 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(_96_printImplBody)))))))); + 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("fmt"))).MSel(Dafny.Sequence.UnicodeFromString("Debug"))).AsType(), RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_4_datatypeName), _1_rTypeParams), Dafny.Sequence.UnicodeFromString(""), 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))))))))), RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_2_rTypeParamsDecls, RAST.__default.DafnyPrint, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_4_datatypeName), _1_rTypeParams), Dafny.Sequence.UnicodeFromString(""), 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(_96_printImplBody)))))))); if ((new BigInteger((_48_rCoerceTypeParams).Count)).Sign == 1) { RAST._IExpr _98_coerceImplBody; _98_coerceImplBody = RAST.Expr.create_Match(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("this")), _70_coerceImplBodyCases); @@ -2185,7 +2225,7 @@ public bool DatatypeIsEq(DAST._IDatatype c) { } else { _100_instantiationType = _99_datatypeType; } - s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(_2_rTypeParamsDecls, _99_datatypeType, Dafny.Sequence.UnicodeFromString(""), 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(_100_instantiationType))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("seq!"))).AsExpr()).Apply(_8_singletonConstructors)).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply(Dafny.Sequence.FromElements()))))))))); + s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(_2_rTypeParamsDecls, _99_datatypeType, Dafny.Sequence.UnicodeFromString(""), 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(_100_instantiationType))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("seq!"))).AsExpr()).Apply(_8_singletonConstructors)).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply0())))))))); } if (_67_cIsEq) { s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_94_rTypeParamsDeclsWithEq, RAST.__default.Eq, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_4_datatypeName), _1_rTypeParams), Dafny.Sequence.UnicodeFromString(""), Dafny.Sequence.FromElements())))); @@ -2200,7 +2240,7 @@ public bool DatatypeIsEq(DAST._IDatatype c) { for (BigInteger _103_i = BigInteger.Zero; _103_i < _hi9; _103_i++) { DAST._IDatatypeDtor _104_dtor; _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(DCOMP.__default.escapeVar(((_104_dtor).dtor_formal).dtor_name), RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("::std::default::Default::default()"))))); + _102_structAssignments = Dafny.Sequence.Concat(_102_structAssignments, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(DCOMP.__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)); @@ -2220,28 +2260,33 @@ public RAST._IPath GenPath(Dafny.ISequence> p, bool r = RAST.Path.create_Self(); return r; } else { - if (((((p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("std"))) { + Dafny.ISequence> _0_p; + _0_p = p; + Dafny.ISequence _1_name; + _1_name = (((_0_p).Select(BigInteger.Zero))); + if (((new BigInteger((_1_name).Count)) >= (new BigInteger(2))) && (((_1_name).Subsequence(BigInteger.Zero, new BigInteger(2))).Equals(Dafny.Sequence.UnicodeFromString("::")))) { r = RAST.Path.create_Global(); - } else if (((((p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("_System"))) { + _0_p = Dafny.Sequence>.Update(_0_p, BigInteger.Zero, (_1_name).Drop(new BigInteger(2))); + } else if (((((_0_p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("_System"))) { r = RAST.__default.dafny__runtime; } else { r = (this).thisFile; } - BigInteger _hi0 = new BigInteger((p).Count); - for (BigInteger _0_i = BigInteger.Zero; _0_i < _hi0; _0_i++) { - Dafny.ISequence _1_name; - _1_name = ((p).Select(_0_i)); + BigInteger _hi0 = new BigInteger((_0_p).Count); + for (BigInteger _2_i = BigInteger.Zero; _2_i < _hi0; _2_i++) { + Dafny.ISequence _3_name; + _3_name = ((_0_p).Select(_2_i)); if (escape) { - _System._ITuple2>, Dafny.ISequence> _let_tmp_rhs0 = DafnyCompilerRustUtils.__default.DafnyNameToContainingPathAndName(_1_name, Dafny.Sequence>.FromElements()); - Dafny.ISequence> _2_modules = _let_tmp_rhs0.dtor__0; - Dafny.ISequence _3_finalName = _let_tmp_rhs0.dtor__1; - BigInteger _hi1 = new BigInteger((_2_modules).Count); - for (BigInteger _4_j = BigInteger.Zero; _4_j < _hi1; _4_j++) { - r = (r).MSel(DCOMP.__default.escapeName(((_2_modules).Select(_4_j)))); - } - r = (r).MSel(DCOMP.__default.escapeName(_3_finalName)); + _System._ITuple2>, Dafny.ISequence> _let_tmp_rhs0 = DafnyCompilerRustUtils.__default.DafnyNameToContainingPathAndName(_3_name, Dafny.Sequence>.FromElements()); + Dafny.ISequence> _4_modules = _let_tmp_rhs0.dtor__0; + Dafny.ISequence _5_finalName = _let_tmp_rhs0.dtor__1; + BigInteger _hi1 = new BigInteger((_4_modules).Count); + for (BigInteger _6_j = BigInteger.Zero; _6_j < _hi1; _6_j++) { + r = (r).MSel(DCOMP.__default.escapeName(((_4_modules).Select(_6_j)))); + } + r = (r).MSel(DCOMP.__default.escapeName(_5_finalName)); } else { - r = (r).MSel(DCOMP.__default.ReplaceDotByDoubleColon((_1_name))); + r = (r).MSels(DCOMP.__default.SplitRustPathElement(DCOMP.__default.ReplaceDotByDoubleColon((_3_name)), Dafny.Sequence>.FromElements(), Dafny.Sequence.UnicodeFromString(""))); } } } @@ -2574,6 +2619,12 @@ public RAST._IType GenType(DAST._IType c, bool genTypeContext) goto after_match3; } } + { + if (_source3.is_Native) { + s = RAST.Type.create_USIZE(); + goto after_match3; + } + } { if (_source3.is_Bool) { s = RAST.Type.create_Bool(); @@ -2798,7 +2849,7 @@ public RAST._IImplMember GenMethod(DAST._IMethod m, bool forTrait, DAST._IType e Std.Wrappers._IOption _29_fBody = Std.Wrappers.Option.Default(); DCOMP._IEnvironment _30_env = DCOMP.Environment.Default(); RAST._IExpr _31_preBody; - _31_preBody = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); + _31_preBody = (this).InitEmptyExpr(); Dafny.ISequence> _32_preAssignNames; _32_preAssignNames = Dafny.Sequence>.FromElements(); Dafny.IMap,RAST._IType> _33_preAssignTypes; @@ -2859,15 +2910,15 @@ public RAST._IImplMember GenMethod(DAST._IMethod m, bool forTrait, DAST._IType e after_match1: ; _30_env = DCOMP.Environment.create(Dafny.Sequence>.Concat(_32_preAssignNames, _1_paramNames), Dafny.Map, RAST._IType>.Merge(_33_preAssignTypes, _2_paramTypes)); RAST._IExpr _46_body; - Dafny.ISet> _47___v71; - DCOMP._IEnvironment _48___v72; + Dafny.ISet> _47___v52; + DCOMP._IEnvironment _48___v53; RAST._IExpr _out6; Dafny.ISet> _out7; DCOMP._IEnvironment _out8; (this).GenStmts((m).dtor_body, _8_selfIdent, _30_env, true, _34_earlyReturn, out _out6, out _out7, out _out8); _46_body = _out6; - _47___v71 = _out7; - _48___v72 = _out8; + _47___v52 = _out7; + _48___v53 = _out8; _29_fBody = Std.Wrappers.Option.create_Some((_31_preBody).Then(_46_body)); } else { _30_env = DCOMP.Environment.create(_1_paramNames, _2_paramTypes); @@ -2881,7 +2932,7 @@ public void GenStmts(Dafny.ISequence stmts, DCOMP._ISelfInfo s generated = RAST.Expr.Default(); readIdents = Dafny.Set>.Empty; newEnv = DCOMP.Environment.Default(); - generated = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); + generated = (this).InitEmptyExpr(); Dafny.ISet> _0_declarations; _0_declarations = Dafny.Set>.FromElements(); readIdents = Dafny.Set>.FromElements(); @@ -3081,20 +3132,20 @@ public void GenAssignLhs(DAST._IAssignLhs lhs, RAST._IExpr rhs, DCOMP._ISelfInfo readIdents = _13_recIdents; _11_onExpr = ((this).modify__macro).Apply1(_11_onExpr); RAST._IExpr _14_r; - _14_r = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); + _14_r = (this).InitEmptyExpr(); Dafny.ISequence _15_indicesExpr; _15_indicesExpr = Dafny.Sequence.FromElements(); BigInteger _hi0 = new BigInteger((_10_indices).Count); for (BigInteger _16_i = BigInteger.Zero; _16_i < _hi0; _16_i++) { RAST._IExpr _17_idx; - DCOMP._IOwnership _18___v81; + DCOMP._IOwnership _18___v62; Dafny.ISet> _19_recIdentsIdx; RAST._IExpr _out6; DCOMP._IOwnership _out7; Dafny.ISet> _out8; (this).GenExpr((_10_indices).Select(_16_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out6, out _out7, out _out8); _17_idx = _out6; - _18___v81 = _out7; + _18___v62 = _out7; _19_recIdentsIdx = _out8; Dafny.ISequence _20_varName; _20_varName = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("__idx"), Std.Strings.__default.OfNat(_16_i)); @@ -3121,7 +3172,7 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE if (_source0.is_ConstructorNewSeparator) { Dafny.ISequence _0_fields = _source0.dtor_fields; { - generated = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); + generated = (this).InitEmptyExpr(); readIdents = Dafny.Set>.FromElements(); newEnv = env; BigInteger _hi0 = new BigInteger((_0_fields).Count); @@ -3138,15 +3189,15 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE _5_isAssignedVar = DCOMP.__default.AddAssignedPrefix(_3_fieldName); if (((newEnv).dtor_names).Contains(_5_isAssignedVar)) { RAST._IExpr _6_rhs; - DCOMP._IOwnership _7___v82; - Dafny.ISet> _8___v83; + DCOMP._IOwnership _7___v63; + Dafny.ISet> _8___v64; RAST._IExpr _out1; DCOMP._IOwnership _out2; Dafny.ISet> _out3; (this).GenExpr(DAST.Expression.create_InitializationValue((_2_field).dtor_typ), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out1, out _out2, out _out3); _6_rhs = _out1; - _7___v82 = _out2; - _8___v83 = _out3; + _7___v63 = _out2; + _8___v64 = _out3; readIdents = Dafny.Set>.Union(readIdents, Dafny.Set>.FromElements(_5_isAssignedVar)); generated = (generated).Then((((RAST.__default.dafny__runtime).MSel((this).update__field__if__uninit__macro)).AsExpr()).Apply(Dafny.Sequence.FromElements(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("this")), RAST.Expr.create_Identifier(_3_fieldName), RAST.Expr.create_Identifier(_5_isAssignedVar), _6_rhs))); newEnv = (newEnv).RemoveAssigned(_5_isAssignedVar); @@ -3173,7 +3224,7 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE bool _14_hasCopySemantics; _14_hasCopySemantics = (_12_tpe).CanReadWithoutClone(); if (((_11_expression).is_InitializationValue) && (!(_14_hasCopySemantics))) { - generated = RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), _13_varName, Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(((((RAST.__default.MaybePlaceboPath).AsExpr()).ApplyType1(_12_tpe)).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply(Dafny.Sequence.FromElements()))); + generated = RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), _13_varName, Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(((((RAST.__default.MaybePlaceboPath).AsExpr()).ApplyType1(_12_tpe)).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply0())); readIdents = Dafny.Set>.FromElements(); newEnv = (env).AddAssigned(_13_varName, RAST.__default.MaybePlaceboType(_12_tpe)); } else { @@ -3233,14 +3284,14 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE DAST._IExpression _22_expression = _source0.dtor_value; { RAST._IExpr _23_exprGen; - DCOMP._IOwnership _24___v84; + DCOMP._IOwnership _24___v65; Dafny.ISet> _25_exprIdents; RAST._IExpr _out11; DCOMP._IOwnership _out12; Dafny.ISet> _out13; (this).GenExpr(_22_expression, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out11, out _out12, out _out13); _23_exprGen = _out11; - _24___v84 = _out12; + _24___v65 = _out12; _25_exprIdents = _out13; if ((_21_lhs).is_Ident) { Dafny.ISequence _26_rustId; @@ -3290,14 +3341,14 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE Dafny.ISequence _36_elsDafny = _source0.dtor_els; { RAST._IExpr _37_cond; - DCOMP._IOwnership _38___v85; + DCOMP._IOwnership _38___v66; Dafny.ISet> _39_recIdents; RAST._IExpr _out18; DCOMP._IOwnership _out19; Dafny.ISet> _out20; (this).GenExpr(_34_cond, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out18, out _out19, out _out20); _37_cond = _out18; - _38___v85 = _out19; + _38___v66 = _out19; _39_recIdents = _out20; Dafny.ISequence _40_condString; _40_condString = (_37_cond)._ToString(DCOMP.__default.IND); @@ -3358,14 +3409,14 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE Dafny.ISequence _53_body = _source0.dtor_body; { RAST._IExpr _54_cond; - DCOMP._IOwnership _55___v86; + DCOMP._IOwnership _55___v67; Dafny.ISet> _56_recIdents; RAST._IExpr _out30; DCOMP._IOwnership _out31; Dafny.ISet> _out32; (this).GenExpr(_52_cond, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out30, out _out31, out _out32); _54_cond = _out30; - _55___v86 = _out31; + _55___v67 = _out31; _56_recIdents = _out32; readIdents = _56_recIdents; RAST._IExpr _57_bodyExpr; @@ -3393,17 +3444,17 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE Dafny.ISequence _63_body = _source0.dtor_body; { RAST._IExpr _64_over; - DCOMP._IOwnership _65___v87; + DCOMP._IOwnership _65___v68; Dafny.ISet> _66_recIdents; RAST._IExpr _out36; DCOMP._IOwnership _out37; Dafny.ISet> _out38; (this).GenExpr(_62_overExpr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out36, out _out37, out _out38); _64_over = _out36; - _65___v87 = _out37; + _65___v68 = _out37; _66_recIdents = _out38; if (((_62_overExpr).is_MapBoundedPool) || ((_62_overExpr).is_SetBoundedPool)) { - _64_over = ((_64_over).Sel(Dafny.Sequence.UnicodeFromString("cloned"))).Apply(Dafny.Sequence.FromElements()); + _64_over = ((_64_over).Sel(Dafny.Sequence.UnicodeFromString("cloned"))).Apply0(); } RAST._IType _67_boundTpe; RAST._IType _out39; @@ -3459,18 +3510,18 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE if (_source0.is_TailRecursive) { Dafny.ISequence _74_body = _source0.dtor_body; { - generated = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); + generated = (this).InitEmptyExpr(); if (!object.Equals(selfIdent, DCOMP.SelfInfo.create_NoSelf())) { RAST._IExpr _75_selfClone; - DCOMP._IOwnership _76___v88; - Dafny.ISet> _77___v89; + DCOMP._IOwnership _76___v69; + Dafny.ISet> _77___v70; RAST._IExpr _out43; DCOMP._IOwnership _out44; Dafny.ISet> _out45; (this).GenIdent((selfIdent).dtor_rSelfName, selfIdent, DCOMP.Environment.Empty(), DCOMP.Ownership.create_OwnershipOwned(), out _out43, out _out44, out _out45); _75_selfClone = _out43; - _76___v88 = _out44; - _77___v89 = _out45; + _76___v69 = _out44; + _77___v70 = _out45; generated = (generated).Then(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("_this"), Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(_75_selfClone))); } newEnv = env; @@ -3484,15 +3535,15 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE goto continue_4_0; } RAST._IExpr _81_paramInit; - DCOMP._IOwnership _82___v90; - Dafny.ISet> _83___v91; + DCOMP._IOwnership _82___v71; + Dafny.ISet> _83___v72; RAST._IExpr _out46; DCOMP._IOwnership _out47; Dafny.ISet> _out48; (this).GenIdent(_80_param, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out46, out _out47, out _out48); _81_paramInit = _out46; - _82___v90 = _out47; - _83___v91 = _out48; + _82___v71 = _out47; + _83___v72 = _out48; Dafny.ISequence _84_recVar; _84_recVar = Dafny.Sequence.Concat(DCOMP.COMP.TailRecursionPrefix, Std.Strings.__default.OfNat(_79_paramI)); generated = (generated).Then(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), _84_recVar, Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(_81_paramInit))); @@ -3586,7 +3637,7 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE RAST._IExpr _out61; DCOMP._IOwnership _out62; Dafny.ISet> _out63; - (this).GenExpr(_89_on, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowedMut(), out _out61, out _out62, out _out63); + (this).GenExpr(_89_on, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out61, out _out62, out _out63); _103_onExpr = _out61; _104_recOwnership = _out62; _105_recIdents = _out63; @@ -3598,14 +3649,14 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE } { RAST._IExpr _106_onExpr; - DCOMP._IOwnership _107___v96; + DCOMP._IOwnership _107___v77; Dafny.ISet> _108_enclosingIdents; RAST._IExpr _out64; DCOMP._IOwnership _out65; Dafny.ISet> _out66; (this).GenExpr(_89_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out64, out _out65, out _out66); _106_onExpr = _out64; - _107___v96 = _out65; + _107___v77 = _out65; _108_enclosingIdents = _out66; readIdents = Dafny.Set>.Union(readIdents, _108_enclosingIdents); Dafny.ISequence _109_renderedName; @@ -3695,14 +3746,14 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE DAST._IExpression _119_exprDafny = _source0.dtor_expr; { RAST._IExpr _120_expr; - DCOMP._IOwnership _121___v106; + DCOMP._IOwnership _121___v87; Dafny.ISet> _122_recIdents; RAST._IExpr _out68; DCOMP._IOwnership _out69; Dafny.ISet> _out70; (this).GenExpr(_119_exprDafny, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out68, out _out69, out _out70); _120_expr = _out68; - _121___v106 = _out69; + _121___v87 = _out69; _122_recIdents = _out70; readIdents = _122_recIdents; if (isLast) { @@ -3732,15 +3783,15 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE BigInteger _hi3 = new BigInteger((_123_rustIdents).Count); for (BigInteger _125_i = BigInteger.Zero; _125_i < _hi3; _125_i++) { RAST._IExpr _126_rIdent; - DCOMP._IOwnership _127___v107; - Dafny.ISet> _128___v108; + DCOMP._IOwnership _127___v88; + Dafny.ISet> _128___v89; RAST._IExpr _out71; DCOMP._IOwnership _out72; Dafny.ISet> _out73; (this).GenIdent((_123_rustIdents).Select(_125_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out71, out _out72, out _out73); _126_rIdent = _out71; - _127___v107 = _out72; - _128___v108 = _out73; + _127___v88 = _out72; + _128___v89 = _out73; _124_tupleArgs = Dafny.Sequence.Concat(_124_tupleArgs, Dafny.Sequence.FromElements(_126_rIdent)); } if ((new BigInteger((_124_tupleArgs).Count)) == (BigInteger.One)) { @@ -3843,6 +3894,11 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE return Std.Wrappers.Option.create_Some(RAST.Type.create_I128()); } } + { + if (_source0.is_USIZE) { + return Std.Wrappers.Option.create_Some(RAST.Type.create_USIZE()); + } + } { return Std.Wrappers.Option.create_None(); } @@ -3861,7 +3917,10 @@ public void FromOwned(RAST._IExpr r, DCOMP._IOwnership expectedOwnership, out RA @out = RAST.__default.Borrow(r); resultingOwnership = DCOMP.Ownership.create_OwnershipBorrowed(); } else { - @out = ((this).modify__macro).Apply1(RAST.Expr.create_RawExpr(Dafny.Sequence.Concat((r)._ToString(Dafny.Sequence.UnicodeFromString("")), Dafny.Sequence.UnicodeFromString("/*TODO: Conversion from Borrowed or BorrowedMut to BorrowedMut*/")))); + RAST._IExpr _out0; + _out0 = (this).Error(Dafny.Sequence.UnicodeFromString("Conversion from Borrowed or BorrowedMut to BorrowedMut"), r); + @out = _out0; + @out = ((this).modify__macro).Apply1(@out); resultingOwnership = DCOMP.Ownership.create_OwnershipBorrowedMut(); } } @@ -3965,7 +4024,7 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM RAST._IType _out2; _out2 = (this).GenType(_3_o, DCOMP.GenTypeContext.@default()); _4_genType = _out2; - r = RAST.Expr.create_TypeAscription(RAST.Expr.create_RawExpr(_1_i), _4_genType); + r = RAST.Expr.create_TypeAscription(RAST.Expr.create_LiteralInt(_1_i), _4_genType); } } after_match1: ; @@ -3995,7 +4054,7 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM DAST._IPrimitive _h71 = _source2.dtor_Primitive_a0; if (_h71.is_Real) { { - r = RAST.__default.RcNew(RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::dafny_runtime::BigRational::new(::dafny_runtime::BigInt::parse_bytes(b\""), _5_n), Dafny.Sequence.UnicodeFromString("\", 10).unwrap(), ::dafny_runtime::BigInt::parse_bytes(b\"")), _6_d), Dafny.Sequence.UnicodeFromString("\", 10).unwrap())")))); + r = ((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("BigRational"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply(Dafny.Sequence.FromElements(((((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("BigInt"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("parse_bytes"))).Apply(Dafny.Sequence.FromElements(RAST.Expr.create_LiteralString(_5_n, true, false), RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("10"))))).Sel(Dafny.Sequence.UnicodeFromString("unwrap"))).Apply0(), ((((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("BigInt"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("parse_bytes"))).Apply(Dafny.Sequence.FromElements(RAST.Expr.create_LiteralString(_6_d, true, false), RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("10"))))).Sel(Dafny.Sequence.UnicodeFromString("unwrap"))).Apply0())); } goto after_match2; } @@ -4008,7 +4067,7 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM RAST._IType _out5; _out5 = (this).GenType(_8_o, DCOMP.GenTypeContext.@default()); _9_genType = _out5; - r = RAST.Expr.create_TypeAscription(RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("("), _5_n), Dafny.Sequence.UnicodeFromString(".0 / ")), _6_d), Dafny.Sequence.UnicodeFromString(".0")), Dafny.Sequence.UnicodeFromString(")"))), _9_genType); + r = RAST.Expr.create_TypeAscription(RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("/"), (RAST.Expr.create_LiteralInt(_5_n)).Sel(Dafny.Sequence.UnicodeFromString("0")), (RAST.Expr.create_LiteralInt(_6_d)).Sel(Dafny.Sequence.UnicodeFromString("0")), DAST.Format.BinaryOpFormat.create_NoFormat()), _9_genType); } } after_match2: ; @@ -4075,7 +4134,7 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM if (!(((this).charType).is_UTF32)) { r = RAST.Expr.create_TypeAscription(r, RAST.Type.create_U16()); } else { - r = (((((((RAST.__default.@global).MSel(Dafny.Sequence.UnicodeFromString("std"))).MSel(Dafny.Sequence.UnicodeFromString("primitive"))).MSel(Dafny.Sequence.UnicodeFromString("char"))).FSel(Dafny.Sequence.UnicodeFromString("from_u32"))).Apply1(r)).Sel(Dafny.Sequence.UnicodeFromString("unwrap"))).Apply(Dafny.Sequence.FromElements()); + r = (((((((RAST.__default.@global).MSel(Dafny.Sequence.UnicodeFromString("std"))).MSel(Dafny.Sequence.UnicodeFromString("primitive"))).MSel(Dafny.Sequence.UnicodeFromString("char"))).FSel(Dafny.Sequence.UnicodeFromString("from_u32"))).Apply1(r)).Sel(Dafny.Sequence.UnicodeFromString("unwrap"))).Apply0(); } r = (((RAST.__default.dafny__runtime).MSel((this).DafnyChar)).AsExpr()).Apply1(r); RAST._IExpr _out12; @@ -4101,7 +4160,7 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM if (((this).pointerType).is_Raw) { r = ((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("Ptr"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("null"))).Apply(Dafny.Sequence.FromElements()); } else { - r = RAST.Expr.create_TypeAscription((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("Object"))).AsExpr()).Apply1(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("None"))), _15_tpeGen); + r = RAST.Expr.create_TypeAscription((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("Object"))).AsExpr()).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("None"))), _15_tpeGen); } RAST._IExpr _out15; DCOMP._IOwnership _out16; @@ -4280,24 +4339,24 @@ public void GenExprBinary(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP _8_expectedRightOwnership = DCOMP.Ownership.create_OwnershipOwned(); } RAST._IExpr _9_left; - DCOMP._IOwnership _10___v113; + DCOMP._IOwnership _10___v94; Dafny.ISet> _11_recIdentsL; RAST._IExpr _out0; DCOMP._IOwnership _out1; Dafny.ISet> _out2; (this).GenExpr(_1_lExpr, selfIdent, env, _7_expectedLeftOwnership, out _out0, out _out1, out _out2); _9_left = _out0; - _10___v113 = _out1; + _10___v94 = _out1; _11_recIdentsL = _out2; RAST._IExpr _12_right; - DCOMP._IOwnership _13___v114; + DCOMP._IOwnership _13___v95; Dafny.ISet> _14_recIdentsR; RAST._IExpr _out3; DCOMP._IOwnership _out4; Dafny.ISet> _out5; (this).GenExpr(_2_rExpr, selfIdent, env, _8_expectedRightOwnership, out _out3, out _out4, out _out5); _12_right = _out3; - _13___v114 = _out4; + _13___v95 = _out4; _14_recIdentsR = _out5; DAST._IBinOp _source3 = _0_op; { @@ -4452,16 +4511,17 @@ public void GenExprBinary(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP { if (_15_referential) { if (((this).pointerType).is_Raw) { - (this).error = Std.Wrappers.Option>.create_Some(Dafny.Sequence.UnicodeFromString("Cannot compare raw pointers yet - need to wrap them with a structure to ensure they are compared properly")); - r = RAST.Expr.create_RawExpr((this.error).dtor_value); + RAST._IExpr _out6; + _out6 = (this).Error(Dafny.Sequence.UnicodeFromString("Cannot compare raw pointers yet - need to wrap them with a structure to ensure they are compared properly"), (this).InitEmptyExpr()); + r = _out6; } else { r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=="), _9_left, _12_right, DAST.Format.BinaryOpFormat.create_NoFormat()); } } else { if (((_2_rExpr).is_SeqValue) && ((new BigInteger(((_2_rExpr).dtor_elements).Count)).Sign == 0)) { - r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=="), ((((_9_left).Sel(Dafny.Sequence.UnicodeFromString("to_array"))).Apply(Dafny.Sequence.FromElements())).Sel(Dafny.Sequence.UnicodeFromString("len"))).Apply(Dafny.Sequence.FromElements()), RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("0")), DAST.Format.BinaryOpFormat.create_NoFormat()); + r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=="), ((((_9_left).Sel(Dafny.Sequence.UnicodeFromString("to_array"))).Apply0()).Sel(Dafny.Sequence.UnicodeFromString("len"))).Apply0(), RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("0")), DAST.Format.BinaryOpFormat.create_NoFormat()); } else if (((_1_lExpr).is_SeqValue) && ((new BigInteger(((_1_lExpr).dtor_elements).Count)).Sign == 0)) { - r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=="), RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("0")), ((((_12_right).Sel(Dafny.Sequence.UnicodeFromString("to_array"))).Apply(Dafny.Sequence.FromElements())).Sel(Dafny.Sequence.UnicodeFromString("len"))).Apply(Dafny.Sequence.FromElements()), DAST.Format.BinaryOpFormat.create_NoFormat()); + r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=="), RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("0")), ((((_12_right).Sel(Dafny.Sequence.UnicodeFromString("to_array"))).Apply0()).Sel(Dafny.Sequence.UnicodeFromString("len"))).Apply0(), DAST.Format.BinaryOpFormat.create_NoFormat()); } else { r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=="), _9_left, _12_right, DAST.Format.BinaryOpFormat.create_NoFormat()); } @@ -4473,7 +4533,7 @@ public void GenExprBinary(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP { if (_source4.is_EuclidianDiv) { { - r = (RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("::dafny_runtime::euclidian_division"))).Apply(Dafny.Sequence.FromElements(_9_left, _12_right)); + r = (((RAST.__default.dafny__runtime).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("euclidian_division"))).Apply(Dafny.Sequence.FromElements(_9_left, _12_right)); } goto after_match4; } @@ -4481,7 +4541,7 @@ public void GenExprBinary(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP { if (_source4.is_EuclidianMod) { { - r = (RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("::dafny_runtime::euclidian_modulo"))).Apply(Dafny.Sequence.FromElements(_9_left, _12_right)); + r = (((RAST.__default.dafny__runtime).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("euclidian_modulo"))).Apply(Dafny.Sequence.FromElements(_9_left, _12_right)); } goto after_match4; } @@ -4497,11 +4557,11 @@ public void GenExprBinary(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP } } after_match3: ; - RAST._IExpr _out6; - DCOMP._IOwnership _out7; - (this).FromOwned(r, expectedOwnership, out _out6, out _out7); - r = _out6; - resultingOwnership = _out7; + RAST._IExpr _out7; + DCOMP._IOwnership _out8; + (this).FromOwned(r, expectedOwnership, out _out7, out _out8); + r = _out7; + resultingOwnership = _out8; readIdents = Dafny.Set>.Union(_11_recIdentsL, _14_recIdentsR); return ; } @@ -4522,9 +4582,9 @@ public void GenExprConvertToNewtype(DAST._IExpression e, DCOMP._ISelfInfo selfId DAST._IType _5_b = _let_tmp_rhs3.dtor_baseType; DAST._INewtypeRange _6_range = _let_tmp_rhs3.dtor_range; bool _7_erase = _let_tmp_rhs3.dtor_erase; - Dafny.ISequence _8___v116 = _let_tmp_rhs2.dtor_attributes; - Dafny.ISequence> _9___v117 = _let_tmp_rhs2.dtor_properMethods; - Dafny.ISequence _10___v118 = _let_tmp_rhs2.dtor_extendedTypes; + Dafny.ISequence _8___v97 = _let_tmp_rhs2.dtor_attributes; + Dafny.ISequence> _9___v98 = _let_tmp_rhs2.dtor_properMethods; + Dafny.ISequence _10___v99 = _let_tmp_rhs2.dtor_extendedTypes; Std.Wrappers._IOption _11_nativeToType; _11_nativeToType = DCOMP.COMP.NewtypeRangeToRustType(_6_range); if (object.Equals(_1_fromTpe, _5_b)) { @@ -4560,7 +4620,7 @@ public void GenExprConvertToNewtype(DAST._IExpression e, DCOMP._ISelfInfo selfId RAST._IType _out5; _out5 = (this).GenType(_2_toTpe, DCOMP.GenTypeContext.@default()); _16_rhsType = _out5; - r = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_16_rhsType)._ToString(DCOMP.__default.IND), Dafny.Sequence.UnicodeFromString("(")), (_12_recursiveGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(")"))); + r = (RAST.Expr.create_ExprFromType(_16_rhsType)).Apply1(_12_recursiveGen); } RAST._IExpr _out6; DCOMP._IOwnership _out7; @@ -4651,15 +4711,15 @@ public void GenExprConvertFromNewtype(DAST._IExpression e, DCOMP._ISelfInfo self DAST._IType _2_toTpe = _let_tmp_rhs0.dtor_typ; DAST._IType _let_tmp_rhs1 = _1_fromTpe; DAST._IResolvedType _let_tmp_rhs2 = _let_tmp_rhs1.dtor_resolved; - Dafny.ISequence> _3___v124 = _let_tmp_rhs2.dtor_path; - Dafny.ISequence _4___v125 = _let_tmp_rhs2.dtor_typeArgs; + Dafny.ISequence> _3___v105 = _let_tmp_rhs2.dtor_path; + Dafny.ISequence _4___v106 = _let_tmp_rhs2.dtor_typeArgs; DAST._IResolvedTypeBase _let_tmp_rhs3 = _let_tmp_rhs2.dtor_kind; DAST._IType _5_b = _let_tmp_rhs3.dtor_baseType; DAST._INewtypeRange _6_range = _let_tmp_rhs3.dtor_range; bool _7_erase = _let_tmp_rhs3.dtor_erase; Dafny.ISequence _8_attributes = _let_tmp_rhs2.dtor_attributes; - Dafny.ISequence> _9___v126 = _let_tmp_rhs2.dtor_properMethods; - Dafny.ISequence _10___v127 = _let_tmp_rhs2.dtor_extendedTypes; + Dafny.ISequence> _9___v107 = _let_tmp_rhs2.dtor_properMethods; + Dafny.ISequence _10___v108 = _let_tmp_rhs2.dtor_extendedTypes; Std.Wrappers._IOption _11_nativeFromType; _11_nativeFromType = DCOMP.COMP.NewtypeRangeToRustType(_6_range); if (object.Equals(_5_b, _2_toTpe)) { @@ -4776,14 +4836,14 @@ public bool SameTypesButDifferentTypeParameters(DAST._IType fromType, RAST._ITyp var _pat_let_tv3 = toTpe; var _pat_let_tv4 = typeParams; if (object.Equals(fromTpe, toTpe)) { - return Std.Wrappers.Result,RAST._IExpr>>>.create_Success(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("upcast_id"))).AsExpr()).ApplyType(Dafny.Sequence.FromElements(fromTpe))).Apply(Dafny.Sequence.FromElements())); + return Std.Wrappers.Result,RAST._IExpr>>>.create_Success(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("upcast_id"))).AsExpr()).ApplyType(Dafny.Sequence.FromElements(fromTpe))).Apply0()); } else if (((fromTpe).IsObjectOrPointer()) && ((toTpe).IsObjectOrPointer())) { if (!(((toTpe).ObjectOrPointerUnderlying()).is_DynType)) { return Std.Wrappers.Result,RAST._IExpr>>>.create_Failure(_System.Tuple5,RAST._IExpr>>.create(fromType, fromTpe, toType, toTpe, typeParams)); } else { RAST._IType _0_fromTpeUnderlying = (fromTpe).ObjectOrPointerUnderlying(); RAST._IType _1_toTpeUnderlying = (toTpe).ObjectOrPointerUnderlying(); - return Std.Wrappers.Result,RAST._IExpr>>>.create_Success(((((RAST.__default.dafny__runtime).MSel((this).upcast)).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_0_fromTpeUnderlying, _1_toTpeUnderlying))).Apply(Dafny.Sequence.FromElements())); + return Std.Wrappers.Result,RAST._IExpr>>>.create_Success(((((RAST.__default.dafny__runtime).MSel((this).upcast)).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_0_fromTpeUnderlying, _1_toTpeUnderlying))).Apply0()); } } else if ((typeParams).Contains(_System.Tuple2.create(fromTpe, toTpe))) { return Std.Wrappers.Result,RAST._IExpr>>>.create_Success(Dafny.Map<_System._ITuple2, RAST._IExpr>.Select(typeParams,_System.Tuple2.create(fromTpe, toTpe))); @@ -4953,15 +5013,14 @@ public void GenExprConvertOther(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DAST._IType _18_toType = _let_tmp_rhs2.dtor__2; RAST._IType _19_toTpeGen = _let_tmp_rhs2.dtor__3; Dafny.IMap<_System._ITuple2,RAST._IExpr> _20_m = _let_tmp_rhs2.dtor__4; - Dafny.ISequence _21_msg; - _21_msg = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("/* Coercion from "), (_17_fromTpeGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(" to ")), (_19_toTpeGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(" not yet implemented */")); - (this).error = Std.Wrappers.Option>.create_Some(_21_msg); - r = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat((_13_recursiveGen)._ToString(DCOMP.__default.IND), _21_msg)); RAST._IExpr _out15; - DCOMP._IOwnership _out16; - (this).FromOwnership(r, _14_recOwned, expectedOwnership, out _out15, out _out16); + _out15 = (this).Error(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Coercion from "), (_17_fromTpeGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(" to ")), (_19_toTpeGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(" not yet implemented")), _13_recursiveGen); r = _out15; - resultingOwnership = _out16; + RAST._IExpr _out16; + DCOMP._IOwnership _out17; + (this).FromOwnership(r, _14_recOwned, expectedOwnership, out _out16, out _out17); + r = _out16; + resultingOwnership = _out17; } } public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnvironment env, DCOMP._IOwnership expectedOwnership, out RAST._IExpr r, out DCOMP._IOwnership resultingOwnership, out Dafny.ISet> readIdents) @@ -5050,16 +5109,16 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM if (_h71.is_Real) { { RAST._IExpr _14_recursiveGen; - DCOMP._IOwnership _15___v138; + DCOMP._IOwnership _15___v119; Dafny.ISet> _16_recIdents; RAST._IExpr _out11; DCOMP._IOwnership _out12; Dafny.ISet> _out13; (this).GenExpr(_0_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out11, out _out12, out _out13); _14_recursiveGen = _out11; - _15___v138 = _out12; + _15___v119 = _out12; _16_recIdents = _out13; - r = RAST.__default.RcNew(RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::dafny_runtime::BigRational::from_integer("), (_14_recursiveGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(")")))); + r = RAST.__default.RcNew(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("BigRational"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("from_integer"))).Apply1(_14_recursiveGen)); RAST._IExpr _out14; DCOMP._IOwnership _out15; (this).FromOwned(r, expectedOwnership, out _out14, out _out15); @@ -5084,16 +5143,16 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM if (_h73.is_Int) { { RAST._IExpr _17_recursiveGen; - DCOMP._IOwnership _18___v139; + DCOMP._IOwnership _18___v120; Dafny.ISet> _19_recIdents; RAST._IExpr _out16; DCOMP._IOwnership _out17; Dafny.ISet> _out18; (this).GenExpr(_0_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out16, out _out17, out _out18); _17_recursiveGen = _out16; - _18___v139 = _out17; + _18___v120 = _out17; _19_recIdents = _out18; - r = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::dafny_runtime::dafny_rational_to_int("), (_17_recursiveGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(")"))); + r = (((RAST.__default.dafny__runtime).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("dafny_rational_to_int"))).Apply1(_17_recursiveGen); RAST._IExpr _out19; DCOMP._IOwnership _out20; (this).FromOwned(r, expectedOwnership, out _out19, out _out20); @@ -5120,16 +5179,16 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM _out21 = (this).GenType(_2_toTpe, DCOMP.GenTypeContext.@default()); _20_rhsType = _out21; RAST._IExpr _21_recursiveGen; - DCOMP._IOwnership _22___v141; + DCOMP._IOwnership _22___v122; Dafny.ISet> _23_recIdents; RAST._IExpr _out22; DCOMP._IOwnership _out23; Dafny.ISet> _out24; (this).GenExpr(_0_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out22, out _out23, out _out24); _21_recursiveGen = _out22; - _22___v141 = _out23; + _22___v122 = _out23; _23_recIdents = _out24; - r = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("<"), (_20_rhsType)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(" as ::dafny_runtime::NumCast>::from(")), (_21_recursiveGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(").unwrap()"))); + r = ((((RAST.Expr.create_TraitCast(_20_rhsType, ((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("NumCast"))).AsType())).FSel(Dafny.Sequence.UnicodeFromString("from"))).Apply1(_21_recursiveGen)).Sel(Dafny.Sequence.UnicodeFromString("unwrap"))).Apply0(); RAST._IExpr _out25; DCOMP._IOwnership _out26; (this).FromOwned(r, expectedOwnership, out _out25, out _out26); @@ -5155,16 +5214,16 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM _out27 = (this).GenType(_1_fromTpe, DCOMP.GenTypeContext.@default()); _24_rhsType = _out27; RAST._IExpr _25_recursiveGen; - DCOMP._IOwnership _26___v143; + DCOMP._IOwnership _26___v124; Dafny.ISet> _27_recIdents; RAST._IExpr _out28; DCOMP._IOwnership _out29; Dafny.ISet> _out30; (this).GenExpr(_0_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out28, out _out29, out _out30); _25_recursiveGen = _out28; - _26___v143 = _out29; + _26___v124 = _out29; _27_recIdents = _out30; - r = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::dafny_runtime::DafnyInt::new(::std::rc::Rc::new(::dafny_runtime::BigInt::from("), (_25_recursiveGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(")))"))); + r = ((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("DafnyInt"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply1((((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("rc"))).MSel(Dafny.Sequence.UnicodeFromString("Rc"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply1(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("BigInt"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("from"))).Apply1(_25_recursiveGen))); RAST._IExpr _out31; DCOMP._IOwnership _out32; (this).FromOwned(r, expectedOwnership, out _out31, out _out32); @@ -5192,16 +5251,27 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM _out33 = (this).GenType(_2_toTpe, DCOMP.GenTypeContext.@default()); _28_rhsType = _out33; RAST._IExpr _29_recursiveGen; - DCOMP._IOwnership _30___v144; + DCOMP._IOwnership _30___v125; Dafny.ISet> _31_recIdents; RAST._IExpr _out34; DCOMP._IOwnership _out35; Dafny.ISet> _out36; (this).GenExpr(_0_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out34, out _out35, out _out36); _29_recursiveGen = _out34; - _30___v144 = _out35; + _30___v125 = _out35; _31_recIdents = _out36; - r = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::dafny_runtime::"), (this).DafnyChar), Dafny.Sequence.UnicodeFromString("(")), ((((this).charType).is_UTF32) ? (Dafny.Sequence.UnicodeFromString("char::from_u32(.UnicodeFromString(".UnicodeFromString(" as ::dafny_runtime::NumCast>::from(")), (_29_recursiveGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(").unwrap())")), ((((this).charType).is_UTF32) ? (Dafny.Sequence.UnicodeFromString(".unwrap())")) : (Dafny.Sequence.UnicodeFromString(""))))); + RAST._IType _32_uType; + if (((this).charType).is_UTF32) { + _32_uType = RAST.Type.create_U32(); + } else { + _32_uType = RAST.Type.create_U16(); + } + r = RAST.Expr.create_TraitCast(_32_uType, ((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("NumCast"))).AsType()); + r = ((((r).FSel(Dafny.Sequence.UnicodeFromString("from"))).Apply1(_29_recursiveGen)).Sel(Dafny.Sequence.UnicodeFromString("unwrap"))).Apply0(); + if (((this).charType).is_UTF32) { + r = ((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("char"))).FSel(Dafny.Sequence.UnicodeFromString("from_u32"))).Apply1(((r).Sel(Dafny.Sequence.UnicodeFromString("unwrap"))).Apply0()); + } + r = (((RAST.__default.dafny__runtime).MSel((this).DafnyChar)).AsExpr()).Apply1(r); RAST._IExpr _out37; DCOMP._IOwnership _out38; (this).FromOwned(r, expectedOwnership, out _out37, out _out38); @@ -5225,27 +5295,27 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM DAST._IPrimitive _h79 = _16.dtor_Primitive_a0; if (_h79.is_Int) { { - RAST._IType _32_rhsType; + RAST._IType _33_rhsType; RAST._IType _out39; _out39 = (this).GenType(_1_fromTpe, DCOMP.GenTypeContext.@default()); - _32_rhsType = _out39; - RAST._IExpr _33_recursiveGen; - DCOMP._IOwnership _34___v145; - Dafny.ISet> _35_recIdents; + _33_rhsType = _out39; + RAST._IExpr _34_recursiveGen; + DCOMP._IOwnership _35___v126; + Dafny.ISet> _36_recIdents; RAST._IExpr _out40; DCOMP._IOwnership _out41; Dafny.ISet> _out42; (this).GenExpr(_0_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out40, out _out41, out _out42); - _33_recursiveGen = _out40; - _34___v145 = _out41; - _35_recIdents = _out42; - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("int!"))).AsExpr()).Apply1((_33_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("0"))); + _34_recursiveGen = _out40; + _35___v126 = _out41; + _36_recIdents = _out42; + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("int!"))).AsExpr()).Apply1((_34_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("0"))); RAST._IExpr _out43; DCOMP._IOwnership _out44; (this).FromOwned(r, expectedOwnership, out _out43, out _out44); r = _out43; resultingOwnership = _out44; - readIdents = _35_recIdents; + readIdents = _36_recIdents; } goto after_match0; } @@ -5259,27 +5329,27 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM DAST._IType _17 = _source0.dtor__1; if (_17.is_Passthrough) { { - RAST._IExpr _36_recursiveGen; - DCOMP._IOwnership _37___v148; - Dafny.ISet> _38_recIdents; + RAST._IExpr _37_recursiveGen; + DCOMP._IOwnership _38___v129; + Dafny.ISet> _39_recIdents; RAST._IExpr _out45; DCOMP._IOwnership _out46; Dafny.ISet> _out47; (this).GenExpr(_0_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out45, out _out46, out _out47); - _36_recursiveGen = _out45; - _37___v148 = _out46; - _38_recIdents = _out47; - RAST._IType _39_toTpeGen; + _37_recursiveGen = _out45; + _38___v129 = _out46; + _39_recIdents = _out47; + RAST._IType _40_toTpeGen; RAST._IType _out48; _out48 = (this).GenType(_2_toTpe, DCOMP.GenTypeContext.@default()); - _39_toTpeGen = _out48; - r = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("(("), (_36_recursiveGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(") as ")), (_39_toTpeGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(")"))); + _40_toTpeGen = _out48; + r = RAST.Expr.create_TypeAscription(_37_recursiveGen, _40_toTpeGen); RAST._IExpr _out49; DCOMP._IOwnership _out50; (this).FromOwned(r, expectedOwnership, out _out49, out _out50); r = _out49; resultingOwnership = _out50; - readIdents = _38_recIdents; + readIdents = _39_recIdents; } goto after_match0; } @@ -5319,7 +5389,7 @@ public void GenIdent(Dafny.ISequence rName, DCOMP._ISelfInfo selfIde bool _3_noNeedOfClone; _3_noNeedOfClone = (env).CanReadWithoutClone(rName); if ((_1_placeboOpt).is_Some) { - r = ((r).Sel(Dafny.Sequence.UnicodeFromString("read"))).Apply(Dafny.Sequence.FromElements()); + r = ((r).Sel(Dafny.Sequence.UnicodeFromString("read"))).Apply0(); _2_currentlyBorrowed = false; _3_noNeedOfClone = true; _0_tpe = Std.Wrappers.Option.create_Some((_1_placeboOpt).dtor_value); @@ -5424,14 +5494,14 @@ public void GenArgs(DCOMP._ISelfInfo selfIdent, DAST._ICallName name, Dafny.ISeq } } RAST._IExpr _4_argExpr; - DCOMP._IOwnership _5___v155; + DCOMP._IOwnership _5___v136; Dafny.ISet> _6_argIdents; RAST._IExpr _out1; DCOMP._IOwnership _out2; Dafny.ISet> _out3; (this).GenExpr((args).Select(_1_i), selfIdent, env, _2_argOwnership, out _out1, out _out2, out _out3); _4_argExpr = _out1; - _5___v155 = _out2; + _5___v136 = _out2; _6_argIdents = _out3; argExprs = Dafny.Sequence.Concat(argExprs, Dafny.Sequence.FromElements(_4_argExpr)); readIdents = Dafny.Set>.Union(readIdents, _6_argIdents); @@ -5610,7 +5680,7 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv if ((_8_typExpr).IsObjectOrPointer()) { r = (_8_typExpr).ToNullExpr(); } else { - r = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("<"), (_8_typExpr)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(" as std::default::Default>::default()"))); + r = ((RAST.Expr.create_TraitCast(_8_typExpr, RAST.__default.DefaultTrait)).FSel(Dafny.Sequence.UnicodeFromString("default"))).Apply0(); } RAST._IExpr _out14; DCOMP._IOwnership _out15; @@ -5633,14 +5703,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv BigInteger _hi1 = new BigInteger((_9_values).Count); for (BigInteger _11_i = BigInteger.Zero; _11_i < _hi1; _11_i++) { RAST._IExpr _12_recursiveGen; - DCOMP._IOwnership _13___v165; + DCOMP._IOwnership _13___v146; Dafny.ISet> _14_recIdents; RAST._IExpr _out16; DCOMP._IOwnership _out17; Dafny.ISet> _out18; (this).GenExpr((_9_values).Select(_11_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out16, out _out17, out _out18); _12_recursiveGen = _out16; - _13___v165 = _out17; + _13___v146 = _out17; _14_recIdents = _out18; _10_exprs = Dafny.Sequence.Concat(_10_exprs, Dafny.Sequence.FromElements(_12_recursiveGen)); readIdents = Dafny.Set>.Union(readIdents, _14_recIdents); @@ -5689,14 +5759,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv BigInteger _hi3 = new BigInteger((_17_args).Count); for (BigInteger _22_i = BigInteger.Zero; _22_i < _hi3; _22_i++) { RAST._IExpr _23_recursiveGen; - DCOMP._IOwnership _24___v166; + DCOMP._IOwnership _24___v147; Dafny.ISet> _25_recIdents; RAST._IExpr _out23; DCOMP._IOwnership _out24; Dafny.ISet> _out25; (this).GenExpr((_17_args).Select(_22_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out23, out _out24, out _out25); _23_recursiveGen = _out23; - _24___v166 = _out24; + _24___v147 = _out24; _25_recIdents = _out25; _21_arguments = Dafny.Sequence.Concat(_21_arguments, Dafny.Sequence.FromElements(_23_recursiveGen)); readIdents = Dafny.Set>.Union(readIdents, _25_recIdents); @@ -5718,212 +5788,211 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv DAST._IType _27_typ = _source0.dtor_typ; { if ((new BigInteger(16)) < (new BigInteger((_26_dims).Count))) { - Dafny.ISequence _28_msg; - _28_msg = Dafny.Sequence.UnicodeFromString("Unsupported: Creation of arrays of more than 16 dimensions"); - if ((this.error).is_None) { - (this).error = Std.Wrappers.Option>.create_Some(_28_msg); - } - r = RAST.Expr.create_RawExpr(_28_msg); + RAST._IExpr _out28; + _out28 = (this).Error(Dafny.Sequence.UnicodeFromString("Unsupported: Creation of arrays of more than 16 dimensions"), (this).InitEmptyExpr()); + r = _out28; readIdents = Dafny.Set>.FromElements(); } else { - r = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); - RAST._IType _29_typeGen; - RAST._IType _out28; - _out28 = (this).GenType(_27_typ, DCOMP.GenTypeContext.@default()); - _29_typeGen = _out28; + r = (this).InitEmptyExpr(); + RAST._IType _28_typeGen; + RAST._IType _out29; + _out29 = (this).GenType(_27_typ, DCOMP.GenTypeContext.@default()); + _28_typeGen = _out29; readIdents = Dafny.Set>.FromElements(); - Dafny.ISequence _30_dimExprs; - _30_dimExprs = Dafny.Sequence.FromElements(); + Dafny.ISequence _29_dimExprs; + _29_dimExprs = Dafny.Sequence.FromElements(); BigInteger _hi4 = new BigInteger((_26_dims).Count); - for (BigInteger _31_i = BigInteger.Zero; _31_i < _hi4; _31_i++) { - RAST._IExpr _32_recursiveGen; - DCOMP._IOwnership _33___v167; - Dafny.ISet> _34_recIdents; - RAST._IExpr _out29; - DCOMP._IOwnership _out30; - Dafny.ISet> _out31; - (this).GenExpr((_26_dims).Select(_31_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out29, out _out30, out _out31); - _32_recursiveGen = _out29; - _33___v167 = _out30; - _34_recIdents = _out31; - _30_dimExprs = Dafny.Sequence.Concat(_30_dimExprs, Dafny.Sequence.FromElements(RAST.__default.IntoUsize(_32_recursiveGen))); - readIdents = Dafny.Set>.Union(readIdents, _34_recIdents); + for (BigInteger _30_i = BigInteger.Zero; _30_i < _hi4; _30_i++) { + RAST._IExpr _31_recursiveGen; + DCOMP._IOwnership _32___v148; + Dafny.ISet> _33_recIdents; + RAST._IExpr _out30; + DCOMP._IOwnership _out31; + Dafny.ISet> _out32; + (this).GenExpr((_26_dims).Select(_30_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out30, out _out31, out _out32); + _31_recursiveGen = _out30; + _32___v148 = _out31; + _33_recIdents = _out32; + _29_dimExprs = Dafny.Sequence.Concat(_29_dimExprs, Dafny.Sequence.FromElements(RAST.__default.IntoUsize(_31_recursiveGen))); + readIdents = Dafny.Set>.Union(readIdents, _33_recIdents); } if ((new BigInteger((_26_dims).Count)) > (BigInteger.One)) { - Dafny.ISequence _35_class__name; - _35_class__name = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Array"), Std.Strings.__default.OfNat(new BigInteger((_26_dims).Count))); - r = (((((RAST.__default.dafny__runtime).MSel(_35_class__name)).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_29_typeGen))).FSel((this).placebos__usize)).Apply(_30_dimExprs); + Dafny.ISequence _34_class__name; + _34_class__name = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Array"), Std.Strings.__default.OfNat(new BigInteger((_26_dims).Count))); + r = (((((RAST.__default.dafny__runtime).MSel(_34_class__name)).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_28_typeGen))).FSel((this).placebos__usize)).Apply(_29_dimExprs); } else { - r = (((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("array"))).AsExpr()).FSel((this).placebos__usize)).ApplyType(Dafny.Sequence.FromElements(_29_typeGen))).Apply(_30_dimExprs); + r = (((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("array"))).AsExpr()).FSel((this).placebos__usize)).ApplyType(Dafny.Sequence.FromElements(_28_typeGen))).Apply(_29_dimExprs); } } - RAST._IExpr _out32; - DCOMP._IOwnership _out33; - (this).FromOwned(r, expectedOwnership, out _out32, out _out33); - r = _out32; - resultingOwnership = _out33; + RAST._IExpr _out33; + DCOMP._IOwnership _out34; + (this).FromOwned(r, expectedOwnership, out _out33, out _out34); + r = _out33; + resultingOwnership = _out34; } goto after_match0; } } { if (_source0.is_ArrayIndexToInt) { - DAST._IExpression _36_underlying = _source0.dtor_value; + DAST._IExpression _35_underlying = _source0.dtor_value; { - RAST._IExpr _37_recursiveGen; - DCOMP._IOwnership _38___v168; - Dafny.ISet> _39_recIdents; - RAST._IExpr _out34; - DCOMP._IOwnership _out35; - Dafny.ISet> _out36; - (this).GenExpr(_36_underlying, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out34, out _out35, out _out36); - _37_recursiveGen = _out34; - _38___v168 = _out35; - _39_recIdents = _out36; - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("int!"))).AsExpr()).Apply1(_37_recursiveGen); - readIdents = _39_recIdents; - RAST._IExpr _out37; - DCOMP._IOwnership _out38; - (this).FromOwned(r, expectedOwnership, out _out37, out _out38); - r = _out37; - resultingOwnership = _out38; + RAST._IExpr _36_recursiveGen; + DCOMP._IOwnership _37___v149; + Dafny.ISet> _38_recIdents; + RAST._IExpr _out35; + DCOMP._IOwnership _out36; + Dafny.ISet> _out37; + (this).GenExpr(_35_underlying, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out35, out _out36, out _out37); + _36_recursiveGen = _out35; + _37___v149 = _out36; + _38_recIdents = _out37; + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("int!"))).AsExpr()).Apply1(_36_recursiveGen); + readIdents = _38_recIdents; + RAST._IExpr _out38; + DCOMP._IOwnership _out39; + (this).FromOwned(r, expectedOwnership, out _out38, out _out39); + r = _out38; + resultingOwnership = _out39; } goto after_match0; } } { if (_source0.is_FinalizeNewArray) { - DAST._IExpression _40_underlying = _source0.dtor_value; - DAST._IType _41_typ = _source0.dtor_typ; + DAST._IExpression _39_underlying = _source0.dtor_value; + DAST._IType _40_typ = _source0.dtor_typ; { - RAST._IType _42_tpe; - RAST._IType _out39; - _out39 = (this).GenType(_41_typ, DCOMP.GenTypeContext.@default()); - _42_tpe = _out39; - RAST._IExpr _43_recursiveGen; - DCOMP._IOwnership _44___v169; - Dafny.ISet> _45_recIdents; - RAST._IExpr _out40; - DCOMP._IOwnership _out41; - Dafny.ISet> _out42; - (this).GenExpr(_40_underlying, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out40, out _out41, out _out42); - _43_recursiveGen = _out40; - _44___v169 = _out41; - _45_recIdents = _out42; - readIdents = _45_recIdents; - if ((_42_tpe).IsObjectOrPointer()) { - RAST._IType _46_t; - _46_t = (_42_tpe).ObjectOrPointerUnderlying(); - if ((_46_t).is_Array) { - r = ((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("array"))).AsExpr()).FSel((this).array__construct)).Apply1(_43_recursiveGen); - } else if ((_46_t).IsMultiArray()) { - Dafny.ISequence _47_c; - _47_c = (_46_t).MultiArrayClass(); - r = ((((RAST.__default.dafny__runtime).MSel(_47_c)).AsExpr()).FSel((this).array__construct)).Apply1(_43_recursiveGen); + RAST._IType _41_tpe; + RAST._IType _out40; + _out40 = (this).GenType(_40_typ, DCOMP.GenTypeContext.@default()); + _41_tpe = _out40; + RAST._IExpr _42_recursiveGen; + DCOMP._IOwnership _43___v150; + Dafny.ISet> _44_recIdents; + RAST._IExpr _out41; + DCOMP._IOwnership _out42; + Dafny.ISet> _out43; + (this).GenExpr(_39_underlying, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out41, out _out42, out _out43); + _42_recursiveGen = _out41; + _43___v150 = _out42; + _44_recIdents = _out43; + readIdents = _44_recIdents; + if ((_41_tpe).IsObjectOrPointer()) { + RAST._IType _45_t; + _45_t = (_41_tpe).ObjectOrPointerUnderlying(); + if ((_45_t).is_Array) { + r = ((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("array"))).AsExpr()).FSel((this).array__construct)).Apply1(_42_recursiveGen); + } else if ((_45_t).IsMultiArray()) { + Dafny.ISequence _46_c; + _46_c = (_45_t).MultiArrayClass(); + r = ((((RAST.__default.dafny__runtime).MSel(_46_c)).AsExpr()).FSel((this).array__construct)).Apply1(_42_recursiveGen); } else { - (this).error = Std.Wrappers.Option>.create_Some(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Finalize New Array with a pointer or object type to something that is not an array or a multi array: "), (_42_tpe)._ToString(DCOMP.__default.IND))); - r = RAST.Expr.create_RawExpr((this.error).dtor_value); + RAST._IExpr _out44; + _out44 = (this).Error(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Finalize New Array with a pointer or object type to something that is not an array or a multi array: "), (_41_tpe)._ToString(DCOMP.__default.IND)), (this).InitEmptyExpr()); + r = _out44; } } else { - (this).error = Std.Wrappers.Option>.create_Some(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Finalize New Array with a type that is not a pointer or an object: "), (_42_tpe)._ToString(DCOMP.__default.IND))); - r = RAST.Expr.create_RawExpr((this.error).dtor_value); + RAST._IExpr _out45; + _out45 = (this).Error(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Finalize New Array with a type that is not a pointer or an object: "), (_41_tpe)._ToString(DCOMP.__default.IND)), (this).InitEmptyExpr()); + r = _out45; } - RAST._IExpr _out43; - DCOMP._IOwnership _out44; - (this).FromOwned(r, expectedOwnership, out _out43, out _out44); - r = _out43; - resultingOwnership = _out44; + RAST._IExpr _out46; + DCOMP._IOwnership _out47; + (this).FromOwned(r, expectedOwnership, out _out46, out _out47); + r = _out46; + resultingOwnership = _out47; } goto after_match0; } } { if (_source0.is_DatatypeValue) { - DAST._IResolvedType _48_datatypeType = _source0.dtor_datatypeType; - Dafny.ISequence _49_typeArgs = _source0.dtor_typeArgs; - Dafny.ISequence _50_variant = _source0.dtor_variant; - bool _51_isCo = _source0.dtor_isCo; - Dafny.ISequence<_System._ITuple2, DAST._IExpression>> _52_values = _source0.dtor_contents; + DAST._IResolvedType _47_datatypeType = _source0.dtor_datatypeType; + Dafny.ISequence _48_typeArgs = _source0.dtor_typeArgs; + Dafny.ISequence _49_variant = _source0.dtor_variant; + bool _50_isCo = _source0.dtor_isCo; + Dafny.ISequence<_System._ITuple2, DAST._IExpression>> _51_values = _source0.dtor_contents; { - RAST._IExpr _out45; - _out45 = (this).GenPathExpr((_48_datatypeType).dtor_path, true); - r = _out45; - Dafny.ISequence _53_genTypeArgs; - _53_genTypeArgs = Dafny.Sequence.FromElements(); - BigInteger _hi5 = new BigInteger((_49_typeArgs).Count); - for (BigInteger _54_i = BigInteger.Zero; _54_i < _hi5; _54_i++) { - RAST._IType _55_typeExpr; - RAST._IType _out46; - _out46 = (this).GenType((_49_typeArgs).Select(_54_i), DCOMP.GenTypeContext.@default()); - _55_typeExpr = _out46; - _53_genTypeArgs = Dafny.Sequence.Concat(_53_genTypeArgs, Dafny.Sequence.FromElements(_55_typeExpr)); - } - if ((new BigInteger((_49_typeArgs).Count)).Sign == 1) { - r = (r).ApplyType(_53_genTypeArgs); - } - r = (r).FSel(DCOMP.__default.escapeName(_50_variant)); + RAST._IExpr _out48; + _out48 = (this).GenPathExpr((_47_datatypeType).dtor_path, true); + r = _out48; + Dafny.ISequence _52_genTypeArgs; + _52_genTypeArgs = Dafny.Sequence.FromElements(); + BigInteger _hi5 = new BigInteger((_48_typeArgs).Count); + for (BigInteger _53_i = BigInteger.Zero; _53_i < _hi5; _53_i++) { + RAST._IType _54_typeExpr; + RAST._IType _out49; + _out49 = (this).GenType((_48_typeArgs).Select(_53_i), DCOMP.GenTypeContext.@default()); + _54_typeExpr = _out49; + _52_genTypeArgs = Dafny.Sequence.Concat(_52_genTypeArgs, Dafny.Sequence.FromElements(_54_typeExpr)); + } + if ((new BigInteger((_48_typeArgs).Count)).Sign == 1) { + r = (r).ApplyType(_52_genTypeArgs); + } + r = (r).FSel(DCOMP.__default.escapeName(_49_variant)); readIdents = Dafny.Set>.FromElements(); - Dafny.ISequence _56_assignments; - _56_assignments = Dafny.Sequence.FromElements(); - BigInteger _hi6 = new BigInteger((_52_values).Count); - for (BigInteger _57_i = BigInteger.Zero; _57_i < _hi6; _57_i++) { - _System._ITuple2, DAST._IExpression> _let_tmp_rhs0 = (_52_values).Select(_57_i); - Dafny.ISequence _58_name = _let_tmp_rhs0.dtor__0; - DAST._IExpression _59_value = _let_tmp_rhs0.dtor__1; - if (_51_isCo) { - RAST._IExpr _60_recursiveGen; - DCOMP._IOwnership _61___v170; - Dafny.ISet> _62_recIdents; - RAST._IExpr _out47; - DCOMP._IOwnership _out48; - Dafny.ISet> _out49; - (this).GenExpr(_59_value, selfIdent, DCOMP.Environment.Empty(), DCOMP.Ownership.create_OwnershipOwned(), out _out47, out _out48, out _out49); - _60_recursiveGen = _out47; - _61___v170 = _out48; - _62_recIdents = _out49; - readIdents = Dafny.Set>.Union(readIdents, _62_recIdents); - Dafny.ISequence _63_allReadCloned; - _63_allReadCloned = Dafny.Sequence.UnicodeFromString(""); - while (!(_62_recIdents).Equals(Dafny.Set>.FromElements())) { - Dafny.ISequence _64_next; - foreach (Dafny.ISequence _assign_such_that_0 in (_62_recIdents).Elements) { - _64_next = (Dafny.ISequence)_assign_such_that_0; - if ((_62_recIdents).Contains(_64_next)) { + Dafny.ISequence _55_assignments; + _55_assignments = Dafny.Sequence.FromElements(); + BigInteger _hi6 = new BigInteger((_51_values).Count); + for (BigInteger _56_i = BigInteger.Zero; _56_i < _hi6; _56_i++) { + _System._ITuple2, DAST._IExpression> _let_tmp_rhs0 = (_51_values).Select(_56_i); + Dafny.ISequence _57_name = _let_tmp_rhs0.dtor__0; + DAST._IExpression _58_value = _let_tmp_rhs0.dtor__1; + if (_50_isCo) { + RAST._IExpr _59_recursiveGen; + DCOMP._IOwnership _60___v151; + Dafny.ISet> _61_recIdents; + RAST._IExpr _out50; + DCOMP._IOwnership _out51; + Dafny.ISet> _out52; + (this).GenExpr(_58_value, selfIdent, DCOMP.Environment.Empty(), DCOMP.Ownership.create_OwnershipOwned(), out _out50, out _out51, out _out52); + _59_recursiveGen = _out50; + _60___v151 = _out51; + _61_recIdents = _out52; + readIdents = Dafny.Set>.Union(readIdents, _61_recIdents); + RAST._IExpr _62_allReadCloned; + _62_allReadCloned = (this).InitEmptyExpr(); + while (!(_61_recIdents).Equals(Dafny.Set>.FromElements())) { + Dafny.ISequence _63_next; + foreach (Dafny.ISequence _assign_such_that_0 in (_61_recIdents).Elements) { + _63_next = (Dafny.ISequence)_assign_such_that_0; + if ((_61_recIdents).Contains(_63_next)) { goto after__ASSIGN_SUCH_THAT_0; } } throw new System.Exception("assign-such-that search produced no value"); after__ASSIGN_SUCH_THAT_0: ; - _63_allReadCloned = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_63_allReadCloned, Dafny.Sequence.UnicodeFromString("let ")), _64_next), Dafny.Sequence.UnicodeFromString(" = ")), _64_next), Dafny.Sequence.UnicodeFromString(".clone();\n")); - _62_recIdents = Dafny.Set>.Difference(_62_recIdents, Dafny.Set>.FromElements(_64_next)); + _62_allReadCloned = (_62_allReadCloned).Then(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_CONST(), _63_next, Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some((RAST.Expr.create_Identifier(_63_next)).Clone()))); + _61_recIdents = Dafny.Set>.Difference(_61_recIdents, Dafny.Set>.FromElements(_63_next)); } - Dafny.ISequence _65_wasAssigned; - _65_wasAssigned = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::dafny_runtime::LazyFieldWrapper(::dafny_runtime::Lazy::new(::std::boxed::Box::new({\n"), _63_allReadCloned), Dafny.Sequence.UnicodeFromString("move || (")), (_60_recursiveGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(")})))")); - _56_assignments = Dafny.Sequence.Concat(_56_assignments, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(DCOMP.__default.escapeVar(_58_name), RAST.Expr.create_RawExpr(_65_wasAssigned)))); + RAST._IExpr _64_wasAssigned; + _64_wasAssigned = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("LazyFieldWrapper"))).AsExpr()).Apply1(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("Lazy"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply1((((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("boxed"))).MSel(Dafny.Sequence.UnicodeFromString("Box"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply1((_62_allReadCloned).Then(RAST.Expr.create_Lambda(Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_None(), _59_recursiveGen))))); + _55_assignments = Dafny.Sequence.Concat(_55_assignments, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(DCOMP.__default.escapeVar(_57_name), _64_wasAssigned))); } else { - RAST._IExpr _66_recursiveGen; - DCOMP._IOwnership _67___v171; - Dafny.ISet> _68_recIdents; - RAST._IExpr _out50; - DCOMP._IOwnership _out51; - Dafny.ISet> _out52; - (this).GenExpr(_59_value, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out50, out _out51, out _out52); - _66_recursiveGen = _out50; - _67___v171 = _out51; - _68_recIdents = _out52; - _56_assignments = Dafny.Sequence.Concat(_56_assignments, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(DCOMP.__default.escapeVar(_58_name), _66_recursiveGen))); - readIdents = Dafny.Set>.Union(readIdents, _68_recIdents); + RAST._IExpr _65_recursiveGen; + DCOMP._IOwnership _66___v152; + Dafny.ISet> _67_recIdents; + RAST._IExpr _out53; + DCOMP._IOwnership _out54; + Dafny.ISet> _out55; + (this).GenExpr(_58_value, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out53, out _out54, out _out55); + _65_recursiveGen = _out53; + _66___v152 = _out54; + _67_recIdents = _out55; + _55_assignments = Dafny.Sequence.Concat(_55_assignments, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(DCOMP.__default.escapeVar(_57_name), _65_recursiveGen))); + readIdents = Dafny.Set>.Union(readIdents, _67_recIdents); } } - r = RAST.Expr.create_StructBuild(r, _56_assignments); - if ((this).IsRcWrapped((_48_datatypeType).dtor_attributes)) { + r = RAST.Expr.create_StructBuild(r, _55_assignments); + if ((this).IsRcWrapped((_47_datatypeType).dtor_attributes)) { r = RAST.__default.RcNew(r); } - RAST._IExpr _out53; - DCOMP._IOwnership _out54; - (this).FromOwned(r, expectedOwnership, out _out53, out _out54); - r = _out53; - resultingOwnership = _out54; + RAST._IExpr _out56; + DCOMP._IOwnership _out57; + (this).FromOwned(r, expectedOwnership, out _out56, out _out57); + r = _out56; + resultingOwnership = _out57; return ; } goto after_match0; @@ -5932,49 +6001,58 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv { if (_source0.is_Convert) { { - RAST._IExpr _out55; - DCOMP._IOwnership _out56; - Dafny.ISet> _out57; - (this).GenExprConvert(e, selfIdent, env, expectedOwnership, out _out55, out _out56, out _out57); - r = _out55; - resultingOwnership = _out56; - readIdents = _out57; + RAST._IExpr _out58; + DCOMP._IOwnership _out59; + Dafny.ISet> _out60; + (this).GenExprConvert(e, selfIdent, env, expectedOwnership, out _out58, out _out59, out _out60); + r = _out58; + resultingOwnership = _out59; + readIdents = _out60; } goto after_match0; } } { if (_source0.is_SeqConstruct) { - DAST._IExpression _69_length = _source0.dtor_length; - DAST._IExpression _70_expr = _source0.dtor_elem; + DAST._IExpression _68_length = _source0.dtor_length; + DAST._IExpression _69_expr = _source0.dtor_elem; { - RAST._IExpr _71_recursiveGen; - DCOMP._IOwnership _72___v175; - Dafny.ISet> _73_recIdents; - RAST._IExpr _out58; - DCOMP._IOwnership _out59; - Dafny.ISet> _out60; - (this).GenExpr(_70_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out58, out _out59, out _out60); - _71_recursiveGen = _out58; - _72___v175 = _out59; - _73_recIdents = _out60; - RAST._IExpr _74_lengthGen; - DCOMP._IOwnership _75___v176; - Dafny.ISet> _76_lengthIdents; + RAST._IExpr _70_recursiveGen; + DCOMP._IOwnership _71___v156; + Dafny.ISet> _72_recIdents; RAST._IExpr _out61; DCOMP._IOwnership _out62; Dafny.ISet> _out63; - (this).GenExpr(_69_length, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out61, out _out62, out _out63); - _74_lengthGen = _out61; - _75___v176 = _out62; - _76_lengthIdents = _out63; - r = RAST.Expr.create_RawExpr(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("{\nlet _initializer = "), (_71_recursiveGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(";\n::dafny_runtime::integer_range(::dafny_runtime::Zero::zero(), ")), (_74_lengthGen)._ToString(DCOMP.__default.IND)), Dafny.Sequence.UnicodeFromString(").map(|i| _initializer(&i)).collect::<::dafny_runtime::Sequence<_>>()\n}"))); - readIdents = Dafny.Set>.Union(_73_recIdents, _76_lengthIdents); + (this).GenExpr(_69_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out61, out _out62, out _out63); + _70_recursiveGen = _out61; + _71___v156 = _out62; + _72_recIdents = _out63; + RAST._IExpr _73_lengthGen; + DCOMP._IOwnership _74___v157; + Dafny.ISet> _75_lengthIdents; RAST._IExpr _out64; DCOMP._IOwnership _out65; - (this).FromOwned(r, expectedOwnership, out _out64, out _out65); - r = _out64; - resultingOwnership = _out65; + Dafny.ISet> _out66; + (this).GenExpr(_68_length, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out64, out _out65, out _out66); + _73_lengthGen = _out64; + _74___v157 = _out65; + _75_lengthIdents = _out66; + r = RAST.Expr.create_DeclareVar(RAST.DeclareType.create_CONST(), Dafny.Sequence.UnicodeFromString("_initializer"), Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(_70_recursiveGen)); + RAST._IExpr _76_range; + _76_range = ((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("integer_range"))).AsExpr(); + _76_range = (_76_range).Apply(Dafny.Sequence.FromElements(((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("Zero"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("zero"))).Apply0(), _73_lengthGen)); + _76_range = (_76_range).Sel(Dafny.Sequence.UnicodeFromString("map")); + RAST._IExpr _77_rangeMap; + _77_rangeMap = RAST.Expr.create_Lambda(Dafny.Sequence.FromElements(RAST.Formal.ImplicitlyTyped(Dafny.Sequence.UnicodeFromString("i"))), Std.Wrappers.Option.create_None(), (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_initializer"))).Apply1(RAST.__default.Borrow(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("i"))))); + _76_range = (_76_range).Apply1(_77_rangeMap); + _76_range = (((_76_range).Sel(Dafny.Sequence.UnicodeFromString("collect"))).ApplyType(Dafny.Sequence.FromElements((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("Sequence"))).AsType()).Apply(Dafny.Sequence.FromElements(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("_"))))))).Apply0(); + r = RAST.Expr.create_Block((r).Then(_76_range)); + readIdents = Dafny.Set>.Union(_72_recIdents, _75_lengthIdents); + RAST._IExpr _out67; + DCOMP._IOwnership _out68; + (this).FromOwned(r, expectedOwnership, out _out67, out _out68); + r = _out67; + resultingOwnership = _out68; return ; } goto after_match0; @@ -5982,42 +6060,42 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_SeqValue) { - Dafny.ISequence _77_exprs = _source0.dtor_elements; - DAST._IType _78_typ = _source0.dtor_typ; + Dafny.ISequence _78_exprs = _source0.dtor_elements; + DAST._IType _79_typ = _source0.dtor_typ; { readIdents = Dafny.Set>.FromElements(); - RAST._IType _79_genTpe; - RAST._IType _out66; - _out66 = (this).GenType(_78_typ, DCOMP.GenTypeContext.@default()); - _79_genTpe = _out66; - BigInteger _80_i; - _80_i = BigInteger.Zero; - Dafny.ISequence _81_args; - _81_args = Dafny.Sequence.FromElements(); - while ((_80_i) < (new BigInteger((_77_exprs).Count))) { - RAST._IExpr _82_recursiveGen; - DCOMP._IOwnership _83___v177; - Dafny.ISet> _84_recIdents; - RAST._IExpr _out67; - DCOMP._IOwnership _out68; - Dafny.ISet> _out69; - (this).GenExpr((_77_exprs).Select(_80_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out67, out _out68, out _out69); - _82_recursiveGen = _out67; - _83___v177 = _out68; - _84_recIdents = _out69; - readIdents = Dafny.Set>.Union(readIdents, _84_recIdents); - _81_args = Dafny.Sequence.Concat(_81_args, Dafny.Sequence.FromElements(_82_recursiveGen)); - _80_i = (_80_i) + (BigInteger.One); - } - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("seq!"))).AsExpr()).Apply(_81_args); - if ((new BigInteger((_81_args).Count)).Sign == 0) { - r = RAST.Expr.create_TypeAscription(r, (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("Sequence"))).AsType()).Apply1(_79_genTpe)); - } - RAST._IExpr _out70; - DCOMP._IOwnership _out71; - (this).FromOwned(r, expectedOwnership, out _out70, out _out71); - r = _out70; - resultingOwnership = _out71; + RAST._IType _80_genTpe; + RAST._IType _out69; + _out69 = (this).GenType(_79_typ, DCOMP.GenTypeContext.@default()); + _80_genTpe = _out69; + BigInteger _81_i; + _81_i = BigInteger.Zero; + Dafny.ISequence _82_args; + _82_args = Dafny.Sequence.FromElements(); + while ((_81_i) < (new BigInteger((_78_exprs).Count))) { + RAST._IExpr _83_recursiveGen; + DCOMP._IOwnership _84___v158; + Dafny.ISet> _85_recIdents; + RAST._IExpr _out70; + DCOMP._IOwnership _out71; + Dafny.ISet> _out72; + (this).GenExpr((_78_exprs).Select(_81_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out70, out _out71, out _out72); + _83_recursiveGen = _out70; + _84___v158 = _out71; + _85_recIdents = _out72; + readIdents = Dafny.Set>.Union(readIdents, _85_recIdents); + _82_args = Dafny.Sequence.Concat(_82_args, Dafny.Sequence.FromElements(_83_recursiveGen)); + _81_i = (_81_i) + (BigInteger.One); + } + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("seq!"))).AsExpr()).Apply(_82_args); + if ((new BigInteger((_82_args).Count)).Sign == 0) { + r = RAST.Expr.create_TypeAscription(r, (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("Sequence"))).AsType()).Apply1(_80_genTpe)); + } + RAST._IExpr _out73; + DCOMP._IOwnership _out74; + (this).FromOwned(r, expectedOwnership, out _out73, out _out74); + r = _out73; + resultingOwnership = _out74; return ; } goto after_match0; @@ -6025,34 +6103,34 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_SetValue) { - Dafny.ISequence _85_exprs = _source0.dtor_elements; + Dafny.ISequence _86_exprs = _source0.dtor_elements; { - Dafny.ISequence _86_generatedValues; - _86_generatedValues = Dafny.Sequence.FromElements(); + Dafny.ISequence _87_generatedValues; + _87_generatedValues = Dafny.Sequence.FromElements(); readIdents = Dafny.Set>.FromElements(); - BigInteger _87_i; - _87_i = BigInteger.Zero; - while ((_87_i) < (new BigInteger((_85_exprs).Count))) { - RAST._IExpr _88_recursiveGen; - DCOMP._IOwnership _89___v178; - Dafny.ISet> _90_recIdents; - RAST._IExpr _out72; - DCOMP._IOwnership _out73; - Dafny.ISet> _out74; - (this).GenExpr((_85_exprs).Select(_87_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out72, out _out73, out _out74); - _88_recursiveGen = _out72; - _89___v178 = _out73; - _90_recIdents = _out74; - _86_generatedValues = Dafny.Sequence.Concat(_86_generatedValues, Dafny.Sequence.FromElements(_88_recursiveGen)); - readIdents = Dafny.Set>.Union(readIdents, _90_recIdents); - _87_i = (_87_i) + (BigInteger.One); - } - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("set!"))).AsExpr()).Apply(_86_generatedValues); - RAST._IExpr _out75; - DCOMP._IOwnership _out76; - (this).FromOwned(r, expectedOwnership, out _out75, out _out76); - r = _out75; - resultingOwnership = _out76; + BigInteger _88_i; + _88_i = BigInteger.Zero; + while ((_88_i) < (new BigInteger((_86_exprs).Count))) { + RAST._IExpr _89_recursiveGen; + DCOMP._IOwnership _90___v159; + Dafny.ISet> _91_recIdents; + RAST._IExpr _out75; + DCOMP._IOwnership _out76; + Dafny.ISet> _out77; + (this).GenExpr((_86_exprs).Select(_88_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out75, out _out76, out _out77); + _89_recursiveGen = _out75; + _90___v159 = _out76; + _91_recIdents = _out77; + _87_generatedValues = Dafny.Sequence.Concat(_87_generatedValues, Dafny.Sequence.FromElements(_89_recursiveGen)); + readIdents = Dafny.Set>.Union(readIdents, _91_recIdents); + _88_i = (_88_i) + (BigInteger.One); + } + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("set!"))).AsExpr()).Apply(_87_generatedValues); + RAST._IExpr _out78; + DCOMP._IOwnership _out79; + (this).FromOwned(r, expectedOwnership, out _out78, out _out79); + r = _out78; + resultingOwnership = _out79; return ; } goto after_match0; @@ -6060,34 +6138,34 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_MultisetValue) { - Dafny.ISequence _91_exprs = _source0.dtor_elements; + Dafny.ISequence _92_exprs = _source0.dtor_elements; { - Dafny.ISequence _92_generatedValues; - _92_generatedValues = Dafny.Sequence.FromElements(); + Dafny.ISequence _93_generatedValues; + _93_generatedValues = Dafny.Sequence.FromElements(); readIdents = Dafny.Set>.FromElements(); - BigInteger _93_i; - _93_i = BigInteger.Zero; - while ((_93_i) < (new BigInteger((_91_exprs).Count))) { - RAST._IExpr _94_recursiveGen; - DCOMP._IOwnership _95___v179; - Dafny.ISet> _96_recIdents; - RAST._IExpr _out77; - DCOMP._IOwnership _out78; - Dafny.ISet> _out79; - (this).GenExpr((_91_exprs).Select(_93_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out77, out _out78, out _out79); - _94_recursiveGen = _out77; - _95___v179 = _out78; - _96_recIdents = _out79; - _92_generatedValues = Dafny.Sequence.Concat(_92_generatedValues, Dafny.Sequence.FromElements(_94_recursiveGen)); - readIdents = Dafny.Set>.Union(readIdents, _96_recIdents); - _93_i = (_93_i) + (BigInteger.One); - } - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("multiset!"))).AsExpr()).Apply(_92_generatedValues); - RAST._IExpr _out80; - DCOMP._IOwnership _out81; - (this).FromOwned(r, expectedOwnership, out _out80, out _out81); - r = _out80; - resultingOwnership = _out81; + BigInteger _94_i; + _94_i = BigInteger.Zero; + while ((_94_i) < (new BigInteger((_92_exprs).Count))) { + RAST._IExpr _95_recursiveGen; + DCOMP._IOwnership _96___v160; + Dafny.ISet> _97_recIdents; + RAST._IExpr _out80; + DCOMP._IOwnership _out81; + Dafny.ISet> _out82; + (this).GenExpr((_92_exprs).Select(_94_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out80, out _out81, out _out82); + _95_recursiveGen = _out80; + _96___v160 = _out81; + _97_recIdents = _out82; + _93_generatedValues = Dafny.Sequence.Concat(_93_generatedValues, Dafny.Sequence.FromElements(_95_recursiveGen)); + readIdents = Dafny.Set>.Union(readIdents, _97_recIdents); + _94_i = (_94_i) + (BigInteger.One); + } + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("multiset!"))).AsExpr()).Apply(_93_generatedValues); + RAST._IExpr _out83; + DCOMP._IOwnership _out84; + (this).FromOwned(r, expectedOwnership, out _out83, out _out84); + r = _out83; + resultingOwnership = _out84; return ; } goto after_match0; @@ -6095,25 +6173,25 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_ToMultiset) { - DAST._IExpression _97_expr = _source0.dtor_ToMultiset_a0; + DAST._IExpression _98_expr = _source0.dtor_ToMultiset_a0; { - RAST._IExpr _98_recursiveGen; - DCOMP._IOwnership _99___v180; - Dafny.ISet> _100_recIdents; - RAST._IExpr _out82; - DCOMP._IOwnership _out83; - Dafny.ISet> _out84; - (this).GenExpr(_97_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out82, out _out83, out _out84); - _98_recursiveGen = _out82; - _99___v180 = _out83; - _100_recIdents = _out84; - r = ((_98_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("as_dafny_multiset"))).Apply(Dafny.Sequence.FromElements()); - readIdents = _100_recIdents; + RAST._IExpr _99_recursiveGen; + DCOMP._IOwnership _100___v161; + Dafny.ISet> _101_recIdents; RAST._IExpr _out85; DCOMP._IOwnership _out86; - (this).FromOwned(r, expectedOwnership, out _out85, out _out86); - r = _out85; - resultingOwnership = _out86; + Dafny.ISet> _out87; + (this).GenExpr(_98_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out85, out _out86, out _out87); + _99_recursiveGen = _out85; + _100___v161 = _out86; + _101_recIdents = _out87; + r = ((_99_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("as_dafny_multiset"))).Apply0(); + readIdents = _101_recIdents; + RAST._IExpr _out88; + DCOMP._IOwnership _out89; + (this).FromOwned(r, expectedOwnership, out _out88, out _out89); + r = _out88; + resultingOwnership = _out89; return ; } goto after_match0; @@ -6121,55 +6199,55 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_MapValue) { - Dafny.ISequence<_System._ITuple2> _101_mapElems = _source0.dtor_mapElems; + Dafny.ISequence<_System._ITuple2> _102_mapElems = _source0.dtor_mapElems; { - Dafny.ISequence<_System._ITuple2> _102_generatedValues; - _102_generatedValues = Dafny.Sequence<_System._ITuple2>.FromElements(); + Dafny.ISequence<_System._ITuple2> _103_generatedValues; + _103_generatedValues = Dafny.Sequence<_System._ITuple2>.FromElements(); readIdents = Dafny.Set>.FromElements(); - BigInteger _103_i; - _103_i = BigInteger.Zero; - while ((_103_i) < (new BigInteger((_101_mapElems).Count))) { - RAST._IExpr _104_recursiveGenKey; - DCOMP._IOwnership _105___v181; - Dafny.ISet> _106_recIdentsKey; - RAST._IExpr _out87; - DCOMP._IOwnership _out88; - Dafny.ISet> _out89; - (this).GenExpr(((_101_mapElems).Select(_103_i)).dtor__0, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out87, out _out88, out _out89); - _104_recursiveGenKey = _out87; - _105___v181 = _out88; - _106_recIdentsKey = _out89; - RAST._IExpr _107_recursiveGenValue; - DCOMP._IOwnership _108___v182; - Dafny.ISet> _109_recIdentsValue; + BigInteger _104_i; + _104_i = BigInteger.Zero; + while ((_104_i) < (new BigInteger((_102_mapElems).Count))) { + RAST._IExpr _105_recursiveGenKey; + DCOMP._IOwnership _106___v162; + Dafny.ISet> _107_recIdentsKey; RAST._IExpr _out90; DCOMP._IOwnership _out91; Dafny.ISet> _out92; - (this).GenExpr(((_101_mapElems).Select(_103_i)).dtor__1, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out90, out _out91, out _out92); - _107_recursiveGenValue = _out90; - _108___v182 = _out91; - _109_recIdentsValue = _out92; - _102_generatedValues = Dafny.Sequence<_System._ITuple2>.Concat(_102_generatedValues, Dafny.Sequence<_System._ITuple2>.FromElements(_System.Tuple2.create(_104_recursiveGenKey, _107_recursiveGenValue))); - readIdents = Dafny.Set>.Union(Dafny.Set>.Union(readIdents, _106_recIdentsKey), _109_recIdentsValue); - _103_i = (_103_i) + (BigInteger.One); - } - _103_i = BigInteger.Zero; - Dafny.ISequence _110_arguments; - _110_arguments = Dafny.Sequence.FromElements(); - while ((_103_i) < (new BigInteger((_102_generatedValues).Count))) { - RAST._IExpr _111_genKey; - _111_genKey = ((_102_generatedValues).Select(_103_i)).dtor__0; - RAST._IExpr _112_genValue; - _112_genValue = ((_102_generatedValues).Select(_103_i)).dtor__1; - _110_arguments = Dafny.Sequence.Concat(_110_arguments, Dafny.Sequence.FromElements(RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=>"), _111_genKey, _112_genValue, DAST.Format.BinaryOpFormat.create_NoFormat()))); - _103_i = (_103_i) + (BigInteger.One); - } - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("map!"))).AsExpr()).Apply(_110_arguments); - RAST._IExpr _out93; - DCOMP._IOwnership _out94; - (this).FromOwned(r, expectedOwnership, out _out93, out _out94); - r = _out93; - resultingOwnership = _out94; + (this).GenExpr(((_102_mapElems).Select(_104_i)).dtor__0, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out90, out _out91, out _out92); + _105_recursiveGenKey = _out90; + _106___v162 = _out91; + _107_recIdentsKey = _out92; + RAST._IExpr _108_recursiveGenValue; + DCOMP._IOwnership _109___v163; + Dafny.ISet> _110_recIdentsValue; + RAST._IExpr _out93; + DCOMP._IOwnership _out94; + Dafny.ISet> _out95; + (this).GenExpr(((_102_mapElems).Select(_104_i)).dtor__1, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out93, out _out94, out _out95); + _108_recursiveGenValue = _out93; + _109___v163 = _out94; + _110_recIdentsValue = _out95; + _103_generatedValues = Dafny.Sequence<_System._ITuple2>.Concat(_103_generatedValues, Dafny.Sequence<_System._ITuple2>.FromElements(_System.Tuple2.create(_105_recursiveGenKey, _108_recursiveGenValue))); + readIdents = Dafny.Set>.Union(Dafny.Set>.Union(readIdents, _107_recIdentsKey), _110_recIdentsValue); + _104_i = (_104_i) + (BigInteger.One); + } + _104_i = BigInteger.Zero; + Dafny.ISequence _111_arguments; + _111_arguments = Dafny.Sequence.FromElements(); + while ((_104_i) < (new BigInteger((_103_generatedValues).Count))) { + RAST._IExpr _112_genKey; + _112_genKey = ((_103_generatedValues).Select(_104_i)).dtor__0; + RAST._IExpr _113_genValue; + _113_genValue = ((_103_generatedValues).Select(_104_i)).dtor__1; + _111_arguments = Dafny.Sequence.Concat(_111_arguments, Dafny.Sequence.FromElements(RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("=>"), _112_genKey, _113_genValue, DAST.Format.BinaryOpFormat.create_NoFormat()))); + _104_i = (_104_i) + (BigInteger.One); + } + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("map!"))).AsExpr()).Apply(_111_arguments); + RAST._IExpr _out96; + DCOMP._IOwnership _out97; + (this).FromOwned(r, expectedOwnership, out _out96, out _out97); + r = _out96; + resultingOwnership = _out97; return ; } goto after_match0; @@ -6177,47 +6255,47 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_SeqUpdate) { - DAST._IExpression _113_expr = _source0.dtor_expr; - DAST._IExpression _114_index = _source0.dtor_indexExpr; - DAST._IExpression _115_value = _source0.dtor_value; + DAST._IExpression _114_expr = _source0.dtor_expr; + DAST._IExpression _115_index = _source0.dtor_indexExpr; + DAST._IExpression _116_value = _source0.dtor_value; { - RAST._IExpr _116_exprR; - DCOMP._IOwnership _117___v183; - Dafny.ISet> _118_exprIdents; - RAST._IExpr _out95; - DCOMP._IOwnership _out96; - Dafny.ISet> _out97; - (this).GenExpr(_113_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out95, out _out96, out _out97); - _116_exprR = _out95; - _117___v183 = _out96; - _118_exprIdents = _out97; - RAST._IExpr _119_indexR; - DCOMP._IOwnership _120_indexOwnership; - Dafny.ISet> _121_indexIdents; + RAST._IExpr _117_exprR; + DCOMP._IOwnership _118___v164; + Dafny.ISet> _119_exprIdents; RAST._IExpr _out98; DCOMP._IOwnership _out99; Dafny.ISet> _out100; - (this).GenExpr(_114_index, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out98, out _out99, out _out100); - _119_indexR = _out98; - _120_indexOwnership = _out99; - _121_indexIdents = _out100; - RAST._IExpr _122_valueR; - DCOMP._IOwnership _123_valueOwnership; - Dafny.ISet> _124_valueIdents; + (this).GenExpr(_114_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out98, out _out99, out _out100); + _117_exprR = _out98; + _118___v164 = _out99; + _119_exprIdents = _out100; + RAST._IExpr _120_indexR; + DCOMP._IOwnership _121_indexOwnership; + Dafny.ISet> _122_indexIdents; RAST._IExpr _out101; DCOMP._IOwnership _out102; Dafny.ISet> _out103; - (this).GenExpr(_115_value, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out101, out _out102, out _out103); - _122_valueR = _out101; - _123_valueOwnership = _out102; - _124_valueIdents = _out103; - r = ((_116_exprR).Sel(Dafny.Sequence.UnicodeFromString("update_index"))).Apply(Dafny.Sequence.FromElements(_119_indexR, _122_valueR)); + (this).GenExpr(_115_index, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out101, out _out102, out _out103); + _120_indexR = _out101; + _121_indexOwnership = _out102; + _122_indexIdents = _out103; + RAST._IExpr _123_valueR; + DCOMP._IOwnership _124_valueOwnership; + Dafny.ISet> _125_valueIdents; RAST._IExpr _out104; DCOMP._IOwnership _out105; - (this).FromOwned(r, expectedOwnership, out _out104, out _out105); - r = _out104; - resultingOwnership = _out105; - readIdents = Dafny.Set>.Union(Dafny.Set>.Union(_118_exprIdents, _121_indexIdents), _124_valueIdents); + Dafny.ISet> _out106; + (this).GenExpr(_116_value, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out104, out _out105, out _out106); + _123_valueR = _out104; + _124_valueOwnership = _out105; + _125_valueIdents = _out106; + r = ((_117_exprR).Sel(Dafny.Sequence.UnicodeFromString("update_index"))).Apply(Dafny.Sequence.FromElements(_120_indexR, _123_valueR)); + RAST._IExpr _out107; + DCOMP._IOwnership _out108; + (this).FromOwned(r, expectedOwnership, out _out107, out _out108); + r = _out107; + resultingOwnership = _out108; + readIdents = Dafny.Set>.Union(Dafny.Set>.Union(_119_exprIdents, _122_indexIdents), _125_valueIdents); return ; } goto after_match0; @@ -6225,47 +6303,47 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_MapUpdate) { - DAST._IExpression _125_expr = _source0.dtor_expr; - DAST._IExpression _126_index = _source0.dtor_indexExpr; - DAST._IExpression _127_value = _source0.dtor_value; + DAST._IExpression _126_expr = _source0.dtor_expr; + DAST._IExpression _127_index = _source0.dtor_indexExpr; + DAST._IExpression _128_value = _source0.dtor_value; { - RAST._IExpr _128_exprR; - DCOMP._IOwnership _129___v184; - Dafny.ISet> _130_exprIdents; - RAST._IExpr _out106; - DCOMP._IOwnership _out107; - Dafny.ISet> _out108; - (this).GenExpr(_125_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out106, out _out107, out _out108); - _128_exprR = _out106; - _129___v184 = _out107; - _130_exprIdents = _out108; - RAST._IExpr _131_indexR; - DCOMP._IOwnership _132_indexOwnership; - Dafny.ISet> _133_indexIdents; + RAST._IExpr _129_exprR; + DCOMP._IOwnership _130___v165; + Dafny.ISet> _131_exprIdents; RAST._IExpr _out109; DCOMP._IOwnership _out110; Dafny.ISet> _out111; - (this).GenExpr(_126_index, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out109, out _out110, out _out111); - _131_indexR = _out109; - _132_indexOwnership = _out110; - _133_indexIdents = _out111; - RAST._IExpr _134_valueR; - DCOMP._IOwnership _135_valueOwnership; - Dafny.ISet> _136_valueIdents; + (this).GenExpr(_126_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out109, out _out110, out _out111); + _129_exprR = _out109; + _130___v165 = _out110; + _131_exprIdents = _out111; + RAST._IExpr _132_indexR; + DCOMP._IOwnership _133_indexOwnership; + Dafny.ISet> _134_indexIdents; RAST._IExpr _out112; DCOMP._IOwnership _out113; Dafny.ISet> _out114; - (this).GenExpr(_127_value, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out112, out _out113, out _out114); - _134_valueR = _out112; - _135_valueOwnership = _out113; - _136_valueIdents = _out114; - r = ((_128_exprR).Sel(Dafny.Sequence.UnicodeFromString("update_index"))).Apply(Dafny.Sequence.FromElements(_131_indexR, _134_valueR)); + (this).GenExpr(_127_index, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out112, out _out113, out _out114); + _132_indexR = _out112; + _133_indexOwnership = _out113; + _134_indexIdents = _out114; + RAST._IExpr _135_valueR; + DCOMP._IOwnership _136_valueOwnership; + Dafny.ISet> _137_valueIdents; RAST._IExpr _out115; DCOMP._IOwnership _out116; - (this).FromOwned(r, expectedOwnership, out _out115, out _out116); - r = _out115; - resultingOwnership = _out116; - readIdents = Dafny.Set>.Union(Dafny.Set>.Union(_130_exprIdents, _133_indexIdents), _136_valueIdents); + Dafny.ISet> _out117; + (this).GenExpr(_128_value, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out115, out _out116, out _out117); + _135_valueR = _out115; + _136_valueOwnership = _out116; + _137_valueIdents = _out117; + r = ((_129_exprR).Sel(Dafny.Sequence.UnicodeFromString("update_index"))).Apply(Dafny.Sequence.FromElements(_132_indexR, _135_valueR)); + RAST._IExpr _out118; + DCOMP._IOwnership _out119; + (this).FromOwned(r, expectedOwnership, out _out118, out _out119); + r = _out118; + resultingOwnership = _out119; + readIdents = Dafny.Set>.Union(Dafny.Set>.Union(_131_exprIdents, _134_indexIdents), _137_valueIdents); return ; } goto after_match0; @@ -6277,29 +6355,31 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv DCOMP._ISelfInfo _source1 = selfIdent; { if (_source1.is_ThisTyped) { - Dafny.ISequence _137_id = _source1.dtor_rSelfName; - DAST._IType _138_dafnyType = _source1.dtor_dafnyType; + Dafny.ISequence _138_id = _source1.dtor_rSelfName; + DAST._IType _139_dafnyType = _source1.dtor_dafnyType; { - RAST._IExpr _out117; - DCOMP._IOwnership _out118; - Dafny.ISet> _out119; - (this).GenIdent(_137_id, selfIdent, env, expectedOwnership, out _out117, out _out118, out _out119); - r = _out117; - resultingOwnership = _out118; - readIdents = _out119; + RAST._IExpr _out120; + DCOMP._IOwnership _out121; + Dafny.ISet> _out122; + (this).GenIdent(_138_id, selfIdent, env, expectedOwnership, out _out120, out _out121, out _out122); + r = _out120; + resultingOwnership = _out121; + readIdents = _out122; } goto after_match1; } } { - DCOMP._ISelfInfo _139_None = _source1; + DCOMP._ISelfInfo _140_None = _source1; { - r = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("panic!(\"this outside of a method\")")); - RAST._IExpr _out120; - DCOMP._IOwnership _out121; - (this).FromOwned(r, expectedOwnership, out _out120, out _out121); - r = _out120; - resultingOwnership = _out121; + RAST._IExpr _out123; + _out123 = (this).Error(Dafny.Sequence.UnicodeFromString("this outside of a method"), (this).InitEmptyExpr()); + r = _out123; + RAST._IExpr _out124; + DCOMP._IOwnership _out125; + (this).FromOwned(r, expectedOwnership, out _out124, out _out125); + r = _out124; + resultingOwnership = _out125; readIdents = Dafny.Set>.FromElements(); } } @@ -6311,47 +6391,47 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_Ite) { - DAST._IExpression _140_cond = _source0.dtor_cond; - DAST._IExpression _141_t = _source0.dtor_thn; - DAST._IExpression _142_f = _source0.dtor_els; + DAST._IExpression _141_cond = _source0.dtor_cond; + DAST._IExpression _142_t = _source0.dtor_thn; + DAST._IExpression _143_f = _source0.dtor_els; { - RAST._IExpr _143_cond; - DCOMP._IOwnership _144___v185; - Dafny.ISet> _145_recIdentsCond; - RAST._IExpr _out122; - DCOMP._IOwnership _out123; - Dafny.ISet> _out124; - (this).GenExpr(_140_cond, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out122, out _out123, out _out124); - _143_cond = _out122; - _144___v185 = _out123; - _145_recIdentsCond = _out124; - RAST._IExpr _146_fExpr; - DCOMP._IOwnership _147_fOwned; - Dafny.ISet> _148_recIdentsF; - RAST._IExpr _out125; - DCOMP._IOwnership _out126; - Dafny.ISet> _out127; - (this).GenExpr(_142_f, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out125, out _out126, out _out127); - _146_fExpr = _out125; - _147_fOwned = _out126; - _148_recIdentsF = _out127; - RAST._IExpr _149_tExpr; - DCOMP._IOwnership _150___v186; - Dafny.ISet> _151_recIdentsT; - RAST._IExpr _out128; - DCOMP._IOwnership _out129; - Dafny.ISet> _out130; - (this).GenExpr(_141_t, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out128, out _out129, out _out130); - _149_tExpr = _out128; - _150___v186 = _out129; - _151_recIdentsT = _out130; - r = RAST.Expr.create_IfExpr(_143_cond, _149_tExpr, _146_fExpr); - RAST._IExpr _out131; - DCOMP._IOwnership _out132; - (this).FromOwnership(r, DCOMP.Ownership.create_OwnershipOwned(), expectedOwnership, out _out131, out _out132); - r = _out131; - resultingOwnership = _out132; - readIdents = Dafny.Set>.Union(Dafny.Set>.Union(_145_recIdentsCond, _151_recIdentsT), _148_recIdentsF); + RAST._IExpr _144_cond; + DCOMP._IOwnership _145___v166; + Dafny.ISet> _146_recIdentsCond; + RAST._IExpr _out126; + DCOMP._IOwnership _out127; + Dafny.ISet> _out128; + (this).GenExpr(_141_cond, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out126, out _out127, out _out128); + _144_cond = _out126; + _145___v166 = _out127; + _146_recIdentsCond = _out128; + RAST._IExpr _147_fExpr; + DCOMP._IOwnership _148_fOwned; + Dafny.ISet> _149_recIdentsF; + RAST._IExpr _out129; + DCOMP._IOwnership _out130; + Dafny.ISet> _out131; + (this).GenExpr(_143_f, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out129, out _out130, out _out131); + _147_fExpr = _out129; + _148_fOwned = _out130; + _149_recIdentsF = _out131; + RAST._IExpr _150_tExpr; + DCOMP._IOwnership _151___v167; + Dafny.ISet> _152_recIdentsT; + RAST._IExpr _out132; + DCOMP._IOwnership _out133; + Dafny.ISet> _out134; + (this).GenExpr(_142_t, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out132, out _out133, out _out134); + _150_tExpr = _out132; + _151___v167 = _out133; + _152_recIdentsT = _out134; + r = RAST.Expr.create_IfExpr(_144_cond, _150_tExpr, _147_fExpr); + RAST._IExpr _out135; + DCOMP._IOwnership _out136; + (this).FromOwnership(r, DCOMP.Ownership.create_OwnershipOwned(), expectedOwnership, out _out135, out _out136); + r = _out135; + resultingOwnership = _out136; + readIdents = Dafny.Set>.Union(Dafny.Set>.Union(_146_recIdentsCond, _152_recIdentsT), _149_recIdentsF); return ; } goto after_match0; @@ -6361,26 +6441,26 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv if (_source0.is_UnOp) { DAST._IUnaryOp unOp0 = _source0.dtor_unOp; if (unOp0.is_Not) { - DAST._IExpression _152_e = _source0.dtor_expr; - DAST.Format._IUnaryOpFormat _153_format = _source0.dtor_format1; + DAST._IExpression _153_e = _source0.dtor_expr; + DAST.Format._IUnaryOpFormat _154_format = _source0.dtor_format1; { - RAST._IExpr _154_recursiveGen; - DCOMP._IOwnership _155___v187; - Dafny.ISet> _156_recIdents; - RAST._IExpr _out133; - DCOMP._IOwnership _out134; - Dafny.ISet> _out135; - (this).GenExpr(_152_e, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out133, out _out134, out _out135); - _154_recursiveGen = _out133; - _155___v187 = _out134; - _156_recIdents = _out135; - r = RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), _154_recursiveGen, _153_format); - RAST._IExpr _out136; - DCOMP._IOwnership _out137; - (this).FromOwned(r, expectedOwnership, out _out136, out _out137); - r = _out136; - resultingOwnership = _out137; - readIdents = _156_recIdents; + RAST._IExpr _155_recursiveGen; + DCOMP._IOwnership _156___v168; + Dafny.ISet> _157_recIdents; + RAST._IExpr _out137; + DCOMP._IOwnership _out138; + Dafny.ISet> _out139; + (this).GenExpr(_153_e, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out137, out _out138, out _out139); + _155_recursiveGen = _out137; + _156___v168 = _out138; + _157_recIdents = _out139; + r = RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("!"), _155_recursiveGen, _154_format); + RAST._IExpr _out140; + DCOMP._IOwnership _out141; + (this).FromOwned(r, expectedOwnership, out _out140, out _out141); + r = _out140; + resultingOwnership = _out141; + readIdents = _157_recIdents; return ; } goto after_match0; @@ -6391,26 +6471,26 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv if (_source0.is_UnOp) { DAST._IUnaryOp unOp1 = _source0.dtor_unOp; if (unOp1.is_BitwiseNot) { - DAST._IExpression _157_e = _source0.dtor_expr; - DAST.Format._IUnaryOpFormat _158_format = _source0.dtor_format1; + DAST._IExpression _158_e = _source0.dtor_expr; + DAST.Format._IUnaryOpFormat _159_format = _source0.dtor_format1; { - RAST._IExpr _159_recursiveGen; - DCOMP._IOwnership _160___v188; - Dafny.ISet> _161_recIdents; - RAST._IExpr _out138; - DCOMP._IOwnership _out139; - Dafny.ISet> _out140; - (this).GenExpr(_157_e, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out138, out _out139, out _out140); - _159_recursiveGen = _out138; - _160___v188 = _out139; - _161_recIdents = _out140; - r = RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("~"), _159_recursiveGen, _158_format); - RAST._IExpr _out141; - DCOMP._IOwnership _out142; - (this).FromOwned(r, expectedOwnership, out _out141, out _out142); - r = _out141; - resultingOwnership = _out142; - readIdents = _161_recIdents; + RAST._IExpr _160_recursiveGen; + DCOMP._IOwnership _161___v169; + Dafny.ISet> _162_recIdents; + RAST._IExpr _out142; + DCOMP._IOwnership _out143; + Dafny.ISet> _out144; + (this).GenExpr(_158_e, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out142, out _out143, out _out144); + _160_recursiveGen = _out142; + _161___v169 = _out143; + _162_recIdents = _out144; + r = RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("~"), _160_recursiveGen, _159_format); + RAST._IExpr _out145; + DCOMP._IOwnership _out146; + (this).FromOwned(r, expectedOwnership, out _out145, out _out146); + r = _out145; + resultingOwnership = _out146; + readIdents = _162_recIdents; return ; } goto after_match0; @@ -6421,26 +6501,26 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv if (_source0.is_UnOp) { DAST._IUnaryOp unOp2 = _source0.dtor_unOp; if (unOp2.is_Cardinality) { - DAST._IExpression _162_e = _source0.dtor_expr; - DAST.Format._IUnaryOpFormat _163_format = _source0.dtor_format1; + DAST._IExpression _163_e = _source0.dtor_expr; + DAST.Format._IUnaryOpFormat _164_format = _source0.dtor_format1; { - RAST._IExpr _164_recursiveGen; - DCOMP._IOwnership _165_recOwned; - Dafny.ISet> _166_recIdents; - RAST._IExpr _out143; - DCOMP._IOwnership _out144; - Dafny.ISet> _out145; - (this).GenExpr(_162_e, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out143, out _out144, out _out145); - _164_recursiveGen = _out143; - _165_recOwned = _out144; - _166_recIdents = _out145; - r = ((_164_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("cardinality"))).Apply(Dafny.Sequence.FromElements()); - RAST._IExpr _out146; - DCOMP._IOwnership _out147; - (this).FromOwned(r, expectedOwnership, out _out146, out _out147); - r = _out146; - resultingOwnership = _out147; - readIdents = _166_recIdents; + RAST._IExpr _165_recursiveGen; + DCOMP._IOwnership _166_recOwned; + Dafny.ISet> _167_recIdents; + RAST._IExpr _out147; + DCOMP._IOwnership _out148; + Dafny.ISet> _out149; + (this).GenExpr(_163_e, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out147, out _out148, out _out149); + _165_recursiveGen = _out147; + _166_recOwned = _out148; + _167_recIdents = _out149; + r = ((_165_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("cardinality"))).Apply0(); + RAST._IExpr _out150; + DCOMP._IOwnership _out151; + (this).FromOwned(r, expectedOwnership, out _out150, out _out151); + r = _out150; + resultingOwnership = _out151; + readIdents = _167_recIdents; return ; } goto after_match0; @@ -6449,64 +6529,63 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_BinOp) { - RAST._IExpr _out148; - DCOMP._IOwnership _out149; - Dafny.ISet> _out150; - (this).GenExprBinary(e, selfIdent, env, expectedOwnership, out _out148, out _out149, out _out150); - r = _out148; - resultingOwnership = _out149; - readIdents = _out150; + RAST._IExpr _out152; + DCOMP._IOwnership _out153; + Dafny.ISet> _out154; + (this).GenExprBinary(e, selfIdent, env, expectedOwnership, out _out152, out _out153, out _out154); + r = _out152; + resultingOwnership = _out153; + readIdents = _out154; goto after_match0; } } { if (_source0.is_ArrayLen) { - DAST._IExpression _167_expr = _source0.dtor_expr; - DAST._IType _168_exprType = _source0.dtor_exprType; - BigInteger _169_dim = _source0.dtor_dim; - bool _170_native = _source0.dtor_native; + DAST._IExpression _168_expr = _source0.dtor_expr; + DAST._IType _169_exprType = _source0.dtor_exprType; + BigInteger _170_dim = _source0.dtor_dim; + bool _171_native = _source0.dtor_native; { - RAST._IExpr _171_recursiveGen; - DCOMP._IOwnership _172___v193; - Dafny.ISet> _173_recIdents; - RAST._IExpr _out151; - DCOMP._IOwnership _out152; - Dafny.ISet> _out153; - (this).GenExpr(_167_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out151, out _out152, out _out153); - _171_recursiveGen = _out151; - _172___v193 = _out152; - _173_recIdents = _out153; - RAST._IType _174_arrayType; - RAST._IType _out154; - _out154 = (this).GenType(_168_exprType, DCOMP.GenTypeContext.@default()); - _174_arrayType = _out154; - if (!((_174_arrayType).IsObjectOrPointer())) { - Dafny.ISequence _175_msg; - _175_msg = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Array length of something not an array but "), (_174_arrayType)._ToString(DCOMP.__default.IND)); - (this).error = Std.Wrappers.Option>.create_Some(_175_msg); - r = RAST.Expr.create_RawExpr(_175_msg); + RAST._IExpr _172_recursiveGen; + DCOMP._IOwnership _173___v174; + Dafny.ISet> _174_recIdents; + RAST._IExpr _out155; + DCOMP._IOwnership _out156; + Dafny.ISet> _out157; + (this).GenExpr(_168_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out155, out _out156, out _out157); + _172_recursiveGen = _out155; + _173___v174 = _out156; + _174_recIdents = _out157; + RAST._IType _175_arrayType; + RAST._IType _out158; + _out158 = (this).GenType(_169_exprType, DCOMP.GenTypeContext.@default()); + _175_arrayType = _out158; + if (!((_175_arrayType).IsObjectOrPointer())) { + RAST._IExpr _out159; + _out159 = (this).Error(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Array length of something not an array but "), (_175_arrayType)._ToString(DCOMP.__default.IND)), (this).InitEmptyExpr()); + r = _out159; } else { RAST._IType _176_underlying; - _176_underlying = (_174_arrayType).ObjectOrPointerUnderlying(); - if (((_169_dim).Sign == 0) && ((_176_underlying).is_Array)) { - r = ((((this).read__macro).Apply1(_171_recursiveGen)).Sel(Dafny.Sequence.UnicodeFromString("len"))).Apply(Dafny.Sequence.FromElements()); + _176_underlying = (_175_arrayType).ObjectOrPointerUnderlying(); + if (((_170_dim).Sign == 0) && ((_176_underlying).is_Array)) { + r = ((((this).read__macro).Apply1(_172_recursiveGen)).Sel(Dafny.Sequence.UnicodeFromString("len"))).Apply0(); } else { - if ((_169_dim).Sign == 0) { - r = (((((this).read__macro).Apply1(_171_recursiveGen)).Sel(Dafny.Sequence.UnicodeFromString("data"))).Sel(Dafny.Sequence.UnicodeFromString("len"))).Apply(Dafny.Sequence.FromElements()); + if ((_170_dim).Sign == 0) { + r = (((((this).read__macro).Apply1(_172_recursiveGen)).Sel(Dafny.Sequence.UnicodeFromString("data"))).Sel(Dafny.Sequence.UnicodeFromString("len"))).Apply0(); } else { - r = ((((this).read__macro).Apply1(_171_recursiveGen)).Sel(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("length"), Std.Strings.__default.OfNat(_169_dim)), Dafny.Sequence.UnicodeFromString("_usize")))).Apply(Dafny.Sequence.FromElements()); + r = ((((this).read__macro).Apply1(_172_recursiveGen)).Sel(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("length"), Std.Strings.__default.OfNat(_170_dim)), Dafny.Sequence.UnicodeFromString("_usize")))).Apply0(); } } - if (!(_170_native)) { + if (!(_171_native)) { r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("int!"))).AsExpr()).Apply1(r); } } - RAST._IExpr _out155; - DCOMP._IOwnership _out156; - (this).FromOwned(r, expectedOwnership, out _out155, out _out156); - r = _out155; - resultingOwnership = _out156; - readIdents = _173_recIdents; + RAST._IExpr _out160; + DCOMP._IOwnership _out161; + (this).FromOwned(r, expectedOwnership, out _out160, out _out161); + r = _out160; + resultingOwnership = _out161; + readIdents = _174_recIdents; return ; } goto after_match0; @@ -6517,22 +6596,22 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv DAST._IExpression _177_expr = _source0.dtor_expr; { RAST._IExpr _178_recursiveGen; - DCOMP._IOwnership _179___v194; + DCOMP._IOwnership _179___v175; Dafny.ISet> _180_recIdents; - RAST._IExpr _out157; - DCOMP._IOwnership _out158; - Dafny.ISet> _out159; - (this).GenExpr(_177_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out157, out _out158, out _out159); - _178_recursiveGen = _out157; - _179___v194 = _out158; - _180_recIdents = _out159; + RAST._IExpr _out162; + DCOMP._IOwnership _out163; + Dafny.ISet> _out164; + (this).GenExpr(_177_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out162, out _out163, out _out164); + _178_recursiveGen = _out162; + _179___v175 = _out163; + _180_recIdents = _out164; readIdents = _180_recIdents; - r = ((_178_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("keys"))).Apply(Dafny.Sequence.FromElements()); - RAST._IExpr _out160; - DCOMP._IOwnership _out161; - (this).FromOwned(r, expectedOwnership, out _out160, out _out161); - r = _out160; - resultingOwnership = _out161; + r = ((_178_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("keys"))).Apply0(); + RAST._IExpr _out165; + DCOMP._IOwnership _out166; + (this).FromOwned(r, expectedOwnership, out _out165, out _out166); + r = _out165; + resultingOwnership = _out166; return ; } goto after_match0; @@ -6543,22 +6622,22 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv DAST._IExpression _181_expr = _source0.dtor_expr; { RAST._IExpr _182_recursiveGen; - DCOMP._IOwnership _183___v195; + DCOMP._IOwnership _183___v176; Dafny.ISet> _184_recIdents; - RAST._IExpr _out162; - DCOMP._IOwnership _out163; - Dafny.ISet> _out164; - (this).GenExpr(_181_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out162, out _out163, out _out164); - _182_recursiveGen = _out162; - _183___v195 = _out163; - _184_recIdents = _out164; + RAST._IExpr _out167; + DCOMP._IOwnership _out168; + Dafny.ISet> _out169; + (this).GenExpr(_181_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out167, out _out168, out _out169); + _182_recursiveGen = _out167; + _183___v176 = _out168; + _184_recIdents = _out169; readIdents = _184_recIdents; - r = ((_182_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("values"))).Apply(Dafny.Sequence.FromElements()); - RAST._IExpr _out165; - DCOMP._IOwnership _out166; - (this).FromOwned(r, expectedOwnership, out _out165, out _out166); - r = _out165; - resultingOwnership = _out166; + r = ((_182_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("values"))).Apply0(); + RAST._IExpr _out170; + DCOMP._IOwnership _out171; + (this).FromOwned(r, expectedOwnership, out _out170, out _out171); + r = _out170; + resultingOwnership = _out171; return ; } goto after_match0; @@ -6569,22 +6648,22 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv DAST._IExpression _185_expr = _source0.dtor_expr; { RAST._IExpr _186_recursiveGen; - DCOMP._IOwnership _187___v196; + DCOMP._IOwnership _187___v177; Dafny.ISet> _188_recIdents; - RAST._IExpr _out167; - DCOMP._IOwnership _out168; - Dafny.ISet> _out169; - (this).GenExpr(_185_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out167, out _out168, out _out169); - _186_recursiveGen = _out167; - _187___v196 = _out168; - _188_recIdents = _out169; + RAST._IExpr _out172; + DCOMP._IOwnership _out173; + Dafny.ISet> _out174; + (this).GenExpr(_185_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out172, out _out173, out _out174); + _186_recursiveGen = _out172; + _187___v177 = _out173; + _188_recIdents = _out174; readIdents = _188_recIdents; - r = ((_186_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("items"))).Apply(Dafny.Sequence.FromElements()); - RAST._IExpr _out170; - DCOMP._IOwnership _out171; - (this).FromOwned(r, expectedOwnership, out _out170, out _out171); - r = _out170; - resultingOwnership = _out171; + r = ((_186_recursiveGen).Sel(Dafny.Sequence.UnicodeFromString("items"))).Apply0(); + RAST._IExpr _out175; + DCOMP._IOwnership _out176; + (this).FromOwned(r, expectedOwnership, out _out175, out _out176); + r = _out175; + resultingOwnership = _out176; return ; } goto after_match0; @@ -6602,99 +6681,89 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv RAST._IExpr _195_onExpr; DCOMP._IOwnership _196_onOwned; Dafny.ISet> _197_recIdents; - RAST._IExpr _out172; - DCOMP._IOwnership _out173; - Dafny.ISet> _out174; - (this).GenExpr(_189_on, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out172, out _out173, out _out174); - _195_onExpr = _out172; - _196_onOwned = _out173; - _197_recIdents = _out174; - Dafny.ISequence _198_s = Dafny.Sequence.Empty; - Dafny.ISequence _199_onString; - _199_onString = (_195_onExpr)._ToString(DCOMP.__default.IND); + RAST._IExpr _out177; + DCOMP._IOwnership _out178; + Dafny.ISet> _out179; + (this).GenExpr(_189_on, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out177, out _out178, out _out179); + _195_onExpr = _out177; + _196_onOwned = _out178; + _197_recIdents = _out179; + Dafny.ISequence _198_onString; + _198_onString = (_195_onExpr)._ToString(DCOMP.__default.IND); + DCOMP._IEnvironment _199_lEnv; + _199_lEnv = env; + Dafny.ISequence<_System._ITuple2, RAST._IType>> _200_args; + _200_args = Dafny.Sequence<_System._ITuple2, RAST._IType>>.FromElements(); + Dafny.ISequence _201_parameters; + _201_parameters = Dafny.Sequence.FromElements(); + BigInteger _hi7 = new BigInteger((_194_arguments).Count); + for (BigInteger _202_i = BigInteger.Zero; _202_i < _hi7; _202_i++) { + RAST._IType _203_ty; + RAST._IType _out180; + _out180 = (this).GenType((_194_arguments).Select(_202_i), DCOMP.GenTypeContext.@default()); + _203_ty = _out180; + RAST._IType _204_bTy; + _204_bTy = RAST.Type.create_Borrowed(_203_ty); + Dafny.ISequence _205_name; + _205_name = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("x"), Std.Strings.__default.OfInt(_202_i)); + _199_lEnv = (_199_lEnv).AddAssigned(_205_name, _204_bTy); + _201_parameters = Dafny.Sequence.Concat(_201_parameters, Dafny.Sequence.FromElements(RAST.Formal.create(_205_name, _204_bTy))); + _200_args = Dafny.Sequence<_System._ITuple2, RAST._IType>>.Concat(_200_args, Dafny.Sequence<_System._ITuple2, RAST._IType>>.FromElements(_System.Tuple2, RAST._IType>.create(_205_name, _203_ty))); + } + RAST._IExpr _206_body; if (_192_isStatic) { - DCOMP._IEnvironment _200_lEnv; - _200_lEnv = env; - Dafny.ISequence<_System._ITuple2, RAST._IType>> _201_args; - _201_args = Dafny.Sequence<_System._ITuple2, RAST._IType>>.FromElements(); - _198_s = Dafny.Sequence.UnicodeFromString("|"); - BigInteger _hi7 = new BigInteger((_194_arguments).Count); - for (BigInteger _202_i = BigInteger.Zero; _202_i < _hi7; _202_i++) { - if ((_202_i).Sign == 1) { - _198_s = Dafny.Sequence.Concat(_198_s, Dafny.Sequence.UnicodeFromString(", ")); - } - RAST._IType _203_ty; - RAST._IType _out175; - _out175 = (this).GenType((_194_arguments).Select(_202_i), DCOMP.GenTypeContext.@default()); - _203_ty = _out175; - RAST._IType _204_bTy; - _204_bTy = RAST.Type.create_Borrowed(_203_ty); - Dafny.ISequence _205_name; - _205_name = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("x"), Std.Strings.__default.OfInt(_202_i)); - _200_lEnv = (_200_lEnv).AddAssigned(_205_name, _204_bTy); - _201_args = Dafny.Sequence<_System._ITuple2, RAST._IType>>.Concat(_201_args, Dafny.Sequence<_System._ITuple2, RAST._IType>>.FromElements(_System.Tuple2, RAST._IType>.create(_205_name, _203_ty))); - _198_s = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_198_s, _205_name), Dafny.Sequence.UnicodeFromString(": ")), (_204_bTy)._ToString(DCOMP.__default.IND)); - } - _198_s = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_198_s, Dafny.Sequence.UnicodeFromString("| ")), _199_onString), Dafny.Sequence.UnicodeFromString("::")), DCOMP.__default.escapeVar(_190_field)), ((_193_isConstant) ? (Dafny.Sequence.UnicodeFromString("()")) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString("(")); - BigInteger _hi8 = new BigInteger((_201_args).Count); - for (BigInteger _206_i = BigInteger.Zero; _206_i < _hi8; _206_i++) { - if ((_206_i).Sign == 1) { - _198_s = Dafny.Sequence.Concat(_198_s, Dafny.Sequence.UnicodeFromString(", ")); - } - _System._ITuple2, RAST._IType> _let_tmp_rhs1 = (_201_args).Select(_206_i); - Dafny.ISequence _207_name = _let_tmp_rhs1.dtor__0; - RAST._IType _208_ty = _let_tmp_rhs1.dtor__1; - RAST._IExpr _209_rIdent; - DCOMP._IOwnership _210___v197; - Dafny.ISet> _211___v198; - RAST._IExpr _out176; - DCOMP._IOwnership _out177; - Dafny.ISet> _out178; - (this).GenIdent(_207_name, selfIdent, _200_lEnv, (((_208_ty).CanReadWithoutClone()) ? (DCOMP.Ownership.create_OwnershipOwned()) : (DCOMP.Ownership.create_OwnershipBorrowed())), out _out176, out _out177, out _out178); - _209_rIdent = _out176; - _210___v197 = _out177; - _211___v198 = _out178; - _198_s = Dafny.Sequence.Concat(_198_s, (_209_rIdent)._ToString(DCOMP.__default.IND)); - } - _198_s = Dafny.Sequence.Concat(_198_s, Dafny.Sequence.UnicodeFromString(")")); + _206_body = (_195_onExpr).FSel(DCOMP.__default.escapeVar(_190_field)); } else { - _198_s = Dafny.Sequence.UnicodeFromString("{\n"); - _198_s = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_198_s, Dafny.Sequence.UnicodeFromString("let callTarget = (")), _199_onString), ((object.Equals(_196_onOwned, DCOMP.Ownership.create_OwnershipOwned())) ? (Dafny.Sequence.UnicodeFromString(")")) : (Dafny.Sequence.UnicodeFromString(").clone()")))), Dafny.Sequence.UnicodeFromString(";\n")); - Dafny.ISequence _212_args; - _212_args = Dafny.Sequence.UnicodeFromString(""); - BigInteger _213_i; - _213_i = BigInteger.Zero; - while ((_213_i) < (new BigInteger((_194_arguments).Count))) { - if ((_213_i).Sign == 1) { - _212_args = Dafny.Sequence.Concat(_212_args, Dafny.Sequence.UnicodeFromString(", ")); - } - _212_args = Dafny.Sequence.Concat(Dafny.Sequence.Concat(_212_args, Dafny.Sequence.UnicodeFromString("arg")), Std.Strings.__default.OfNat(_213_i)); - _213_i = (_213_i) + (BigInteger.One); - } - _198_s = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_198_s, Dafny.Sequence.UnicodeFromString("move |")), _212_args), Dafny.Sequence.UnicodeFromString("| {\n")); - _198_s = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_198_s, Dafny.Sequence.UnicodeFromString("callTarget.")), DCOMP.__default.escapeVar(_190_field)), ((_193_isConstant) ? (Dafny.Sequence.UnicodeFromString("()")) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString("(")), _212_args), Dafny.Sequence.UnicodeFromString(")\n")); - _198_s = Dafny.Sequence.Concat(_198_s, Dafny.Sequence.UnicodeFromString("}\n")); - _198_s = Dafny.Sequence.Concat(_198_s, Dafny.Sequence.UnicodeFromString("}")); - } - Dafny.ISequence _214_typeShape; - _214_typeShape = Dafny.Sequence.UnicodeFromString("dyn ::std::ops::Fn("); - BigInteger _215_i; - _215_i = BigInteger.Zero; - while ((_215_i) < (new BigInteger((_194_arguments).Count))) { - if ((_215_i).Sign == 1) { - _214_typeShape = Dafny.Sequence.Concat(_214_typeShape, Dafny.Sequence.UnicodeFromString(", ")); + _206_body = (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("callTarget"))).Sel(DCOMP.__default.escapeVar(_190_field)); + } + if (_193_isConstant) { + _206_body = (_206_body).Apply0(); + } + Dafny.ISequence _207_onExprArgs; + _207_onExprArgs = Dafny.Sequence.FromElements(); + BigInteger _hi8 = new BigInteger((_200_args).Count); + for (BigInteger _208_i = BigInteger.Zero; _208_i < _hi8; _208_i++) { + _System._ITuple2, RAST._IType> _let_tmp_rhs1 = (_200_args).Select(_208_i); + Dafny.ISequence _209_name = _let_tmp_rhs1.dtor__0; + RAST._IType _210_ty = _let_tmp_rhs1.dtor__1; + RAST._IExpr _211_rIdent; + DCOMP._IOwnership _212___v178; + Dafny.ISet> _213___v179; + RAST._IExpr _out181; + DCOMP._IOwnership _out182; + Dafny.ISet> _out183; + (this).GenIdent(_209_name, selfIdent, _199_lEnv, (((_210_ty).CanReadWithoutClone()) ? (DCOMP.Ownership.create_OwnershipOwned()) : (DCOMP.Ownership.create_OwnershipBorrowed())), out _out181, out _out182, out _out183); + _211_rIdent = _out181; + _212___v178 = _out182; + _213___v179 = _out183; + _207_onExprArgs = Dafny.Sequence.Concat(_207_onExprArgs, Dafny.Sequence.FromElements(_211_rIdent)); + } + _206_body = (_206_body).Apply(_207_onExprArgs); + r = RAST.Expr.create_Lambda(_201_parameters, Std.Wrappers.Option.create_None(), _206_body); + if (_192_isStatic) { + } else { + RAST._IExpr _214_target; + if (object.Equals(_196_onOwned, DCOMP.Ownership.create_OwnershipOwned())) { + _214_target = _195_onExpr; + } else { + _214_target = (_195_onExpr).Clone(); } - _214_typeShape = Dafny.Sequence.Concat(_214_typeShape, Dafny.Sequence.UnicodeFromString("&_")); - _215_i = (_215_i) + (BigInteger.One); - } - _214_typeShape = Dafny.Sequence.Concat(_214_typeShape, Dafny.Sequence.UnicodeFromString(") -> _")); - _198_s = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::std::rc::Rc::new("), _198_s), Dafny.Sequence.UnicodeFromString(") as ::std::rc::Rc<")), _214_typeShape), Dafny.Sequence.UnicodeFromString(">")); - r = RAST.Expr.create_RawExpr(_198_s); - RAST._IExpr _out179; - DCOMP._IOwnership _out180; - (this).FromOwned(r, expectedOwnership, out _out179, out _out180); - r = _out179; - resultingOwnership = _out180; + r = RAST.Expr.create_Block((RAST.Expr.create_DeclareVar(RAST.DeclareType.create_CONST(), Dafny.Sequence.UnicodeFromString("callTarget"), Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(_214_target))).Then(r)); + } + Dafny.ISequence _215_typeShapeArgs; + _215_typeShapeArgs = Dafny.Sequence.FromElements(); + BigInteger _hi9 = new BigInteger((_194_arguments).Count); + for (BigInteger _216_i = BigInteger.Zero; _216_i < _hi9; _216_i++) { + _215_typeShapeArgs = Dafny.Sequence.Concat(_215_typeShapeArgs, Dafny.Sequence.FromElements(RAST.Type.create_Borrowed(RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("_"))))); + } + RAST._IType _217_typeShape; + _217_typeShape = RAST.Type.create_DynType(RAST.Type.create_FnType(_215_typeShapeArgs, RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("_")))); + r = RAST.Expr.create_TypeAscription((RAST.__default.std__rc__Rc__new).Apply1(r), ((RAST.__default.std__rc__Rc).AsType()).Apply(Dafny.Sequence.FromElements(_217_typeShape))); + RAST._IExpr _out184; + DCOMP._IOwnership _out185; + (this).FromOwned(r, expectedOwnership, out _out184, out _out185); + r = _out184; + resultingOwnership = _out185; readIdents = _197_recIdents; return ; } @@ -6703,67 +6772,67 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_Select) { - DAST._IExpression _216_on = _source0.dtor_expr; - Dafny.ISequence _217_field = _source0.dtor_field; - bool _218_isConstant = _source0.dtor_isConstant; - bool _219_isDatatype = _source0.dtor_onDatatype; - DAST._IType _220_fieldType = _source0.dtor_fieldType; + DAST._IExpression _218_on = _source0.dtor_expr; + Dafny.ISequence _219_field = _source0.dtor_field; + bool _220_isConstant = _source0.dtor_isConstant; + bool _221_isDatatype = _source0.dtor_onDatatype; + DAST._IType _222_fieldType = _source0.dtor_fieldType; { - if (((_216_on).is_Companion) || ((_216_on).is_ExternCompanion)) { - RAST._IExpr _221_onExpr; - DCOMP._IOwnership _222_onOwned; - Dafny.ISet> _223_recIdents; - RAST._IExpr _out181; - DCOMP._IOwnership _out182; - Dafny.ISet> _out183; - (this).GenExpr(_216_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out181, out _out182, out _out183); - _221_onExpr = _out181; - _222_onOwned = _out182; - _223_recIdents = _out183; - r = ((_221_onExpr).FSel(DCOMP.__default.escapeVar(_217_field))).Apply(Dafny.Sequence.FromElements()); - RAST._IExpr _out184; - DCOMP._IOwnership _out185; - (this).FromOwned(r, expectedOwnership, out _out184, out _out185); - r = _out184; - resultingOwnership = _out185; - readIdents = _223_recIdents; - return ; - } else if (_219_isDatatype) { - RAST._IExpr _224_onExpr; - DCOMP._IOwnership _225_onOwned; - Dafny.ISet> _226_recIdents; + if (((_218_on).is_Companion) || ((_218_on).is_ExternCompanion)) { + RAST._IExpr _223_onExpr; + DCOMP._IOwnership _224_onOwned; + Dafny.ISet> _225_recIdents; RAST._IExpr _out186; DCOMP._IOwnership _out187; Dafny.ISet> _out188; - (this).GenExpr(_216_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out186, out _out187, out _out188); - _224_onExpr = _out186; - _225_onOwned = _out187; - _226_recIdents = _out188; - r = ((_224_onExpr).Sel(DCOMP.__default.escapeVar(_217_field))).Apply(Dafny.Sequence.FromElements()); - RAST._IType _227_typ; - RAST._IType _out189; - _out189 = (this).GenType(_220_fieldType, DCOMP.GenTypeContext.@default()); - _227_typ = _out189; - RAST._IExpr _out190; - DCOMP._IOwnership _out191; - (this).FromOwnership(r, DCOMP.Ownership.create_OwnershipBorrowed(), expectedOwnership, out _out190, out _out191); - r = _out190; - resultingOwnership = _out191; - readIdents = _226_recIdents; + (this).GenExpr(_218_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out186, out _out187, out _out188); + _223_onExpr = _out186; + _224_onOwned = _out187; + _225_recIdents = _out188; + r = ((_223_onExpr).FSel(DCOMP.__default.escapeVar(_219_field))).Apply0(); + RAST._IExpr _out189; + DCOMP._IOwnership _out190; + (this).FromOwned(r, expectedOwnership, out _out189, out _out190); + r = _out189; + resultingOwnership = _out190; + readIdents = _225_recIdents; + return ; + } else if (_221_isDatatype) { + RAST._IExpr _226_onExpr; + DCOMP._IOwnership _227_onOwned; + Dafny.ISet> _228_recIdents; + RAST._IExpr _out191; + DCOMP._IOwnership _out192; + Dafny.ISet> _out193; + (this).GenExpr(_218_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out191, out _out192, out _out193); + _226_onExpr = _out191; + _227_onOwned = _out192; + _228_recIdents = _out193; + r = ((_226_onExpr).Sel(DCOMP.__default.escapeVar(_219_field))).Apply0(); + RAST._IType _229_typ; + RAST._IType _out194; + _out194 = (this).GenType(_222_fieldType, DCOMP.GenTypeContext.@default()); + _229_typ = _out194; + RAST._IExpr _out195; + DCOMP._IOwnership _out196; + (this).FromOwnership(r, DCOMP.Ownership.create_OwnershipBorrowed(), expectedOwnership, out _out195, out _out196); + r = _out195; + resultingOwnership = _out196; + readIdents = _228_recIdents; } else { - RAST._IExpr _228_onExpr; - DCOMP._IOwnership _229_onOwned; - Dafny.ISet> _230_recIdents; - RAST._IExpr _out192; - DCOMP._IOwnership _out193; - Dafny.ISet> _out194; - (this).GenExpr(_216_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out192, out _out193, out _out194); - _228_onExpr = _out192; - _229_onOwned = _out193; - _230_recIdents = _out194; - r = _228_onExpr; - if (!object.Equals(_228_onExpr, RAST.__default.self)) { - RAST._IExpr _source2 = _228_onExpr; + RAST._IExpr _230_onExpr; + DCOMP._IOwnership _231_onOwned; + Dafny.ISet> _232_recIdents; + RAST._IExpr _out197; + DCOMP._IOwnership _out198; + Dafny.ISet> _out199; + (this).GenExpr(_218_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out197, out _out198, out _out199); + _230_onExpr = _out197; + _231_onOwned = _out198; + _232_recIdents = _out199; + r = _230_onExpr; + if (!object.Equals(_230_onExpr, RAST.__default.self)) { + RAST._IExpr _source2 = _230_onExpr; { if (_source2.is_UnaryOp) { Dafny.ISequence op10 = _source2.dtor_op1; @@ -6787,17 +6856,17 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } r = ((this).read__macro).Apply1(r); } - r = (r).Sel(DCOMP.__default.escapeVar(_217_field)); - if (_218_isConstant) { - r = (r).Apply(Dafny.Sequence.FromElements()); + r = (r).Sel(DCOMP.__default.escapeVar(_219_field)); + if (_220_isConstant) { + r = (r).Apply0(); } r = (r).Clone(); - RAST._IExpr _out195; - DCOMP._IOwnership _out196; - (this).FromOwned(r, expectedOwnership, out _out195, out _out196); - r = _out195; - resultingOwnership = _out196; - readIdents = _230_recIdents; + RAST._IExpr _out200; + DCOMP._IOwnership _out201; + (this).FromOwned(r, expectedOwnership, out _out200, out _out201); + r = _out200; + resultingOwnership = _out201; + readIdents = _232_recIdents; } return ; } @@ -6806,70 +6875,70 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_Index) { - DAST._IExpression _231_on = _source0.dtor_expr; - DAST._ICollKind _232_collKind = _source0.dtor_collKind; - Dafny.ISequence _233_indices = _source0.dtor_indices; + DAST._IExpression _233_on = _source0.dtor_expr; + DAST._ICollKind _234_collKind = _source0.dtor_collKind; + Dafny.ISequence _235_indices = _source0.dtor_indices; { - RAST._IExpr _234_onExpr; - DCOMP._IOwnership _235_onOwned; - Dafny.ISet> _236_recIdents; - RAST._IExpr _out197; - DCOMP._IOwnership _out198; - Dafny.ISet> _out199; - (this).GenExpr(_231_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out197, out _out198, out _out199); - _234_onExpr = _out197; - _235_onOwned = _out198; - _236_recIdents = _out199; - readIdents = _236_recIdents; - r = _234_onExpr; - bool _237_hadArray; - _237_hadArray = false; - if (object.Equals(_232_collKind, DAST.CollKind.create_Array())) { + RAST._IExpr _236_onExpr; + DCOMP._IOwnership _237_onOwned; + Dafny.ISet> _238_recIdents; + RAST._IExpr _out202; + DCOMP._IOwnership _out203; + Dafny.ISet> _out204; + (this).GenExpr(_233_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out202, out _out203, out _out204); + _236_onExpr = _out202; + _237_onOwned = _out203; + _238_recIdents = _out204; + readIdents = _238_recIdents; + r = _236_onExpr; + bool _239_hadArray; + _239_hadArray = false; + if (object.Equals(_234_collKind, DAST.CollKind.create_Array())) { r = ((this).read__macro).Apply1(r); - _237_hadArray = true; - if ((new BigInteger((_233_indices).Count)) > (BigInteger.One)) { + _239_hadArray = true; + if ((new BigInteger((_235_indices).Count)) > (BigInteger.One)) { r = (r).Sel(Dafny.Sequence.UnicodeFromString("data")); } } - BigInteger _hi9 = new BigInteger((_233_indices).Count); - for (BigInteger _238_i = BigInteger.Zero; _238_i < _hi9; _238_i++) { - if (object.Equals(_232_collKind, DAST.CollKind.create_Array())) { - RAST._IExpr _239_idx; - DCOMP._IOwnership _240_idxOwned; - Dafny.ISet> _241_recIdentsIdx; - RAST._IExpr _out200; - DCOMP._IOwnership _out201; - Dafny.ISet> _out202; - (this).GenExpr((_233_indices).Select(_238_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out200, out _out201, out _out202); - _239_idx = _out200; - _240_idxOwned = _out201; - _241_recIdentsIdx = _out202; - _239_idx = RAST.__default.IntoUsize(_239_idx); - r = RAST.Expr.create_SelectIndex(r, _239_idx); - readIdents = Dafny.Set>.Union(readIdents, _241_recIdentsIdx); + BigInteger _hi10 = new BigInteger((_235_indices).Count); + for (BigInteger _240_i = BigInteger.Zero; _240_i < _hi10; _240_i++) { + if (object.Equals(_234_collKind, DAST.CollKind.create_Array())) { + RAST._IExpr _241_idx; + DCOMP._IOwnership _242_idxOwned; + Dafny.ISet> _243_recIdentsIdx; + RAST._IExpr _out205; + DCOMP._IOwnership _out206; + Dafny.ISet> _out207; + (this).GenExpr((_235_indices).Select(_240_i), selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out205, out _out206, out _out207); + _241_idx = _out205; + _242_idxOwned = _out206; + _243_recIdentsIdx = _out207; + _241_idx = RAST.__default.IntoUsize(_241_idx); + r = RAST.Expr.create_SelectIndex(r, _241_idx); + readIdents = Dafny.Set>.Union(readIdents, _243_recIdentsIdx); } else { - RAST._IExpr _242_idx; - DCOMP._IOwnership _243_idxOwned; - Dafny.ISet> _244_recIdentsIdx; - RAST._IExpr _out203; - DCOMP._IOwnership _out204; - Dafny.ISet> _out205; - (this).GenExpr((_233_indices).Select(_238_i), selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out203, out _out204, out _out205); - _242_idx = _out203; - _243_idxOwned = _out204; - _244_recIdentsIdx = _out205; - r = ((r).Sel(Dafny.Sequence.UnicodeFromString("get"))).Apply1(_242_idx); - readIdents = Dafny.Set>.Union(readIdents, _244_recIdentsIdx); + RAST._IExpr _244_idx; + DCOMP._IOwnership _245_idxOwned; + Dafny.ISet> _246_recIdentsIdx; + RAST._IExpr _out208; + DCOMP._IOwnership _out209; + Dafny.ISet> _out210; + (this).GenExpr((_235_indices).Select(_240_i), selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out208, out _out209, out _out210); + _244_idx = _out208; + _245_idxOwned = _out209; + _246_recIdentsIdx = _out210; + r = ((r).Sel(Dafny.Sequence.UnicodeFromString("get"))).Apply1(_244_idx); + readIdents = Dafny.Set>.Union(readIdents, _246_recIdentsIdx); } } - if (_237_hadArray) { + if (_239_hadArray) { r = (r).Clone(); } - RAST._IExpr _out206; - DCOMP._IOwnership _out207; - (this).FromOwned(r, expectedOwnership, out _out206, out _out207); - r = _out206; - resultingOwnership = _out207; + RAST._IExpr _out211; + DCOMP._IOwnership _out212; + (this).FromOwned(r, expectedOwnership, out _out211, out _out212); + r = _out211; + resultingOwnership = _out212; return ; } goto after_match0; @@ -6877,63 +6946,63 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_IndexRange) { - DAST._IExpression _245_on = _source0.dtor_expr; - bool _246_isArray = _source0.dtor_isArray; - Std.Wrappers._IOption _247_low = _source0.dtor_low; - Std.Wrappers._IOption _248_high = _source0.dtor_high; + DAST._IExpression _247_on = _source0.dtor_expr; + bool _248_isArray = _source0.dtor_isArray; + Std.Wrappers._IOption _249_low = _source0.dtor_low; + Std.Wrappers._IOption _250_high = _source0.dtor_high; { - DCOMP._IOwnership _249_onExpectedOwnership; - if (_246_isArray) { + DCOMP._IOwnership _251_onExpectedOwnership; + if (_248_isArray) { if (((this).pointerType).is_Raw) { - _249_onExpectedOwnership = DCOMP.Ownership.create_OwnershipOwned(); + _251_onExpectedOwnership = DCOMP.Ownership.create_OwnershipOwned(); } else { - _249_onExpectedOwnership = DCOMP.Ownership.create_OwnershipBorrowed(); + _251_onExpectedOwnership = DCOMP.Ownership.create_OwnershipBorrowed(); } } else { - _249_onExpectedOwnership = DCOMP.Ownership.create_OwnershipAutoBorrowed(); - } - RAST._IExpr _250_onExpr; - DCOMP._IOwnership _251_onOwned; - Dafny.ISet> _252_recIdents; - RAST._IExpr _out208; - DCOMP._IOwnership _out209; - Dafny.ISet> _out210; - (this).GenExpr(_245_on, selfIdent, env, _249_onExpectedOwnership, out _out208, out _out209, out _out210); - _250_onExpr = _out208; - _251_onOwned = _out209; - _252_recIdents = _out210; - readIdents = _252_recIdents; - Dafny.ISequence _253_methodName; - if ((_247_low).is_Some) { - if ((_248_high).is_Some) { - _253_methodName = Dafny.Sequence.UnicodeFromString("slice"); + _251_onExpectedOwnership = DCOMP.Ownership.create_OwnershipAutoBorrowed(); + } + RAST._IExpr _252_onExpr; + DCOMP._IOwnership _253_onOwned; + Dafny.ISet> _254_recIdents; + RAST._IExpr _out213; + DCOMP._IOwnership _out214; + Dafny.ISet> _out215; + (this).GenExpr(_247_on, selfIdent, env, _251_onExpectedOwnership, out _out213, out _out214, out _out215); + _252_onExpr = _out213; + _253_onOwned = _out214; + _254_recIdents = _out215; + readIdents = _254_recIdents; + Dafny.ISequence _255_methodName; + if ((_249_low).is_Some) { + if ((_250_high).is_Some) { + _255_methodName = Dafny.Sequence.UnicodeFromString("slice"); } else { - _253_methodName = Dafny.Sequence.UnicodeFromString("drop"); + _255_methodName = Dafny.Sequence.UnicodeFromString("drop"); } - } else if ((_248_high).is_Some) { - _253_methodName = Dafny.Sequence.UnicodeFromString("take"); + } else if ((_250_high).is_Some) { + _255_methodName = Dafny.Sequence.UnicodeFromString("take"); } else { - _253_methodName = Dafny.Sequence.UnicodeFromString(""); + _255_methodName = Dafny.Sequence.UnicodeFromString(""); } - Dafny.ISequence _254_arguments; - _254_arguments = Dafny.Sequence.FromElements(); - Std.Wrappers._IOption _source3 = _247_low; + Dafny.ISequence _256_arguments; + _256_arguments = Dafny.Sequence.FromElements(); + Std.Wrappers._IOption _source3 = _249_low; { if (_source3.is_Some) { - DAST._IExpression _255_l = _source3.dtor_value; + DAST._IExpression _257_l = _source3.dtor_value; { - RAST._IExpr _256_lExpr; - DCOMP._IOwnership _257___v201; - Dafny.ISet> _258_recIdentsL; - RAST._IExpr _out211; - DCOMP._IOwnership _out212; - Dafny.ISet> _out213; - (this).GenExpr(_255_l, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out211, out _out212, out _out213); - _256_lExpr = _out211; - _257___v201 = _out212; - _258_recIdentsL = _out213; - _254_arguments = Dafny.Sequence.Concat(_254_arguments, Dafny.Sequence.FromElements(_256_lExpr)); - readIdents = Dafny.Set>.Union(readIdents, _258_recIdentsL); + RAST._IExpr _258_lExpr; + DCOMP._IOwnership _259___v182; + Dafny.ISet> _260_recIdentsL; + RAST._IExpr _out216; + DCOMP._IOwnership _out217; + Dafny.ISet> _out218; + (this).GenExpr(_257_l, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out216, out _out217, out _out218); + _258_lExpr = _out216; + _259___v182 = _out217; + _260_recIdentsL = _out218; + _256_arguments = Dafny.Sequence.Concat(_256_arguments, Dafny.Sequence.FromElements(_258_lExpr)); + readIdents = Dafny.Set>.Union(readIdents, _260_recIdentsL); } goto after_match3; } @@ -6941,23 +7010,23 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv { } after_match3: ; - Std.Wrappers._IOption _source4 = _248_high; + Std.Wrappers._IOption _source4 = _250_high; { if (_source4.is_Some) { - DAST._IExpression _259_h = _source4.dtor_value; + DAST._IExpression _261_h = _source4.dtor_value; { - RAST._IExpr _260_hExpr; - DCOMP._IOwnership _261___v202; - Dafny.ISet> _262_recIdentsH; - RAST._IExpr _out214; - DCOMP._IOwnership _out215; - Dafny.ISet> _out216; - (this).GenExpr(_259_h, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out214, out _out215, out _out216); - _260_hExpr = _out214; - _261___v202 = _out215; - _262_recIdentsH = _out216; - _254_arguments = Dafny.Sequence.Concat(_254_arguments, Dafny.Sequence.FromElements(_260_hExpr)); - readIdents = Dafny.Set>.Union(readIdents, _262_recIdentsH); + RAST._IExpr _262_hExpr; + DCOMP._IOwnership _263___v183; + Dafny.ISet> _264_recIdentsH; + RAST._IExpr _out219; + DCOMP._IOwnership _out220; + Dafny.ISet> _out221; + (this).GenExpr(_261_h, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out219, out _out220, out _out221); + _262_hExpr = _out219; + _263___v183 = _out220; + _264_recIdentsH = _out221; + _256_arguments = Dafny.Sequence.Concat(_256_arguments, Dafny.Sequence.FromElements(_262_hExpr)); + readIdents = Dafny.Set>.Union(readIdents, _264_recIdentsH); } goto after_match4; } @@ -6965,30 +7034,30 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv { } after_match4: ; - r = _250_onExpr; - if (_246_isArray) { - if (!(_253_methodName).Equals(Dafny.Sequence.UnicodeFromString(""))) { - _253_methodName = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_"), _253_methodName); + r = _252_onExpr; + if (_248_isArray) { + if (!(_255_methodName).Equals(Dafny.Sequence.UnicodeFromString(""))) { + _255_methodName = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_"), _255_methodName); } - Dafny.ISequence _263_object__suffix; + Dafny.ISequence _265_object__suffix; if (((this).pointerType).is_Raw) { - _263_object__suffix = Dafny.Sequence.UnicodeFromString(""); + _265_object__suffix = Dafny.Sequence.UnicodeFromString(""); } else { - _263_object__suffix = Dafny.Sequence.UnicodeFromString("_object"); + _265_object__suffix = Dafny.Sequence.UnicodeFromString("_object"); } - r = ((RAST.__default.dafny__runtime__Sequence).FSel(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("from_array"), _253_methodName), _263_object__suffix))).Apply(Dafny.Sequence.Concat(Dafny.Sequence.FromElements(_250_onExpr), _254_arguments)); + r = ((RAST.__default.dafny__runtime__Sequence).FSel(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("from_array"), _255_methodName), _265_object__suffix))).Apply(Dafny.Sequence.Concat(Dafny.Sequence.FromElements(_252_onExpr), _256_arguments)); } else { - if (!(_253_methodName).Equals(Dafny.Sequence.UnicodeFromString(""))) { - r = ((r).Sel(_253_methodName)).Apply(_254_arguments); + if (!(_255_methodName).Equals(Dafny.Sequence.UnicodeFromString(""))) { + r = ((r).Sel(_255_methodName)).Apply(_256_arguments); } else { r = (r).Clone(); } } - RAST._IExpr _out217; - DCOMP._IOwnership _out218; - (this).FromOwned(r, expectedOwnership, out _out217, out _out218); - r = _out217; - resultingOwnership = _out218; + RAST._IExpr _out222; + DCOMP._IOwnership _out223; + (this).FromOwned(r, expectedOwnership, out _out222, out _out223); + r = _out222; + resultingOwnership = _out223; return ; } goto after_match0; @@ -6996,28 +7065,28 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_TupleSelect) { - DAST._IExpression _264_on = _source0.dtor_expr; - BigInteger _265_idx = _source0.dtor_index; - DAST._IType _266_fieldType = _source0.dtor_fieldType; + DAST._IExpression _266_on = _source0.dtor_expr; + BigInteger _267_idx = _source0.dtor_index; + DAST._IType _268_fieldType = _source0.dtor_fieldType; { - RAST._IExpr _267_onExpr; - DCOMP._IOwnership _268_onOwnership; - Dafny.ISet> _269_recIdents; - RAST._IExpr _out219; - DCOMP._IOwnership _out220; - Dafny.ISet> _out221; - (this).GenExpr(_264_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out219, out _out220, out _out221); - _267_onExpr = _out219; - _268_onOwnership = _out220; - _269_recIdents = _out221; - Dafny.ISequence _270_selName; - _270_selName = Std.Strings.__default.OfNat(_265_idx); - DAST._IType _source5 = _266_fieldType; + RAST._IExpr _269_onExpr; + DCOMP._IOwnership _270_onOwnership; + Dafny.ISet> _271_recIdents; + RAST._IExpr _out224; + DCOMP._IOwnership _out225; + Dafny.ISet> _out226; + (this).GenExpr(_266_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out224, out _out225, out _out226); + _269_onExpr = _out224; + _270_onOwnership = _out225; + _271_recIdents = _out226; + Dafny.ISequence _272_selName; + _272_selName = Std.Strings.__default.OfNat(_267_idx); + DAST._IType _source5 = _268_fieldType; { if (_source5.is_Tuple) { - Dafny.ISequence _271_tps = _source5.dtor_Tuple_a0; - if (((_266_fieldType).is_Tuple) && ((new BigInteger((_271_tps).Count)) > (RAST.__default.MAX__TUPLE__SIZE))) { - _270_selName = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_"), _270_selName); + Dafny.ISequence _273_tps = _source5.dtor_Tuple_a0; + if (((_268_fieldType).is_Tuple) && ((new BigInteger((_273_tps).Count)) > (RAST.__default.MAX__TUPLE__SIZE))) { + _272_selName = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_"), _272_selName); } goto after_match5; } @@ -7025,13 +7094,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv { } after_match5: ; - r = ((_267_onExpr).Sel(_270_selName)).Clone(); - RAST._IExpr _out222; - DCOMP._IOwnership _out223; - (this).FromOwnership(r, DCOMP.Ownership.create_OwnershipOwned(), expectedOwnership, out _out222, out _out223); - r = _out222; - resultingOwnership = _out223; - readIdents = _269_recIdents; + r = ((_269_onExpr).Sel(_272_selName)).Clone(); + RAST._IExpr _out227; + DCOMP._IOwnership _out228; + (this).FromOwnership(r, DCOMP.Ownership.create_OwnershipOwned(), expectedOwnership, out _out227, out _out228); + r = _out227; + resultingOwnership = _out228; + readIdents = _271_recIdents; return ; } goto after_match0; @@ -7039,87 +7108,87 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_Call) { - DAST._IExpression _272_on = _source0.dtor_on; - DAST._ICallName _273_name = _source0.dtor_callName; - Dafny.ISequence _274_typeArgs = _source0.dtor_typeArgs; - Dafny.ISequence _275_args = _source0.dtor_args; + DAST._IExpression _274_on = _source0.dtor_on; + DAST._ICallName _275_name = _source0.dtor_callName; + Dafny.ISequence _276_typeArgs = _source0.dtor_typeArgs; + Dafny.ISequence _277_args = _source0.dtor_args; { - Dafny.ISequence _276_argExprs; - Dafny.ISet> _277_recIdents; - Dafny.ISequence _278_typeExprs; - Std.Wrappers._IOption _279_fullNameQualifier; - Dafny.ISequence _out224; - Dafny.ISet> _out225; - Dafny.ISequence _out226; - Std.Wrappers._IOption _out227; - (this).GenArgs(selfIdent, _273_name, _274_typeArgs, _275_args, env, out _out224, out _out225, out _out226, out _out227); - _276_argExprs = _out224; - _277_recIdents = _out225; - _278_typeExprs = _out226; - _279_fullNameQualifier = _out227; - readIdents = _277_recIdents; - Std.Wrappers._IOption _source6 = _279_fullNameQualifier; + Dafny.ISequence _278_argExprs; + Dafny.ISet> _279_recIdents; + Dafny.ISequence _280_typeExprs; + Std.Wrappers._IOption _281_fullNameQualifier; + Dafny.ISequence _out229; + Dafny.ISet> _out230; + Dafny.ISequence _out231; + Std.Wrappers._IOption _out232; + (this).GenArgs(selfIdent, _275_name, _276_typeArgs, _277_args, env, out _out229, out _out230, out _out231, out _out232); + _278_argExprs = _out229; + _279_recIdents = _out230; + _280_typeExprs = _out231; + _281_fullNameQualifier = _out232; + readIdents = _279_recIdents; + Std.Wrappers._IOption _source6 = _281_fullNameQualifier; { if (_source6.is_Some) { DAST._IResolvedType value0 = _source6.dtor_value; - Dafny.ISequence> _280_path = value0.dtor_path; - Dafny.ISequence _281_onTypeArgs = value0.dtor_typeArgs; - DAST._IResolvedTypeBase _282_base = value0.dtor_kind; - RAST._IExpr _283_fullPath; - RAST._IExpr _out228; - _out228 = (this).GenPathExpr(_280_path, true); - _283_fullPath = _out228; - Dafny.ISequence _284_onTypeExprs; - Dafny.ISequence _out229; - _out229 = (this).GenTypeArgs(_281_onTypeArgs, DCOMP.GenTypeContext.@default()); - _284_onTypeExprs = _out229; - RAST._IExpr _285_onExpr = RAST.Expr.Default(); - DCOMP._IOwnership _286_recOwnership = DCOMP.Ownership.Default(); - Dafny.ISet> _287_recIdents = Dafny.Set>.Empty; - if (((_282_base).is_Trait) || ((_282_base).is_Class)) { - RAST._IExpr _out230; - DCOMP._IOwnership _out231; - Dafny.ISet> _out232; - (this).GenExpr(_272_on, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out230, out _out231, out _out232); - _285_onExpr = _out230; - _286_recOwnership = _out231; - _287_recIdents = _out232; - _285_onExpr = ((this).read__macro).Apply1(_285_onExpr); - readIdents = Dafny.Set>.Union(readIdents, _287_recIdents); + Dafny.ISequence> _282_path = value0.dtor_path; + Dafny.ISequence _283_onTypeArgs = value0.dtor_typeArgs; + DAST._IResolvedTypeBase _284_base = value0.dtor_kind; + RAST._IExpr _285_fullPath; + RAST._IExpr _out233; + _out233 = (this).GenPathExpr(_282_path, true); + _285_fullPath = _out233; + Dafny.ISequence _286_onTypeExprs; + Dafny.ISequence _out234; + _out234 = (this).GenTypeArgs(_283_onTypeArgs, DCOMP.GenTypeContext.@default()); + _286_onTypeExprs = _out234; + RAST._IExpr _287_onExpr = RAST.Expr.Default(); + DCOMP._IOwnership _288_recOwnership = DCOMP.Ownership.Default(); + Dafny.ISet> _289_recIdents = Dafny.Set>.Empty; + if (((_284_base).is_Trait) || ((_284_base).is_Class)) { + RAST._IExpr _out235; + DCOMP._IOwnership _out236; + Dafny.ISet> _out237; + (this).GenExpr(_274_on, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out235, out _out236, out _out237); + _287_onExpr = _out235; + _288_recOwnership = _out236; + _289_recIdents = _out237; + _287_onExpr = ((this).read__macro).Apply1(_287_onExpr); + readIdents = Dafny.Set>.Union(readIdents, _289_recIdents); } else { - RAST._IExpr _out233; - DCOMP._IOwnership _out234; - Dafny.ISet> _out235; - (this).GenExpr(_272_on, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out233, out _out234, out _out235); - _285_onExpr = _out233; - _286_recOwnership = _out234; - _287_recIdents = _out235; - readIdents = Dafny.Set>.Union(readIdents, _287_recIdents); + RAST._IExpr _out238; + DCOMP._IOwnership _out239; + Dafny.ISet> _out240; + (this).GenExpr(_274_on, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out238, out _out239, out _out240); + _287_onExpr = _out238; + _288_recOwnership = _out239; + _289_recIdents = _out240; + readIdents = Dafny.Set>.Union(readIdents, _289_recIdents); } - r = ((((_283_fullPath).ApplyType(_284_onTypeExprs)).FSel(DCOMP.__default.escapeName((_273_name).dtor_name))).ApplyType(_278_typeExprs)).Apply(Dafny.Sequence.Concat(Dafny.Sequence.FromElements(_285_onExpr), _276_argExprs)); - RAST._IExpr _out236; - DCOMP._IOwnership _out237; - (this).FromOwned(r, expectedOwnership, out _out236, out _out237); - r = _out236; - resultingOwnership = _out237; + r = ((((_285_fullPath).ApplyType(_286_onTypeExprs)).FSel(DCOMP.__default.escapeName((_275_name).dtor_name))).ApplyType(_280_typeExprs)).Apply(Dafny.Sequence.Concat(Dafny.Sequence.FromElements(_287_onExpr), _278_argExprs)); + RAST._IExpr _out241; + DCOMP._IOwnership _out242; + (this).FromOwned(r, expectedOwnership, out _out241, out _out242); + r = _out241; + resultingOwnership = _out242; goto after_match6; } } { - RAST._IExpr _288_onExpr; - DCOMP._IOwnership _289___v208; - Dafny.ISet> _290_recIdents; - RAST._IExpr _out238; - DCOMP._IOwnership _out239; - Dafny.ISet> _out240; - (this).GenExpr(_272_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out238, out _out239, out _out240); - _288_onExpr = _out238; - _289___v208 = _out239; - _290_recIdents = _out240; - readIdents = Dafny.Set>.Union(readIdents, _290_recIdents); - Dafny.ISequence _291_renderedName; - _291_renderedName = (this).GetMethodName(_272_on, _273_name); - DAST._IExpression _source7 = _272_on; + RAST._IExpr _290_onExpr; + DCOMP._IOwnership _291___v189; + Dafny.ISet> _292_recIdents; + RAST._IExpr _out243; + DCOMP._IOwnership _out244; + Dafny.ISet> _out245; + (this).GenExpr(_274_on, selfIdent, env, DCOMP.Ownership.create_OwnershipAutoBorrowed(), out _out243, out _out244, out _out245); + _290_onExpr = _out243; + _291___v189 = _out244; + _292_recIdents = _out245; + readIdents = Dafny.Set>.Union(readIdents, _292_recIdents); + Dafny.ISequence _293_renderedName; + _293_renderedName = (this).GetMethodName(_274_on, _275_name); + DAST._IExpression _source7 = _274_on; { bool disjunctiveMatch0 = false; if (_source7.is_Companion) { @@ -7130,26 +7199,26 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } if (disjunctiveMatch0) { { - _288_onExpr = (_288_onExpr).FSel(_291_renderedName); + _290_onExpr = (_290_onExpr).FSel(_293_renderedName); } goto after_match7; } } { { - if (!object.Equals(_288_onExpr, RAST.__default.self)) { - DAST._ICallName _source8 = _273_name; + if (!object.Equals(_290_onExpr, RAST.__default.self)) { + DAST._ICallName _source8 = _275_name; { if (_source8.is_CallName) { Std.Wrappers._IOption onType0 = _source8.dtor_onType; if (onType0.is_Some) { - DAST._IType _292_tpe = onType0.dtor_value; - RAST._IType _293_typ; - RAST._IType _out241; - _out241 = (this).GenType(_292_tpe, DCOMP.GenTypeContext.@default()); - _293_typ = _out241; - if ((_293_typ).IsObjectOrPointer()) { - _288_onExpr = ((this).read__macro).Apply1(_288_onExpr); + DAST._IType _294_tpe = onType0.dtor_value; + RAST._IType _295_typ; + RAST._IType _out246; + _out246 = (this).GenType(_294_tpe, DCOMP.GenTypeContext.@default()); + _295_typ = _out246; + if ((_295_typ).IsObjectOrPointer()) { + _290_onExpr = ((this).read__macro).Apply1(_290_onExpr); } goto after_match8; } @@ -7159,16 +7228,16 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } after_match8: ; } - _288_onExpr = (_288_onExpr).Sel(_291_renderedName); + _290_onExpr = (_290_onExpr).Sel(_293_renderedName); } } after_match7: ; - r = ((_288_onExpr).ApplyType(_278_typeExprs)).Apply(_276_argExprs); - RAST._IExpr _out242; - DCOMP._IOwnership _out243; - (this).FromOwned(r, expectedOwnership, out _out242, out _out243); - r = _out242; - resultingOwnership = _out243; + r = ((_290_onExpr).ApplyType(_280_typeExprs)).Apply(_278_argExprs); + RAST._IExpr _out247; + DCOMP._IOwnership _out248; + (this).FromOwned(r, expectedOwnership, out _out247, out _out248); + r = _out247; + resultingOwnership = _out248; return ; } after_match6: ; @@ -7178,90 +7247,90 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_Lambda) { - Dafny.ISequence _294_paramsDafny = _source0.dtor_params; - DAST._IType _295_retType = _source0.dtor_retType; - Dafny.ISequence _296_body = _source0.dtor_body; + Dafny.ISequence _296_paramsDafny = _source0.dtor_params; + DAST._IType _297_retType = _source0.dtor_retType; + Dafny.ISequence _298_body = _source0.dtor_body; { - Dafny.ISequence _297_params; - Dafny.ISequence _out244; - _out244 = (this).GenParams(_294_paramsDafny, true); - _297_params = _out244; - Dafny.ISequence> _298_paramNames; - _298_paramNames = Dafny.Sequence>.FromElements(); - Dafny.IMap,RAST._IType> _299_paramTypesMap; - _299_paramTypesMap = Dafny.Map, RAST._IType>.FromElements(); - BigInteger _hi10 = new BigInteger((_297_params).Count); - for (BigInteger _300_i = BigInteger.Zero; _300_i < _hi10; _300_i++) { - Dafny.ISequence _301_name; - _301_name = ((_297_params).Select(_300_i)).dtor_name; - _298_paramNames = Dafny.Sequence>.Concat(_298_paramNames, Dafny.Sequence>.FromElements(_301_name)); - _299_paramTypesMap = Dafny.Map, RAST._IType>.Update(_299_paramTypesMap, _301_name, ((_297_params).Select(_300_i)).dtor_tpe); - } - DCOMP._IEnvironment _302_subEnv; - _302_subEnv = ((env).ToOwned()).merge(DCOMP.Environment.create(_298_paramNames, _299_paramTypesMap)); - RAST._IExpr _303_recursiveGen; - Dafny.ISet> _304_recIdents; - DCOMP._IEnvironment _305___v218; - RAST._IExpr _out245; - Dafny.ISet> _out246; - DCOMP._IEnvironment _out247; - (this).GenStmts(_296_body, ((!object.Equals(selfIdent, DCOMP.SelfInfo.create_NoSelf())) ? (DCOMP.SelfInfo.create_ThisTyped(Dafny.Sequence.UnicodeFromString("_this"), (selfIdent).dtor_dafnyType)) : (DCOMP.SelfInfo.create_NoSelf())), _302_subEnv, true, Std.Wrappers.Option>>.create_None(), out _out245, out _out246, out _out247); - _303_recursiveGen = _out245; - _304_recIdents = _out246; - _305___v218 = _out247; + Dafny.ISequence _299_params; + Dafny.ISequence _out249; + _out249 = (this).GenParams(_296_paramsDafny, true); + _299_params = _out249; + Dafny.ISequence> _300_paramNames; + _300_paramNames = Dafny.Sequence>.FromElements(); + Dafny.IMap,RAST._IType> _301_paramTypesMap; + _301_paramTypesMap = Dafny.Map, RAST._IType>.FromElements(); + BigInteger _hi11 = new BigInteger((_299_params).Count); + for (BigInteger _302_i = BigInteger.Zero; _302_i < _hi11; _302_i++) { + Dafny.ISequence _303_name; + _303_name = ((_299_params).Select(_302_i)).dtor_name; + _300_paramNames = Dafny.Sequence>.Concat(_300_paramNames, Dafny.Sequence>.FromElements(_303_name)); + _301_paramTypesMap = Dafny.Map, RAST._IType>.Update(_301_paramTypesMap, _303_name, ((_299_params).Select(_302_i)).dtor_tpe); + } + DCOMP._IEnvironment _304_subEnv; + _304_subEnv = ((env).ToOwned()).merge(DCOMP.Environment.create(_300_paramNames, _301_paramTypesMap)); + RAST._IExpr _305_recursiveGen; + Dafny.ISet> _306_recIdents; + DCOMP._IEnvironment _307___v199; + RAST._IExpr _out250; + Dafny.ISet> _out251; + DCOMP._IEnvironment _out252; + (this).GenStmts(_298_body, ((!object.Equals(selfIdent, DCOMP.SelfInfo.create_NoSelf())) ? (DCOMP.SelfInfo.create_ThisTyped(Dafny.Sequence.UnicodeFromString("_this"), (selfIdent).dtor_dafnyType)) : (DCOMP.SelfInfo.create_NoSelf())), _304_subEnv, true, Std.Wrappers.Option>>.create_None(), out _out250, out _out251, out _out252); + _305_recursiveGen = _out250; + _306_recIdents = _out251; + _307___v199 = _out252; readIdents = Dafny.Set>.FromElements(); - _304_recIdents = Dafny.Set>.Difference(_304_recIdents, Dafny.Helpers.Id>, Dafny.ISet>>>((_306_paramNames) => ((System.Func>>)(() => { + _306_recIdents = Dafny.Set>.Difference(_306_recIdents, Dafny.Helpers.Id>, Dafny.ISet>>>((_308_paramNames) => ((System.Func>>)(() => { var _coll0 = new System.Collections.Generic.List>(); - foreach (Dafny.ISequence _compr_0 in (_306_paramNames).CloneAsArray()) { - Dafny.ISequence _307_name = (Dafny.ISequence)_compr_0; - if ((_306_paramNames).Contains(_307_name)) { - _coll0.Add(_307_name); + foreach (Dafny.ISequence _compr_0 in (_308_paramNames).CloneAsArray()) { + Dafny.ISequence _309_name = (Dafny.ISequence)_compr_0; + if ((_308_paramNames).Contains(_309_name)) { + _coll0.Add(_309_name); } } return Dafny.Set>.FromCollection(_coll0); - }))())(_298_paramNames)); - RAST._IExpr _308_allReadCloned; - _308_allReadCloned = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); - while (!(_304_recIdents).Equals(Dafny.Set>.FromElements())) { - Dafny.ISequence _309_next; - foreach (Dafny.ISequence _assign_such_that_1 in (_304_recIdents).Elements) { - _309_next = (Dafny.ISequence)_assign_such_that_1; - if ((_304_recIdents).Contains(_309_next)) { + }))())(_300_paramNames)); + RAST._IExpr _310_allReadCloned; + _310_allReadCloned = (this).InitEmptyExpr(); + while (!(_306_recIdents).Equals(Dafny.Set>.FromElements())) { + Dafny.ISequence _311_next; + foreach (Dafny.ISequence _assign_such_that_1 in (_306_recIdents).Elements) { + _311_next = (Dafny.ISequence)_assign_such_that_1; + if ((_306_recIdents).Contains(_311_next)) { goto after__ASSIGN_SUCH_THAT_1; } } throw new System.Exception("assign-such-that search produced no value"); after__ASSIGN_SUCH_THAT_1: ; - if ((!object.Equals(selfIdent, DCOMP.SelfInfo.create_NoSelf())) && ((_309_next).Equals(Dafny.Sequence.UnicodeFromString("_this")))) { - RAST._IExpr _310_selfCloned; - DCOMP._IOwnership _311___v219; - Dafny.ISet> _312___v220; - RAST._IExpr _out248; - DCOMP._IOwnership _out249; - Dafny.ISet> _out250; - (this).GenIdent(Dafny.Sequence.UnicodeFromString("self"), selfIdent, DCOMP.Environment.Empty(), DCOMP.Ownership.create_OwnershipOwned(), out _out248, out _out249, out _out250); - _310_selfCloned = _out248; - _311___v219 = _out249; - _312___v220 = _out250; - _308_allReadCloned = (_308_allReadCloned).Then(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("_this"), Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(_310_selfCloned))); - } else if (!((_298_paramNames).Contains(_309_next))) { - RAST._IExpr _313_copy; - _313_copy = (RAST.Expr.create_Identifier(_309_next)).Clone(); - _308_allReadCloned = (_308_allReadCloned).Then(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), _309_next, Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(_313_copy))); - readIdents = Dafny.Set>.Union(readIdents, Dafny.Set>.FromElements(_309_next)); + if ((!object.Equals(selfIdent, DCOMP.SelfInfo.create_NoSelf())) && ((_311_next).Equals(Dafny.Sequence.UnicodeFromString("_this")))) { + RAST._IExpr _312_selfCloned; + DCOMP._IOwnership _313___v200; + Dafny.ISet> _314___v201; + RAST._IExpr _out253; + DCOMP._IOwnership _out254; + Dafny.ISet> _out255; + (this).GenIdent(Dafny.Sequence.UnicodeFromString("self"), selfIdent, DCOMP.Environment.Empty(), DCOMP.Ownership.create_OwnershipOwned(), out _out253, out _out254, out _out255); + _312_selfCloned = _out253; + _313___v200 = _out254; + _314___v201 = _out255; + _310_allReadCloned = (_310_allReadCloned).Then(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), Dafny.Sequence.UnicodeFromString("_this"), Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(_312_selfCloned))); + } else if (!((_300_paramNames).Contains(_311_next))) { + RAST._IExpr _315_copy; + _315_copy = (RAST.Expr.create_Identifier(_311_next)).Clone(); + _310_allReadCloned = (_310_allReadCloned).Then(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), _311_next, Std.Wrappers.Option.create_None(), Std.Wrappers.Option.create_Some(_315_copy))); + readIdents = Dafny.Set>.Union(readIdents, Dafny.Set>.FromElements(_311_next)); } - _304_recIdents = Dafny.Set>.Difference(_304_recIdents, Dafny.Set>.FromElements(_309_next)); - } - RAST._IType _314_retTypeGen; - RAST._IType _out251; - _out251 = (this).GenType(_295_retType, DCOMP.GenTypeContext.@default()); - _314_retTypeGen = _out251; - r = RAST.Expr.create_Block((_308_allReadCloned).Then(RAST.__default.RcNew(RAST.Expr.create_Lambda(_297_params, Std.Wrappers.Option.create_Some(_314_retTypeGen), RAST.Expr.create_Block(_303_recursiveGen))))); - RAST._IExpr _out252; - DCOMP._IOwnership _out253; - (this).FromOwned(r, expectedOwnership, out _out252, out _out253); - r = _out252; - resultingOwnership = _out253; + _306_recIdents = Dafny.Set>.Difference(_306_recIdents, Dafny.Set>.FromElements(_311_next)); + } + RAST._IType _316_retTypeGen; + RAST._IType _out256; + _out256 = (this).GenType(_297_retType, DCOMP.GenTypeContext.@default()); + _316_retTypeGen = _out256; + r = RAST.Expr.create_Block((_310_allReadCloned).Then(RAST.__default.RcNew(RAST.Expr.create_Lambda(_299_params, Std.Wrappers.Option.create_Some(_316_retTypeGen), RAST.Expr.create_Block(_305_recursiveGen))))); + RAST._IExpr _out257; + DCOMP._IOwnership _out258; + (this).FromOwned(r, expectedOwnership, out _out257, out _out258); + r = _out257; + resultingOwnership = _out258; return ; } goto after_match0; @@ -7269,72 +7338,72 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_BetaRedex) { - Dafny.ISequence<_System._ITuple2> _315_values = _source0.dtor_values; - DAST._IType _316_retType = _source0.dtor_retType; - DAST._IExpression _317_expr = _source0.dtor_expr; + Dafny.ISequence<_System._ITuple2> _317_values = _source0.dtor_values; + DAST._IType _318_retType = _source0.dtor_retType; + DAST._IExpression _319_expr = _source0.dtor_expr; { - Dafny.ISequence> _318_paramNames; - _318_paramNames = Dafny.Sequence>.FromElements(); - Dafny.ISequence _319_paramFormals; - Dafny.ISequence _out254; - _out254 = (this).GenParams(Std.Collections.Seq.__default.Map<_System._ITuple2, DAST._IFormal>(((System.Func<_System._ITuple2, DAST._IFormal>)((_320_value) => { - return (_320_value).dtor__0; - })), _315_values), false); - _319_paramFormals = _out254; - Dafny.IMap,RAST._IType> _321_paramTypes; - _321_paramTypes = Dafny.Map, RAST._IType>.FromElements(); - Dafny.ISet> _322_paramNamesSet; - _322_paramNamesSet = Dafny.Set>.FromElements(); - BigInteger _hi11 = new BigInteger((_315_values).Count); - for (BigInteger _323_i = BigInteger.Zero; _323_i < _hi11; _323_i++) { - Dafny.ISequence _324_name; - _324_name = (((_315_values).Select(_323_i)).dtor__0).dtor_name; - Dafny.ISequence _325_rName; - _325_rName = DCOMP.__default.escapeVar(_324_name); - _318_paramNames = Dafny.Sequence>.Concat(_318_paramNames, Dafny.Sequence>.FromElements(_325_rName)); - _321_paramTypes = Dafny.Map, RAST._IType>.Update(_321_paramTypes, _325_rName, ((_319_paramFormals).Select(_323_i)).dtor_tpe); - _322_paramNamesSet = Dafny.Set>.Union(_322_paramNamesSet, Dafny.Set>.FromElements(_325_rName)); + Dafny.ISequence> _320_paramNames; + _320_paramNames = Dafny.Sequence>.FromElements(); + Dafny.ISequence _321_paramFormals; + Dafny.ISequence _out259; + _out259 = (this).GenParams(Std.Collections.Seq.__default.Map<_System._ITuple2, DAST._IFormal>(((System.Func<_System._ITuple2, DAST._IFormal>)((_322_value) => { + return (_322_value).dtor__0; + })), _317_values), false); + _321_paramFormals = _out259; + Dafny.IMap,RAST._IType> _323_paramTypes; + _323_paramTypes = Dafny.Map, RAST._IType>.FromElements(); + Dafny.ISet> _324_paramNamesSet; + _324_paramNamesSet = Dafny.Set>.FromElements(); + BigInteger _hi12 = new BigInteger((_317_values).Count); + for (BigInteger _325_i = BigInteger.Zero; _325_i < _hi12; _325_i++) { + Dafny.ISequence _326_name; + _326_name = (((_317_values).Select(_325_i)).dtor__0).dtor_name; + Dafny.ISequence _327_rName; + _327_rName = DCOMP.__default.escapeVar(_326_name); + _320_paramNames = Dafny.Sequence>.Concat(_320_paramNames, Dafny.Sequence>.FromElements(_327_rName)); + _323_paramTypes = Dafny.Map, RAST._IType>.Update(_323_paramTypes, _327_rName, ((_321_paramFormals).Select(_325_i)).dtor_tpe); + _324_paramNamesSet = Dafny.Set>.Union(_324_paramNamesSet, Dafny.Set>.FromElements(_327_rName)); } readIdents = Dafny.Set>.FromElements(); - r = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); - BigInteger _hi12 = new BigInteger((_315_values).Count); - for (BigInteger _326_i = BigInteger.Zero; _326_i < _hi12; _326_i++) { - RAST._IType _327_typeGen; - RAST._IType _out255; - _out255 = (this).GenType((((_315_values).Select(_326_i)).dtor__0).dtor_typ, DCOMP.GenTypeContext.@default()); - _327_typeGen = _out255; - RAST._IExpr _328_valueGen; - DCOMP._IOwnership _329___v221; - Dafny.ISet> _330_recIdents; - RAST._IExpr _out256; - DCOMP._IOwnership _out257; - Dafny.ISet> _out258; - (this).GenExpr(((_315_values).Select(_326_i)).dtor__1, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out256, out _out257, out _out258); - _328_valueGen = _out256; - _329___v221 = _out257; - _330_recIdents = _out258; - r = (r).Then(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_CONST(), DCOMP.__default.escapeVar((((_315_values).Select(_326_i)).dtor__0).dtor_name), Std.Wrappers.Option.create_Some(_327_typeGen), Std.Wrappers.Option.create_Some(_328_valueGen))); - readIdents = Dafny.Set>.Union(readIdents, _330_recIdents); - } - DCOMP._IEnvironment _331_newEnv; - _331_newEnv = DCOMP.Environment.create(_318_paramNames, _321_paramTypes); - RAST._IExpr _332_recGen; - DCOMP._IOwnership _333_recOwned; - Dafny.ISet> _334_recIdents; - RAST._IExpr _out259; - DCOMP._IOwnership _out260; - Dafny.ISet> _out261; - (this).GenExpr(_317_expr, selfIdent, _331_newEnv, expectedOwnership, out _out259, out _out260, out _out261); - _332_recGen = _out259; - _333_recOwned = _out260; - _334_recIdents = _out261; - readIdents = Dafny.Set>.Difference(_334_recIdents, _322_paramNamesSet); - r = RAST.Expr.create_Block((r).Then(_332_recGen)); - RAST._IExpr _out262; - DCOMP._IOwnership _out263; - (this).FromOwnership(r, _333_recOwned, expectedOwnership, out _out262, out _out263); - r = _out262; - resultingOwnership = _out263; + r = (this).InitEmptyExpr(); + BigInteger _hi13 = new BigInteger((_317_values).Count); + for (BigInteger _328_i = BigInteger.Zero; _328_i < _hi13; _328_i++) { + RAST._IType _329_typeGen; + RAST._IType _out260; + _out260 = (this).GenType((((_317_values).Select(_328_i)).dtor__0).dtor_typ, DCOMP.GenTypeContext.@default()); + _329_typeGen = _out260; + RAST._IExpr _330_valueGen; + DCOMP._IOwnership _331___v202; + Dafny.ISet> _332_recIdents; + RAST._IExpr _out261; + DCOMP._IOwnership _out262; + Dafny.ISet> _out263; + (this).GenExpr(((_317_values).Select(_328_i)).dtor__1, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out261, out _out262, out _out263); + _330_valueGen = _out261; + _331___v202 = _out262; + _332_recIdents = _out263; + r = (r).Then(RAST.Expr.create_DeclareVar(RAST.DeclareType.create_CONST(), DCOMP.__default.escapeVar((((_317_values).Select(_328_i)).dtor__0).dtor_name), Std.Wrappers.Option.create_Some(_329_typeGen), Std.Wrappers.Option.create_Some(_330_valueGen))); + readIdents = Dafny.Set>.Union(readIdents, _332_recIdents); + } + DCOMP._IEnvironment _333_newEnv; + _333_newEnv = DCOMP.Environment.create(_320_paramNames, _323_paramTypes); + RAST._IExpr _334_recGen; + DCOMP._IOwnership _335_recOwned; + Dafny.ISet> _336_recIdents; + RAST._IExpr _out264; + DCOMP._IOwnership _out265; + Dafny.ISet> _out266; + (this).GenExpr(_319_expr, selfIdent, _333_newEnv, expectedOwnership, out _out264, out _out265, out _out266); + _334_recGen = _out264; + _335_recOwned = _out265; + _336_recIdents = _out266; + readIdents = Dafny.Set>.Difference(_336_recIdents, _324_paramNamesSet); + r = RAST.Expr.create_Block((r).Then(_334_recGen)); + RAST._IExpr _out267; + DCOMP._IOwnership _out268; + (this).FromOwnership(r, _335_recOwned, expectedOwnership, out _out267, out _out268); + r = _out267; + resultingOwnership = _out268; return ; } goto after_match0; @@ -7342,45 +7411,45 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_IIFE) { - Dafny.ISequence _335_name = _source0.dtor_ident; - DAST._IType _336_tpe = _source0.dtor_typ; - DAST._IExpression _337_value = _source0.dtor_value; - DAST._IExpression _338_iifeBody = _source0.dtor_iifeBody; + Dafny.ISequence _337_name = _source0.dtor_ident; + DAST._IType _338_tpe = _source0.dtor_typ; + DAST._IExpression _339_value = _source0.dtor_value; + DAST._IExpression _340_iifeBody = _source0.dtor_iifeBody; { - RAST._IExpr _339_valueGen; - DCOMP._IOwnership _340___v222; - Dafny.ISet> _341_recIdents; - RAST._IExpr _out264; - DCOMP._IOwnership _out265; - Dafny.ISet> _out266; - (this).GenExpr(_337_value, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out264, out _out265, out _out266); - _339_valueGen = _out264; - _340___v222 = _out265; - _341_recIdents = _out266; - readIdents = _341_recIdents; - RAST._IType _342_valueTypeGen; - RAST._IType _out267; - _out267 = (this).GenType(_336_tpe, DCOMP.GenTypeContext.@default()); - _342_valueTypeGen = _out267; - Dafny.ISequence _343_iifeVar; - _343_iifeVar = DCOMP.__default.escapeVar(_335_name); - RAST._IExpr _344_bodyGen; - DCOMP._IOwnership _345___v223; - Dafny.ISet> _346_bodyIdents; - RAST._IExpr _out268; - DCOMP._IOwnership _out269; - Dafny.ISet> _out270; - (this).GenExpr(_338_iifeBody, selfIdent, (env).AddAssigned(_343_iifeVar, _342_valueTypeGen), DCOMP.Ownership.create_OwnershipOwned(), out _out268, out _out269, out _out270); - _344_bodyGen = _out268; - _345___v223 = _out269; - _346_bodyIdents = _out270; - readIdents = Dafny.Set>.Union(readIdents, Dafny.Set>.Difference(_346_bodyIdents, Dafny.Set>.FromElements(_343_iifeVar))); - r = RAST.Expr.create_Block((RAST.Expr.create_DeclareVar(RAST.DeclareType.create_CONST(), _343_iifeVar, Std.Wrappers.Option.create_Some(_342_valueTypeGen), Std.Wrappers.Option.create_Some(_339_valueGen))).Then(_344_bodyGen)); - RAST._IExpr _out271; - DCOMP._IOwnership _out272; - (this).FromOwned(r, expectedOwnership, out _out271, out _out272); - r = _out271; - resultingOwnership = _out272; + RAST._IExpr _341_valueGen; + DCOMP._IOwnership _342___v203; + Dafny.ISet> _343_recIdents; + RAST._IExpr _out269; + DCOMP._IOwnership _out270; + Dafny.ISet> _out271; + (this).GenExpr(_339_value, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out269, out _out270, out _out271); + _341_valueGen = _out269; + _342___v203 = _out270; + _343_recIdents = _out271; + readIdents = _343_recIdents; + RAST._IType _344_valueTypeGen; + RAST._IType _out272; + _out272 = (this).GenType(_338_tpe, DCOMP.GenTypeContext.@default()); + _344_valueTypeGen = _out272; + Dafny.ISequence _345_iifeVar; + _345_iifeVar = DCOMP.__default.escapeVar(_337_name); + RAST._IExpr _346_bodyGen; + DCOMP._IOwnership _347___v204; + Dafny.ISet> _348_bodyIdents; + RAST._IExpr _out273; + DCOMP._IOwnership _out274; + Dafny.ISet> _out275; + (this).GenExpr(_340_iifeBody, selfIdent, (env).AddAssigned(_345_iifeVar, _344_valueTypeGen), DCOMP.Ownership.create_OwnershipOwned(), out _out273, out _out274, out _out275); + _346_bodyGen = _out273; + _347___v204 = _out274; + _348_bodyIdents = _out275; + readIdents = Dafny.Set>.Union(readIdents, Dafny.Set>.Difference(_348_bodyIdents, Dafny.Set>.FromElements(_345_iifeVar))); + r = RAST.Expr.create_Block((RAST.Expr.create_DeclareVar(RAST.DeclareType.create_CONST(), _345_iifeVar, Std.Wrappers.Option.create_Some(_344_valueTypeGen), Std.Wrappers.Option.create_Some(_341_valueGen))).Then(_346_bodyGen)); + RAST._IExpr _out276; + DCOMP._IOwnership _out277; + (this).FromOwned(r, expectedOwnership, out _out276, out _out277); + r = _out276; + resultingOwnership = _out277; return ; } goto after_match0; @@ -7388,43 +7457,43 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_Apply) { - DAST._IExpression _347_func = _source0.dtor_expr; - Dafny.ISequence _348_args = _source0.dtor_args; + DAST._IExpression _349_func = _source0.dtor_expr; + Dafny.ISequence _350_args = _source0.dtor_args; { - RAST._IExpr _349_funcExpr; - DCOMP._IOwnership _350___v224; - Dafny.ISet> _351_recIdents; - RAST._IExpr _out273; - DCOMP._IOwnership _out274; - Dafny.ISet> _out275; - (this).GenExpr(_347_func, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out273, out _out274, out _out275); - _349_funcExpr = _out273; - _350___v224 = _out274; - _351_recIdents = _out275; - readIdents = _351_recIdents; - Dafny.ISequence _352_rArgs; - _352_rArgs = Dafny.Sequence.FromElements(); - BigInteger _hi13 = new BigInteger((_348_args).Count); - for (BigInteger _353_i = BigInteger.Zero; _353_i < _hi13; _353_i++) { - RAST._IExpr _354_argExpr; - DCOMP._IOwnership _355_argOwned; - Dafny.ISet> _356_argIdents; - RAST._IExpr _out276; - DCOMP._IOwnership _out277; - Dafny.ISet> _out278; - (this).GenExpr((_348_args).Select(_353_i), selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out276, out _out277, out _out278); - _354_argExpr = _out276; - _355_argOwned = _out277; - _356_argIdents = _out278; - _352_rArgs = Dafny.Sequence.Concat(_352_rArgs, Dafny.Sequence.FromElements(_354_argExpr)); - readIdents = Dafny.Set>.Union(readIdents, _356_argIdents); - } - r = (_349_funcExpr).Apply(_352_rArgs); - RAST._IExpr _out279; - DCOMP._IOwnership _out280; - (this).FromOwned(r, expectedOwnership, out _out279, out _out280); - r = _out279; - resultingOwnership = _out280; + RAST._IExpr _351_funcExpr; + DCOMP._IOwnership _352___v205; + Dafny.ISet> _353_recIdents; + RAST._IExpr _out278; + DCOMP._IOwnership _out279; + Dafny.ISet> _out280; + (this).GenExpr(_349_func, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out278, out _out279, out _out280); + _351_funcExpr = _out278; + _352___v205 = _out279; + _353_recIdents = _out280; + readIdents = _353_recIdents; + Dafny.ISequence _354_rArgs; + _354_rArgs = Dafny.Sequence.FromElements(); + BigInteger _hi14 = new BigInteger((_350_args).Count); + for (BigInteger _355_i = BigInteger.Zero; _355_i < _hi14; _355_i++) { + RAST._IExpr _356_argExpr; + DCOMP._IOwnership _357_argOwned; + Dafny.ISet> _358_argIdents; + RAST._IExpr _out281; + DCOMP._IOwnership _out282; + Dafny.ISet> _out283; + (this).GenExpr((_350_args).Select(_355_i), selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out281, out _out282, out _out283); + _356_argExpr = _out281; + _357_argOwned = _out282; + _358_argIdents = _out283; + _354_rArgs = Dafny.Sequence.Concat(_354_rArgs, Dafny.Sequence.FromElements(_356_argExpr)); + readIdents = Dafny.Set>.Union(readIdents, _358_argIdents); + } + r = (_351_funcExpr).Apply(_354_rArgs); + RAST._IExpr _out284; + DCOMP._IOwnership _out285; + (this).FromOwned(r, expectedOwnership, out _out284, out _out285); + r = _out284; + resultingOwnership = _out285; return ; } goto after_match0; @@ -7432,31 +7501,31 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_TypeTest) { - DAST._IExpression _357_on = _source0.dtor_on; - Dafny.ISequence> _358_dType = _source0.dtor_dType; - Dafny.ISequence _359_variant = _source0.dtor_variant; + DAST._IExpression _359_on = _source0.dtor_on; + Dafny.ISequence> _360_dType = _source0.dtor_dType; + Dafny.ISequence _361_variant = _source0.dtor_variant; { - RAST._IExpr _360_exprGen; - DCOMP._IOwnership _361___v225; - Dafny.ISet> _362_recIdents; - RAST._IExpr _out281; - DCOMP._IOwnership _out282; - Dafny.ISet> _out283; - (this).GenExpr(_357_on, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out281, out _out282, out _out283); - _360_exprGen = _out281; - _361___v225 = _out282; - _362_recIdents = _out283; - RAST._IType _363_dTypePath; - RAST._IType _out284; - _out284 = (this).GenPathType(Dafny.Sequence>.Concat(_358_dType, Dafny.Sequence>.FromElements(_359_variant))); - _363_dTypePath = _out284; - r = (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("matches!"))).Apply(Dafny.Sequence.FromElements(((_360_exprGen).Sel(Dafny.Sequence.UnicodeFromString("as_ref"))).Apply(Dafny.Sequence.FromElements()), RAST.Expr.create_RawExpr(Dafny.Sequence.Concat((_363_dTypePath)._ToString(DCOMP.__default.IND), Dafny.Sequence.UnicodeFromString("{ .. }"))))); - RAST._IExpr _out285; - DCOMP._IOwnership _out286; - (this).FromOwned(r, expectedOwnership, out _out285, out _out286); - r = _out285; - resultingOwnership = _out286; - readIdents = _362_recIdents; + RAST._IExpr _362_exprGen; + DCOMP._IOwnership _363___v206; + Dafny.ISet> _364_recIdents; + RAST._IExpr _out286; + DCOMP._IOwnership _out287; + Dafny.ISet> _out288; + (this).GenExpr(_359_on, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out286, out _out287, out _out288); + _362_exprGen = _out286; + _363___v206 = _out287; + _364_recIdents = _out288; + RAST._IExpr _365_variantExprPath; + RAST._IExpr _out289; + _out289 = (this).GenPathExpr(Dafny.Sequence>.Concat(_360_dType, Dafny.Sequence>.FromElements(_361_variant)), true); + _365_variantExprPath = _out289; + r = (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("matches!"))).Apply(Dafny.Sequence.FromElements(((_362_exprGen).Sel(Dafny.Sequence.UnicodeFromString("as_ref"))).Apply0(), RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("{ .. }"), _365_variantExprPath, DAST.Format.UnaryOpFormat.create_NoFormat()))); + RAST._IExpr _out290; + DCOMP._IOwnership _out291; + (this).FromOwned(r, expectedOwnership, out _out290, out _out291); + r = _out290; + resultingOwnership = _out291; + readIdents = _364_recIdents; return ; } goto after_match0; @@ -7464,41 +7533,42 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_Is) { - DAST._IExpression _364_expr = _source0.dtor_expr; - DAST._IType _365_fromType = _source0.dtor_fromType; - DAST._IType _366_toType = _source0.dtor_toType; + DAST._IExpression _366_expr = _source0.dtor_expr; + DAST._IType _367_fromType = _source0.dtor_fromType; + DAST._IType _368_toType = _source0.dtor_toType; { - RAST._IExpr _367_expr; - DCOMP._IOwnership _368_recOwned; - Dafny.ISet> _369_recIdents; - RAST._IExpr _out287; - DCOMP._IOwnership _out288; - Dafny.ISet> _out289; - (this).GenExpr(_364_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out287, out _out288, out _out289); - _367_expr = _out287; - _368_recOwned = _out288; - _369_recIdents = _out289; - RAST._IType _370_fromType; - RAST._IType _out290; - _out290 = (this).GenType(_365_fromType, DCOMP.GenTypeContext.@default()); - _370_fromType = _out290; - RAST._IType _371_toType; - RAST._IType _out291; - _out291 = (this).GenType(_366_toType, DCOMP.GenTypeContext.@default()); - _371_toType = _out291; - if (((_370_fromType).IsObjectOrPointer()) && ((_371_toType).IsObjectOrPointer())) { - r = (((_367_expr).Sel(Dafny.Sequence.UnicodeFromString("is_instance_of"))).ApplyType(Dafny.Sequence.FromElements((_371_toType).ObjectOrPointerUnderlying()))).Apply(Dafny.Sequence.FromElements()); + RAST._IExpr _369_expr; + DCOMP._IOwnership _370_recOwned; + Dafny.ISet> _371_recIdents; + RAST._IExpr _out292; + DCOMP._IOwnership _out293; + Dafny.ISet> _out294; + (this).GenExpr(_366_expr, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out292, out _out293, out _out294); + _369_expr = _out292; + _370_recOwned = _out293; + _371_recIdents = _out294; + RAST._IType _372_fromType; + RAST._IType _out295; + _out295 = (this).GenType(_367_fromType, DCOMP.GenTypeContext.@default()); + _372_fromType = _out295; + RAST._IType _373_toType; + RAST._IType _out296; + _out296 = (this).GenType(_368_toType, DCOMP.GenTypeContext.@default()); + _373_toType = _out296; + if (((_372_fromType).IsObjectOrPointer()) && ((_373_toType).IsObjectOrPointer())) { + r = (((_369_expr).Sel(Dafny.Sequence.UnicodeFromString("is_instance_of"))).ApplyType(Dafny.Sequence.FromElements((_373_toType).ObjectOrPointerUnderlying()))).Apply0(); } else { - (this).error = Std.Wrappers.Option>.create_Some(Dafny.Sequence.UnicodeFromString("Source and/or target types of type test is/are not Object or Ptr")); - r = RAST.Expr.create_RawExpr((this.error).dtor_value); + RAST._IExpr _out297; + _out297 = (this).Error(Dafny.Sequence.UnicodeFromString("Source and/or target types of type test is/are not Object or Ptr"), (this).InitEmptyExpr()); + r = _out297; readIdents = Dafny.Set>.FromElements(); } - RAST._IExpr _out292; - DCOMP._IOwnership _out293; - (this).FromOwnership(r, _368_recOwned, expectedOwnership, out _out292, out _out293); - r = _out292; - resultingOwnership = _out293; - readIdents = _369_recIdents; + RAST._IExpr _out298; + DCOMP._IOwnership _out299; + (this).FromOwnership(r, _370_recOwned, expectedOwnership, out _out298, out _out299); + r = _out298; + resultingOwnership = _out299; + readIdents = _371_recIdents; return ; } goto after_match0; @@ -7508,11 +7578,11 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv if (_source0.is_BoolBoundedPool) { { r = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("[false, true]")); - RAST._IExpr _out294; - DCOMP._IOwnership _out295; - (this).FromOwned(r, expectedOwnership, out _out294, out _out295); - r = _out294; - resultingOwnership = _out295; + RAST._IExpr _out300; + DCOMP._IOwnership _out301; + (this).FromOwned(r, expectedOwnership, out _out300, out _out301); + r = _out300; + resultingOwnership = _out301; readIdents = Dafny.Set>.FromElements(); return ; } @@ -7521,25 +7591,25 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_SetBoundedPool) { - DAST._IExpression _372_of = _source0.dtor_of; + DAST._IExpression _374_of = _source0.dtor_of; { - RAST._IExpr _373_exprGen; - DCOMP._IOwnership _374___v226; - Dafny.ISet> _375_recIdents; - RAST._IExpr _out296; - DCOMP._IOwnership _out297; - Dafny.ISet> _out298; - (this).GenExpr(_372_of, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out296, out _out297, out _out298); - _373_exprGen = _out296; - _374___v226 = _out297; - _375_recIdents = _out298; - r = ((_373_exprGen).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply(Dafny.Sequence.FromElements()); - RAST._IExpr _out299; - DCOMP._IOwnership _out300; - (this).FromOwned(r, expectedOwnership, out _out299, out _out300); - r = _out299; - resultingOwnership = _out300; - readIdents = _375_recIdents; + RAST._IExpr _375_exprGen; + DCOMP._IOwnership _376___v207; + Dafny.ISet> _377_recIdents; + RAST._IExpr _out302; + DCOMP._IOwnership _out303; + Dafny.ISet> _out304; + (this).GenExpr(_374_of, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out302, out _out303, out _out304); + _375_exprGen = _out302; + _376___v207 = _out303; + _377_recIdents = _out304; + r = ((_375_exprGen).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply0(); + RAST._IExpr _out305; + DCOMP._IOwnership _out306; + (this).FromOwned(r, expectedOwnership, out _out305, out _out306); + r = _out305; + resultingOwnership = _out306; + readIdents = _377_recIdents; return ; } goto after_match0; @@ -7547,29 +7617,29 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_SeqBoundedPool) { - DAST._IExpression _376_of = _source0.dtor_of; - bool _377_includeDuplicates = _source0.dtor_includeDuplicates; + DAST._IExpression _378_of = _source0.dtor_of; + bool _379_includeDuplicates = _source0.dtor_includeDuplicates; { - RAST._IExpr _378_exprGen; - DCOMP._IOwnership _379___v227; - Dafny.ISet> _380_recIdents; - RAST._IExpr _out301; - DCOMP._IOwnership _out302; - Dafny.ISet> _out303; - (this).GenExpr(_376_of, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out301, out _out302, out _out303); - _378_exprGen = _out301; - _379___v227 = _out302; - _380_recIdents = _out303; - r = ((_378_exprGen).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply(Dafny.Sequence.FromElements()); - if (!(_377_includeDuplicates)) { - r = (((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("itertools"))).MSel(Dafny.Sequence.UnicodeFromString("Itertools"))).MSel(Dafny.Sequence.UnicodeFromString("unique"))).AsExpr()).Apply1(r); - } - RAST._IExpr _out304; - DCOMP._IOwnership _out305; - (this).FromOwned(r, expectedOwnership, out _out304, out _out305); - r = _out304; - resultingOwnership = _out305; - readIdents = _380_recIdents; + RAST._IExpr _380_exprGen; + DCOMP._IOwnership _381___v208; + Dafny.ISet> _382_recIdents; + RAST._IExpr _out307; + DCOMP._IOwnership _out308; + Dafny.ISet> _out309; + (this).GenExpr(_378_of, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out307, out _out308, out _out309); + _380_exprGen = _out307; + _381___v208 = _out308; + _382_recIdents = _out309; + r = ((_380_exprGen).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply0(); + if (!(_379_includeDuplicates)) { + r = (((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("itertools"))).MSel(Dafny.Sequence.UnicodeFromString("Itertools"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("unique"))).Apply1(r); + } + RAST._IExpr _out310; + DCOMP._IOwnership _out311; + (this).FromOwned(r, expectedOwnership, out _out310, out _out311); + r = _out310; + resultingOwnership = _out311; + readIdents = _382_recIdents; return ; } goto after_match0; @@ -7577,99 +7647,99 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_MapBoundedPool) { - DAST._IExpression _381_of = _source0.dtor_of; + DAST._IExpression _383_of = _source0.dtor_of; { - RAST._IExpr _382_exprGen; - DCOMP._IOwnership _383___v228; - Dafny.ISet> _384_recIdents; - RAST._IExpr _out306; - DCOMP._IOwnership _out307; - Dafny.ISet> _out308; - (this).GenExpr(_381_of, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out306, out _out307, out _out308); - _382_exprGen = _out306; - _383___v228 = _out307; - _384_recIdents = _out308; - r = ((((_382_exprGen).Sel(Dafny.Sequence.UnicodeFromString("keys"))).Apply(Dafny.Sequence.FromElements())).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply(Dafny.Sequence.FromElements()); - readIdents = _384_recIdents; - RAST._IExpr _out309; - DCOMP._IOwnership _out310; - (this).FromOwned(r, expectedOwnership, out _out309, out _out310); - r = _out309; - resultingOwnership = _out310; + RAST._IExpr _384_exprGen; + DCOMP._IOwnership _385___v209; + Dafny.ISet> _386_recIdents; + RAST._IExpr _out312; + DCOMP._IOwnership _out313; + Dafny.ISet> _out314; + (this).GenExpr(_383_of, selfIdent, env, DCOMP.Ownership.create_OwnershipBorrowed(), out _out312, out _out313, out _out314); + _384_exprGen = _out312; + _385___v209 = _out313; + _386_recIdents = _out314; + r = ((((_384_exprGen).Sel(Dafny.Sequence.UnicodeFromString("keys"))).Apply0()).Sel(Dafny.Sequence.UnicodeFromString("iter"))).Apply0(); + readIdents = _386_recIdents; + RAST._IExpr _out315; + DCOMP._IOwnership _out316; + (this).FromOwned(r, expectedOwnership, out _out315, out _out316); + r = _out315; + resultingOwnership = _out316; } goto after_match0; } } { if (_source0.is_ExactBoundedPool) { - DAST._IExpression _385_of = _source0.dtor_of; + DAST._IExpression _387_of = _source0.dtor_of; { - RAST._IExpr _386_exprGen; - DCOMP._IOwnership _387___v229; - Dafny.ISet> _388_recIdents; - RAST._IExpr _out311; - DCOMP._IOwnership _out312; - Dafny.ISet> _out313; - (this).GenExpr(_385_of, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out311, out _out312, out _out313); - _386_exprGen = _out311; - _387___v229 = _out312; - _388_recIdents = _out313; - r = ((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("iter"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("once"))).Apply1(_386_exprGen); - readIdents = _388_recIdents; - RAST._IExpr _out314; - DCOMP._IOwnership _out315; - (this).FromOwned(r, expectedOwnership, out _out314, out _out315); - r = _out314; - resultingOwnership = _out315; + RAST._IExpr _388_exprGen; + DCOMP._IOwnership _389___v210; + Dafny.ISet> _390_recIdents; + RAST._IExpr _out317; + DCOMP._IOwnership _out318; + Dafny.ISet> _out319; + (this).GenExpr(_387_of, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out317, out _out318, out _out319); + _388_exprGen = _out317; + _389___v210 = _out318; + _390_recIdents = _out319; + r = ((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("iter"))).AsExpr()).FSel(Dafny.Sequence.UnicodeFromString("once"))).Apply1(_388_exprGen); + readIdents = _390_recIdents; + RAST._IExpr _out320; + DCOMP._IOwnership _out321; + (this).FromOwned(r, expectedOwnership, out _out320, out _out321); + r = _out320; + resultingOwnership = _out321; } goto after_match0; } } { if (_source0.is_IntRange) { - DAST._IType _389_typ = _source0.dtor_elemType; - DAST._IExpression _390_lo = _source0.dtor_lo; - DAST._IExpression _391_hi = _source0.dtor_hi; - bool _392_up = _source0.dtor_up; + DAST._IType _391_typ = _source0.dtor_elemType; + DAST._IExpression _392_lo = _source0.dtor_lo; + DAST._IExpression _393_hi = _source0.dtor_hi; + bool _394_up = _source0.dtor_up; { - RAST._IExpr _393_lo; - DCOMP._IOwnership _394___v230; - Dafny.ISet> _395_recIdentsLo; - RAST._IExpr _out316; - DCOMP._IOwnership _out317; - Dafny.ISet> _out318; - (this).GenExpr(_390_lo, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out316, out _out317, out _out318); - _393_lo = _out316; - _394___v230 = _out317; - _395_recIdentsLo = _out318; - RAST._IExpr _396_hi; - DCOMP._IOwnership _397___v231; - Dafny.ISet> _398_recIdentsHi; - RAST._IExpr _out319; - DCOMP._IOwnership _out320; - Dafny.ISet> _out321; - (this).GenExpr(_391_hi, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out319, out _out320, out _out321); - _396_hi = _out319; - _397___v231 = _out320; - _398_recIdentsHi = _out321; - if (_392_up) { - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("integer_range"))).AsExpr()).Apply(Dafny.Sequence.FromElements(_393_lo, _396_hi)); + RAST._IExpr _395_lo; + DCOMP._IOwnership _396___v211; + Dafny.ISet> _397_recIdentsLo; + RAST._IExpr _out322; + DCOMP._IOwnership _out323; + Dafny.ISet> _out324; + (this).GenExpr(_392_lo, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out322, out _out323, out _out324); + _395_lo = _out322; + _396___v211 = _out323; + _397_recIdentsLo = _out324; + RAST._IExpr _398_hi; + DCOMP._IOwnership _399___v212; + Dafny.ISet> _400_recIdentsHi; + RAST._IExpr _out325; + DCOMP._IOwnership _out326; + Dafny.ISet> _out327; + (this).GenExpr(_393_hi, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out325, out _out326, out _out327); + _398_hi = _out325; + _399___v212 = _out326; + _400_recIdentsHi = _out327; + if (_394_up) { + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("integer_range"))).AsExpr()).Apply(Dafny.Sequence.FromElements(_395_lo, _398_hi)); } else { - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("integer_range_down"))).AsExpr()).Apply(Dafny.Sequence.FromElements(_396_hi, _393_lo)); - } - if (!((_389_typ).is_Primitive)) { - RAST._IType _399_tpe; - RAST._IType _out322; - _out322 = (this).GenType(_389_typ, DCOMP.GenTypeContext.@default()); - _399_tpe = _out322; - r = ((r).Sel(Dafny.Sequence.UnicodeFromString("map"))).Apply1((((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("convert"))).MSel(Dafny.Sequence.UnicodeFromString("Into"))).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_399_tpe))).FSel(Dafny.Sequence.UnicodeFromString("into"))); - } - RAST._IExpr _out323; - DCOMP._IOwnership _out324; - (this).FromOwned(r, expectedOwnership, out _out323, out _out324); - r = _out323; - resultingOwnership = _out324; - readIdents = Dafny.Set>.Union(_395_recIdentsLo, _398_recIdentsHi); + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("integer_range_down"))).AsExpr()).Apply(Dafny.Sequence.FromElements(_398_hi, _395_lo)); + } + if (!((_391_typ).is_Primitive)) { + RAST._IType _401_tpe; + RAST._IType _out328; + _out328 = (this).GenType(_391_typ, DCOMP.GenTypeContext.@default()); + _401_tpe = _out328; + r = ((r).Sel(Dafny.Sequence.UnicodeFromString("map"))).Apply1((((((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("convert"))).MSel(Dafny.Sequence.UnicodeFromString("Into"))).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_401_tpe))).FSel(Dafny.Sequence.UnicodeFromString("into"))); + } + RAST._IExpr _out329; + DCOMP._IOwnership _out330; + (this).FromOwned(r, expectedOwnership, out _out329, out _out330); + r = _out329; + resultingOwnership = _out330; + readIdents = Dafny.Set>.Union(_397_recIdentsLo, _400_recIdentsHi); return ; } goto after_match0; @@ -7677,30 +7747,30 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_UnboundedIntRange) { - DAST._IExpression _400_start = _source0.dtor_start; - bool _401_up = _source0.dtor_up; + DAST._IExpression _402_start = _source0.dtor_start; + bool _403_up = _source0.dtor_up; { - RAST._IExpr _402_start; - DCOMP._IOwnership _403___v232; - Dafny.ISet> _404_recIdentStart; - RAST._IExpr _out325; - DCOMP._IOwnership _out326; - Dafny.ISet> _out327; - (this).GenExpr(_400_start, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out325, out _out326, out _out327); - _402_start = _out325; - _403___v232 = _out326; - _404_recIdentStart = _out327; - if (_401_up) { - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("integer_range_unbounded"))).AsExpr()).Apply1(_402_start); + RAST._IExpr _404_start; + DCOMP._IOwnership _405___v213; + Dafny.ISet> _406_recIdentStart; + RAST._IExpr _out331; + DCOMP._IOwnership _out332; + Dafny.ISet> _out333; + (this).GenExpr(_402_start, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out331, out _out332, out _out333); + _404_start = _out331; + _405___v213 = _out332; + _406_recIdentStart = _out333; + if (_403_up) { + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("integer_range_unbounded"))).AsExpr()).Apply1(_404_start); } else { - r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("integer_range_down_unbounded"))).AsExpr()).Apply1(_402_start); - } - RAST._IExpr _out328; - DCOMP._IOwnership _out329; - (this).FromOwned(r, expectedOwnership, out _out328, out _out329); - r = _out328; - resultingOwnership = _out329; - readIdents = _404_recIdentStart; + r = (((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("integer_range_down_unbounded"))).AsExpr()).Apply1(_404_start); + } + RAST._IExpr _out334; + DCOMP._IOwnership _out335; + (this).FromOwned(r, expectedOwnership, out _out334, out _out335); + r = _out334; + resultingOwnership = _out335; + readIdents = _406_recIdentStart; return ; } goto after_match0; @@ -7708,23 +7778,23 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_MapBuilder) { - DAST._IType _405_keyType = _source0.dtor_keyType; - DAST._IType _406_valueType = _source0.dtor_valueType; + DAST._IType _407_keyType = _source0.dtor_keyType; + DAST._IType _408_valueType = _source0.dtor_valueType; { - RAST._IType _407_kType; - RAST._IType _out330; - _out330 = (this).GenType(_405_keyType, DCOMP.GenTypeContext.@default()); - _407_kType = _out330; - RAST._IType _408_vType; - RAST._IType _out331; - _out331 = (this).GenType(_406_valueType, DCOMP.GenTypeContext.@default()); - _408_vType = _out331; - r = (((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("MapBuilder"))).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_407_kType, _408_vType))).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply(Dafny.Sequence.FromElements()); - RAST._IExpr _out332; - DCOMP._IOwnership _out333; - (this).FromOwned(r, expectedOwnership, out _out332, out _out333); - r = _out332; - resultingOwnership = _out333; + RAST._IType _409_kType; + RAST._IType _out336; + _out336 = (this).GenType(_407_keyType, DCOMP.GenTypeContext.@default()); + _409_kType = _out336; + RAST._IType _410_vType; + RAST._IType _out337; + _out337 = (this).GenType(_408_valueType, DCOMP.GenTypeContext.@default()); + _410_vType = _out337; + r = (((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("MapBuilder"))).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_409_kType, _410_vType))).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply0(); + RAST._IExpr _out338; + DCOMP._IOwnership _out339; + (this).FromOwned(r, expectedOwnership, out _out338, out _out339); + r = _out338; + resultingOwnership = _out339; readIdents = Dafny.Set>.FromElements(); return ; } @@ -7733,96 +7803,109 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } { if (_source0.is_SetBuilder) { - DAST._IType _409_elemType = _source0.dtor_elemType; + DAST._IType _411_elemType = _source0.dtor_elemType; { - RAST._IType _410_eType; - RAST._IType _out334; - _out334 = (this).GenType(_409_elemType, DCOMP.GenTypeContext.@default()); - _410_eType = _out334; + RAST._IType _412_eType; + RAST._IType _out340; + _out340 = (this).GenType(_411_elemType, DCOMP.GenTypeContext.@default()); + _412_eType = _out340; readIdents = Dafny.Set>.FromElements(); - r = (((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("SetBuilder"))).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_410_eType))).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply(Dafny.Sequence.FromElements()); - RAST._IExpr _out335; - DCOMP._IOwnership _out336; - (this).FromOwned(r, expectedOwnership, out _out335, out _out336); - r = _out335; - resultingOwnership = _out336; + r = (((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("SetBuilder"))).AsExpr()).ApplyType(Dafny.Sequence.FromElements(_412_eType))).FSel(Dafny.Sequence.UnicodeFromString("new"))).Apply0(); + RAST._IExpr _out341; + DCOMP._IOwnership _out342; + (this).FromOwned(r, expectedOwnership, out _out341, out _out342); + r = _out341; + resultingOwnership = _out342; return ; } goto after_match0; } } { - DAST._IType _411_elemType = _source0.dtor_elemType; - DAST._IExpression _412_collection = _source0.dtor_collection; - bool _413_is__forall = _source0.dtor_is__forall; - DAST._IExpression _414_lambda = _source0.dtor_lambda; + DAST._IType _413_elemType = _source0.dtor_elemType; + DAST._IExpression _414_collection = _source0.dtor_collection; + bool _415_is__forall = _source0.dtor_is__forall; + DAST._IExpression _416_lambda = _source0.dtor_lambda; { - RAST._IType _415_tpe; - RAST._IType _out337; - _out337 = (this).GenType(_411_elemType, DCOMP.GenTypeContext.@default()); - _415_tpe = _out337; - RAST._IExpr _416_collectionGen; - DCOMP._IOwnership _417___v233; - Dafny.ISet> _418_recIdents; - RAST._IExpr _out338; - DCOMP._IOwnership _out339; - Dafny.ISet> _out340; - (this).GenExpr(_412_collection, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out338, out _out339, out _out340); - _416_collectionGen = _out338; - _417___v233 = _out339; - _418_recIdents = _out340; - Dafny.ISequence _419_extraAttributes; - _419_extraAttributes = Dafny.Sequence.FromElements(); - if (((((_412_collection).is_IntRange) || ((_412_collection).is_UnboundedIntRange)) || ((_412_collection).is_SeqBoundedPool)) || ((_412_collection).is_ExactBoundedPool)) { - _419_extraAttributes = Dafny.Sequence.FromElements(DCOMP.__default.AttributeOwned); - } - if ((_414_lambda).is_Lambda) { - Dafny.ISequence _420_formals; - _420_formals = (_414_lambda).dtor_params; - Dafny.ISequence _421_newFormals; - _421_newFormals = Dafny.Sequence.FromElements(); - BigInteger _hi14 = new BigInteger((_420_formals).Count); - for (BigInteger _422_i = BigInteger.Zero; _422_i < _hi14; _422_i++) { - var _pat_let_tv0 = _419_extraAttributes; - var _pat_let_tv1 = _420_formals; - _421_newFormals = Dafny.Sequence.Concat(_421_newFormals, Dafny.Sequence.FromElements(Dafny.Helpers.Let((_420_formals).Select(_422_i), _pat_let28_0 => Dafny.Helpers.Let(_pat_let28_0, _423_dt__update__tmp_h0 => Dafny.Helpers.Let, DAST._IFormal>(Dafny.Sequence.Concat(_pat_let_tv0, ((_pat_let_tv1).Select(_422_i)).dtor_attributes), _pat_let29_0 => Dafny.Helpers.Let, DAST._IFormal>(_pat_let29_0, _424_dt__update_hattributes_h0 => DAST.Formal.create((_423_dt__update__tmp_h0).dtor_name, (_423_dt__update__tmp_h0).dtor_typ, _424_dt__update_hattributes_h0))))))); - } - DAST._IExpression _425_newLambda; - DAST._IExpression _426_dt__update__tmp_h1 = _414_lambda; - Dafny.ISequence _427_dt__update_hparams_h0 = _421_newFormals; - _425_newLambda = DAST.Expression.create_Lambda(_427_dt__update_hparams_h0, (_426_dt__update__tmp_h1).dtor_retType, (_426_dt__update__tmp_h1).dtor_body); - RAST._IExpr _428_lambdaGen; - DCOMP._IOwnership _429___v234; - Dafny.ISet> _430_recLambdaIdents; - RAST._IExpr _out341; - DCOMP._IOwnership _out342; - Dafny.ISet> _out343; - (this).GenExpr(_425_newLambda, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out341, out _out342, out _out343); - _428_lambdaGen = _out341; - _429___v234 = _out342; - _430_recLambdaIdents = _out343; - Dafny.ISequence _431_fn; - if (_413_is__forall) { - _431_fn = Dafny.Sequence.UnicodeFromString("all"); + RAST._IType _417_tpe; + RAST._IType _out343; + _out343 = (this).GenType(_413_elemType, DCOMP.GenTypeContext.@default()); + _417_tpe = _out343; + RAST._IExpr _418_collectionGen; + DCOMP._IOwnership _419___v214; + Dafny.ISet> _420_recIdents; + RAST._IExpr _out344; + DCOMP._IOwnership _out345; + Dafny.ISet> _out346; + (this).GenExpr(_414_collection, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out344, out _out345, out _out346); + _418_collectionGen = _out344; + _419___v214 = _out345; + _420_recIdents = _out346; + Dafny.ISequence _421_extraAttributes; + _421_extraAttributes = Dafny.Sequence.FromElements(); + if (((((_414_collection).is_IntRange) || ((_414_collection).is_UnboundedIntRange)) || ((_414_collection).is_SeqBoundedPool)) || ((_414_collection).is_ExactBoundedPool)) { + _421_extraAttributes = Dafny.Sequence.FromElements(DCOMP.__default.AttributeOwned); + } + if ((_416_lambda).is_Lambda) { + Dafny.ISequence _422_formals; + _422_formals = (_416_lambda).dtor_params; + Dafny.ISequence _423_newFormals; + _423_newFormals = Dafny.Sequence.FromElements(); + BigInteger _hi15 = new BigInteger((_422_formals).Count); + for (BigInteger _424_i = BigInteger.Zero; _424_i < _hi15; _424_i++) { + var _pat_let_tv0 = _421_extraAttributes; + var _pat_let_tv1 = _422_formals; + _423_newFormals = Dafny.Sequence.Concat(_423_newFormals, Dafny.Sequence.FromElements(Dafny.Helpers.Let((_422_formals).Select(_424_i), _pat_let28_0 => Dafny.Helpers.Let(_pat_let28_0, _425_dt__update__tmp_h0 => Dafny.Helpers.Let, DAST._IFormal>(Dafny.Sequence.Concat(_pat_let_tv0, ((_pat_let_tv1).Select(_424_i)).dtor_attributes), _pat_let29_0 => Dafny.Helpers.Let, DAST._IFormal>(_pat_let29_0, _426_dt__update_hattributes_h0 => DAST.Formal.create((_425_dt__update__tmp_h0).dtor_name, (_425_dt__update__tmp_h0).dtor_typ, _426_dt__update_hattributes_h0))))))); + } + DAST._IExpression _427_newLambda; + DAST._IExpression _428_dt__update__tmp_h1 = _416_lambda; + Dafny.ISequence _429_dt__update_hparams_h0 = _423_newFormals; + _427_newLambda = DAST.Expression.create_Lambda(_429_dt__update_hparams_h0, (_428_dt__update__tmp_h1).dtor_retType, (_428_dt__update__tmp_h1).dtor_body); + RAST._IExpr _430_lambdaGen; + DCOMP._IOwnership _431___v215; + Dafny.ISet> _432_recLambdaIdents; + RAST._IExpr _out347; + DCOMP._IOwnership _out348; + Dafny.ISet> _out349; + (this).GenExpr(_427_newLambda, selfIdent, env, DCOMP.Ownership.create_OwnershipOwned(), out _out347, out _out348, out _out349); + _430_lambdaGen = _out347; + _431___v215 = _out348; + _432_recLambdaIdents = _out349; + Dafny.ISequence _433_fn; + if (_415_is__forall) { + _433_fn = Dafny.Sequence.UnicodeFromString("all"); } else { - _431_fn = Dafny.Sequence.UnicodeFromString("any"); + _433_fn = Dafny.Sequence.UnicodeFromString("any"); } - r = ((_416_collectionGen).Sel(_431_fn)).Apply1(((_428_lambdaGen).Sel(Dafny.Sequence.UnicodeFromString("as_ref"))).Apply(Dafny.Sequence.FromElements())); - readIdents = Dafny.Set>.Union(_418_recIdents, _430_recLambdaIdents); + r = ((_418_collectionGen).Sel(_433_fn)).Apply1(((_430_lambdaGen).Sel(Dafny.Sequence.UnicodeFromString("as_ref"))).Apply0()); + readIdents = Dafny.Set>.Union(_420_recIdents, _432_recLambdaIdents); } else { - (this).error = Std.Wrappers.Option>.create_Some(Dafny.Sequence.UnicodeFromString("Quantifier without an inline lambda")); - r = RAST.Expr.create_RawExpr((this.error).dtor_value); + RAST._IExpr _out350; + _out350 = (this).Error(Dafny.Sequence.UnicodeFromString("Quantifier without an inline lambda"), (this).InitEmptyExpr()); + r = _out350; readIdents = Dafny.Set>.FromElements(); } - RAST._IExpr _out344; - DCOMP._IOwnership _out345; - (this).FromOwned(r, expectedOwnership, out _out344, out _out345); - r = _out344; - resultingOwnership = _out345; + RAST._IExpr _out351; + DCOMP._IOwnership _out352; + (this).FromOwned(r, expectedOwnership, out _out351, out _out352); + r = _out351; + resultingOwnership = _out352; } } after_match0: ; } + public RAST._IExpr InitEmptyExpr() { + return RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); + } + public RAST._IExpr Error(Dafny.ISequence message, RAST._IExpr defaultExpr) + { + RAST._IExpr r = RAST.Expr.Default(); + if ((this.error).is_None) { + (this).error = Std.Wrappers.Option>.create_Some(message); + } + r = RAST.Expr.create_UnaryOp(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("/*"), message), Dafny.Sequence.UnicodeFromString("*/")), defaultExpr, DAST.Format.UnaryOpFormat.create_NoFormat()); + return r; + } public Dafny.ISequence Compile(Dafny.ISequence p, Dafny.ISequence> externalFiles) { Dafny.ISequence s = Dafny.Sequence.Empty; diff --git a/Source/DafnyCore/GeneratedFromDafny/ExpressionOptimization.cs b/Source/DafnyCore/GeneratedFromDafny/ExpressionOptimization.cs new file mode 100644 index 00000000000..85c98391cc4 --- /dev/null +++ b/Source/DafnyCore/GeneratedFromDafny/ExpressionOptimization.cs @@ -0,0 +1,172 @@ +// Dafny program the_program compiled into C# +// To recompile, you will need the libraries +// System.Runtime.Numerics.dll System.Collections.Immutable.dll +// but the 'dotnet' tool in net6.0 should pick those up automatically. +// Optionally, you may want to include compiler switches like +// /debug /nowarn:162,164,168,183,219,436,1717,1718 + +using System; +using System.Numerics; +using System.Collections; +#pragma warning disable CS0164 // This label has not been referenced +#pragma warning disable CS0162 // Unreachable code detected +#pragma warning disable CS1717 // Assignment made to same variable + +namespace ExpressionOptimization { + + public partial class __default { + public static RAST._IMod apply(RAST._IMod mod) { + return (ExpressionOptimization.__default.ExprSimplifier()).ReplaceMod(mod, (RAST.__default.crate).MSel((mod).dtor_name)); + } + public static RAST._IRASTBottomUpReplacer ExprSimplifier() { + return RAST.RASTBottomUpReplacer.create(((System.Func)((_0_m, _1_SelfPath) => { + return _0_m; +})), ((System.Func)((_2_t) => { + return _2_t; +})), ((System.Func)((_3_e) => { + return ((System.Func)(() => { + RAST._IExpr _source0 = _3_e; + { + if (_source0.is_UnaryOp) { + Dafny.ISequence op10 = _source0.dtor_op1; + if (object.Equals(op10, Dafny.Sequence.UnicodeFromString("!"))) { + RAST._IExpr underlying0 = _source0.dtor_underlying; + if (underlying0.is_BinaryOp) { + Dafny.ISequence _4_op = underlying0.dtor_op2; + RAST._IExpr _5_left = underlying0.dtor_left; + RAST._IExpr _6_right = underlying0.dtor_right; + DAST.Format._IBinaryOpFormat _7_format = underlying0.dtor_format2; + DAST.Format._IUnaryOpFormat format0 = _source0.dtor_format; + if (format0.is_CombineFormat) { + Dafny.ISequence _source1 = _4_op; + { + if (object.Equals(_source1, Dafny.Sequence.UnicodeFromString("=="))) { + return RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("!="), _5_left, _6_right, DAST.Format.BinaryOpFormat.create_NoFormat()); + } + } + { + if (object.Equals(_source1, Dafny.Sequence.UnicodeFromString("<"))) { + if ((_7_format).is_NoFormat) { + return RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString(">="), _5_left, _6_right, DAST.Format.BinaryOpFormat.create_NoFormat()); + } else if ((_7_format).is_ReverseFormat) { + return RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<="), _6_right, _5_left, DAST.Format.BinaryOpFormat.create_NoFormat()); + } else { + return _3_e; + } + } + } + { + return _3_e; + } + } + } + } + } + } + { + if (_source0.is_Call) { + RAST._IExpr obj0 = _source0.dtor_obj; + if (obj0.is_ExprFromPath) { + RAST._IPath path0 = obj0.dtor_path; + if (path0.is_PMemberSelect) { + RAST._IPath _8_r = path0.dtor_base; + Dafny.ISequence name0 = path0.dtor_name; + if (object.Equals(name0, Dafny.Sequence.UnicodeFromString("truncate!"))) { + Dafny.ISequence _9_args = _source0.dtor_arguments; + if (((!object.Equals(_8_r, RAST.__default.dafny__runtime)) && (!object.Equals(_8_r, RAST.__default.@global))) || ((new BigInteger((_9_args).Count)) != (new BigInteger(2)))) { + return _3_e; + } else { + RAST._IExpr _10_expr = (_9_args).Select(BigInteger.Zero); + RAST._IExpr _11_tpeExpr = (_9_args).Select(BigInteger.One); + if (!((_11_tpeExpr).is_ExprFromType)) { + return _3_e; + } else { + RAST._IType _12_tpe = (_11_tpeExpr).dtor_tpe; + if ((((((((((((_12_tpe).is_U8) || ((_12_tpe).is_U16)) || ((_12_tpe).is_U32)) || ((_12_tpe).is_U64)) || ((_12_tpe).is_U128)) || ((_12_tpe).is_I8)) || ((_12_tpe).is_I16)) || ((_12_tpe).is_I32)) || ((_12_tpe).is_I64)) || ((_12_tpe).is_I128)) || ((_12_tpe).is_USIZE)) { + RAST._IExpr _source2 = _10_expr; + { + if (_source2.is_Call) { + RAST._IExpr obj1 = _source2.dtor_obj; + if (obj1.is_ExprFromPath) { + RAST._IPath path1 = obj1.dtor_path; + if (path1.is_PMemberSelect) { + RAST._IPath _13_base = path1.dtor_base; + Dafny.ISequence name1 = path1.dtor_name; + if (object.Equals(name1, Dafny.Sequence.UnicodeFromString("int!"))) { + Dafny.ISequence _14_args = _source2.dtor_arguments; + if (((new BigInteger((_14_args).Count)) == (BigInteger.One)) && ((object.Equals(_13_base, RAST.__default.dafny__runtime)) || (object.Equals(_13_base, RAST.__default.@global)))) { + RAST._IExpr _source3 = (_14_args).Select(BigInteger.Zero); + { + if (_source3.is_LiteralInt) { + Dafny.ISequence _15_number = _source3.dtor_value; + return RAST.Expr.create_LiteralInt(_15_number); + } + } + { + if (_source3.is_LiteralString) { + Dafny.ISequence _16_number = _source3.dtor_value; + return RAST.Expr.create_LiteralInt(_16_number); + } + } + { + return _3_e; + } + } else { + return _3_e; + } + } + } + } + } + } + { + return _3_e; + } + } else { + return _3_e; + } + } + } + } + } + } + } + } + { + if (_source0.is_StmtExpr) { + RAST._IExpr stmt0 = _source0.dtor_stmt; + if (stmt0.is_DeclareVar) { + RAST._IDeclareType _17_mod = stmt0.dtor_declareType; + Dafny.ISequence _18_name = stmt0.dtor_name; + Std.Wrappers._IOption optType0 = stmt0.dtor_optType; + if (optType0.is_Some) { + RAST._IType _19_tpe = optType0.dtor_value; + Std.Wrappers._IOption optRhs0 = stmt0.dtor_optRhs; + if (optRhs0.is_None) { + RAST._IExpr rhs0 = _source0.dtor_rhs; + if (rhs0.is_StmtExpr) { + RAST._IExpr stmt1 = rhs0.dtor_stmt; + if (stmt1.is_Assign) { + Std.Wrappers._IOption _20_name2 = stmt1.dtor_names; + RAST._IExpr _21_rhs = stmt1.dtor_rhs; + RAST._IExpr _22_last = rhs0.dtor_rhs; + if (object.Equals(_20_name2, Std.Wrappers.Option.create_Some(RAST.AssignLhs.create_LocalVar(_18_name)))) { + return RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(_17_mod, _18_name, Std.Wrappers.Option.create_Some(_19_tpe), Std.Wrappers.Option.create_Some(_21_rhs)), _22_last); + } else { + return _3_e; + } + } + } + } + } + } + } + } + { + return _3_e; + } + }))(); +}))); + } + } +} // end of namespace ExpressionOptimization \ No newline at end of file diff --git a/Source/DafnyCore/GeneratedFromDafny/FactorPathsOptimization.cs b/Source/DafnyCore/GeneratedFromDafny/FactorPathsOptimization.cs index f84ad3e437e..c16bca4427a 100644 --- a/Source/DafnyCore/GeneratedFromDafny/FactorPathsOptimization.cs +++ b/Source/DafnyCore/GeneratedFromDafny/FactorPathsOptimization.cs @@ -15,32 +15,27 @@ namespace FactorPathsOptimization { public partial class __default { - public static Func apply(RAST._IPath thisFile) { - return Dafny.Helpers.Id>>((_0_thisFile) => ((System.Func)((_1_mod) => { - return FactorPathsOptimization.__default.applyPrefix(_1_mod, (_0_thisFile).MSel((_1_mod).dtor_name)); - })))(thisFile); + public static Func apply(RAST._IPath root) { + return Dafny.Helpers.Id>>((_0_root) => ((System.Func)((_1_mod) => { + return FactorPathsOptimization.__default.applyPrefix(_1_mod, (_0_root).MSel((_1_mod).dtor_name)); + })))(root); } public static RAST._IMod applyPrefix(RAST._IMod mod, RAST._IPath SelfPath) { if ((mod).is_ExternMod) { return mod; } else { - FactorPathsOptimization._IMapping _0_initialMapping = FactorPathsOptimization.Mapping.create(Dafny.Map, Dafny.ISet>.FromElements(), Dafny.Sequence>.FromElements()); - FactorPathsOptimization._IMapping _1_mappings = (mod).Fold(_0_initialMapping, Dafny.Helpers.Id>>((_2_SelfPath) => ((System.Func)((_3_current, _4_modDecl) => { - return FactorPathsOptimization.__default.GatherModMapping(_2_SelfPath, _4_modDecl, _3_current); - })))(SelfPath)); - Dafny.IMap,RAST._IPath> _5_pathsToRemove = (_1_mappings).ToFinalReplacement(); - Dafny.ISequence _6_imports = (_1_mappings).ToUseStatements(_5_pathsToRemove, SelfPath); - Dafny.ISequence _7_rewrittenDeclarations = (mod).Fold>(Dafny.Sequence.FromElements(), Dafny.Helpers.Id,RAST._IPath>, RAST._IMod, Func, RAST._IModDecl, Dafny.ISequence>>>((_8_SelfPath, _9_pathsToRemove, _10_mod) => ((System.Func, RAST._IModDecl, Dafny.ISequence>)((_11_current, _12_modDecl) => { - return Dafny.Sequence.Concat(_11_current, Dafny.Sequence.FromElements(FactorPathsOptimization.__default.ReplaceModDecl(_12_modDecl, _8_SelfPath, _9_pathsToRemove))); - })))(SelfPath, _5_pathsToRemove, mod)); - RAST._IMod _13_dt__update__tmp_h0 = mod; - Dafny.ISequence _14_dt__update_hbody_h0 = Dafny.Sequence.Concat(_6_imports, _7_rewrittenDeclarations); - return RAST.Mod.create_Mod((_13_dt__update__tmp_h0).dtor_name, (_13_dt__update__tmp_h0).dtor_attributes, _14_dt__update_hbody_h0); + FactorPathsOptimization._IMapping _0_mappings = (FactorPathsOptimization.__default.PathsVisitor()).VisitMod(FactorPathsOptimization.Mapping.create(Dafny.Map, Dafny.ISet>.FromElements(), Dafny.Sequence>.FromElements()), mod, SelfPath); + Dafny.IMap,RAST._IPath> _1_pathsToRemove = (_0_mappings).ToFinalReplacement(SelfPath); + Dafny.ISequence _2_imports = (_0_mappings).ToUseStatements(_1_pathsToRemove, 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); } } public static __T UniqueElementOf<__T>(Dafny.ISet<__T> s) { - return Dafny.Helpers.Let(0, _let_dummy_14 => { + return Dafny.Helpers.Let(0, _let_dummy_22 => { __T _0_e = default(__T); foreach (__T _assign_such_that_0 in (s).Elements) { _0_e = (__T)_assign_such_that_0; @@ -54,278 +49,182 @@ public static __T UniqueElementOf<__T>(Dafny.ISet<__T> s) { } ); } - public static FactorPathsOptimization._IMapping GatherTypeParams(Dafny.ISequence typeParams, FactorPathsOptimization._IMapping current) + public static RAST._IRASTTopDownVisitor PathsVisitor() { + return RAST.RASTTopDownVisitor.create(((System.Func)((_0_current, _1_t) => { + return ((System.Func)(() => { + RAST._IType _source0 = _1_t; { - return RAST.__default.FoldLeft(((System.Func)((_0_current, _1_t) => { - return RAST.__default.FoldLeft(((System.Func)((_2_current, _3_t) => { - return FactorPathsOptimization.__default.GatherTypeMapping(_3_t, _2_current); - })), _0_current, (_1_t).dtor_constraints); - })), current, typeParams); - } - public static FactorPathsOptimization._IMapping GatherFields(RAST._IFields fields, FactorPathsOptimization._IMapping current) - { - RAST._IFields _source0 = fields; - { - if (_source0.is_NamedFields) { - Dafny.ISequence _0_sFields = _source0.dtor_fields; - return RAST.__default.FoldLeft(((System.Func)((_1_current, _2_f) => { - return FactorPathsOptimization.__default.GatherTypeMapping(((_2_f).dtor_formal).dtor_tpe, _1_current); - })), current, _0_sFields); + if (_source0.is_TypeFromPath) { + RAST._IPath path0 = _source0.dtor_path; + if (path0.is_PMemberSelect) { + RAST._IPath _2_base = path0.dtor_base; + Dafny.ISequence _3_name = path0.dtor_name; + if (object.Equals(_2_base, RAST.Path.create_Self())) { + return _0_current; + } else { + return (_0_current).Add(_3_name, _2_base); + } } } - { - Dafny.ISequence _3_sFields = _source0.dtor_types; - return RAST.__default.FoldLeft(((System.Func)((_4_current, _5_f) => { - return FactorPathsOptimization.__default.GatherTypeMapping((_5_f).dtor_tpe, _4_current); - })), current, _3_sFields); - } } - public static FactorPathsOptimization._IMapping GatherModMapping(RAST._IPath prefix, RAST._IModDecl modDecl, FactorPathsOptimization._IMapping current) { - RAST._IModDecl _source0 = modDecl; - { - if (_source0.is_ModDecl) { - RAST._IMod _0_mod = _source0.dtor_mod; - return (current).Add((_0_mod).dtor_name, prefix); - } - } - { - if (_source0.is_StructDecl) { - RAST._IStruct _1_struct = _source0.dtor_struct; - return FactorPathsOptimization.__default.GatherStructMapping(_1_struct, (current).Add((_1_struct).dtor_name, prefix)); - } - } - { - if (_source0.is_TypeDecl) { - RAST._ITypeSynonym _2_tpe = _source0.dtor_tpe; - return (current).Add((_2_tpe).dtor_name, prefix); - } - } - { - if (_source0.is_ConstDecl) { - RAST._IConstant _3_c = _source0.dtor_c; - return (current).Add((_3_c).dtor_name, prefix); - } - } - { - if (_source0.is_EnumDecl) { - RAST._IEnum _4_enum = _source0.dtor_enum; - return (current).Add((_4_enum).dtor_name, prefix); - } - } - { - if (_source0.is_ImplDecl) { - RAST._IImpl _5_impl = _source0.dtor_impl; - return FactorPathsOptimization.__default.GatherImplMapping(_5_impl, current); - } - } - { - if (_source0.is_TraitDecl) { - RAST._ITrait _6_tr = _source0.dtor_tr; - return current; - } - } - { - if (_source0.is_TopFnDecl) { - RAST._ITopFnDecl _7_fn = _source0.dtor_fn; - return (current).Add(((_7_fn).dtor_fn).dtor_name, prefix); + return _0_current; + } + }))(); +})), ((System.Func)((_4_current, _5_e) => { + return ((System.Func)(() => { + RAST._IExpr _source1 = _5_e; + { + if (_source1.is_ExprFromPath) { + RAST._IPath path1 = _source1.dtor_path; + if (path1.is_PMemberSelect) { + RAST._IPath _6_base = path1.dtor_base; + Dafny.ISequence _7_id = path1.dtor_name; + if (object.Equals(_6_base, RAST.Path.create_Self())) { + return _4_current; + } else if (((new BigInteger((_7_id).Count)).Sign == 1) && (((_7_id).Select((new BigInteger((_7_id).Count)) - (BigInteger.One))) == (new Dafny.Rune('!')))) { + return (_4_current).Add((_7_id).Take((new BigInteger((_7_id).Count)) - (BigInteger.One)), _6_base); + } else { + return (_4_current).Add(_7_id, _6_base); + } } } - { - RAST._IUse _8_use = _source0.dtor_use; - return current; - } } - public static FactorPathsOptimization._IMapping GatherStructMapping(RAST._IStruct @struct, FactorPathsOptimization._IMapping current) { - return FactorPathsOptimization.__default.GatherTypeParams((@struct).dtor_typeParams, current); + return _4_current; } - public static FactorPathsOptimization._IMapping GatherTypeMapping(RAST._IType tpe, FactorPathsOptimization._IMapping current) + }))(); +})), ((System.Func)((_8_current, _9_modDecl, _10_prefix) => { + return ((System.Func)(() => { + RAST._IModDecl _source2 = _9_modDecl; { - return (tpe).Fold(current, ((System.Func)((_0_current, _1_t) => { - return ((System.Func)(() => { - RAST._IType _source0 = _1_t; - { - if (_source0.is_TypeFromPath) { - RAST._IPath path0 = _source0.dtor_path; - if (path0.is_PMemberSelect) { - RAST._IPath _2_base = path0.dtor_base; - Dafny.ISequence _3_name = path0.dtor_name; - return (_0_current).Add(_3_name, _2_base); - } - } - } - { - return _0_current; - } - }))(); - }))); + if (_source2.is_ModDecl) { + RAST._IMod _11_mod = _source2.dtor_mod; + return (_8_current).Add((_11_mod).dtor_name, _10_prefix); + } } - public static FactorPathsOptimization._IMapping GatherImplMapping(RAST._IImpl impl, FactorPathsOptimization._IMapping current) { - RAST._IImpl _source0 = impl; - { - if (_source0.is_ImplFor) { - Dafny.ISequence _0_typeParams = _source0.dtor_typeParams; - RAST._IType _1_tpe = _source0.dtor_tpe; - RAST._IType _2_forType = _source0.dtor_forType; - Dafny.ISequence _3_where = _source0.dtor_where; - Dafny.ISequence _4_body = _source0.dtor_body; - FactorPathsOptimization._IMapping _5_current = FactorPathsOptimization.__default.GatherTypeParams(_0_typeParams, current); - FactorPathsOptimization._IMapping _6_current = FactorPathsOptimization.__default.GatherTypeMapping(_1_tpe, _5_current); - return FactorPathsOptimization.__default.GatherTypeMapping(_2_forType, _6_current); - } - } - { - Dafny.ISequence _7_typeParams = _source0.dtor_typeParams; - RAST._IType _8_tpe = _source0.dtor_tpe; - Dafny.ISequence _9_where = _source0.dtor_where; - Dafny.ISequence _10_body = _source0.dtor_body; - return FactorPathsOptimization.__default.GatherTypeMapping(_8_tpe, current); + if (_source2.is_StructDecl) { + RAST._IStruct _12_struct = _source2.dtor_struct; + return (_8_current).Add((_12_struct).dtor_name, _10_prefix); } } - public static RAST._IModDecl ReplaceModDecl(RAST._IModDecl modDecl, RAST._IPath SelfPath, Dafny.IMap,RAST._IPath> replacement) { - RAST._IModDecl _source0 = modDecl; - { - if (_source0.is_ModDecl) { - RAST._IMod _0_mod = _source0.dtor_mod; - return RAST.ModDecl.create_ModDecl(FactorPathsOptimization.__default.applyPrefix(_0_mod, (SelfPath).MSel((_0_mod).dtor_name))); - } - } - { - if (_source0.is_StructDecl) { - RAST._IStruct _1_struct = _source0.dtor_struct; - return RAST.ModDecl.create_StructDecl(FactorPathsOptimization.__default.ReplaceStruct(_1_struct, replacement)); - } + if (_source2.is_TypeDecl) { + RAST._ITypeSynonym _13_tpe = _source2.dtor_tpe; + return (_8_current).Add((_13_tpe).dtor_name, _10_prefix); } - { - if (_source0.is_TypeDecl) { - RAST._ITypeSynonym _2_tpe = _source0.dtor_tpe; - return modDecl; - } - } - { - if (_source0.is_ConstDecl) { - RAST._IConstant _3_c = _source0.dtor_c; - return modDecl; - } - } - { - if (_source0.is_EnumDecl) { - RAST._IEnum _4_enum = _source0.dtor_enum; - return modDecl; - } - } - { - if (_source0.is_ImplDecl) { - RAST._IImpl _5_impl = _source0.dtor_impl; - return RAST.ModDecl.create_ImplDecl(FactorPathsOptimization.__default.ReplaceImplDecl(_5_impl, replacement)); - } - } - { - if (_source0.is_TraitDecl) { - RAST._ITrait _6_tr = _source0.dtor_tr; - return modDecl; - } + } + { + if (_source2.is_ConstDecl) { + RAST._IConstant _14_c = _source2.dtor_c; + return (_8_current).Add((_14_c).dtor_name, _10_prefix); } - { - if (_source0.is_TopFnDecl) { - RAST._ITopFnDecl _7_fn = _source0.dtor_fn; - return modDecl; - } + } + { + if (_source2.is_EnumDecl) { + RAST._IEnum _15_enum = _source2.dtor_enum; + return (_8_current).Add((_15_enum).dtor_name, _10_prefix); } - { - RAST._IUse _8_use = _source0.dtor_use; - return modDecl; + } + { + if (_source2.is_ImplDecl) { + RAST._IImpl _16_impl = _source2.dtor_impl; + return _8_current; } } - public static RAST._IType ReplaceType(RAST._IType t, Dafny.IMap,RAST._IPath> replacement) { - RAST._IType _source0 = t; - { - if (_source0.is_TypeFromPath) { - RAST._IPath path0 = _source0.dtor_path; - if (path0.is_PMemberSelect) { - RAST._IPath _0_base = path0.dtor_base; - Dafny.ISequence _1_id = path0.dtor_name; - if (((replacement).Contains(_1_id)) && (object.Equals(Dafny.Map, RAST._IPath>.Select(replacement,_1_id), _0_base))) { - return RAST.Type.create_TSynonym(RAST.Type.create_TIdentifier(_1_id), t); - } else { - return t; + if (_source2.is_TraitDecl) { + RAST._ITrait _17_tr = _source2.dtor_tr; + RAST._IType _source3 = (_17_tr).dtor_tpe; + { + if (_source3.is_TypeApp) { + RAST._IType baseName0 = _source3.dtor_baseName; + if (baseName0.is_TIdentifier) { + Dafny.ISequence _18_name = baseName0.dtor_name; + return (_8_current).Add(_18_name, _10_prefix); } } } + { + if (_source3.is_TIdentifier) { + Dafny.ISequence _19_name = _source3.dtor_name; + return (_8_current).Add(_19_name, _10_prefix); + } + } + { + return _8_current; + } } - { - return t; + } + { + if (_source2.is_TopFnDecl) { + RAST._ITopFnDecl _20_fn = _source2.dtor_fn; + return (_8_current).Add(((_20_fn).dtor_fn).dtor_name, _10_prefix); } } - public static Dafny.ISequence ReplaceTypeParams(Dafny.ISequence typeParams, Dafny.IMap,RAST._IPath> replacement) { - return Std.Collections.Seq.__default.Map(Dafny.Helpers.Id,RAST._IPath>, Func>>((_0_replacement) => ((System.Func)((_1_t) => { - return Dafny.Helpers.Let(_1_t, _pat_let15_0 => Dafny.Helpers.Let(_pat_let15_0, _2_dt__update__tmp_h0 => Dafny.Helpers.Let, RAST._ITypeParamDecl>(Std.Collections.Seq.__default.Map(Dafny.Helpers.Id,RAST._IPath>, Func>>((_3_replacement) => ((System.Func)((_4_constraint) => { - return FactorPathsOptimization.__default.ReplaceType(_4_constraint, _3_replacement); - })))(_0_replacement), (_1_t).dtor_constraints), _pat_let16_0 => Dafny.Helpers.Let, RAST._ITypeParamDecl>(_pat_let16_0, _5_dt__update_hconstraints_h0 => RAST.TypeParamDecl.create((_2_dt__update__tmp_h0).dtor_name, _5_dt__update_hconstraints_h0))))); - })))(replacement), typeParams); + RAST._IUse _21_use = _source2.dtor_use; + return _8_current; + } + }))(); +})), false); } - public static RAST._IImpl ReplaceImplDecl(RAST._IImpl impl, Dafny.IMap,RAST._IPath> replacement) + public static RAST._IRASTBottomUpReplacer PathSimplifier(Dafny.IMap,RAST._IPath> replacement) { - RAST._IImpl _source0 = impl; - { - if (_source0.is_ImplFor) { - Dafny.ISequence _0_typeParams = _source0.dtor_typeParams; - RAST._IType _1_tpe = _source0.dtor_tpe; - RAST._IType _2_forType = _source0.dtor_forType; - Dafny.ISequence _3_where = _source0.dtor_where; - Dafny.ISequence _4_body = _source0.dtor_body; - return RAST.Impl.create_ImplFor(FactorPathsOptimization.__default.ReplaceTypeParams(_0_typeParams, replacement), (_1_tpe).Replace(Dafny.Helpers.Id,RAST._IPath>, Func>>(FactorPathsOptimization.__default.typeReplacer)(replacement)), (_2_forType).Replace(Dafny.Helpers.Id,RAST._IPath>, Func>>(FactorPathsOptimization.__default.typeReplacer)(replacement)), _3_where, _4_body); + return RAST.RASTBottomUpReplacer.create(((System.Func)((_0_m, _1_SelfPath) => { + return FactorPathsOptimization.__default.applyPrefix(_0_m, (_1_SelfPath).MSel((_0_m).dtor_name)); +})), Dafny.Helpers.Id,RAST._IPath>, Func>>((_2_replacement) => ((System.Func)((_3_t) => { + return ((System.Func)(() => { + RAST._IType _source0 = _3_t; + { + if (_source0.is_TypeFromPath) { + RAST._IPath path0 = _source0.dtor_path; + if (path0.is_PMemberSelect) { + RAST._IPath _4_base = path0.dtor_base; + Dafny.ISequence _5_id = path0.dtor_name; + if (((_2_replacement).Contains(_5_id)) && (object.Equals(Dafny.Map, RAST._IPath>.Select(_2_replacement,_5_id), _4_base))) { + return RAST.Type.create_TSynonym(RAST.Type.create_TIdentifier(_5_id), _3_t); + } else { + return _3_t; + } } } - { - Dafny.ISequence _5_typeParams = _source0.dtor_typeParams; - RAST._IType _6_tpe = _source0.dtor_tpe; - Dafny.ISequence _7_where = _source0.dtor_where; - Dafny.ISequence _8_body = _source0.dtor_body; - return RAST.Impl.create_Impl(FactorPathsOptimization.__default.ReplaceTypeParams(_5_typeParams, replacement), (_6_tpe).Replace(Dafny.Helpers.Id,RAST._IPath>, Func>>(FactorPathsOptimization.__default.typeReplacer)(replacement)), _7_where, _8_body); - } } - public static RAST._IStruct ReplaceStruct(RAST._IStruct @struct, Dafny.IMap,RAST._IPath> replacement) { - 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, FactorPathsOptimization.__default.ReplaceTypeParams(_2_typeParams, replacement), FactorPathsOptimization.__default.ReplaceFields(_3_fields, replacement)); - } + return _3_t; } - public static RAST._IFields ReplaceFields(RAST._IFields fields, Dafny.IMap,RAST._IPath> replacement) + }))(); +})))(replacement), Dafny.Helpers.Id,RAST._IPath>, Func>>((_6_replacement) => ((System.Func)((_7_e) => { + return ((System.Func)(() => { + RAST._IExpr _source1 = _7_e; { - RAST._IFields _source0 = fields; - { - if (_source0.is_NamedFields) { - Dafny.ISequence _0_sFields = _source0.dtor_fields; - return RAST.Fields.create_NamedFields(Std.Collections.Seq.__default.Map(Dafny.Helpers.Id,RAST._IPath>, Func>>((_1_replacement) => ((System.Func)((_2_f) => { - return Dafny.Helpers.Let(_2_f, _pat_let17_0 => Dafny.Helpers.Let(_pat_let17_0, _3_dt__update__tmp_h0 => Dafny.Helpers.Let(Dafny.Helpers.Let((_2_f).dtor_formal, _pat_let19_0 => Dafny.Helpers.Let(_pat_let19_0, _4_dt__update__tmp_h1 => Dafny.Helpers.Let(FactorPathsOptimization.__default.ReplaceType(((_2_f).dtor_formal).dtor_tpe, _1_replacement), _pat_let20_0 => Dafny.Helpers.Let(_pat_let20_0, _5_dt__update_htpe_h0 => RAST.Formal.create((_4_dt__update__tmp_h1).dtor_name, _5_dt__update_htpe_h0))))), _pat_let18_0 => Dafny.Helpers.Let(_pat_let18_0, _6_dt__update_hformal_h0 => RAST.Field.create((_3_dt__update__tmp_h0).dtor_visibility, _6_dt__update_hformal_h0))))); -})))(replacement), _0_sFields)); + if (_source1.is_ExprFromPath) { + RAST._IPath path1 = _source1.dtor_path; + if (path1.is_PMemberSelect) { + RAST._IPath _8_base = path1.dtor_base; + Dafny.ISequence _9_id = path1.dtor_name; + if (((_6_replacement).Contains(_9_id)) && (object.Equals(Dafny.Map, RAST._IPath>.Select(_6_replacement,_9_id), _8_base))) { + return RAST.Expr.create_Identifier(_9_id); + } else if (((new BigInteger((_9_id).Count)).Sign == 1) && (((_9_id).Select((new BigInteger((_9_id).Count)) - (BigInteger.One))) == (new Dafny.Rune('!')))) { + Dafny.ISequence _10_macro__id = (_9_id).Take((new BigInteger((_9_id).Count)) - (BigInteger.One)); + if (((_6_replacement).Contains(_10_macro__id)) && (object.Equals(Dafny.Map, RAST._IPath>.Select(_6_replacement,_10_macro__id), _8_base))) { + return RAST.Expr.create_Identifier(_9_id); + } else { + return _7_e; + } + } else { + return _7_e; + } } } - { - Dafny.ISequence _7_sFields = _source0.dtor_types; - return RAST.Fields.create_NamelessFields(Std.Collections.Seq.__default.Map(Dafny.Helpers.Id,RAST._IPath>, Func>>((_8_replacement) => ((System.Func)((_9_f) => { - return Dafny.Helpers.Let(_9_f, _pat_let21_0 => Dafny.Helpers.Let(_pat_let21_0, _10_dt__update__tmp_h2 => Dafny.Helpers.Let(FactorPathsOptimization.__default.ReplaceType((_9_f).dtor_tpe, _8_replacement), _pat_let22_0 => Dafny.Helpers.Let(_pat_let22_0, _11_dt__update_htpe_h1 => RAST.NamelessField.create((_10_dt__update__tmp_h2).dtor_visibility, _11_dt__update_htpe_h1))))); -})))(replacement), _7_sFields)); - } } - public static Func,RAST._IPath>, Func> typeReplacer { get { - return ((System.Func,RAST._IPath>, Func>)((_0_replacement) => { - return Dafny.Helpers.Id,RAST._IPath>, Func>>((_1_replacement) => ((System.Func)((_2_t) => { - return FactorPathsOptimization.__default.ReplaceType(_2_t, _1_replacement); - })))(_0_replacement); - })); - } } + { + return _7_e; + } + }))(); +})))(replacement)); + } } public interface _IMapping { @@ -334,7 +233,7 @@ public interface _IMapping { Dafny.ISequence> dtor_keys { get; } _IMapping DowncastClone(); FactorPathsOptimization._IMapping Add(Dafny.ISequence k, RAST._IPath path); - Dafny.IMap,RAST._IPath> ToFinalReplacement(); + Dafny.IMap,RAST._IPath> ToFinalReplacement(RAST._IPath SelfPath); Dafny.ISequence ToUseStatements(Dafny.IMap,RAST._IPath> finalReplacement, RAST._IPath SelfPath); } public class Mapping : _IMapping { @@ -406,25 +305,22 @@ public FactorPathsOptimization._IMapping Add(Dafny.ISequence k, RAST return FactorPathsOptimization.Mapping.create(_4_dt__update_hprovenance_h1, _3_dt__update_hkeys_h0); } } - public Dafny.IMap,RAST._IPath> ToFinalReplacement() { - return ((System.Func,RAST._IPath>>)(() => { + public Dafny.IMap,RAST._IPath> ToFinalReplacement(RAST._IPath SelfPath) { + return Dafny.Helpers.Id,RAST._IPath>>>((_0_SelfPath) => ((System.Func,RAST._IPath>>)(() => { var _coll0 = new System.Collections.Generic.List,RAST._IPath>>(); foreach (Dafny.ISequence _compr_0 in ((this).dtor_provenance).Keys.Elements) { - Dafny.ISequence _0_identifier = (Dafny.ISequence)_compr_0; - if (((this).dtor_provenance).Contains(_0_identifier)) { - foreach (Dafny.ISet _compr_1 in Dafny.Helpers.SingleValue>(Dafny.Map, Dafny.ISet>.Select((this).dtor_provenance,_0_identifier))) { - Dafny.ISet _1_paths = (Dafny.ISet)_compr_1; - if (((_1_paths).Equals(Dafny.Map, Dafny.ISet>.Select((this).dtor_provenance,_0_identifier))) && (((new BigInteger((_1_paths).Count)) == (BigInteger.One)) || (Dafny.Helpers.Id, bool>>((_2_paths) => Dafny.Helpers.Quantifier(Dafny.Helpers.SingleValue(RAST.__default.dafny__runtime), false, (((_exists_var_0) => { - RAST._IPath _3_p = (RAST._IPath)_exists_var_0; - return ((_2_paths).Contains(_3_p)) && (object.Equals(_3_p, RAST.__default.dafny__runtime)); - }))))(_1_paths)))) { - _coll0.Add(new Dafny.Pair,RAST._IPath>(_0_identifier, (((new BigInteger((_1_paths).Count)) == (BigInteger.One)) ? (FactorPathsOptimization.__default.UniqueElementOf(_1_paths)) : (RAST.__default.dafny__runtime)))); + Dafny.ISequence _1_identifier = (Dafny.ISequence)_compr_0; + if (((this).dtor_provenance).Contains(_1_identifier)) { + foreach (Dafny.ISet _compr_1 in Dafny.Helpers.SingleValue>(Dafny.Map, Dafny.ISet>.Select((this).dtor_provenance,_1_identifier))) { + Dafny.ISet _2_paths = (Dafny.ISet)_compr_1; + if (((_2_paths).Equals(Dafny.Map, Dafny.ISet>.Select((this).dtor_provenance,_1_identifier))) && ((((new BigInteger((_2_paths).Count)) == (BigInteger.One)) || ((_2_paths).Contains(_0_SelfPath))) || ((_2_paths).Contains(RAST.__default.dafny__runtime)))) { + _coll0.Add(new Dafny.Pair,RAST._IPath>(_1_identifier, (((new BigInteger((_2_paths).Count)) == (BigInteger.One)) ? (FactorPathsOptimization.__default.UniqueElementOf(_2_paths)) : ((((_2_paths).Contains(_0_SelfPath)) ? (_0_SelfPath) : (RAST.__default.dafny__runtime)))))); } } } } return Dafny.Map,RAST._IPath>.FromCollection(_coll0); - }))(); + }))())(SelfPath); } public Dafny.ISequence ToUseStatements(Dafny.IMap,RAST._IPath> finalReplacement, RAST._IPath SelfPath) { diff --git a/Source/DafnyCore/GeneratedFromDafny/RAST.cs b/Source/DafnyCore/GeneratedFromDafny/RAST.cs index 5ab668e20a2..efb368ea485 100644 --- a/Source/DafnyCore/GeneratedFromDafny/RAST.cs +++ b/Source/DafnyCore/GeneratedFromDafny/RAST.cs @@ -153,6 +153,9 @@ public static RAST._IExpr AssignMember(RAST._IExpr @on, Dafny.ISequence.create_Some(RAST.AssignLhs.create_SelectMember(@on, field)), rhs); } + public static RAST._IExpr Unsafe(RAST._IExpr underlying) { + return RAST.Expr.create_UnaryOp(Dafny.Sequence.UnicodeFromString("unsafe"), underlying, DAST.Format.UnaryOpFormat.create_NoFormat()); + } public static RAST._IExpr MaybePlacebo(RAST._IExpr underlying) { return ((RAST.__default.MaybePlaceboPath).FSel(Dafny.Sequence.UnicodeFromString("from"))).Apply1(underlying); } @@ -207,11 +210,11 @@ public static RAST._IType RefcellType { get { public static RAST._IType CloneTrait { get { return (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("clone"))).MSel(Dafny.Sequence.UnicodeFromString("Clone"))).AsType(); } } - public static RAST._IPath DefaultPath { get { + public static RAST._IPath std__default__Default { get { return ((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("default"))).MSel(Dafny.Sequence.UnicodeFromString("Default")); } } public static RAST._IType DefaultTrait { get { - return (RAST.__default.DefaultPath).AsType(); + return (RAST.__default.std__default__Default).AsType(); } } public static RAST._IType AnyTrait { get { return (((RAST.__default.std).MSel(Dafny.Sequence.UnicodeFromString("any"))).MSel(Dafny.Sequence.UnicodeFromString("Any"))).AsType(); @@ -288,14 +291,663 @@ public static RAST._IPath std__rc__Rc { get { public static RAST._IExpr std__rc__Rc__new { get { return (RAST.__default.std__rc__Rc).FSel(Dafny.Sequence.UnicodeFromString("new")); } } - public static RAST._IExpr std__Default__default { get { - return ((RAST.__default.DefaultPath).FSel(Dafny.Sequence.UnicodeFromString("default"))).Apply(Dafny.Sequence.FromElements()); + public static RAST._IExpr std__default__Default__default { get { + return ((RAST.__default.std__default__Default).FSel(Dafny.Sequence.UnicodeFromString("default"))).Apply0(); } } public static BigInteger MAX__TUPLE__SIZE { get { return new BigInteger(12); } } } + public interface _IRASTTopDownVisitor { + bool is_RASTTopDownVisitor { get; } + Func dtor_VisitTypeSingle { get; } + Func dtor_VisitExprSingle { get; } + Func dtor_VisitModDeclSingle { get; } + bool dtor_recurseSubmodules { get; } + _IRASTTopDownVisitor<__T> DowncastClone<__T>(Func converter0); + T VisitMod(T acc, RAST._IMod mod, RAST._IPath SelfPath); + T VisitTypeParams(T acc, Dafny.ISequence typeParams); + T VisitFields(T acc, RAST._IFields fields); + T VisitModMapping(T acc, RAST._IModDecl modDecl, RAST._IPath SelfPath); + T VisitStructMapping(T acc, RAST._IStruct @struct); + T VisitTraitDecl(T acc, RAST._ITrait tr); + T VisitTopFn(T acc, RAST._ITopFnDecl t); + T VisitUse(T acc, RAST._IUse u); + T VisitType(T acc, RAST._IType tpe); + T VisitImplMapping(T acc, RAST._IImpl impl); + T VisitBody(T acc, Dafny.ISequence members); + T VisitMember(T acc, RAST._IImplMember member); + T VisitFn(T acc, RAST._IFn fn); + } + public class RASTTopDownVisitor : _IRASTTopDownVisitor { + public readonly Func _VisitTypeSingle; + public readonly Func _VisitExprSingle; + public readonly Func _VisitModDeclSingle; + public readonly bool _recurseSubmodules; + public RASTTopDownVisitor(Func VisitTypeSingle, Func VisitExprSingle, Func VisitModDeclSingle, bool recurseSubmodules) { + this._VisitTypeSingle = VisitTypeSingle; + this._VisitExprSingle = VisitExprSingle; + this._VisitModDeclSingle = VisitModDeclSingle; + this._recurseSubmodules = recurseSubmodules; + } + public _IRASTTopDownVisitor<__T> DowncastClone<__T>(Func converter0) { + if (this is _IRASTTopDownVisitor<__T> dt) { return dt; } + return new RASTTopDownVisitor<__T>((_VisitTypeSingle).DowncastClone(Dafny.Helpers.CastConverter<__T, T>, Dafny.Helpers.Id, Dafny.Helpers.CastConverter), (_VisitExprSingle).DowncastClone(Dafny.Helpers.CastConverter<__T, T>, Dafny.Helpers.Id, Dafny.Helpers.CastConverter), (_VisitModDeclSingle).DowncastClone(Dafny.Helpers.CastConverter<__T, T>, Dafny.Helpers.Id, Dafny.Helpers.Id, Dafny.Helpers.CastConverter), _recurseSubmodules); + } + public override bool Equals(object other) { + var oth = other as RAST.RASTTopDownVisitor; + return oth != null && object.Equals(this._VisitTypeSingle, oth._VisitTypeSingle) && object.Equals(this._VisitExprSingle, oth._VisitExprSingle) && object.Equals(this._VisitModDeclSingle, oth._VisitModDeclSingle) && this._recurseSubmodules == oth._recurseSubmodules; + } + public override int GetHashCode() { + ulong hash = 5381; + hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._VisitTypeSingle)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._VisitExprSingle)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._VisitModDeclSingle)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._recurseSubmodules)); + return (int) hash; + } + public override string ToString() { + string s = "RAST.RASTTopDownVisitor.RASTTopDownVisitor"; + s += "("; + s += Dafny.Helpers.ToString(this._VisitTypeSingle); + s += ", "; + s += Dafny.Helpers.ToString(this._VisitExprSingle); + s += ", "; + s += Dafny.Helpers.ToString(this._VisitModDeclSingle); + s += ", "; + s += Dafny.Helpers.ToString(this._recurseSubmodules); + s += ")"; + return s; + } + public static RAST._IRASTTopDownVisitor Default(T _default_T) { + return create(((T x2, RAST._IType x3) => _default_T), ((T x4, RAST._IExpr x5) => _default_T), ((T x6, RAST._IModDecl x7, RAST._IPath x8) => _default_T), false); + } + public static Dafny.TypeDescriptor> _TypeDescriptor(Dafny.TypeDescriptor _td_T) { + return new Dafny.TypeDescriptor>(RAST.RASTTopDownVisitor.Default(_td_T.Default())); + } + public static _IRASTTopDownVisitor create(Func VisitTypeSingle, Func VisitExprSingle, Func VisitModDeclSingle, bool recurseSubmodules) { + return new RASTTopDownVisitor(VisitTypeSingle, VisitExprSingle, VisitModDeclSingle, recurseSubmodules); + } + public static _IRASTTopDownVisitor create_RASTTopDownVisitor(Func VisitTypeSingle, Func VisitExprSingle, Func VisitModDeclSingle, bool recurseSubmodules) { + return create(VisitTypeSingle, VisitExprSingle, VisitModDeclSingle, recurseSubmodules); + } + public bool is_RASTTopDownVisitor { get { return true; } } + public Func dtor_VisitTypeSingle { + get { + return this._VisitTypeSingle; + } + } + public Func dtor_VisitExprSingle { + get { + return this._VisitExprSingle; + } + } + public Func dtor_VisitModDeclSingle { + get { + return this._VisitModDeclSingle; + } + } + public bool dtor_recurseSubmodules { + get { + return this._recurseSubmodules; + } + } + public T VisitMod(T acc, RAST._IMod mod, RAST._IPath SelfPath) + { + return (mod).Fold(acc, Dafny.Helpers.Id>>((_0_SelfPath, _1_mod) => ((System.Func)((_2_acc, _3_modDecl) => { + return (this).VisitModMapping(_2_acc, _3_modDecl, _0_SelfPath); + })))(SelfPath, mod)); + } + public T VisitTypeParams(T acc, Dafny.ISequence typeParams) + { + return RAST.__default.FoldLeft(((System.Func)((_0_acc, _1_t) => { + return RAST.__default.FoldLeft(((System.Func)((_2_acc, _3_t) => { + return (this).VisitType(_2_acc, _3_t); + })), _0_acc, (_1_t).dtor_constraints); + })), acc, typeParams); + } + public T VisitFields(T acc, RAST._IFields fields) + { + RAST._IFields _source0 = fields; + { + if (_source0.is_NamedFields) { + Dafny.ISequence _0_sFields = _source0.dtor_fields; + return RAST.__default.FoldLeft(((System.Func)((_1_acc, _2_f) => { + return (this).VisitType(_1_acc, ((_2_f).dtor_formal).dtor_tpe); + })), acc, _0_sFields); + } + } + { + Dafny.ISequence _3_sFields = _source0.dtor_types; + return RAST.__default.FoldLeft(((System.Func)((_4_acc, _5_f) => { + return (this).VisitType(_4_acc, (_5_f).dtor_tpe); + })), acc, _3_sFields); + } + } + public T VisitModMapping(T acc, RAST._IModDecl modDecl, RAST._IPath SelfPath) + { + T _0_acc = Dafny.Helpers.Id>((this).dtor_VisitModDeclSingle)(acc, modDecl, SelfPath); + RAST._IModDecl _source0 = modDecl; + { + if (_source0.is_ModDecl) { + RAST._IMod _1_mod = _source0.dtor_mod; + if ((this).dtor_recurseSubmodules) { + return (this).VisitMod(_0_acc, _1_mod, (SelfPath).MSel((_1_mod).dtor_name)); + } else { + return _0_acc; + } + } + } + { + if (_source0.is_StructDecl) { + RAST._IStruct _2_struct = _source0.dtor_struct; + return (this).VisitStructMapping(_0_acc, _2_struct); + } + } + { + if (_source0.is_TypeDecl) { + RAST._ITypeSynonym tpe0 = _source0.dtor_tpe; + Dafny.ISequence> _3_attributes = tpe0.dtor_attributes; + Dafny.ISequence _4_name = tpe0.dtor_name; + Dafny.ISequence _5_typeParams = tpe0.dtor_typeParams; + RAST._IType _6_tpe = tpe0.dtor_tpe; + T _7_acc = (this).VisitTypeParams(_0_acc, _5_typeParams); + T _8_acc = (this).VisitType(_7_acc, _6_tpe); + return _8_acc; + } + } + { + if (_source0.is_ConstDecl) { + RAST._IConstant c0 = _source0.dtor_c; + Dafny.ISequence> _9_attributes = c0.dtor_attributes; + Dafny.ISequence _10_name = c0.dtor_name; + RAST._IType _11_tpe = c0.dtor_tpe; + RAST._IExpr _12_value = c0.dtor_value; + T _13_acc = (this).VisitType(_0_acc, _11_tpe); + T _14_acc = (_12_value).Fold(_13_acc, (this).dtor_VisitExprSingle, (this).dtor_VisitTypeSingle); + return _14_acc; + } + } + { + if (_source0.is_EnumDecl) { + RAST._IEnum enum0 = _source0.dtor_enum; + Dafny.ISequence> _15_attributes = enum0.dtor_attributes; + Dafny.ISequence _16_name = enum0.dtor_name; + Dafny.ISequence _17_typeParams = enum0.dtor_typeParams; + Dafny.ISequence _18_variants = enum0.dtor_variants; + return RAST.__default.FoldLeft(Dafny.Helpers.Id, Func>>((_19_variants) => ((System.Func)((_20_acc, _21_enumCase) => { + return (this).VisitFields(_20_acc, (_21_enumCase).dtor_fields); + })))(_18_variants), (this).VisitTypeParams(_0_acc, _17_typeParams), _18_variants); + } + } + { + if (_source0.is_ImplDecl) { + RAST._IImpl _22_impl = _source0.dtor_impl; + return (this).VisitImplMapping(_0_acc, _22_impl); + } + } + { + if (_source0.is_TraitDecl) { + RAST._ITrait _23_tr = _source0.dtor_tr; + return (this).VisitTraitDecl(_0_acc, _23_tr); + } + } + { + if (_source0.is_TopFnDecl) { + RAST._ITopFnDecl _24_fn = _source0.dtor_fn; + return (this).VisitTopFn(_0_acc, _24_fn); + } + } + { + RAST._IUse _25_use = _source0.dtor_use; + return (this).VisitUse(_0_acc, _25_use); + } + } + public T VisitStructMapping(T acc, RAST._IStruct @struct) + { + return (this).VisitTypeParams(acc, (@struct).dtor_typeParams); + } + public T VisitTraitDecl(T acc, 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; + T _4_acc = (this).VisitTypeParams(acc, _0_typeParams); + T _5_acc = (_1_tpe).Fold(_4_acc, (this).dtor_VisitTypeSingle); + T _6_acc = RAST.__default.FoldLeft(((System.Func)((_7_acc, _8_parent) => { + return (_8_parent).Fold(_7_acc, (this).dtor_VisitTypeSingle); + })), _5_acc, _2_parents); + return (this).VisitBody(_6_acc, _3_body); + } + } + public T VisitTopFn(T acc, 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 (this).VisitFn(acc, _2_fn); + } + } + public T VisitUse(T acc, RAST._IUse u) + { + return acc; + } + public T VisitType(T acc, RAST._IType tpe) + { + return (tpe).Fold(acc, ((System.Func)((_0_acc, _1_t) => { + return Dafny.Helpers.Id>((this).dtor_VisitTypeSingle)(_0_acc, _1_t); + }))); + } + public T VisitImplMapping(T acc, RAST._IImpl impl) + { + RAST._IImpl _source0 = impl; + { + if (_source0.is_ImplFor) { + Dafny.ISequence _0_typeParams = _source0.dtor_typeParams; + RAST._IType _1_tpe = _source0.dtor_tpe; + RAST._IType _2_forType = _source0.dtor_forType; + Dafny.ISequence _3_where = _source0.dtor_where; + Dafny.ISequence _4_body = _source0.dtor_body; + T _5_acc = (this).VisitTypeParams(acc, _0_typeParams); + T _6_acc = (this).VisitType(_5_acc, _1_tpe); + T _7_acc = (this).VisitType(_6_acc, _2_forType); + return (this).VisitBody(_7_acc, _4_body); + } + } + { + Dafny.ISequence _8_typeParams = _source0.dtor_typeParams; + RAST._IType _9_tpe = _source0.dtor_tpe; + Dafny.ISequence _10_where = _source0.dtor_where; + Dafny.ISequence _11_body = _source0.dtor_body; + T _12_acc = (this).VisitType(acc, _9_tpe); + return (this).VisitBody(_12_acc, _11_body); + } + } + public T VisitBody(T acc, Dafny.ISequence members) + { + return RAST.__default.FoldLeft(Dafny.Helpers.Id, Func>>((_0_members) => ((System.Func)((_1_acc, _2_member) => { + return (this).VisitMember(_1_acc, _2_member); + })))(members), acc, members); + } + public T VisitMember(T acc, RAST._IImplMember member) + { + RAST._IImplMember _source0 = member; + { + if (_source0.is_RawImplMember) { + Dafny.ISequence _0_content = _source0.dtor_content; + return acc; + } + } + { + if (_source0.is_FnDecl) { + RAST._IVisibility _1_pub = _source0.dtor_pub; + RAST._IFn _2_fun = _source0.dtor_fun; + return (this).VisitFn(acc, _2_fun); + } + } + { + RAST._IExpr _3_expr = _source0.dtor_expr; + return (_3_expr).Fold(acc, (this).dtor_VisitExprSingle, (this).dtor_VisitTypeSingle); + } + } + public T VisitFn(T acc, RAST._IFn fn) + { + RAST._IFn _source0 = fn; + { + Dafny.ISequence _0_name = _source0.dtor_name; + 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; + } + } + } + + public interface _IRASTBottomUpReplacer { + bool is_RASTBottomUpReplacer { get; } + Func dtor_ReplaceModSingle { get; } + Func dtor_ReplaceTypeSingle { get; } + Func dtor_ReplaceExprSingle { get; } + _IRASTBottomUpReplacer DowncastClone(); + RAST._IMod ReplaceMod(RAST._IMod mod, RAST._IPath SelfPath); + RAST._IModDecl ReplaceModDecl(RAST._IModDecl modDecl, RAST._IPath SelfPath); + RAST._IStruct ReplaceStruct(RAST._IStruct @struct); + RAST._ITypeSynonym ReplaceTypeDecl(RAST._ITypeSynonym t); + RAST._IConstant ReplaceConst(RAST._IConstant t); + RAST._IEnum ReplaceEnum(RAST._IEnum @enum); + RAST._IEnumCase ReplaceEnumCase(RAST._IEnumCase enumCase); + RAST._IImpl ReplaceImplDecl(RAST._IImpl impl); + RAST._ITrait ReplaceTrait(RAST._ITrait tr); + RAST._ITopFnDecl ReplaceTopFn(RAST._ITopFnDecl t); + RAST._IFn ReplaceFn(RAST._IFn t); + RAST._IUse ReplaceUse(RAST._IUse use); + Dafny.ISequence ReplaceBody(Dafny.ISequence decls); + RAST._IImplMember ReplaceImplMember(RAST._IImplMember t); + RAST._IExpr ReplaceExpr(RAST._IExpr e); + Dafny.ISequence ReplaceTypeParams(Dafny.ISequence typeParams); + RAST._IType ReplaceType(RAST._IType t); + RAST._IFields ReplaceFields(RAST._IFields fields); + } + public class RASTBottomUpReplacer : _IRASTBottomUpReplacer { + public readonly Func _ReplaceModSingle; + public readonly Func _ReplaceTypeSingle; + public readonly Func _ReplaceExprSingle; + public RASTBottomUpReplacer(Func ReplaceModSingle, Func ReplaceTypeSingle, Func ReplaceExprSingle) { + this._ReplaceModSingle = ReplaceModSingle; + this._ReplaceTypeSingle = ReplaceTypeSingle; + this._ReplaceExprSingle = ReplaceExprSingle; + } + public _IRASTBottomUpReplacer DowncastClone() { + if (this is _IRASTBottomUpReplacer dt) { return dt; } + return new RASTBottomUpReplacer(_ReplaceModSingle, _ReplaceTypeSingle, _ReplaceExprSingle); + } + public override bool Equals(object other) { + var oth = other as RAST.RASTBottomUpReplacer; + return oth != null && object.Equals(this._ReplaceModSingle, oth._ReplaceModSingle) && object.Equals(this._ReplaceTypeSingle, oth._ReplaceTypeSingle) && object.Equals(this._ReplaceExprSingle, oth._ReplaceExprSingle); + } + public override int GetHashCode() { + ulong hash = 5381; + hash = ((hash << 5) + hash) + 0; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._ReplaceModSingle)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._ReplaceTypeSingle)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._ReplaceExprSingle)); + return (int) hash; + } + public override string ToString() { + string s = "RAST.RASTBottomUpReplacer.RASTBottomUpReplacer"; + s += "("; + s += Dafny.Helpers.ToString(this._ReplaceModSingle); + s += ", "; + s += Dafny.Helpers.ToString(this._ReplaceTypeSingle); + s += ", "; + s += Dafny.Helpers.ToString(this._ReplaceExprSingle); + s += ")"; + return s; + } + private static readonly RAST._IRASTBottomUpReplacer theDefault = create(((Func)null), ((RAST._IType x9) => RAST.Type.Default()), ((RAST._IExpr x10) => RAST.Expr.Default())); + public static RAST._IRASTBottomUpReplacer Default() { + return theDefault; + } + private static readonly Dafny.TypeDescriptor _TYPE = new Dafny.TypeDescriptor(RAST.RASTBottomUpReplacer.Default()); + public static Dafny.TypeDescriptor _TypeDescriptor() { + return _TYPE; + } + public static _IRASTBottomUpReplacer create(Func ReplaceModSingle, Func ReplaceTypeSingle, Func ReplaceExprSingle) { + return new RASTBottomUpReplacer(ReplaceModSingle, ReplaceTypeSingle, ReplaceExprSingle); + } + public static _IRASTBottomUpReplacer create_RASTBottomUpReplacer(Func ReplaceModSingle, Func ReplaceTypeSingle, Func ReplaceExprSingle) { + return create(ReplaceModSingle, ReplaceTypeSingle, ReplaceExprSingle); + } + public bool is_RASTBottomUpReplacer { get { return true; } } + public Func dtor_ReplaceModSingle { + get { + return this._ReplaceModSingle; + } + } + public Func dtor_ReplaceTypeSingle { + get { + return this._ReplaceTypeSingle; + } + } + public Func dtor_ReplaceExprSingle { + get { + return this._ReplaceExprSingle; + } + } + public RAST._IMod ReplaceMod(RAST._IMod mod, RAST._IPath SelfPath) + { + if ((mod).is_ExternMod) { + return mod; + } else { + Dafny.ISequence _0_newModDeclarations = (mod).Fold>(Dafny.Sequence.FromElements(), Dafny.Helpers.Id, RAST._IModDecl, Dafny.ISequence>>>((_1_SelfPath, _2_mod) => ((System.Func, RAST._IModDecl, Dafny.ISequence>)((_3_current, _4_modDecl) => { + return Dafny.Sequence.Concat(_3_current, Dafny.Sequence.FromElements((this).ReplaceModDecl(_4_modDecl, _1_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); + } + } + public RAST._IModDecl ReplaceModDecl(RAST._IModDecl modDecl, RAST._IPath SelfPath) + { + RAST._IModDecl _source0 = modDecl; + { + if (_source0.is_ModDecl) { + RAST._IMod _0_mod = _source0.dtor_mod; + return RAST.ModDecl.create_ModDecl(Dafny.Helpers.Id>((this).dtor_ReplaceModSingle)(_0_mod, (SelfPath).MSel((_0_mod).dtor_name))); + } + } + { + if (_source0.is_StructDecl) { + RAST._IStruct _1_struct = _source0.dtor_struct; + return RAST.ModDecl.create_StructDecl((this).ReplaceStruct(_1_struct)); + } + } + { + if (_source0.is_TypeDecl) { + RAST._ITypeSynonym _2_tpe = _source0.dtor_tpe; + return RAST.ModDecl.create_TypeDecl((this).ReplaceTypeDecl(_2_tpe)); + } + } + { + if (_source0.is_ConstDecl) { + RAST._IConstant _3_c = _source0.dtor_c; + return RAST.ModDecl.create_ConstDecl((this).ReplaceConst(_3_c)); + } + } + { + if (_source0.is_EnumDecl) { + RAST._IEnum _4_enum = _source0.dtor_enum; + return RAST.ModDecl.create_EnumDecl((this).ReplaceEnum(_4_enum)); + } + } + { + if (_source0.is_ImplDecl) { + RAST._IImpl _5_impl = _source0.dtor_impl; + return RAST.ModDecl.create_ImplDecl((this).ReplaceImplDecl(_5_impl)); + } + } + { + if (_source0.is_TraitDecl) { + RAST._ITrait _6_tr = _source0.dtor_tr; + return RAST.ModDecl.create_TraitDecl((this).ReplaceTrait(_6_tr)); + } + } + { + if (_source0.is_TopFnDecl) { + RAST._ITopFnDecl _7_fn = _source0.dtor_fn; + return RAST.ModDecl.create_TopFnDecl((this).ReplaceTopFn(_7_fn)); + } + } + { + RAST._IUse _8_use = _source0.dtor_use; + return RAST.ModDecl.create_UseDecl((this).ReplaceUse(_8_use)); + } + } + 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)); + } + } + 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)); + } + } + 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)); + } + } + 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)); + } + } + 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)); + } + } + public RAST._IImpl ReplaceImplDecl(RAST._IImpl impl) { + RAST._IImpl _source0 = impl; + { + if (_source0.is_ImplFor) { + Dafny.ISequence _0_typeParams = _source0.dtor_typeParams; + RAST._IType _1_tpe = _source0.dtor_tpe; + RAST._IType _2_forType = _source0.dtor_forType; + Dafny.ISequence _3_where = _source0.dtor_where; + Dafny.ISequence _4_body = _source0.dtor_body; + return RAST.Impl.create_ImplFor((this).ReplaceTypeParams(_0_typeParams), (this).ReplaceType(_1_tpe), (this).ReplaceType(_2_forType), _3_where, (this).ReplaceBody(_4_body)); + } + } + { + Dafny.ISequence _5_typeParams = _source0.dtor_typeParams; + RAST._IType _6_tpe = _source0.dtor_tpe; + Dafny.ISequence _7_where = _source0.dtor_where; + Dafny.ISequence _8_body = _source0.dtor_body; + return RAST.Impl.create_Impl((this).ReplaceTypeParams(_5_typeParams), (this).ReplaceType(_6_tpe), _7_where, (this).ReplaceBody(_8_body)); + } + } + 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)); + } + } + 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)); + } + } + public RAST._IFn ReplaceFn(RAST._IFn t) { + RAST._IFn _source0 = t; + { + Dafny.ISequence _0_name = _source0.dtor_name; + 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))))); + } + } + public RAST._IUse ReplaceUse(RAST._IUse use) { + RAST._IUse _source0 = use; + { + RAST._IVisibility _0_visibility = _source0.dtor_visibility; + RAST._IPath _1_path = _source0.dtor_path; + return RAST.Use.create(_0_visibility, _1_path); + } + } + public Dafny.ISequence ReplaceBody(Dafny.ISequence decls) { + return Std.Collections.Seq.__default.Map(((System.Func)((_0_t) => { + return (this).ReplaceImplMember(_0_t); + })), decls); + } + public RAST._IImplMember ReplaceImplMember(RAST._IImplMember t) { + RAST._IImplMember _source0 = t; + { + if (_source0.is_RawImplMember) { + Dafny.ISequence _0_content = _source0.dtor_content; + return 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)); + } + } + { + RAST._IExpr _3_expr = _source0.dtor_expr; + return RAST.ImplMember.create_ImplMemberMacro((this).ReplaceExpr(_3_expr)); + } + } + public RAST._IExpr ReplaceExpr(RAST._IExpr e) { + return (e).Replace((this).dtor_ReplaceExprSingle, (this).dtor_ReplaceTypeSingle); + } + public Dafny.ISequence ReplaceTypeParams(Dafny.ISequence typeParams) { + return Std.Collections.Seq.__default.Map(((System.Func)((_0_t) => { + return Dafny.Helpers.Let(_0_t, _pat_let5_0 => Dafny.Helpers.Let(_pat_let5_0, _1_dt__update__tmp_h0 => Dafny.Helpers.Let, RAST._ITypeParamDecl>(Std.Collections.Seq.__default.Map(((System.Func)((_2_constraint) => { + return (this).ReplaceType(_2_constraint); + })), (_0_t).dtor_constraints), _pat_let6_0 => Dafny.Helpers.Let, RAST._ITypeParamDecl>(_pat_let6_0, _3_dt__update_hconstraints_h0 => RAST.TypeParamDecl.create((_1_dt__update__tmp_h0).dtor_name, _3_dt__update_hconstraints_h0))))); + })), typeParams); + } + public RAST._IType ReplaceType(RAST._IType t) { + return (t).Replace((this).dtor_ReplaceTypeSingle); + } + public RAST._IFields ReplaceFields(RAST._IFields fields) { + RAST._IFields _source0 = fields; + { + if (_source0.is_NamedFields) { + Dafny.ISequence _0_sFields = _source0.dtor_fields; + return RAST.Fields.create_NamedFields(Std.Collections.Seq.__default.Map(((System.Func)((_1_f) => { + return Dafny.Helpers.Let(_1_f, _pat_let7_0 => Dafny.Helpers.Let(_pat_let7_0, _2_dt__update__tmp_h0 => Dafny.Helpers.Let(Dafny.Helpers.Let((_1_f).dtor_formal, _pat_let9_0 => Dafny.Helpers.Let(_pat_let9_0, _3_dt__update__tmp_h1 => Dafny.Helpers.Let((this).ReplaceType(((_1_f).dtor_formal).dtor_tpe), _pat_let10_0 => Dafny.Helpers.Let(_pat_let10_0, _4_dt__update_htpe_h0 => RAST.Formal.create((_3_dt__update__tmp_h1).dtor_name, _4_dt__update_htpe_h0))))), _pat_let8_0 => Dafny.Helpers.Let(_pat_let8_0, _5_dt__update_hformal_h0 => RAST.Field.create((_2_dt__update__tmp_h0).dtor_visibility, _5_dt__update_hformal_h0))))); +})), _0_sFields)); + } + } + { + Dafny.ISequence _6_sFields = _source0.dtor_types; + return RAST.Fields.create_NamelessFields(Std.Collections.Seq.__default.Map(((System.Func)((_7_f) => { + return Dafny.Helpers.Let(_7_f, _pat_let11_0 => Dafny.Helpers.Let(_pat_let11_0, _8_dt__update__tmp_h2 => Dafny.Helpers.Let((this).ReplaceType((_7_f).dtor_tpe), _pat_let12_0 => Dafny.Helpers.Let(_pat_let12_0, _9_dt__update_htpe_h1 => RAST.NamelessField.create((_8_dt__update__tmp_h2).dtor_visibility, _9_dt__update_htpe_h1))))); +})), _6_sFields)); + } + } + } + public interface _IMod { bool is_Mod { get; } bool is_ExternMod { get; } @@ -371,7 +1023,7 @@ public __T Fold<__T>(__T acc, Func<__T, RAST._IModDecl, __T> accBuilder) Dafny.ISequence _1_name = _source0.dtor_name; 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_let5_0 => Dafny.Helpers.Let>(_pat_let5_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_let6_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let6_0, _5_prefixIfNotUseDecl => Dafny.Helpers.Let, Dafny.ISequence>(((_4_startWithUse) ? (Dafny.Sequence.Concat(_pat_let_tv1, RAST.__default.IND)) : (Dafny.Sequence.UnicodeFromString(""))), _pat_let7_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let7_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_let8_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let8_0, _7_infixDecl => Dafny.Helpers.Let, Dafny.ISequence>(((_4_startWithUse) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat(_pat_let_tv3, RAST.__default.IND))), _pat_let9_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let9_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(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("}"))))))))))))); } @@ -1302,7 +1954,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(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(";")); } } @@ -1842,6 +2494,7 @@ public interface _IPath { Dafny.ISequence dtor_name { get; } _IPath DowncastClone(); RAST._IPath MSel(Dafny.ISequence name); + RAST._IPath MSels(Dafny.ISequence> names); RAST._IExpr FSel(Dafny.ISequence name); RAST._IType AsType(); RAST._IExpr AsExpr(); @@ -1891,6 +2544,20 @@ public Dafny.ISequence dtor_name { public RAST._IPath MSel(Dafny.ISequence name) { return RAST.Path.create_PMemberSelect(this, name); } + public RAST._IPath MSels(Dafny.ISequence> names) { + _IPath _this = this; + TAIL_CALL_START: ; + if ((new BigInteger((names).Count)).Sign == 0) { + return _this; + } else { + RAST._IPath _in0 = (_this).MSel((names).Select(BigInteger.Zero)); + Dafny.ISequence> _in1 = (names).Drop(BigInteger.One); + _this = _in0; + ; + names = _in1; + goto TAIL_CALL_START; + } + } public RAST._IExpr FSel(Dafny.ISequence name) { return ((this).AsExpr()).FSel(name); } @@ -2054,6 +2721,7 @@ public interface _IType { bool is_I32 { get; } bool is_I64 { get; } bool is_I128 { get; } + bool is_USIZE { get; } bool is_Bool { get; } bool is_TIdentifier { get; } bool is_TypeFromPath { get; } @@ -2149,6 +2817,9 @@ public static _IType create_I64() { public static _IType create_I128() { return new Type_I128(); } + public static _IType create_USIZE() { + return new Type_USIZE(); + } public static _IType create_Bool() { return new Type_Bool(); } @@ -2198,6 +2869,7 @@ public static _IType create_TSynonym(RAST._IType display, RAST._IType @base) { public bool is_I32 { get { return this is Type_I32; } } public bool is_I64 { get { return this is Type_I64; } } public bool is_I128 { get { return this is Type_I128; } } + public bool is_USIZE { get { return this is Type_USIZE; } } public bool is_Bool { get { return this is Type_Bool; } } public bool is_TIdentifier { get { return this is Type_TIdentifier; } } public bool is_TypeFromPath { get { return this is Type_TypeFromPath; } } @@ -2339,6 +3011,9 @@ public RAST._IType Replace(Func mapping) { if (_source0.is_I128) { disjunctiveMatch0 = true; } + if (_source0.is_USIZE) { + disjunctiveMatch0 = true; + } if (_source0.is_Bool) { disjunctiveMatch0 = true; } @@ -2545,6 +3220,9 @@ public __T Fold<__T>(__T acc, Func<__T, RAST._IType, __T> f) if (_source0.is_I128) { disjunctiveMatch0 = true; } + if (_source0.is_USIZE) { + disjunctiveMatch0 = true; + } if (_source0.is_Bool) { disjunctiveMatch0 = true; } @@ -2567,74 +3245,75 @@ public __T Fold<__T>(__T acc, Func<__T, RAST._IType, __T> f) if (_source0.is_TypeApp) { RAST._IType _2_baseName = _source0.dtor_baseName; Dafny.ISequence _3_arguments = _source0.dtor_arguments; - return Std.Collections.Seq.__default.FoldLeft<__T, RAST._IType>(Dafny.Helpers.Id, Func<__T, RAST._IType, __T>>>((_4_f) => ((System.Func<__T, RAST._IType, __T>)((_5_acc, _6_argType) => { - return (_6_argType).Fold<__T>(_5_acc, _4_f); - })))(f), (_2_baseName).Fold<__T>(_0_newAcc, f), _3_arguments); + __T _4_newAcc = (_2_baseName).Fold<__T>(_0_newAcc, f); + return RAST.__default.FoldLeft<__T, RAST._IType>(Dafny.Helpers.Id, Dafny.ISequence, Func<__T, RAST._IType, __T>>>((_5_f, _6_arguments) => ((System.Func<__T, RAST._IType, __T>)((_7_acc, _8_argType) => { + return (_8_argType).Fold<__T>(_7_acc, _5_f); + })))(f, _3_arguments), _4_newAcc, _3_arguments); } } { if (_source0.is_Borrowed) { - RAST._IType _7_underlying = _source0.dtor_underlying; - return (_7_underlying).Fold<__T>(_0_newAcc, f); + RAST._IType _9_underlying = _source0.dtor_underlying; + return (_9_underlying).Fold<__T>(_0_newAcc, f); } } { if (_source0.is_BorrowedMut) { - RAST._IType _8_underlying = _source0.dtor_underlying; - return (_8_underlying).Fold<__T>(_0_newAcc, f); + RAST._IType _10_underlying = _source0.dtor_underlying; + return (_10_underlying).Fold<__T>(_0_newAcc, f); } } { if (_source0.is_ImplType) { - RAST._IType _9_underlying = _source0.dtor_underlying; - return (_9_underlying).Fold<__T>(_0_newAcc, f); + RAST._IType _11_underlying = _source0.dtor_underlying; + return (_11_underlying).Fold<__T>(_0_newAcc, f); } } { if (_source0.is_DynType) { - RAST._IType _10_underlying = _source0.dtor_underlying; - return (_10_underlying).Fold<__T>(_0_newAcc, f); + RAST._IType _12_underlying = _source0.dtor_underlying; + return (_12_underlying).Fold<__T>(_0_newAcc, f); } } { if (_source0.is_TupleType) { - Dafny.ISequence _11_arguments = _source0.dtor_arguments; - return Std.Collections.Seq.__default.FoldLeft<__T, RAST._IType>(Dafny.Helpers.Id, Func<__T, RAST._IType, __T>>>((_12_f) => ((System.Func<__T, RAST._IType, __T>)((_13_acc, _14_argType) => { - return (_14_argType).Fold<__T>(_13_acc, _12_f); - })))(f), _0_newAcc, _11_arguments); + Dafny.ISequence _13_arguments = _source0.dtor_arguments; + return RAST.__default.FoldLeft<__T, RAST._IType>(Dafny.Helpers.Id, Dafny.ISequence, Func<__T, RAST._IType, __T>>>((_14_f, _15_arguments) => ((System.Func<__T, RAST._IType, __T>)((_16_acc, _17_argType) => { + return (_17_argType).Fold<__T>(_16_acc, _14_f); + })))(f, _13_arguments), _0_newAcc, _13_arguments); } } { if (_source0.is_FnType) { - Dafny.ISequence _15_arguments = _source0.dtor_arguments; - RAST._IType _16_returnType = _source0.dtor_returnType; - return (_16_returnType).Fold<__T>(Std.Collections.Seq.__default.FoldLeft<__T, RAST._IType>(Dafny.Helpers.Id, Func<__T, RAST._IType, __T>>>((_17_f) => ((System.Func<__T, RAST._IType, __T>)((_18_acc, _19_argType) => { - return (_19_argType).Fold<__T>(_18_acc, _17_f); - })))(f), _0_newAcc, _15_arguments), f); + Dafny.ISequence _18_arguments = _source0.dtor_arguments; + RAST._IType _19_returnType = _source0.dtor_returnType; + return (_19_returnType).Fold<__T>(RAST.__default.FoldLeft<__T, RAST._IType>(Dafny.Helpers.Id, Dafny.ISequence, Func<__T, RAST._IType, __T>>>((_20_f, _21_arguments) => ((System.Func<__T, RAST._IType, __T>)((_22_acc, _23_argType) => { + return (_23_argType).Fold<__T>(_22_acc, _20_f); + })))(f, _18_arguments), _0_newAcc, _18_arguments), f); } } { if (_source0.is_IntersectionType) { - RAST._IType _20_left = _source0.dtor_left; - RAST._IType _21_right = _source0.dtor_right; - return (_21_right).Fold<__T>((_20_left).Fold<__T>(_0_newAcc, f), f); + RAST._IType _24_left = _source0.dtor_left; + RAST._IType _25_right = _source0.dtor_right; + return (_25_right).Fold<__T>((_24_left).Fold<__T>(_0_newAcc, f), f); } } { if (_source0.is_Array) { - RAST._IType _22_underlying = _source0.dtor_underlying; - Std.Wrappers._IOption> _23_size = _source0.dtor_size; - return (_22_underlying).Fold<__T>(_0_newAcc, f); + RAST._IType _26_underlying = _source0.dtor_underlying; + Std.Wrappers._IOption> _27_size = _source0.dtor_size; + return (_26_underlying).Fold<__T>(_0_newAcc, f); } } { - RAST._IType _24_display = _source0.dtor_display; - RAST._IType _25_base = _source0.dtor_base; - return (_24_display).Fold<__T>(_0_newAcc, f); + RAST._IType _28_display = _source0.dtor_display; + RAST._IType _29_base = _source0.dtor_base; + return (_28_display).Fold<__T>(_0_newAcc, f); } } public bool CanReadWithoutClone() { - return (((((((((((((this).is_U8) || ((this).is_U16)) || ((this).is_U32)) || ((this).is_U64)) || ((this).is_U128)) || ((this).is_I8)) || ((this).is_I16)) || ((this).is_I32)) || ((this).is_I64)) || ((this).is_I128)) || ((this).is_Bool)) || (((this).is_TSynonym) && (((this).dtor_base).CanReadWithoutClone()))) || ((this).IsPointer()); + return ((((((((((((((this).is_U8) || ((this).is_U16)) || ((this).is_U32)) || ((this).is_U64)) || ((this).is_U128)) || ((this).is_I8)) || ((this).is_I16)) || ((this).is_I32)) || ((this).is_I64)) || ((this).is_I128)) || ((this).is_USIZE)) || ((this).is_Bool)) || (((this).is_TSynonym) && (((this).dtor_base).CanReadWithoutClone()))) || ((this).IsPointer()); } public bool IsRcOrBorrowedRc() { return ((((this).is_TypeApp) && (object.Equals((this).dtor_baseName, RAST.__default.RcType))) || (((this).is_Borrowed) && (((this).dtor_underlying).IsRcOrBorrowedRc()))) || (((this).is_TSynonym) && (((this).dtor_base).IsRcOrBorrowedRc())); @@ -2800,6 +3479,11 @@ public bool IsRcOrBorrowedRc() { return Dafny.Sequence.UnicodeFromString("i128"); } } + { + if (_source0.is_USIZE) { + return Dafny.Sequence.UnicodeFromString("usize"); + } + } { if (_source0.is_Array) { RAST._IType _19_underlying = _source0.dtor_underlying; @@ -2840,14 +3524,14 @@ public RAST._IType ToOwned() { } public RAST._IExpr ToNullExpr() { if (((this).Expand()).IsObject()) { - return ((RAST.__default.Object).FSel(Dafny.Sequence.UnicodeFromString("null"))).Apply(Dafny.Sequence.FromElements()); + return ((RAST.__default.Object).FSel(Dafny.Sequence.UnicodeFromString("null"))).Apply0(); } else { - return ((RAST.__default.Ptr).FSel(Dafny.Sequence.UnicodeFromString("null"))).Apply(Dafny.Sequence.FromElements()); + return ((RAST.__default.Ptr).FSel(Dafny.Sequence.UnicodeFromString("null"))).Apply0(); } } public bool IsMultiArray() { RAST._IType _0_t = (this).Expand(); - return ((_0_t).is_TypeApp) && (Dafny.Helpers.Let((_0_t).dtor_baseName, _pat_let10_0 => Dafny.Helpers.Let(_pat_let10_0, _1_baseName => Dafny.Helpers.Let, bool>((_0_t).dtor_arguments, _pat_let11_0 => Dafny.Helpers.Let, bool>(_pat_let11_0, _2_args => ((((((new BigInteger((_2_args).Count)) == (BigInteger.One)) && ((_1_baseName).is_TypeFromPath)) && (((_1_baseName).dtor_path).is_PMemberSelect)) && (object.Equals(((_1_baseName).dtor_path).dtor_base, RAST.__default.dafny__runtime))) && ((new BigInteger((((_1_baseName).dtor_path).dtor_name).Count)) >= (new BigInteger(5)))) && (((((_1_baseName).dtor_path).dtor_name).Subsequence(BigInteger.Zero, new BigInteger(5))).Equals(Dafny.Sequence.UnicodeFromString("Array")))))))); + return ((_0_t).is_TypeApp) && (Dafny.Helpers.Let((_0_t).dtor_baseName, _pat_let18_0 => Dafny.Helpers.Let(_pat_let18_0, _1_baseName => Dafny.Helpers.Let, bool>((_0_t).dtor_arguments, _pat_let19_0 => Dafny.Helpers.Let, bool>(_pat_let19_0, _2_args => ((((((new BigInteger((_2_args).Count)) == (BigInteger.One)) && ((_1_baseName).is_TypeFromPath)) && (((_1_baseName).dtor_path).is_PMemberSelect)) && (object.Equals(((_1_baseName).dtor_path).dtor_base, RAST.__default.dafny__runtime))) && ((new BigInteger((((_1_baseName).dtor_path).dtor_name).Count)) >= (new BigInteger(5)))) && (((((_1_baseName).dtor_path).dtor_name).Subsequence(BigInteger.Zero, new BigInteger(5))).Equals(Dafny.Sequence.UnicodeFromString("Array")))))))); } public Dafny.ISequence MultiArrayClass() { return ((((this).Expand()).dtor_baseName).dtor_path).dtor_name; @@ -3206,15 +3890,15 @@ public override string ToString() { return s; } } - public class Type_Bool : Type { - public Type_Bool() : base() { + public class Type_USIZE : Type { + public Type_USIZE() : base() { } public override _IType DowncastClone() { if (this is _IType dt) { return dt; } - return new Type_Bool(); + return new Type_USIZE(); } public override bool Equals(object other) { - var oth = other as RAST.Type_Bool; + var oth = other as RAST.Type_USIZE; return oth != null; } public override int GetHashCode() { @@ -3222,6 +3906,27 @@ public override int GetHashCode() { hash = ((hash << 5) + hash) + 10; return (int) hash; } + public override string ToString() { + string s = "RAST.Type.USIZE"; + return s; + } + } + public class Type_Bool : Type { + public Type_Bool() : base() { + } + public override _IType DowncastClone() { + if (this is _IType dt) { return dt; } + return new Type_Bool(); + } + public override bool Equals(object other) { + var oth = other as RAST.Type_Bool; + return oth != null; + } + public override int GetHashCode() { + ulong hash = 5381; + hash = ((hash << 5) + hash) + 11; + return (int) hash; + } public override string ToString() { string s = "RAST.Type.Bool"; return s; @@ -3242,7 +3947,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 11; + hash = ((hash << 5) + hash) + 12; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); return (int) hash; } @@ -3269,7 +3974,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 12; + hash = ((hash << 5) + hash) + 13; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._path)); return (int) hash; } @@ -3298,7 +4003,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 13; + hash = ((hash << 5) + hash) + 14; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._baseName)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._arguments)); return (int) hash; @@ -3328,7 +4033,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 14; + hash = ((hash << 5) + hash) + 15; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._underlying)); return (int) hash; } @@ -3355,7 +4060,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 15; + hash = ((hash << 5) + hash) + 16; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._underlying)); return (int) hash; } @@ -3382,7 +4087,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 16; + hash = ((hash << 5) + hash) + 17; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._underlying)); return (int) hash; } @@ -3409,7 +4114,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 17; + hash = ((hash << 5) + hash) + 18; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._underlying)); return (int) hash; } @@ -3436,7 +4141,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 18; + hash = ((hash << 5) + hash) + 19; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._arguments)); return (int) hash; } @@ -3465,7 +4170,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 19; + hash = ((hash << 5) + hash) + 20; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._arguments)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._returnType)); return (int) hash; @@ -3497,7 +4202,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 20; + hash = ((hash << 5) + hash) + 21; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._left)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._right)); return (int) hash; @@ -3529,7 +4234,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 21; + hash = ((hash << 5) + hash) + 22; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._underlying)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._size)); return (int) hash; @@ -3561,7 +4266,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 22; + hash = ((hash << 5) + hash) + 23; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._display)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._base)); return (int) hash; @@ -4084,6 +4789,8 @@ public interface _IFormal { Dafny.ISequence dtor_name { get; } RAST._IType dtor_tpe { get; } _IFormal DowncastClone(); + RAST._IFormal Replace(Func ft); + __T Fold<__T>(__T acc, Func<__T, RAST._IType, __T> ft); Dafny.ISequence _ToString(Dafny.ISequence ind); } public class Formal : _IFormal { @@ -4142,6 +4849,16 @@ public RAST._IType dtor_tpe { return this._tpe; } } + public static RAST._IFormal ImplicitlyTyped(Dafny.ISequence name) { + return RAST.Formal.create(name, RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("_"))); + } + public RAST._IFormal Replace(Func ft) { + return RAST.Formal.create((this).dtor_name, ((this).dtor_tpe).Replace(ft)); + } + public __T Fold<__T>(__T acc, Func<__T, RAST._IType, __T> ft) + { + return ((this).dtor_tpe).Fold<__T>(acc, ft); + } public Dafny.ISequence _ToString(Dafny.ISequence ind) { if ((((this).dtor_name).Equals(Dafny.Sequence.UnicodeFromString("self"))) && (object.Equals((this).dtor_tpe, RAST.__default.SelfOwned))) { return (this).dtor_name; @@ -4149,6 +4866,8 @@ public RAST._IType dtor_tpe { return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("&"), (this).dtor_name); } else if ((((this).dtor_name).Equals(Dafny.Sequence.UnicodeFromString("self"))) && (object.Equals((this).dtor_tpe, RAST.__default.SelfBorrowedMut))) { return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("&mut "), (this).dtor_name); + } else if ((((this).dtor_tpe).is_TIdentifier) && ((((this).dtor_tpe).dtor_name).Equals(Dafny.Sequence.UnicodeFromString("_")))) { + return (this).dtor_name; } else { return Dafny.Sequence.Concat(Dafny.Sequence.Concat((this).dtor_name, Dafny.Sequence.UnicodeFromString(": ")), ((this).dtor_tpe)._ToString(ind)); } @@ -4223,6 +4942,8 @@ public interface _IMatchCase { Dafny.ISequence dtor_pattern { get; } RAST._IExpr dtor_rhs { get; } _IMatchCase DowncastClone(); + RAST._IMatchCase Replace(Func mapping, Func mappingType); + __T Fold<__T>(__T acc, Func<__T, RAST._IExpr, __T> f, Func<__T, RAST._IType, __T> ft); Dafny.ISequence _ToString(Dafny.ISequence ind); } public class MatchCase : _IMatchCase { @@ -4281,6 +5002,14 @@ public RAST._IExpr dtor_rhs { return this._rhs; } } + public RAST._IMatchCase Replace(Func mapping, Func mappingType) + { + return RAST.MatchCase.create((this).dtor_pattern, ((this).dtor_rhs).Replace(mapping, mappingType)); + } + public __T Fold<__T>(__T acc, Func<__T, RAST._IExpr, __T> f, Func<__T, RAST._IType, __T> ft) + { + return ((this).dtor_rhs).Fold<__T>(acc, f, ft); + } public Dafny.ISequence _ToString(Dafny.ISequence ind) { Dafny.ISequence _0_newIndent = ((((this).dtor_rhs).is_Block) ? (ind) : (Dafny.Sequence.Concat(ind, RAST.__default.IND))); Dafny.ISequence _1_rhsString = ((this).dtor_rhs)._ToString(_0_newIndent); @@ -4293,6 +5022,8 @@ public interface _IAssignIdentifier { Dafny.ISequence dtor_identifier { get; } RAST._IExpr dtor_rhs { get; } _IAssignIdentifier DowncastClone(); + RAST._IAssignIdentifier Replace(Func f, Func ft); + __T Fold<__T>(__T acc, Func<__T, RAST._IExpr, __T> f, Func<__T, RAST._IType, __T> ft); Dafny.ISequence _ToString(Dafny.ISequence ind); } public class AssignIdentifier : _IAssignIdentifier { @@ -4351,6 +5082,14 @@ public RAST._IExpr dtor_rhs { return this._rhs; } } + public RAST._IAssignIdentifier Replace(Func f, Func ft) + { + return RAST.AssignIdentifier.create((this).dtor_identifier, ((this).dtor_rhs).Replace(f, ft)); + } + public __T Fold<__T>(__T acc, Func<__T, RAST._IExpr, __T> f, Func<__T, RAST._IType, __T> ft) + { + return ((this).dtor_rhs).Fold<__T>(acc, f, ft); + } public Dafny.ISequence _ToString(Dafny.ISequence ind) { return Dafny.Sequence.Concat(Dafny.Sequence.Concat((this).dtor_identifier, Dafny.Sequence.UnicodeFromString(": ")), ((this).dtor_rhs)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))); } @@ -4938,6 +5677,7 @@ public interface _IExpr { bool is_UnaryOp { get; } bool is_BinaryOp { get; } bool is_TypeAscription { get; } + bool is_TraitCast { get; } bool is_LiteralInt { get; } bool is_LiteralBool { get; } bool is_LiteralString { get; } @@ -4973,6 +5713,7 @@ public interface _IExpr { RAST._IExpr dtor_left { get; } RAST._IExpr dtor_right { get; } DAST.Format._IBinaryOpFormat dtor_format2 { get; } + RAST._IType dtor_leftTpe { get; } Dafny.ISequence dtor_value { get; } bool dtor_bvalue { get; } bool dtor_binary { get; } @@ -4991,14 +5732,15 @@ public interface _IExpr { Std.Wrappers._IOption> dtor_optLbl { get; } Std.Wrappers._IOption dtor_optExpr { get; } RAST._IExpr dtor_obj { get; } - Dafny.ISequence dtor_typeParameters { get; } + Dafny.ISequence dtor_typeArguments { get; } RAST._IPath dtor_path { get; } Dafny.ISequence dtor_params { get; } Std.Wrappers._IOption dtor_retType { get; } _IExpr DowncastClone(); + RAST._IExpr Replace(Func f, Func ft); + __T Fold<__T>(__T acc, Func<__T, RAST._IExpr, __T> f, Func<__T, RAST._IType, __T> ft); bool NoExtraSemicolonAfter(); RAST._IPrintingInfo printingInfo { get; } - RAST._IExpr Optimize(); bool LeftRequiresParentheses(RAST._IExpr left); _System._ITuple2, Dafny.ISequence> LeftParentheses(RAST._IExpr left); bool RightRequiresParentheses(RAST._IExpr right); @@ -5008,10 +5750,11 @@ public interface _IExpr { RAST._IExpr Then(RAST._IExpr rhs2); RAST._IExpr Sel(Dafny.ISequence name); RAST._IExpr FSel(Dafny.ISequence name); - RAST._IExpr ApplyType(Dafny.ISequence typeParameters); - RAST._IExpr ApplyType1(RAST._IType typeParameter); + RAST._IExpr ApplyType(Dafny.ISequence typeArguments); + RAST._IExpr ApplyType1(RAST._IType typeArgument); RAST._IExpr Apply(Dafny.ISequence arguments); RAST._IExpr Apply1(RAST._IExpr argument); + RAST._IExpr Apply0(); bool IsLhsIdentifier(); Dafny.ISequence LhsIdentifierName(); RAST._IExpr Clone(); @@ -5060,6 +5803,9 @@ public static _IExpr create_BinaryOp(Dafny.ISequence op2, RAST._IExp public static _IExpr create_TypeAscription(RAST._IExpr left, RAST._IType tpe) { return new Expr_TypeAscription(left, tpe); } + public static _IExpr create_TraitCast(RAST._IType leftTpe, RAST._IType tpe) { + return new Expr_TraitCast(leftTpe, tpe); + } public static _IExpr create_LiteralInt(Dafny.ISequence @value) { return new Expr_LiteralInt(@value); } @@ -5096,8 +5842,8 @@ public static _IExpr create_Continue(Std.Wrappers._IOption optExpr) { return new Expr_Return(optExpr); } - public static _IExpr create_CallType(RAST._IExpr obj, Dafny.ISequence typeParameters) { - return new Expr_CallType(obj, typeParameters); + public static _IExpr create_CallType(RAST._IExpr obj, Dafny.ISequence typeArguments) { + return new Expr_CallType(obj, typeArguments); } public static _IExpr create_Call(RAST._IExpr obj, Dafny.ISequence arguments) { return new Expr_Call(obj, arguments); @@ -5128,6 +5874,7 @@ public static _IExpr create_Lambda(Dafny.ISequence @params, Std.W public bool is_UnaryOp { get { return this is Expr_UnaryOp; } } public bool is_BinaryOp { get { return this is Expr_BinaryOp; } } public bool is_TypeAscription { get { return this is Expr_TypeAscription; } } + public bool is_TraitCast { get { return this is Expr_TraitCast; } } public bool is_LiteralInt { get { return this is Expr_LiteralInt; } } public bool is_LiteralBool { get { return this is Expr_LiteralBool; } } public bool is_LiteralString { get { return this is Expr_LiteralString; } } @@ -5157,7 +5904,8 @@ public RAST._IType dtor_tpe { get { var d = this; if (d is Expr_ExprFromType) { return ((Expr_ExprFromType)d)._tpe; } - return ((Expr_TypeAscription)d)._tpe; + if (d is Expr_TypeAscription) { return ((Expr_TypeAscription)d)._tpe; } + return ((Expr_TraitCast)d)._tpe; } } public Dafny.ISequence dtor_name { @@ -5255,6 +6003,12 @@ public DAST.Format._IBinaryOpFormat dtor_format2 { return ((Expr_BinaryOp)d)._format2; } } + public RAST._IType dtor_leftTpe { + get { + var d = this; + return ((Expr_TraitCast)d)._leftTpe; + } + } public Dafny.ISequence dtor_value { get { var d = this; @@ -5371,10 +6125,10 @@ public RAST._IExpr dtor_obj { return ((Expr_FunctionSelect)d)._obj; } } - public Dafny.ISequence dtor_typeParameters { + public Dafny.ISequence dtor_typeArguments { get { var d = this; - return ((Expr_CallType)d)._typeParameters; + return ((Expr_CallType)d)._typeArguments; } } public RAST._IPath dtor_path { @@ -5396,219 +6150,491 @@ public Std.Wrappers._IOption dtor_retType { } } public abstract _IExpr DowncastClone(); - public bool NoExtraSemicolonAfter() { - return (((((((this).is_DeclareVar) || ((this).is_Assign)) || ((this).is_Break)) || ((this).is_Continue)) || ((this).is_Return)) || ((this).is_For)) || ((((this).is_RawExpr) && ((new BigInteger(((this).dtor_content).Count)).Sign == 1)) && ((((this).dtor_content).Select((new BigInteger(((this).dtor_content).Count)) - (BigInteger.One))) == (new Dafny.Rune(';')))); + public RAST._IExpr Replace(Func f, Func ft) + { + RAST._IExpr _0_r = ((System.Func)(() => { + RAST._IExpr _source0 = this; + { + if (_source0.is_RawExpr) { + Dafny.ISequence _1_content = _source0.dtor_content; + return this; + } + } + { + if (_source0.is_ExprFromType) { + RAST._IType _2_tpe = _source0.dtor_tpe; + return RAST.Expr.create_ExprFromType((_2_tpe).Replace(ft)); + } + } + { + if (_source0.is_Identifier) { + Dafny.ISequence _3_name = _source0.dtor_name; + return this; + } + } + { + if (_source0.is_Match) { + RAST._IExpr _4_matchee = _source0.dtor_matchee; + Dafny.ISequence _5_cases = _source0.dtor_cases; + return RAST.Expr.create_Match((_4_matchee).Replace(f, ft), Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func, Dafny.ISequence, Func>>((_6_f, _7_ft, _8_cases) => ((System.Func)((_9_c) => { + return (_9_c).Replace(_6_f, _7_ft); +})))(f, ft, _5_cases), _5_cases)); + } + } + { + if (_source0.is_StmtExpr) { + RAST._IExpr _10_stmt = _source0.dtor_stmt; + RAST._IExpr _11_rhs = _source0.dtor_rhs; + return RAST.Expr.create_StmtExpr((_10_stmt).Replace(f, ft), (_11_rhs).Replace(f, ft)); + } + } + { + if (_source0.is_Block) { + RAST._IExpr _12_underlying = _source0.dtor_underlying; + return RAST.Expr.create_Block((_12_underlying).Replace(f, ft)); + } + } + { + if (_source0.is_StructBuild) { + RAST._IExpr _13_underlying = _source0.dtor_underlying; + Dafny.ISequence _14_assignments = _source0.dtor_assignments; + return RAST.Expr.create_StructBuild((_13_underlying).Replace(f, ft), Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func, Dafny.ISequence, Func>>((_15_f, _16_ft, _17_assignments) => ((System.Func)((_18_a) => { + return (_18_a).Replace(_15_f, _16_ft); +})))(f, ft, _14_assignments), _14_assignments)); + } + } + { + if (_source0.is_Tuple) { + Dafny.ISequence _19_arguments = _source0.dtor_arguments; + return RAST.Expr.create_Tuple(Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func, Dafny.ISequence, Func>>((_20_f, _21_ft, _22_arguments) => ((System.Func)((_23_e) => { + return (_23_e).Replace(_20_f, _21_ft); +})))(f, ft, _19_arguments), _19_arguments)); + } + } + { + if (_source0.is_UnaryOp) { + Dafny.ISequence _24_op1 = _source0.dtor_op1; + RAST._IExpr _25_underlying = _source0.dtor_underlying; + DAST.Format._IUnaryOpFormat _26_format = _source0.dtor_format; + return RAST.Expr.create_UnaryOp(_24_op1, (_25_underlying).Replace(f, ft), _26_format); + } + } + { + if (_source0.is_BinaryOp) { + Dafny.ISequence _27_op2 = _source0.dtor_op2; + RAST._IExpr _28_left = _source0.dtor_left; + RAST._IExpr _29_right = _source0.dtor_right; + DAST.Format._IBinaryOpFormat _30_format2 = _source0.dtor_format2; + return RAST.Expr.create_BinaryOp(_27_op2, (_28_left).Replace(f, ft), (_29_right).Replace(f, ft), _30_format2); + } + } + { + if (_source0.is_TypeAscription) { + RAST._IExpr _31_left = _source0.dtor_left; + RAST._IType _32_tpe = _source0.dtor_tpe; + return RAST.Expr.create_TypeAscription((_31_left).Replace(f, ft), (_32_tpe).Replace(ft)); + } + } + { + if (_source0.is_TraitCast) { + RAST._IType _33_leftTpe = _source0.dtor_leftTpe; + RAST._IType _34_tpe = _source0.dtor_tpe; + return RAST.Expr.create_TraitCast((_33_leftTpe).Replace(ft), (_34_tpe).Replace(ft)); + } + } + { + if (_source0.is_LiteralInt) { + Dafny.ISequence _35_value = _source0.dtor_value; + return this; + } + } + { + if (_source0.is_LiteralBool) { + bool _36_bvalue = _source0.dtor_bvalue; + return this; + } + } + { + if (_source0.is_LiteralString) { + Dafny.ISequence _37_value = _source0.dtor_value; + bool _38_binary = _source0.dtor_binary; + bool _39_verbatim = _source0.dtor_verbatim; + return this; + } + } + { + if (_source0.is_DeclareVar) { + RAST._IDeclareType _40_declareType = _source0.dtor_declareType; + Dafny.ISequence _41_name = _source0.dtor_name; + Std.Wrappers._IOption _42_optType = _source0.dtor_optType; + Std.Wrappers._IOption _43_optRhs = _source0.dtor_optRhs; + return RAST.Expr.create_DeclareVar(_40_declareType, _41_name, (((_42_optType).is_None) ? (_42_optType) : (Std.Wrappers.Option.create_Some(((_42_optType).dtor_value).Replace(ft)))), (((_43_optRhs).is_None) ? (_43_optRhs) : (Std.Wrappers.Option.create_Some(((_43_optRhs).dtor_value).Replace(f, ft))))); + } + } + { + if (_source0.is_Assign) { + Std.Wrappers._IOption _44_names = _source0.dtor_names; + RAST._IExpr _45_rhs = _source0.dtor_rhs; + return RAST.Expr.create_Assign(_44_names, (_45_rhs).Replace(f, ft)); + } + } + { + if (_source0.is_IfExpr) { + RAST._IExpr _46_cond = _source0.dtor_cond; + RAST._IExpr _47_thn = _source0.dtor_thn; + RAST._IExpr _48_els = _source0.dtor_els; + return RAST.Expr.create_IfExpr((_46_cond).Replace(f, ft), (_47_thn).Replace(f, ft), (_48_els).Replace(f, ft)); + } + } + { + if (_source0.is_Loop) { + Std.Wrappers._IOption _49_optCond = _source0.dtor_optCond; + RAST._IExpr _50_underlying = _source0.dtor_underlying; + return RAST.Expr.create_Loop((((_49_optCond).is_None) ? (Std.Wrappers.Option.create_None()) : (Std.Wrappers.Option.create_Some(((_49_optCond).dtor_value).Replace(f, ft)))), (_50_underlying).Replace(f, ft)); + } + } + { + if (_source0.is_For) { + Dafny.ISequence _51_name = _source0.dtor_name; + RAST._IExpr _52_range = _source0.dtor_range; + RAST._IExpr _53_body = _source0.dtor_body; + return RAST.Expr.create_For(_51_name, (_52_range).Replace(f, ft), (_53_body).Replace(f, ft)); + } + } + { + if (_source0.is_Labelled) { + Dafny.ISequence _54_lbl = _source0.dtor_lbl; + RAST._IExpr _55_underlying = _source0.dtor_underlying; + return RAST.Expr.create_Labelled(_54_lbl, (_55_underlying).Replace(f, ft)); + } + } + { + if (_source0.is_Break) { + Std.Wrappers._IOption> _56_optLbl = _source0.dtor_optLbl; + return this; + } + } + { + if (_source0.is_Continue) { + Std.Wrappers._IOption> _57_optLbl = _source0.dtor_optLbl; + return this; + } + } + { + if (_source0.is_Return) { + Std.Wrappers._IOption _58_optExpr = _source0.dtor_optExpr; + return RAST.Expr.create_Return((((_58_optExpr).is_None) ? (Std.Wrappers.Option.create_None()) : (Std.Wrappers.Option.create_Some(((_58_optExpr).dtor_value).Replace(f, ft))))); + } + } + { + if (_source0.is_CallType) { + RAST._IExpr _59_obj = _source0.dtor_obj; + Dafny.ISequence _60_typeArguments = _source0.dtor_typeArguments; + return RAST.Expr.create_CallType((_59_obj).Replace(f, ft), Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func>>((_61_ft) => ((System.Func)((_62_tp) => { + return (_62_tp).Replace(_61_ft); +})))(ft), _60_typeArguments)); + } + } + { + if (_source0.is_Call) { + RAST._IExpr _63_obj = _source0.dtor_obj; + Dafny.ISequence _64_arguments = _source0.dtor_arguments; + return RAST.Expr.create_Call((_63_obj).Replace(f, ft), Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func, Func>>((_65_f, _66_ft) => ((System.Func)((_67_a) => { + return (_67_a).Replace(_65_f, _66_ft); +})))(f, ft), _64_arguments)); + } + } + { + if (_source0.is_Select) { + RAST._IExpr _68_obj = _source0.dtor_obj; + Dafny.ISequence _69_name = _source0.dtor_name; + return RAST.Expr.create_Select((_68_obj).Replace(f, ft), _69_name); + } + } + { + if (_source0.is_SelectIndex) { + RAST._IExpr _70_obj = _source0.dtor_obj; + RAST._IExpr _71_range = _source0.dtor_range; + return RAST.Expr.create_SelectIndex((_70_obj).Replace(f, ft), (_71_range).Replace(f, ft)); + } + } + { + if (_source0.is_ExprFromPath) { + RAST._IPath _72_path = _source0.dtor_path; + return RAST.Expr.create_ExprFromPath(_72_path); + } + } + { + if (_source0.is_FunctionSelect) { + RAST._IExpr _73_obj = _source0.dtor_obj; + Dafny.ISequence _74_name = _source0.dtor_name; + return RAST.Expr.create_FunctionSelect((_73_obj).Replace(f, ft), _74_name); + } + } + { + Dafny.ISequence _75_params = _source0.dtor_params; + Std.Wrappers._IOption _76_retType = _source0.dtor_retType; + RAST._IExpr _77_body = _source0.dtor_body; + return RAST.Expr.create_Lambda(Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func>>((_78_ft) => ((System.Func)((_79_f) => { + return (_79_f).Replace(_78_ft); +})))(ft), _75_params), (((_76_retType).is_None) ? (Std.Wrappers.Option.create_None()) : (Std.Wrappers.Option.create_Some(((_76_retType).dtor_value).Replace(ft)))), (_77_body).Replace(f, ft)); + } + }))(); + return Dafny.Helpers.Id>(f)(_0_r); } - public RAST._IExpr Optimize() { + public __T Fold<__T>(__T acc, Func<__T, RAST._IExpr, __T> f, Func<__T, RAST._IType, __T> ft) + { + __T _0_acc = Dafny.Helpers.Id>(f)(acc, this); RAST._IExpr _source0 = this; { - if (_source0.is_UnaryOp) { - Dafny.ISequence op10 = _source0.dtor_op1; - if (object.Equals(op10, Dafny.Sequence.UnicodeFromString("!"))) { - RAST._IExpr underlying0 = _source0.dtor_underlying; - if (underlying0.is_BinaryOp) { - Dafny.ISequence op20 = underlying0.dtor_op2; - if (object.Equals(op20, Dafny.Sequence.UnicodeFromString("=="))) { - RAST._IExpr _0_left = underlying0.dtor_left; - RAST._IExpr _1_right = underlying0.dtor_right; - DAST.Format._IBinaryOpFormat _2_format = underlying0.dtor_format2; - DAST.Format._IUnaryOpFormat format0 = _source0.dtor_format; - if (format0.is_CombineFormat) { - return RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("!="), _0_left, _1_right, DAST.Format.BinaryOpFormat.create_NoFormat()); - } - } - } - } + if (_source0.is_RawExpr) { + Dafny.ISequence _1_content = _source0.dtor_content; + return _0_acc; + } + } + { + if (_source0.is_ExprFromType) { + RAST._IType _2_tpe = _source0.dtor_tpe; + return (_2_tpe).Fold<__T>(_0_acc, ft); + } + } + { + if (_source0.is_Identifier) { + Dafny.ISequence _3_name = _source0.dtor_name; + return _0_acc; + } + } + { + if (_source0.is_Match) { + RAST._IExpr _4_matchee = _source0.dtor_matchee; + Dafny.ISequence _5_cases = _source0.dtor_cases; + __T _6_acc = (_4_matchee).Fold<__T>(_0_acc, f, ft); + return RAST.__default.FoldLeft<__T, RAST._IMatchCase>(Dafny.Helpers.Id, Func<__T, RAST._IType, __T>, Dafny.ISequence, Func<__T, RAST._IMatchCase, __T>>>((_7_f, _8_ft, _9_cases) => ((System.Func<__T, RAST._IMatchCase, __T>)((_10_acc, _11_c) => { + return (_11_c).Fold<__T>(_10_acc, _7_f, _8_ft); + })))(f, ft, _5_cases), _6_acc, _5_cases); + } + } + { + if (_source0.is_StmtExpr) { + RAST._IExpr _12_stmt = _source0.dtor_stmt; + RAST._IExpr _13_rhs = _source0.dtor_rhs; + return (_13_rhs).Fold<__T>((_12_stmt).Fold<__T>(_0_acc, f, ft), f, ft); + } + } + { + if (_source0.is_Block) { + RAST._IExpr _14_underlying = _source0.dtor_underlying; + return (_14_underlying).Fold<__T>(_0_acc, f, ft); + } + } + { + if (_source0.is_StructBuild) { + RAST._IExpr _15_underlying = _source0.dtor_underlying; + Dafny.ISequence _16_assignments = _source0.dtor_assignments; + return RAST.__default.FoldLeft<__T, RAST._IAssignIdentifier>(Dafny.Helpers.Id, Func<__T, RAST._IType, __T>, Dafny.ISequence, Func<__T, RAST._IAssignIdentifier, __T>>>((_17_f, _18_ft, _19_assignments) => ((System.Func<__T, RAST._IAssignIdentifier, __T>)((_20_acc, _21_c) => { + return (_21_c).Fold<__T>(_20_acc, _17_f, _18_ft); + })))(f, ft, _16_assignments), (_15_underlying).Fold<__T>(_0_acc, f, ft), _16_assignments); + } + } + { + if (_source0.is_Tuple) { + Dafny.ISequence _22_arguments = _source0.dtor_arguments; + return RAST.__default.FoldLeft<__T, RAST._IExpr>(Dafny.Helpers.Id, Func<__T, RAST._IType, __T>, Dafny.ISequence, Func<__T, RAST._IExpr, __T>>>((_23_f, _24_ft, _25_arguments) => ((System.Func<__T, RAST._IExpr, __T>)((_26_acc, _27_e) => { + return (_27_e).Fold<__T>(_26_acc, _23_f, _24_ft); + })))(f, ft, _22_arguments), _0_acc, _22_arguments); } } { if (_source0.is_UnaryOp) { - Dafny.ISequence op11 = _source0.dtor_op1; - if (object.Equals(op11, Dafny.Sequence.UnicodeFromString("!"))) { - RAST._IExpr underlying1 = _source0.dtor_underlying; - if (underlying1.is_BinaryOp) { - Dafny.ISequence op21 = underlying1.dtor_op2; - if (object.Equals(op21, Dafny.Sequence.UnicodeFromString("<"))) { - RAST._IExpr _3_left = underlying1.dtor_left; - RAST._IExpr _4_right = underlying1.dtor_right; - DAST.Format._IBinaryOpFormat format20 = underlying1.dtor_format2; - if (format20.is_NoFormat) { - DAST.Format._IUnaryOpFormat format1 = _source0.dtor_format; - if (format1.is_CombineFormat) { - return RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString(">="), _3_left, _4_right, DAST.Format.BinaryOpFormat.create_NoFormat()); - } - } - } - } + Dafny.ISequence _28_op1 = _source0.dtor_op1; + RAST._IExpr _29_underlying = _source0.dtor_underlying; + DAST.Format._IUnaryOpFormat _30_format = _source0.dtor_format; + return (_29_underlying).Fold<__T>(_0_acc, f, ft); + } + } + { + if (_source0.is_BinaryOp) { + Dafny.ISequence _31_op2 = _source0.dtor_op2; + RAST._IExpr _32_left = _source0.dtor_left; + RAST._IExpr _33_right = _source0.dtor_right; + DAST.Format._IBinaryOpFormat _34_format2 = _source0.dtor_format2; + return (_33_right).Fold<__T>((_32_left).Fold<__T>(_0_acc, f, ft), f, ft); + } + } + { + if (_source0.is_TypeAscription) { + RAST._IExpr _35_left = _source0.dtor_left; + RAST._IType _36_tpe = _source0.dtor_tpe; + return (_36_tpe).Fold<__T>((_35_left).Fold<__T>(_0_acc, f, ft), ft); + } + } + { + if (_source0.is_TraitCast) { + RAST._IType _37_leftTpe = _source0.dtor_leftTpe; + RAST._IType _38_tpe = _source0.dtor_tpe; + return (_38_tpe).Fold<__T>((_37_leftTpe).Fold<__T>(_0_acc, ft), ft); + } + } + { + if (_source0.is_LiteralInt) { + Dafny.ISequence _39_value = _source0.dtor_value; + return _0_acc; + } + } + { + if (_source0.is_LiteralBool) { + bool _40_bvalue = _source0.dtor_bvalue; + return _0_acc; + } + } + { + if (_source0.is_LiteralString) { + Dafny.ISequence _41_value = _source0.dtor_value; + bool _42_binary = _source0.dtor_binary; + bool _43_verbatim = _source0.dtor_verbatim; + return _0_acc; + } + } + { + if (_source0.is_DeclareVar) { + RAST._IDeclareType _44_declareType = _source0.dtor_declareType; + Dafny.ISequence _45_name = _source0.dtor_name; + Std.Wrappers._IOption _46_optType = _source0.dtor_optType; + Std.Wrappers._IOption _47_optRhs = _source0.dtor_optRhs; + __T _48_acc = (((_46_optType).is_None) ? (_0_acc) : (((_46_optType).dtor_value).Fold<__T>(_0_acc, ft))); + if ((_47_optRhs).is_None) { + return _48_acc; + } else { + return ((_47_optRhs).dtor_value).Fold<__T>(_48_acc, f, ft); } } } { - if (_source0.is_UnaryOp) { - Dafny.ISequence op12 = _source0.dtor_op1; - if (object.Equals(op12, Dafny.Sequence.UnicodeFromString("!"))) { - RAST._IExpr underlying2 = _source0.dtor_underlying; - if (underlying2.is_BinaryOp) { - Dafny.ISequence op22 = underlying2.dtor_op2; - if (object.Equals(op22, Dafny.Sequence.UnicodeFromString("<"))) { - RAST._IExpr _5_left = underlying2.dtor_left; - RAST._IExpr _6_right = underlying2.dtor_right; - DAST.Format._IBinaryOpFormat format21 = underlying2.dtor_format2; - if (format21.is_ReverseFormat) { - DAST.Format._IUnaryOpFormat format2 = _source0.dtor_format; - if (format2.is_CombineFormat) { - return RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<="), _6_right, _5_left, DAST.Format.BinaryOpFormat.create_NoFormat()); - } - } - } - } + if (_source0.is_Assign) { + Std.Wrappers._IOption _49_names = _source0.dtor_names; + RAST._IExpr _50_rhs = _source0.dtor_rhs; + return (_50_rhs).Fold<__T>(_0_acc, f, ft); + } + } + { + if (_source0.is_IfExpr) { + RAST._IExpr _51_cond = _source0.dtor_cond; + RAST._IExpr _52_thn = _source0.dtor_thn; + RAST._IExpr _53_els = _source0.dtor_els; + __T _54_acc = (_51_cond).Fold<__T>(_0_acc, f, ft); + __T _55_acc = (_52_thn).Fold<__T>(_54_acc, f, ft); + return (_53_els).Fold<__T>(_55_acc, f, ft); + } + } + { + if (_source0.is_Loop) { + Std.Wrappers._IOption _56_optCond = _source0.dtor_optCond; + RAST._IExpr _57_underlying = _source0.dtor_underlying; + __T _58_acc = (((_56_optCond).is_None) ? (_0_acc) : (((_56_optCond).dtor_value).Fold<__T>(_0_acc, f, ft))); + return (_57_underlying).Fold<__T>(_58_acc, f, ft); + } + } + { + if (_source0.is_For) { + Dafny.ISequence _59_name = _source0.dtor_name; + RAST._IExpr _60_range = _source0.dtor_range; + RAST._IExpr _61_body = _source0.dtor_body; + __T _62_acc = (_60_range).Fold<__T>(_0_acc, f, ft); + return (_61_body).Fold<__T>(_62_acc, f, ft); + } + } + { + if (_source0.is_Labelled) { + Dafny.ISequence _63_lbl = _source0.dtor_lbl; + RAST._IExpr _64_underlying = _source0.dtor_underlying; + return (_64_underlying).Fold<__T>(_0_acc, f, ft); + } + } + { + if (_source0.is_Break) { + Std.Wrappers._IOption> _65_optLbl = _source0.dtor_optLbl; + return _0_acc; + } + } + { + if (_source0.is_Continue) { + Std.Wrappers._IOption> _66_optLbl = _source0.dtor_optLbl; + return _0_acc; + } + } + { + if (_source0.is_Return) { + Std.Wrappers._IOption _67_optExpr = _source0.dtor_optExpr; + if ((_67_optExpr).is_None) { + return _0_acc; + } else { + return ((_67_optExpr).dtor_value).Fold<__T>(_0_acc, f, ft); } } } + { + if (_source0.is_CallType) { + RAST._IExpr _68_obj = _source0.dtor_obj; + Dafny.ISequence _69_typeArguments = _source0.dtor_typeArguments; + __T _70_acc = (_68_obj).Fold<__T>(_0_acc, f, ft); + return RAST.__default.FoldLeft<__T, RAST._IType>(Dafny.Helpers.Id, Dafny.ISequence, Func<__T, RAST._IType, __T>>>((_71_ft, _72_typeArguments) => ((System.Func<__T, RAST._IType, __T>)((_73_acc, _74_t) => { + return (_74_t).Fold<__T>(_73_acc, _71_ft); + })))(ft, _69_typeArguments), _70_acc, _69_typeArguments); + } + } { if (_source0.is_Call) { - RAST._IExpr obj0 = _source0.dtor_obj; - if (obj0.is_ExprFromPath) { - RAST._IPath path0 = obj0.dtor_path; - if (path0.is_PMemberSelect) { - RAST._IPath _7_r = path0.dtor_base; - Dafny.ISequence name0 = path0.dtor_name; - if (object.Equals(name0, Dafny.Sequence.UnicodeFromString("truncate!"))) { - Dafny.ISequence _8_args = _source0.dtor_arguments; - if (((!object.Equals(_7_r, RAST.__default.dafny__runtime)) && (!object.Equals(_7_r, RAST.__default.@global))) || ((new BigInteger((_8_args).Count)) != (new BigInteger(2)))) { - return this; - } else { - RAST._IExpr _9_expr = (_8_args).Select(BigInteger.Zero); - RAST._IExpr _10_tpeExpr = (_8_args).Select(BigInteger.One); - if (!((_10_tpeExpr).is_ExprFromType)) { - return this; - } else { - RAST._IType _11_tpe = (_10_tpeExpr).dtor_tpe; - if (((((((((((_11_tpe).is_U8) || ((_11_tpe).is_U16)) || ((_11_tpe).is_U32)) || ((_11_tpe).is_U64)) || ((_11_tpe).is_U128)) || ((_11_tpe).is_I8)) || ((_11_tpe).is_I16)) || ((_11_tpe).is_I32)) || ((_11_tpe).is_I64)) || ((_11_tpe).is_I128)) { - RAST._IExpr _source1 = _9_expr; - { - if (_source1.is_Call) { - RAST._IExpr obj1 = _source1.dtor_obj; - if (obj1.is_ExprFromPath) { - RAST._IPath path1 = obj1.dtor_path; - if (path1.is_PMemberSelect) { - RAST._IPath _12_base = path1.dtor_base; - Dafny.ISequence name1 = path1.dtor_name; - if (object.Equals(name1, Dafny.Sequence.UnicodeFromString("int!"))) { - Dafny.ISequence _13_args = _source1.dtor_arguments; - if (((new BigInteger((_13_args).Count)) == (BigInteger.One)) && ((object.Equals(_12_base, RAST.__default.dafny__runtime)) || (object.Equals(_12_base, RAST.__default.@global)))) { - RAST._IExpr _source2 = (_13_args).Select(BigInteger.Zero); - { - if (_source2.is_LiteralInt) { - Dafny.ISequence _14_number = _source2.dtor_value; - return RAST.Expr.create_LiteralInt(_14_number); - } - } - { - if (_source2.is_LiteralString) { - Dafny.ISequence _15_number = _source2.dtor_value; - return RAST.Expr.create_LiteralInt(_15_number); - } - } - { - return this; - } - } else { - return this; - } - } - } - } - } - } - { - return this; - } - } else { - return this; - } - } - } - } - } - } + RAST._IExpr _75_obj = _source0.dtor_obj; + Dafny.ISequence _76_arguments = _source0.dtor_arguments; + __T _77_acc = (_75_obj).Fold<__T>(_0_acc, f, ft); + return RAST.__default.FoldLeft<__T, RAST._IExpr>(Dafny.Helpers.Id, Func<__T, RAST._IType, __T>, Dafny.ISequence, Func<__T, RAST._IExpr, __T>>>((_78_f, _79_ft, _80_arguments) => ((System.Func<__T, RAST._IExpr, __T>)((_81_acc, _82_e) => { + return (_82_e).Fold<__T>(_81_acc, _78_f, _79_ft); + })))(f, ft, _76_arguments), _77_acc, _76_arguments); } } { - if (_source0.is_StmtExpr) { - RAST._IExpr stmt0 = _source0.dtor_stmt; - if (stmt0.is_DeclareVar) { - RAST._IDeclareType _16_mod = stmt0.dtor_declareType; - Dafny.ISequence _17_name = stmt0.dtor_name; - Std.Wrappers._IOption optType0 = stmt0.dtor_optType; - if (optType0.is_Some) { - RAST._IType _18_tpe = optType0.dtor_value; - Std.Wrappers._IOption optRhs0 = stmt0.dtor_optRhs; - if (optRhs0.is_None) { - RAST._IExpr rhs0 = _source0.dtor_rhs; - if (rhs0.is_StmtExpr) { - RAST._IExpr stmt1 = rhs0.dtor_stmt; - if (stmt1.is_Assign) { - Std.Wrappers._IOption _19_name2 = stmt1.dtor_names; - RAST._IExpr _20_rhs = stmt1.dtor_rhs; - RAST._IExpr _21_last = rhs0.dtor_rhs; - if (object.Equals(_19_name2, Std.Wrappers.Option.create_Some(RAST.AssignLhs.create_LocalVar(_17_name)))) { - RAST._IExpr _22_rewriting = RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(_16_mod, _17_name, Std.Wrappers.Option.create_Some(_18_tpe), Std.Wrappers.Option.create_Some(_20_rhs)), _21_last); - return _22_rewriting; - } else { - return this; - } - } - } - } - } - } + if (_source0.is_Select) { + RAST._IExpr _83_obj = _source0.dtor_obj; + Dafny.ISequence _84_name = _source0.dtor_name; + return (_83_obj).Fold<__T>(_0_acc, f, ft); } } { - if (_source0.is_StmtExpr) { - RAST._IExpr stmt2 = _source0.dtor_stmt; - if (stmt2.is_IfExpr) { - RAST._IExpr cond0 = stmt2.dtor_cond; - if (cond0.is_UnaryOp) { - Dafny.ISequence op13 = cond0.dtor_op1; - if (object.Equals(op13, Dafny.Sequence.UnicodeFromString("!"))) { - RAST._IExpr underlying3 = cond0.dtor_underlying; - if (underlying3.is_BinaryOp) { - Dafny.ISequence op23 = underlying3.dtor_op2; - if (object.Equals(op23, Dafny.Sequence.UnicodeFromString("=="))) { - RAST._IExpr _23_a = underlying3.dtor_left; - RAST._IExpr _24_b = underlying3.dtor_right; - DAST.Format._IBinaryOpFormat _25_f = underlying3.dtor_format2; - DAST.Format._IUnaryOpFormat _26_of = cond0.dtor_format; - RAST._IExpr thn0 = stmt2.dtor_thn; - if (thn0.is_RawExpr) { - Dafny.ISequence content0 = thn0.dtor_content; - if (object.Equals(content0, Dafny.Sequence.UnicodeFromString("panic!(\"Halt\");"))) { - RAST._IExpr els0 = stmt2.dtor_els; - if (els0.is_RawExpr) { - Dafny.ISequence content1 = els0.dtor_content; - if (object.Equals(content1, Dafny.Sequence.UnicodeFromString(""))) { - RAST._IExpr _27_last = _source0.dtor_rhs; - RAST._IExpr _28_rewriting = RAST.Expr.create_StmtExpr((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("assert_eq!"))).Apply(Dafny.Sequence.FromElements(_23_a, _24_b)), _27_last); - return _28_rewriting; - } - } - } - } - } - } - } - } - } + if (_source0.is_SelectIndex) { + RAST._IExpr _85_obj = _source0.dtor_obj; + RAST._IExpr _86_range = _source0.dtor_range; + return (_86_range).Fold<__T>((_85_obj).Fold<__T>(_0_acc, f, ft), f, ft); } } { - return this; + if (_source0.is_ExprFromPath) { + RAST._IPath _87_path = _source0.dtor_path; + return _0_acc; + } + } + { + if (_source0.is_FunctionSelect) { + RAST._IExpr _88_obj = _source0.dtor_obj; + Dafny.ISequence _89_name = _source0.dtor_name; + return (_88_obj).Fold<__T>(_0_acc, f, ft); + } } + { + Dafny.ISequence _90_params = _source0.dtor_params; + Std.Wrappers._IOption _91_retType = _source0.dtor_retType; + RAST._IExpr _92_body = _source0.dtor_body; + __T _93_acc = RAST.__default.FoldLeft<__T, RAST._IFormal>(Dafny.Helpers.Id, Dafny.ISequence, Func<__T, RAST._IFormal, __T>>>((_94_ft, _95_params) => ((System.Func<__T, RAST._IFormal, __T>)((_96_acc, _97_param) => { + return (_97_param).Fold<__T>(_96_acc, _94_ft); + })))(ft, _90_params), _0_acc, _90_params); + __T _98_acc = (((_91_retType).is_None) ? (_93_acc) : (((_91_retType).dtor_value).Fold<__T>(_93_acc, ft))); + return (_92_body).Fold<__T>(_98_acc, f, ft); + } + } + public bool NoExtraSemicolonAfter() { + return (((((((this).is_DeclareVar) || ((this).is_Assign)) || ((this).is_Break)) || ((this).is_Continue)) || ((this).is_Return)) || ((this).is_For)) || ((((this).is_RawExpr) && ((new BigInteger(((this).dtor_content).Count)).Sign == 1)) && ((((this).dtor_content).Select((new BigInteger(((this).dtor_content).Count)) - (BigInteger.One))) == (new Dafny.Rune(';')))); } public bool LeftRequiresParentheses(RAST._IExpr left) { - return ((this).printingInfo).NeedParenthesesForLeft(((left).Optimize()).printingInfo); + return ((this).printingInfo).NeedParenthesesForLeft((left).printingInfo); } public _System._ITuple2, Dafny.ISequence> LeftParentheses(RAST._IExpr left) { if ((this).LeftRequiresParentheses(left)) { @@ -5618,7 +6644,7 @@ public bool LeftRequiresParentheses(RAST._IExpr left) { } } public bool RightRequiresParentheses(RAST._IExpr right) { - return ((this).printingInfo).NeedParenthesesForRight(((right).Optimize()).printingInfo); + return ((this).printingInfo).NeedParenthesesForRight((right).printingInfo); } public _System._ITuple2, Dafny.ISequence> RightParentheses(RAST._IExpr right) { if ((this).RightRequiresParentheses(right)) { @@ -5641,6 +6667,12 @@ public bool RightRequiresParentheses(RAST._IExpr right) { return (_1_p).RightMostIdentifier(); } } + { + if (_source0.is_Identifier) { + Dafny.ISequence _2_id = _source0.dtor_name; + return Std.Wrappers.Option>.create_Some(_2_id); + } + } { return Std.Wrappers.Option>.create_None(); } @@ -5690,7 +6722,7 @@ public bool RightRequiresParentheses(RAST._IExpr right) { } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - RAST._IExpr _source0 = (this).Optimize(); + RAST._IExpr _source0 = this; { if (_source0.is_Identifier) { Dafny.ISequence _0_name = _source0.dtor_name; @@ -5732,121 +6764,132 @@ public bool RightRequiresParentheses(RAST._IExpr right) { if (_source0.is_Match) { RAST._IExpr _8_matchee = _source0.dtor_matchee; Dafny.ISequence _9_cases = _source0.dtor_cases; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("match "), (_8_matchee)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString(_9_cases, Dafny.Helpers.Id, Func>>>((_10_ind) => ((System.Func>)((_11_c) => { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _10_ind), RAST.__default.IND), (_11_c)._ToString(Dafny.Sequence.Concat(_10_ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(",")); - })))(ind), Dafny.Sequence.UnicodeFromString(""))), Dafny.Sequence.UnicodeFromString("\n")), 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.UnicodeFromString("match "), (_8_matchee)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString(_9_cases, Dafny.Helpers.Id, Dafny.ISequence, Func>>>((_10_ind, _11_cases) => ((System.Func>)((_12_c) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _10_ind), RAST.__default.IND), (_12_c)._ToString(Dafny.Sequence.Concat(_10_ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(",")); + })))(ind, _9_cases), Dafny.Sequence.UnicodeFromString(""))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } } { if (_source0.is_StmtExpr) { - RAST._IExpr _12_stmt = _source0.dtor_stmt; - RAST._IExpr _13_rhs = _source0.dtor_rhs; - if (((_12_stmt).is_RawExpr) && (((_12_stmt).dtor_content).Equals(Dafny.Sequence.UnicodeFromString("")))) { - return (_13_rhs)._ToString(ind); + RAST._IExpr _13_stmt = _source0.dtor_stmt; + RAST._IExpr _14_rhs = _source0.dtor_rhs; + if (((_13_stmt).is_RawExpr) && (((_13_stmt).dtor_content).Equals(Dafny.Sequence.UnicodeFromString("")))) { + return (_14_rhs)._ToString(ind); } else { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_12_stmt)._ToString(ind), (((_12_stmt).NoExtraSemicolonAfter()) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.UnicodeFromString(";")))), Dafny.Sequence.UnicodeFromString("\n")), ind), (_13_rhs)._ToString(ind)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_13_stmt)._ToString(ind), (((_13_stmt).NoExtraSemicolonAfter()) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.UnicodeFromString(";")))), Dafny.Sequence.UnicodeFromString("\n")), ind), (_14_rhs)._ToString(ind)); } } } { if (_source0.is_Block) { - RAST._IExpr _14_underlying = _source0.dtor_underlying; - return 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), (_14_underlying)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); + RAST._IExpr _15_underlying = _source0.dtor_underlying; + return 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), (_15_underlying)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } } { if (_source0.is_IfExpr) { - RAST._IExpr _15_cond = _source0.dtor_cond; - RAST._IExpr _16_thn = _source0.dtor_thn; - RAST._IExpr _17_els = _source0.dtor_els; - 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(Dafny.Sequence.UnicodeFromString("if "), (_15_cond)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {\n")), ind), RAST.__default.IND), (_16_thn)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")), ((object.Equals(_17_els, RAST.Expr.create_RawExpr(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(" else {\n"), ind), RAST.__default.IND), (_17_els)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}"))))); + RAST._IExpr _16_cond = _source0.dtor_cond; + RAST._IExpr _17_thn = _source0.dtor_thn; + RAST._IExpr _18_els = _source0.dtor_els; + 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(Dafny.Sequence.UnicodeFromString("if "), (_16_cond)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {\n")), ind), RAST.__default.IND), (_17_thn)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")), ((object.Equals(_18_els, RAST.Expr.create_RawExpr(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(" else {\n"), ind), RAST.__default.IND), (_18_els)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}"))))); } } { if (_source0.is_StructBuild) { - RAST._IExpr _18_name = _source0.dtor_underlying; - Dafny.ISequence _19_assignments = _source0.dtor_assignments; - if (((new BigInteger((_19_assignments).Count)).Sign == 1) && ((((_19_assignments).Select(BigInteger.Zero)).dtor_identifier).Equals(Dafny.Sequence.UnicodeFromString("0")))) { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_18_name)._ToString(ind), Dafny.Sequence.UnicodeFromString(" (")), RAST.__default.SeqToString(_19_assignments, Dafny.Helpers.Id, Func>>>((_20_ind) => ((System.Func>)((_21_assignment) => { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _20_ind), RAST.__default.IND), ((_21_assignment).dtor_rhs)._ToString(Dafny.Sequence.Concat(_20_ind, RAST.__default.IND))); - })))(ind), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_19_assignments).Count)) > (BigInteger.One)) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(")")); + RAST._IExpr _19_name = _source0.dtor_underlying; + Dafny.ISequence _20_assignments = _source0.dtor_assignments; + if (((new BigInteger((_20_assignments).Count)).Sign == 1) && ((((_20_assignments).Select(BigInteger.Zero)).dtor_identifier).Equals(Dafny.Sequence.UnicodeFromString("0")))) { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_19_name)._ToString(ind), Dafny.Sequence.UnicodeFromString(" (")), RAST.__default.SeqToString(_20_assignments, Dafny.Helpers.Id, Dafny.ISequence, Func>>>((_21_ind, _22_assignments) => ((System.Func>)((_23_assignment) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _21_ind), RAST.__default.IND), ((_23_assignment).dtor_rhs)._ToString(Dafny.Sequence.Concat(_21_ind, RAST.__default.IND))); + })))(ind, _20_assignments), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_20_assignments).Count)) > (BigInteger.One)) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(")")); } else { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_18_name)._ToString(ind), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString(_19_assignments, Dafny.Helpers.Id, Func>>>((_22_ind) => ((System.Func>)((_23_assignment) => { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _22_ind), RAST.__default.IND), (_23_assignment)._ToString(Dafny.Sequence.Concat(_22_ind, RAST.__default.IND))); - })))(ind), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_19_assignments).Count)).Sign == 1) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString("}")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_19_name)._ToString(ind), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString(_20_assignments, Dafny.Helpers.Id, Dafny.ISequence, Func>>>((_24_ind, _25_assignments) => ((System.Func>)((_26_assignment) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _24_ind), RAST.__default.IND), (_26_assignment)._ToString(Dafny.Sequence.Concat(_24_ind, RAST.__default.IND))); + })))(ind, _20_assignments), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_20_assignments).Count)).Sign == 1) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString("}")); } } } { if (_source0.is_Tuple) { - Dafny.ISequence _24_arguments = _source0.dtor_arguments; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("("), RAST.__default.SeqToString(_24_arguments, Dafny.Helpers.Id, Func>>>((_25_ind) => ((System.Func>)((_26_arg) => { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _25_ind), RAST.__default.IND), (_26_arg)._ToString(Dafny.Sequence.Concat(_25_ind, RAST.__default.IND))); - })))(ind), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_24_arguments).Count)).Sign == 1) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(")")); + Dafny.ISequence _27_arguments = _source0.dtor_arguments; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("("), RAST.__default.SeqToString(_27_arguments, Dafny.Helpers.Id, Dafny.ISequence, Func>>>((_28_ind, _29_arguments) => ((System.Func>)((_30_arg) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _28_ind), RAST.__default.IND), (_30_arg)._ToString(Dafny.Sequence.Concat(_28_ind, RAST.__default.IND))); + })))(ind, _27_arguments), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_27_arguments).Count)).Sign == 1) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(")")); } } { if (_source0.is_UnaryOp) { - Dafny.ISequence _27_op = _source0.dtor_op1; - RAST._IExpr _28_underlying = _source0.dtor_underlying; - DAST.Format._IUnaryOpFormat _29_format = _source0.dtor_format; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs0 = ((((this).printingInfo).NeedParenthesesFor(((_28_underlying).Optimize()).printingInfo)) ? (_System.Tuple2, Dafny.ISequence>.create(Dafny.Sequence.UnicodeFromString("("), Dafny.Sequence.UnicodeFromString(")"))) : (_System.Tuple2, Dafny.ISequence>.create(Dafny.Sequence.UnicodeFromString(""), Dafny.Sequence.UnicodeFromString("")))); - Dafny.ISequence _30_leftP = _let_tmp_rhs0.dtor__0; - Dafny.ISequence _31_rightP = _let_tmp_rhs0.dtor__1; - Dafny.ISequence _32_leftOp = ((((_27_op).Equals(Dafny.Sequence.UnicodeFromString("&mut"))) && (!(_30_leftP).Equals(Dafny.Sequence.UnicodeFromString("(")))) ? (Dafny.Sequence.Concat(_27_op, Dafny.Sequence.UnicodeFromString(" "))) : ((((_27_op).Equals(Dafny.Sequence.UnicodeFromString("?"))) ? (Dafny.Sequence.UnicodeFromString("")) : (_27_op)))); - Dafny.ISequence _33_rightOp = (((_27_op).Equals(Dafny.Sequence.UnicodeFromString("?"))) ? (_27_op) : (Dafny.Sequence.UnicodeFromString(""))); - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_32_leftOp, _30_leftP), (_28_underlying)._ToString(ind)), _31_rightP), _33_rightOp); + Dafny.ISequence _31_op = _source0.dtor_op1; + RAST._IExpr _32_underlying = _source0.dtor_underlying; + DAST.Format._IUnaryOpFormat _33_format = _source0.dtor_format; + bool _34_isPattern = ((new BigInteger((_31_op).Count)) >= (BigInteger.One)) && (((_31_op).Subsequence(BigInteger.Zero, BigInteger.One)).Equals(Dafny.Sequence.UnicodeFromString("{"))); + bool _35_isUnsafe = (_31_op).Equals(Dafny.Sequence.UnicodeFromString("unsafe")); + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs0 = ((((!(_34_isPattern)) && (!(_35_isUnsafe))) && (((this).printingInfo).NeedParenthesesFor((_32_underlying).printingInfo))) ? (_System.Tuple2, Dafny.ISequence>.create(Dafny.Sequence.UnicodeFromString("("), Dafny.Sequence.UnicodeFromString(")"))) : (_System.Tuple2, Dafny.ISequence>.create(Dafny.Sequence.UnicodeFromString(""), Dafny.Sequence.UnicodeFromString("")))); + Dafny.ISequence _36_leftP = _let_tmp_rhs0.dtor__0; + Dafny.ISequence _37_rightP = _let_tmp_rhs0.dtor__1; + bool _38_opToRight = (((_31_op).Equals(Dafny.Sequence.UnicodeFromString("?"))) || (((new BigInteger((_31_op).Count)) >= (new BigInteger(2))) && (((_31_op).Subsequence(BigInteger.Zero, new BigInteger(2))).Equals(Dafny.Sequence.UnicodeFromString("/*"))))) || (_34_isPattern); + Dafny.ISequence _39_leftOp = ((_38_opToRight) ? (Dafny.Sequence.UnicodeFromString("")) : (_31_op)); + Dafny.ISequence _40_leftOp = (((((_31_op).Equals(Dafny.Sequence.UnicodeFromString("&mut"))) || (_35_isUnsafe)) && (!(_36_leftP).Equals(Dafny.Sequence.UnicodeFromString("(")))) ? (Dafny.Sequence.Concat(_39_leftOp, Dafny.Sequence.UnicodeFromString(" "))) : (_39_leftOp)); + Dafny.ISequence _41_rightOp = ((_38_opToRight) ? (_31_op) : (Dafny.Sequence.UnicodeFromString(""))); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_40_leftOp, _36_leftP), (_32_underlying)._ToString(ind)), _37_rightP), _41_rightOp); } } { if (_source0.is_TypeAscription) { - RAST._IExpr _34_left = _source0.dtor_left; - RAST._IType _35_tpe = _source0.dtor_tpe; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs1 = (this).LeftParentheses(_34_left); - Dafny.ISequence _36_leftLeftP = _let_tmp_rhs1.dtor__0; - Dafny.ISequence _37_leftRightP = _let_tmp_rhs1.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_36_leftLeftP, (_34_left)._ToString(RAST.__default.IND)), _37_leftRightP), Dafny.Sequence.UnicodeFromString(" as ")), (_35_tpe)._ToString(RAST.__default.IND)); + RAST._IExpr _42_left = _source0.dtor_left; + RAST._IType _43_tpe = _source0.dtor_tpe; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs1 = (this).LeftParentheses(_42_left); + Dafny.ISequence _44_leftLeftP = _let_tmp_rhs1.dtor__0; + Dafny.ISequence _45_leftRightP = _let_tmp_rhs1.dtor__1; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_44_leftLeftP, (_42_left)._ToString(RAST.__default.IND)), _45_leftRightP), Dafny.Sequence.UnicodeFromString(" as ")), (_43_tpe)._ToString(RAST.__default.IND)); + } + } + { + if (_source0.is_TraitCast) { + RAST._IType _46_leftTpe = _source0.dtor_leftTpe; + RAST._IType _47_tpe = _source0.dtor_tpe; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("<"), (_46_leftTpe)._ToString(RAST.__default.IND)), Dafny.Sequence.UnicodeFromString(" as ")), (_47_tpe)._ToString(RAST.__default.IND)), Dafny.Sequence.UnicodeFromString(">")); } } { if (_source0.is_BinaryOp) { - Dafny.ISequence _38_op2 = _source0.dtor_op2; - RAST._IExpr _39_left = _source0.dtor_left; - RAST._IExpr _40_right = _source0.dtor_right; - DAST.Format._IBinaryOpFormat _41_format = _source0.dtor_format2; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs2 = (this).LeftParentheses(_39_left); - Dafny.ISequence _42_leftLeftP = _let_tmp_rhs2.dtor__0; - Dafny.ISequence _43_leftRighP = _let_tmp_rhs2.dtor__1; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs3 = (this).RightParentheses(_40_right); - Dafny.ISequence _44_rightLeftP = _let_tmp_rhs3.dtor__0; - Dafny.ISequence _45_rightRightP = _let_tmp_rhs3.dtor__1; - Dafny.ISequence _46_opRendered = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" "), _38_op2), Dafny.Sequence.UnicodeFromString(" ")); - Dafny.ISequence _47_indLeft = (((_42_leftLeftP).Equals(Dafny.Sequence.UnicodeFromString("("))) ? (Dafny.Sequence.Concat(ind, RAST.__default.IND)) : (ind)); - Dafny.ISequence _48_indRight = (((_44_rightLeftP).Equals(Dafny.Sequence.UnicodeFromString("("))) ? (Dafny.Sequence.Concat(ind, RAST.__default.IND)) : (ind)); - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_42_leftLeftP, (_39_left)._ToString(_47_indLeft)), _43_leftRighP), _46_opRendered), _44_rightLeftP), (_40_right)._ToString(_48_indRight)), _45_rightRightP); + Dafny.ISequence _48_op2 = _source0.dtor_op2; + RAST._IExpr _49_left = _source0.dtor_left; + RAST._IExpr _50_right = _source0.dtor_right; + DAST.Format._IBinaryOpFormat _51_format = _source0.dtor_format2; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs2 = (this).LeftParentheses(_49_left); + Dafny.ISequence _52_leftLeftP = _let_tmp_rhs2.dtor__0; + Dafny.ISequence _53_leftRighP = _let_tmp_rhs2.dtor__1; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs3 = (this).RightParentheses(_50_right); + Dafny.ISequence _54_rightLeftP = _let_tmp_rhs3.dtor__0; + Dafny.ISequence _55_rightRightP = _let_tmp_rhs3.dtor__1; + Dafny.ISequence _56_opRendered = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" "), _48_op2), Dafny.Sequence.UnicodeFromString(" ")); + Dafny.ISequence _57_indLeft = (((_52_leftLeftP).Equals(Dafny.Sequence.UnicodeFromString("("))) ? (Dafny.Sequence.Concat(ind, RAST.__default.IND)) : (ind)); + Dafny.ISequence _58_indRight = (((_54_rightLeftP).Equals(Dafny.Sequence.UnicodeFromString("("))) ? (Dafny.Sequence.Concat(ind, RAST.__default.IND)) : (ind)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_52_leftLeftP, (_49_left)._ToString(_57_indLeft)), _53_leftRighP), _56_opRendered), _54_rightLeftP), (_50_right)._ToString(_58_indRight)), _55_rightRightP); } } { if (_source0.is_DeclareVar) { - RAST._IDeclareType _49_declareType = _source0.dtor_declareType; - Dafny.ISequence _50_name = _source0.dtor_name; - Std.Wrappers._IOption _51_optType = _source0.dtor_optType; - Std.Wrappers._IOption _52_optExpr = _source0.dtor_optRhs; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("let "), ((object.Equals(_49_declareType, RAST.DeclareType.create_MUT())) ? (Dafny.Sequence.UnicodeFromString("mut ")) : (Dafny.Sequence.UnicodeFromString("")))), _50_name), (((_51_optType).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(": "), ((_51_optType).dtor_value)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)))) : (Dafny.Sequence.UnicodeFromString("")))), (((_52_optExpr).is_Some) ? (Dafny.Helpers.Let, Dafny.ISequence>(((_52_optExpr).dtor_value)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)), _pat_let12_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let12_0, _53_optExprString => (((_53_optExprString).Equals(Dafny.Sequence.UnicodeFromString(""))) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("= /*issue with empty RHS*/"), ((((_52_optExpr).dtor_value).is_RawExpr) ? (Dafny.Sequence.UnicodeFromString("Empty Raw expr")) : (((((_52_optExpr).dtor_value).is_LiteralString) ? (Dafny.Sequence.UnicodeFromString("Empty string literal")) : (((((_52_optExpr).dtor_value).is_LiteralInt) ? (Dafny.Sequence.UnicodeFromString("Empty int literal")) : (Dafny.Sequence.UnicodeFromString("Another case"))))))))) : (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" = "), _53_optExprString)))))) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(";")); + RAST._IDeclareType _59_declareType = _source0.dtor_declareType; + Dafny.ISequence _60_name = _source0.dtor_name; + Std.Wrappers._IOption _61_optType = _source0.dtor_optType; + Std.Wrappers._IOption _62_optExpr = _source0.dtor_optRhs; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("let "), ((object.Equals(_59_declareType, RAST.DeclareType.create_MUT())) ? (Dafny.Sequence.UnicodeFromString("mut ")) : (Dafny.Sequence.UnicodeFromString("")))), _60_name), (((_61_optType).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(": "), ((_61_optType).dtor_value)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)))) : (Dafny.Sequence.UnicodeFromString("")))), (((_62_optExpr).is_Some) ? (Dafny.Helpers.Let, Dafny.ISequence>(((_62_optExpr).dtor_value)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)), _pat_let20_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let20_0, _63_optExprString => (((_63_optExprString).Equals(Dafny.Sequence.UnicodeFromString(""))) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("= /*issue with empty RHS*/"), ((((_62_optExpr).dtor_value).is_RawExpr) ? (Dafny.Sequence.UnicodeFromString("Empty Raw expr")) : (((((_62_optExpr).dtor_value).is_LiteralString) ? (Dafny.Sequence.UnicodeFromString("Empty string literal")) : (((((_62_optExpr).dtor_value).is_LiteralInt) ? (Dafny.Sequence.UnicodeFromString("Empty int literal")) : (Dafny.Sequence.UnicodeFromString("Another case"))))))))) : (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" = "), _63_optExprString)))))) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(";")); } } { if (_source0.is_Assign) { - Std.Wrappers._IOption _54_names = _source0.dtor_names; - RAST._IExpr _55_expr = _source0.dtor_rhs; - Dafny.ISequence _56_lhs = ((System.Func>)(() => { - Std.Wrappers._IOption _source1 = _54_names; + Std.Wrappers._IOption _64_names = _source0.dtor_names; + RAST._IExpr _65_expr = _source0.dtor_rhs; + Dafny.ISequence _66_lhs = ((System.Func>)(() => { + Std.Wrappers._IOption _source1 = _64_names; { if (_source1.is_Some) { RAST._IAssignLhs value0 = _source1.dtor_value; if (value0.is_LocalVar) { - Dafny.ISequence _57_name = value0.dtor_name; - return Dafny.Sequence.Concat(_57_name, Dafny.Sequence.UnicodeFromString(" = ")); + Dafny.ISequence _67_name = value0.dtor_name; + return Dafny.Sequence.Concat(_67_name, Dafny.Sequence.UnicodeFromString(" = ")); } } } @@ -5854,12 +6897,12 @@ public bool RightRequiresParentheses(RAST._IExpr right) { if (_source1.is_Some) { RAST._IAssignLhs value1 = _source1.dtor_value; if (value1.is_SelectMember) { - RAST._IExpr _58_member = value1.dtor_on; - Dafny.ISequence _59_field = value1.dtor_field; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs4 = (RAST.Expr.create_Select(_58_member, _59_field)).LeftParentheses(_58_member); - Dafny.ISequence _60_leftP = _let_tmp_rhs4.dtor__0; - Dafny.ISequence _61_rightP = _let_tmp_rhs4.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_60_leftP, (_58_member)._ToString(ind)), _61_rightP), Dafny.Sequence.UnicodeFromString(".")), _59_field), Dafny.Sequence.UnicodeFromString(" = ")); + RAST._IExpr _68_member = value1.dtor_on; + Dafny.ISequence _69_field = value1.dtor_field; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs4 = (RAST.Expr.create_Select(_68_member, _69_field)).LeftParentheses(_68_member); + Dafny.ISequence _70_leftP = _let_tmp_rhs4.dtor__0; + Dafny.ISequence _71_rightP = _let_tmp_rhs4.dtor__1; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_70_leftP, (_68_member)._ToString(ind)), _71_rightP), Dafny.Sequence.UnicodeFromString(".")), _69_field), Dafny.Sequence.UnicodeFromString(" = ")); } } } @@ -5867,9 +6910,9 @@ public bool RightRequiresParentheses(RAST._IExpr right) { if (_source1.is_Some) { RAST._IAssignLhs value2 = _source1.dtor_value; if (value2.is_ExtractTuple) { - Dafny.ISequence> _62_names = value2.dtor_names; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("("), RAST.__default.SeqToString>(_62_names, ((System.Func, Dafny.ISequence>)((_63_name) => { - return _63_name; + Dafny.ISequence> _72_names = value2.dtor_names; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("("), RAST.__default.SeqToString>(_72_names, ((System.Func, Dafny.ISequence>)((_73_name) => { + return _73_name; })), Dafny.Sequence.UnicodeFromString(","))), Dafny.Sequence.UnicodeFromString(") = ")); } } @@ -5878,14 +6921,14 @@ public bool RightRequiresParentheses(RAST._IExpr right) { if (_source1.is_Some) { RAST._IAssignLhs value3 = _source1.dtor_value; if (value3.is_Index) { - RAST._IExpr _64_e = value3.dtor_expr; - Dafny.ISequence _65_indices = value3.dtor_indices; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs5 = (RAST.Expr.create_Call(_64_e, _65_indices)).LeftParentheses(_64_e); - Dafny.ISequence _66_leftP = _let_tmp_rhs5.dtor__0; - Dafny.ISequence _67_rightP = _let_tmp_rhs5.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_66_leftP, (_64_e)._ToString(ind)), _67_rightP), Dafny.Sequence.UnicodeFromString("[")), RAST.__default.SeqToString(_65_indices, Dafny.Helpers.Id, Func>>>((_68_ind) => ((System.Func>)((_69_index) => { - return (_69_index)._ToString(Dafny.Sequence.Concat(_68_ind, RAST.__default.IND)); - })))(ind), Dafny.Sequence.UnicodeFromString("]["))), Dafny.Sequence.UnicodeFromString("] = ")); + RAST._IExpr _74_e = value3.dtor_expr; + Dafny.ISequence _75_indices = value3.dtor_indices; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs5 = (RAST.Expr.create_Call(_74_e, _75_indices)).LeftParentheses(_74_e); + Dafny.ISequence _76_leftP = _let_tmp_rhs5.dtor__0; + Dafny.ISequence _77_rightP = _let_tmp_rhs5.dtor__1; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_76_leftP, (_74_e)._ToString(ind)), _77_rightP), Dafny.Sequence.UnicodeFromString("[")), RAST.__default.SeqToString(_75_indices, Dafny.Helpers.Id, Dafny.ISequence, Func>>>((_78_ind, _79_indices) => ((System.Func>)((_80_index) => { + return (_80_index)._ToString(Dafny.Sequence.Concat(_78_ind, RAST.__default.IND)); + })))(ind, _75_indices), Dafny.Sequence.UnicodeFromString("]["))), Dafny.Sequence.UnicodeFromString("] = ")); } } } @@ -5893,24 +6936,24 @@ public bool RightRequiresParentheses(RAST._IExpr right) { return Dafny.Sequence.UnicodeFromString("_ = "); } }))(); - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(_56_lhs, (_55_expr)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(";")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(_66_lhs, (_65_expr)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(";")); } } { if (_source0.is_Labelled) { - Dafny.ISequence _70_name = _source0.dtor_lbl; - RAST._IExpr _71_underlying = _source0.dtor_underlying; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("'"), _70_name), Dafny.Sequence.UnicodeFromString(": ")), (_71_underlying)._ToString(ind)); + Dafny.ISequence _81_name = _source0.dtor_lbl; + RAST._IExpr _82_underlying = _source0.dtor_underlying; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("'"), _81_name), Dafny.Sequence.UnicodeFromString(": ")), (_82_underlying)._ToString(ind)); } } { if (_source0.is_Break) { - Std.Wrappers._IOption> _72_optLbl = _source0.dtor_optLbl; - Std.Wrappers._IOption> _source2 = _72_optLbl; + Std.Wrappers._IOption> _83_optLbl = _source0.dtor_optLbl; + Std.Wrappers._IOption> _source2 = _83_optLbl; { if (_source2.is_Some) { - Dafny.ISequence _73_lbl = _source2.dtor_value; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("break '"), _73_lbl), Dafny.Sequence.UnicodeFromString(";")); + Dafny.ISequence _84_lbl = _source2.dtor_value; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("break '"), _84_lbl), Dafny.Sequence.UnicodeFromString(";")); } } { @@ -5920,12 +6963,12 @@ public bool RightRequiresParentheses(RAST._IExpr right) { } { if (_source0.is_Continue) { - Std.Wrappers._IOption> _74_optLbl = _source0.dtor_optLbl; - Std.Wrappers._IOption> _source3 = _74_optLbl; + Std.Wrappers._IOption> _85_optLbl = _source0.dtor_optLbl; + Std.Wrappers._IOption> _source3 = _85_optLbl; { if (_source3.is_Some) { - Dafny.ISequence _75_lbl = _source3.dtor_value; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("continue '"), _75_lbl), Dafny.Sequence.UnicodeFromString(";")); + Dafny.ISequence _86_lbl = _source3.dtor_value; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("continue '"), _86_lbl), Dafny.Sequence.UnicodeFromString(";")); } } { @@ -5935,61 +6978,61 @@ public bool RightRequiresParentheses(RAST._IExpr right) { } { if (_source0.is_Loop) { - Std.Wrappers._IOption _76_optCond = _source0.dtor_optCond; - RAST._IExpr _77_underlying = _source0.dtor_underlying; + Std.Wrappers._IOption _87_optCond = _source0.dtor_optCond; + RAST._IExpr _88_underlying = _source0.dtor_underlying; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(((System.Func>)(() => { - Std.Wrappers._IOption _source4 = _76_optCond; + Std.Wrappers._IOption _source4 = _87_optCond; { if (_source4.is_None) { return Dafny.Sequence.UnicodeFromString("loop"); } } { - RAST._IExpr _78_c = _source4.dtor_value; - return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("while "), (_78_c)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))); + RAST._IExpr _89_c = _source4.dtor_value; + return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("while "), (_89_c)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))); } - }))(), Dafny.Sequence.UnicodeFromString(" {\n")), ind), RAST.__default.IND), (_77_underlying)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); + }))(), Dafny.Sequence.UnicodeFromString(" {\n")), ind), RAST.__default.IND), (_88_underlying)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } } { if (_source0.is_For) { - Dafny.ISequence _79_name = _source0.dtor_name; - RAST._IExpr _80_range = _source0.dtor_range; - RAST._IExpr _81_body = _source0.dtor_body; - 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(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("for "), _79_name), Dafny.Sequence.UnicodeFromString(" in ")), (_80_range)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {\n")), ind), RAST.__default.IND), (_81_body)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); + Dafny.ISequence _90_name = _source0.dtor_name; + RAST._IExpr _91_range = _source0.dtor_range; + RAST._IExpr _92_body = _source0.dtor_body; + 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(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("for "), _90_name), Dafny.Sequence.UnicodeFromString(" in ")), (_91_range)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {\n")), ind), RAST.__default.IND), (_92_body)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } } { if (_source0.is_Return) { - Std.Wrappers._IOption _82_optExpr = _source0.dtor_optExpr; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("return"), (((_82_optExpr).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" "), ((_82_optExpr).dtor_value)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)))) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(";")); + Std.Wrappers._IOption _93_optExpr = _source0.dtor_optExpr; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("return"), (((_93_optExpr).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" "), ((_93_optExpr).dtor_value)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)))) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(";")); } } { if (_source0.is_CallType) { - RAST._IExpr _83_expr = _source0.dtor_obj; - Dafny.ISequence _84_tpes = _source0.dtor_typeParameters; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs6 = (this).LeftParentheses(_83_expr); - Dafny.ISequence _85_leftP = _let_tmp_rhs6.dtor__0; - Dafny.ISequence _86_rightP = _let_tmp_rhs6.dtor__1; - if ((_84_tpes).Equals(Dafny.Sequence.FromElements())) { - return (_83_expr)._ToString(ind); + RAST._IExpr _94_expr = _source0.dtor_obj; + Dafny.ISequence _95_tpes = _source0.dtor_typeArguments; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs6 = (this).LeftParentheses(_94_expr); + Dafny.ISequence _96_leftP = _let_tmp_rhs6.dtor__0; + Dafny.ISequence _97_rightP = _let_tmp_rhs6.dtor__1; + if ((_95_tpes).Equals(Dafny.Sequence.FromElements())) { + return (_94_expr)._ToString(ind); } else { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_85_leftP, (_83_expr)._ToString(ind)), _86_rightP), Dafny.Sequence.UnicodeFromString("::<")), RAST.__default.SeqToString(_84_tpes, Dafny.Helpers.Id, Func>>>((_87_ind) => ((System.Func>)((_88_tpe) => { - return (_88_tpe)._ToString(Dafny.Sequence.Concat(_87_ind, RAST.__default.IND)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_96_leftP, (_94_expr)._ToString(ind)), _97_rightP), Dafny.Sequence.UnicodeFromString("::<")), RAST.__default.SeqToString(_95_tpes, Dafny.Helpers.Id, Func>>>((_98_ind) => ((System.Func>)((_99_tpe) => { + return (_99_tpe)._ToString(Dafny.Sequence.Concat(_98_ind, RAST.__default.IND)); })))(ind), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(">")); } } } { if (_source0.is_Call) { - RAST._IExpr _89_expr = _source0.dtor_obj; - Dafny.ISequence _90_args = _source0.dtor_arguments; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs7 = (this).LeftParentheses(_89_expr); - Dafny.ISequence _91_leftP = _let_tmp_rhs7.dtor__0; - Dafny.ISequence _92_rightP = _let_tmp_rhs7.dtor__1; + RAST._IExpr _100_expr = _source0.dtor_obj; + Dafny.ISequence _101_args = _source0.dtor_arguments; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs7 = (this).LeftParentheses(_100_expr); + Dafny.ISequence _102_leftP = _let_tmp_rhs7.dtor__0; + Dafny.ISequence _103_rightP = _let_tmp_rhs7.dtor__1; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs8 = ((System.Func<_System._ITuple2, Dafny.ISequence>>)(() => { - Std.Wrappers._IOption> _source5 = (_89_expr).RightMostIdentifier(); + Std.Wrappers._IOption> _source5 = (_100_expr).RightMostIdentifier(); { bool disjunctiveMatch0 = false; if (_source5.is_Some) { @@ -6030,63 +7073,63 @@ public bool RightRequiresParentheses(RAST._IExpr right) { return _System.Tuple2, Dafny.ISequence>.create(Dafny.Sequence.UnicodeFromString("("), Dafny.Sequence.UnicodeFromString(")")); } }))(); - Dafny.ISequence _93_leftCallP = _let_tmp_rhs8.dtor__0; - Dafny.ISequence _94_rightCallP = _let_tmp_rhs8.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_91_leftP, (_89_expr)._ToString(ind)), _92_rightP), _93_leftCallP), RAST.__default.SeqToString(_90_args, Dafny.Helpers.Id, Func>>>((_95_ind) => ((System.Func>)((_96_arg) => { - return (_96_arg)._ToString(Dafny.Sequence.Concat(_95_ind, RAST.__default.IND)); - })))(ind), Dafny.Sequence.UnicodeFromString(", "))), _94_rightCallP); + Dafny.ISequence _104_leftCallP = _let_tmp_rhs8.dtor__0; + Dafny.ISequence _105_rightCallP = _let_tmp_rhs8.dtor__1; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_102_leftP, (_100_expr)._ToString(ind)), _103_rightP), _104_leftCallP), RAST.__default.SeqToString(_101_args, Dafny.Helpers.Id, Dafny.ISequence, Func>>>((_106_ind, _107_args) => ((System.Func>)((_108_arg) => { + return (_108_arg)._ToString(Dafny.Sequence.Concat(_106_ind, RAST.__default.IND)); + })))(ind, _101_args), Dafny.Sequence.UnicodeFromString(", "))), _105_rightCallP); } } { if (_source0.is_Select) { - RAST._IExpr _97_expression = _source0.dtor_obj; - Dafny.ISequence _98_name = _source0.dtor_name; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs9 = (this).LeftParentheses(_97_expression); - Dafny.ISequence _99_leftP = _let_tmp_rhs9.dtor__0; - Dafny.ISequence _100_rightP = _let_tmp_rhs9.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_99_leftP, (_97_expression)._ToString(ind)), _100_rightP), Dafny.Sequence.UnicodeFromString(".")), _98_name); + RAST._IExpr _109_expression = _source0.dtor_obj; + Dafny.ISequence _110_name = _source0.dtor_name; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs9 = (this).LeftParentheses(_109_expression); + Dafny.ISequence _111_leftP = _let_tmp_rhs9.dtor__0; + Dafny.ISequence _112_rightP = _let_tmp_rhs9.dtor__1; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_111_leftP, (_109_expression)._ToString(ind)), _112_rightP), Dafny.Sequence.UnicodeFromString(".")), _110_name); } } { if (_source0.is_SelectIndex) { - RAST._IExpr _101_expression = _source0.dtor_obj; - RAST._IExpr _102_range = _source0.dtor_range; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs10 = (this).LeftParentheses(_101_expression); - Dafny.ISequence _103_leftP = _let_tmp_rhs10.dtor__0; - Dafny.ISequence _104_rightP = _let_tmp_rhs10.dtor__1; - Dafny.ISequence _105_rangeStr = (_102_range)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)); - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_103_leftP, (_101_expression)._ToString(ind)), _104_rightP), Dafny.Sequence.UnicodeFromString("[")), _105_rangeStr), Dafny.Sequence.UnicodeFromString("]")); + RAST._IExpr _113_expression = _source0.dtor_obj; + RAST._IExpr _114_range = _source0.dtor_range; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs10 = (this).LeftParentheses(_113_expression); + Dafny.ISequence _115_leftP = _let_tmp_rhs10.dtor__0; + Dafny.ISequence _116_rightP = _let_tmp_rhs10.dtor__1; + Dafny.ISequence _117_rangeStr = (_114_range)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_115_leftP, (_113_expression)._ToString(ind)), _116_rightP), Dafny.Sequence.UnicodeFromString("[")), _117_rangeStr), Dafny.Sequence.UnicodeFromString("]")); } } { if (_source0.is_ExprFromPath) { - RAST._IPath _106_path = _source0.dtor_path; - return (_106_path)._ToString(); + RAST._IPath _118_path = _source0.dtor_path; + return (_118_path)._ToString(); } } { if (_source0.is_FunctionSelect) { - RAST._IExpr _107_expression = _source0.dtor_obj; - Dafny.ISequence _108_name = _source0.dtor_name; - _System._ITuple2, Dafny.ISequence> _let_tmp_rhs11 = (this).LeftParentheses(_107_expression); - Dafny.ISequence _109_leftP = _let_tmp_rhs11.dtor__0; - Dafny.ISequence _110_rightP = _let_tmp_rhs11.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_109_leftP, (_107_expression)._ToString(ind)), _110_rightP), Dafny.Sequence.UnicodeFromString("::")), _108_name); + RAST._IExpr _119_expression = _source0.dtor_obj; + Dafny.ISequence _120_name = _source0.dtor_name; + _System._ITuple2, Dafny.ISequence> _let_tmp_rhs11 = (this).LeftParentheses(_119_expression); + Dafny.ISequence _121_leftP = _let_tmp_rhs11.dtor__0; + Dafny.ISequence _122_rightP = _let_tmp_rhs11.dtor__1; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_121_leftP, (_119_expression)._ToString(ind)), _122_rightP), Dafny.Sequence.UnicodeFromString("::")), _120_name); } } { if (_source0.is_Lambda) { - Dafny.ISequence _111_params = _source0.dtor_params; - Std.Wrappers._IOption _112_retType = _source0.dtor_retType; - RAST._IExpr _113_body = _source0.dtor_body; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("move |"), RAST.__default.SeqToString(_111_params, Dafny.Helpers.Id, Func>>>((_114_ind) => ((System.Func>)((_115_arg) => { - return (_115_arg)._ToString(_114_ind); - })))(ind), Dafny.Sequence.UnicodeFromString(","))), Dafny.Sequence.UnicodeFromString("| ")), (((_112_retType).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("-> "), ((_112_retType).dtor_value)._ToString(ind))) : (Dafny.Sequence.UnicodeFromString("")))), ((((_112_retType).is_Some) && (!((_113_body).is_Block))) ? ((RAST.Expr.create_Block(_113_body))._ToString(ind)) : ((_113_body)._ToString(ind)))); + Dafny.ISequence _123_params = _source0.dtor_params; + Std.Wrappers._IOption _124_retType = _source0.dtor_retType; + RAST._IExpr _125_body = _source0.dtor_body; + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("move |"), RAST.__default.SeqToString(_123_params, Dafny.Helpers.Id, Func>>>((_126_ind) => ((System.Func>)((_127_arg) => { + return (_127_arg)._ToString(_126_ind); + })))(ind), Dafny.Sequence.UnicodeFromString(","))), Dafny.Sequence.UnicodeFromString("| ")), (((_124_retType).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("-> "), ((_124_retType).dtor_value)._ToString(ind))) : (Dafny.Sequence.UnicodeFromString("")))), ((((_124_retType).is_Some) && (!((_125_body).is_Block))) ? (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), (_125_body)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}"))) : ((_125_body)._ToString(ind)))); } } { - RAST._IExpr _116_r = _source0; - return RAST.__default.AddIndent((_116_r).dtor_content, ind); + RAST._IExpr _128_r = _source0; + return RAST.__default.AddIndent((_128_r).dtor_content, ind); } } public RAST._IExpr Then(RAST._IExpr rhs2) { @@ -6104,15 +7147,15 @@ public RAST._IExpr Sel(Dafny.ISequence name) { public RAST._IExpr FSel(Dafny.ISequence name) { return RAST.Expr.create_FunctionSelect(this, name); } - public RAST._IExpr ApplyType(Dafny.ISequence typeParameters) { - if ((new BigInteger((typeParameters).Count)).Sign == 0) { + public RAST._IExpr ApplyType(Dafny.ISequence typeArguments) { + if ((new BigInteger((typeArguments).Count)).Sign == 0) { return this; } else { - return RAST.Expr.create_CallType(this, typeParameters); + return RAST.Expr.create_CallType(this, typeArguments); } } - public RAST._IExpr ApplyType1(RAST._IType typeParameter) { - return RAST.Expr.create_CallType(this, Dafny.Sequence.FromElements(typeParameter)); + public RAST._IExpr ApplyType1(RAST._IType typeArgument) { + return RAST.Expr.create_CallType(this, Dafny.Sequence.FromElements(typeArgument)); } public RAST._IExpr Apply(Dafny.ISequence arguments) { return RAST.Expr.create_Call(this, arguments); @@ -6120,8 +7163,11 @@ public RAST._IExpr Apply(Dafny.ISequence arguments) { public RAST._IExpr Apply1(RAST._IExpr argument) { return RAST.Expr.create_Call(this, Dafny.Sequence.FromElements(argument)); } + public RAST._IExpr Apply0() { + return RAST.Expr.create_Call(this, Dafny.Sequence.FromElements()); + } public bool IsLhsIdentifier() { - return ((this).is_Identifier) || (((this).is_Call) && (((((((this).dtor_obj).is_ExprFromPath) && (object.Equals(((this).dtor_obj).dtor_path, (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("modify!"))))) && ((new BigInteger(((this).dtor_arguments).Count)) == (BigInteger.One))) && ((((this).dtor_arguments).Select(BigInteger.Zero)).is_Identifier)) || ((((((this).dtor_obj).is_ExprFromPath) && (object.Equals(((this).dtor_obj).dtor_path, (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("md!"))))) && ((new BigInteger(((this).dtor_arguments).Count)) == (BigInteger.One))) && (Dafny.Helpers.Let(((this).dtor_arguments).Select(BigInteger.Zero), _pat_let13_0 => Dafny.Helpers.Let(_pat_let13_0, _0_lhs => (((_0_lhs).is_Call) && (((_0_lhs).dtor_obj).is_Select)) && ((((_0_lhs).dtor_obj).dtor_obj).is_Identifier))))))); + return ((this).is_Identifier) || (((this).is_Call) && (((((((this).dtor_obj).is_ExprFromPath) && (object.Equals(((this).dtor_obj).dtor_path, (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("modify!"))))) && ((new BigInteger(((this).dtor_arguments).Count)) == (BigInteger.One))) && ((((this).dtor_arguments).Select(BigInteger.Zero)).is_Identifier)) || ((((((this).dtor_obj).is_ExprFromPath) && (object.Equals(((this).dtor_obj).dtor_path, (RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("md!"))))) && ((new BigInteger(((this).dtor_arguments).Count)) == (BigInteger.One))) && (Dafny.Helpers.Let(((this).dtor_arguments).Select(BigInteger.Zero), _pat_let21_0 => Dafny.Helpers.Let(_pat_let21_0, _0_lhs => (((_0_lhs).is_Call) && (((_0_lhs).dtor_obj).is_Select)) && ((((_0_lhs).dtor_obj).dtor_obj).is_Identifier))))))); } public Dafny.ISequence LhsIdentifierName() { if ((this).is_Identifier) { @@ -6133,7 +7179,7 @@ public bool IsLhsIdentifier() { } } public RAST._IExpr Clone() { - return (RAST.Expr.create_Select(this, Dafny.Sequence.UnicodeFromString("clone"))).Apply(Dafny.Sequence.FromElements()); + return (RAST.Expr.create_Select(this, Dafny.Sequence.UnicodeFromString("clone"))).Apply0(); } public RAST._IPrintingInfo printingInfo { get { RAST._IExpr _source0 = this; @@ -6248,13 +7294,20 @@ public RAST._IPrintingInfo printingInfo { get { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(10), RAST.Associativity.create_LeftToRight()); } } + { + if (_source0.is_TraitCast) { + RAST._IType _12_leftTpe = _source0.dtor_leftTpe; + RAST._IType _13_tpe = _source0.dtor_tpe; + return RAST.PrintingInfo.create_Precedence(BigInteger.One); + } + } { if (_source0.is_BinaryOp) { - Dafny.ISequence _12_op2 = _source0.dtor_op2; - RAST._IExpr _13_left = _source0.dtor_left; - RAST._IExpr _14_right = _source0.dtor_right; - DAST.Format._IBinaryOpFormat _15_format = _source0.dtor_format2; - Dafny.ISequence _source2 = _12_op2; + Dafny.ISequence _14_op2 = _source0.dtor_op2; + RAST._IExpr _15_left = _source0.dtor_left; + RAST._IExpr _16_right = _source0.dtor_right; + DAST.Format._IBinaryOpFormat _17_format = _source0.dtor_format2; + Dafny.ISequence _source2 = _14_op2; { bool disjunctiveMatch1 = false; if (object.Equals(_source2, Dafny.Sequence.UnicodeFromString("*"))) { @@ -6291,7 +7344,7 @@ public RAST._IPrintingInfo printingInfo { get { disjunctiveMatch3 = true; } if (disjunctiveMatch3) { - if ((((_12_op2).Equals(Dafny.Sequence.UnicodeFromString("<<"))) && ((_13_left).is_TypeAscription)) && (((_13_left).dtor_tpe).EndsWithNameThatCanAcceptGenerics())) { + if ((((_14_op2).Equals(Dafny.Sequence.UnicodeFromString("<<"))) && ((_15_left).is_TypeAscription)) && (((_15_left).dtor_tpe).EndsWithNameThatCanAcceptGenerics())) { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(9), RAST.Associativity.create_LeftToRight()); } else { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(40), RAST.Associativity.create_LeftToRight()); @@ -6334,7 +7387,7 @@ public RAST._IPrintingInfo printingInfo { get { disjunctiveMatch4 = true; } if (disjunctiveMatch4) { - if (((((_12_op2).Equals(Dafny.Sequence.UnicodeFromString("<"))) || ((_12_op2).Equals(Dafny.Sequence.UnicodeFromString("<=")))) && ((_13_left).is_TypeAscription)) && (((_13_left).dtor_tpe).EndsWithNameThatCanAcceptGenerics())) { + if (((((_14_op2).Equals(Dafny.Sequence.UnicodeFromString("<"))) || ((_14_op2).Equals(Dafny.Sequence.UnicodeFromString("<=")))) && ((_15_left).is_TypeAscription)) && (((_15_left).dtor_tpe).EndsWithNameThatCanAcceptGenerics())) { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(9), RAST.Associativity.create_LeftToRight()); } else { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(80), RAST.Associativity.create_RequiresParentheses()); @@ -6399,7 +7452,7 @@ public RAST._IPrintingInfo printingInfo { get { disjunctiveMatch6 = true; } if (disjunctiveMatch6) { - if ((((_12_op2).Equals(Dafny.Sequence.UnicodeFromString("<<="))) && ((_13_left).is_TypeAscription)) && (((_13_left).dtor_tpe).EndsWithNameThatCanAcceptGenerics())) { + if ((((_14_op2).Equals(Dafny.Sequence.UnicodeFromString("<<="))) && ((_15_left).is_TypeAscription)) && (((_15_left).dtor_tpe).EndsWithNameThatCanAcceptGenerics())) { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(9), RAST.Associativity.create_LeftToRight()); } else { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(110), RAST.Associativity.create_RightToLeft()); @@ -6763,6 +7816,38 @@ public override string ToString() { return s; } } + public class Expr_TraitCast : Expr { + public readonly RAST._IType _leftTpe; + public readonly RAST._IType _tpe; + public Expr_TraitCast(RAST._IType leftTpe, RAST._IType tpe) : base() { + this._leftTpe = leftTpe; + this._tpe = tpe; + } + public override _IExpr DowncastClone() { + if (this is _IExpr dt) { return dt; } + return new Expr_TraitCast(_leftTpe, _tpe); + } + public override bool Equals(object other) { + var oth = other as RAST.Expr_TraitCast; + return oth != null && object.Equals(this._leftTpe, oth._leftTpe) && object.Equals(this._tpe, oth._tpe); + } + public override int GetHashCode() { + ulong hash = 5381; + hash = ((hash << 5) + hash) + 11; + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._leftTpe)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._tpe)); + return (int) hash; + } + public override string ToString() { + string s = "RAST.Expr.TraitCast"; + s += "("; + s += Dafny.Helpers.ToString(this._leftTpe); + s += ", "; + s += Dafny.Helpers.ToString(this._tpe); + s += ")"; + return s; + } + } public class Expr_LiteralInt : Expr { public readonly Dafny.ISequence _value; public Expr_LiteralInt(Dafny.ISequence @value) : base() { @@ -6778,7 +7863,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 11; + hash = ((hash << 5) + hash) + 12; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._value)); return (int) hash; } @@ -6805,7 +7890,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 12; + hash = ((hash << 5) + hash) + 13; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._bvalue)); return (int) hash; } @@ -6836,7 +7921,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 13; + hash = ((hash << 5) + hash) + 14; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._value)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._binary)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._verbatim)); @@ -6875,7 +7960,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 14; + hash = ((hash << 5) + hash) + 15; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._declareType)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._optType)); @@ -6913,7 +7998,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 15; + hash = ((hash << 5) + hash) + 16; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._names)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._rhs)); return (int) hash; @@ -6947,7 +8032,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 16; + hash = ((hash << 5) + hash) + 17; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._cond)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._thn)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._els)); @@ -6982,7 +8067,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 17; + hash = ((hash << 5) + hash) + 18; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._optCond)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._underlying)); return (int) hash; @@ -7016,7 +8101,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 18; + hash = ((hash << 5) + hash) + 19; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._range)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._body)); @@ -7051,7 +8136,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 19; + hash = ((hash << 5) + hash) + 20; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._lbl)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._underlying)); return (int) hash; @@ -7081,7 +8166,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 20; + hash = ((hash << 5) + hash) + 21; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._optLbl)); return (int) hash; } @@ -7108,7 +8193,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 21; + hash = ((hash << 5) + hash) + 22; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._optLbl)); return (int) hash; } @@ -7135,7 +8220,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 22; + hash = ((hash << 5) + hash) + 23; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._optExpr)); return (int) hash; } @@ -7149,24 +8234,24 @@ public override string ToString() { } public class Expr_CallType : Expr { public readonly RAST._IExpr _obj; - public readonly Dafny.ISequence _typeParameters; - public Expr_CallType(RAST._IExpr obj, Dafny.ISequence typeParameters) : base() { + public readonly Dafny.ISequence _typeArguments; + public Expr_CallType(RAST._IExpr obj, Dafny.ISequence typeArguments) : base() { this._obj = obj; - this._typeParameters = typeParameters; + this._typeArguments = typeArguments; } public override _IExpr DowncastClone() { if (this is _IExpr dt) { return dt; } - return new Expr_CallType(_obj, _typeParameters); + return new Expr_CallType(_obj, _typeArguments); } public override bool Equals(object other) { var oth = other as RAST.Expr_CallType; - return oth != null && object.Equals(this._obj, oth._obj) && object.Equals(this._typeParameters, oth._typeParameters); + return oth != null && object.Equals(this._obj, oth._obj) && object.Equals(this._typeArguments, oth._typeArguments); } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 23; + hash = ((hash << 5) + hash) + 24; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._obj)); - hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._typeParameters)); + hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._typeArguments)); return (int) hash; } public override string ToString() { @@ -7174,7 +8259,7 @@ public override string ToString() { s += "("; s += Dafny.Helpers.ToString(this._obj); s += ", "; - s += Dafny.Helpers.ToString(this._typeParameters); + s += Dafny.Helpers.ToString(this._typeArguments); s += ")"; return s; } @@ -7196,7 +8281,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 24; + hash = ((hash << 5) + hash) + 25; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._obj)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._arguments)); return (int) hash; @@ -7228,7 +8313,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 25; + hash = ((hash << 5) + hash) + 26; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._obj)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); return (int) hash; @@ -7260,7 +8345,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 26; + hash = ((hash << 5) + hash) + 27; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._obj)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._range)); return (int) hash; @@ -7290,7 +8375,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 27; + hash = ((hash << 5) + hash) + 28; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._path)); return (int) hash; } @@ -7319,7 +8404,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 28; + hash = ((hash << 5) + hash) + 29; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._obj)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._name)); return (int) hash; @@ -7353,7 +8438,7 @@ public override bool Equals(object other) { } public override int GetHashCode() { ulong hash = 5381; - hash = ((hash << 5) + hash) + 29; + hash = ((hash << 5) + hash) + 30; hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._params)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._retType)); hash = ((hash << 5) + hash) + ((ulong)Dafny.Helpers.GetHashCode(this._body)); diff --git a/Source/DafnyRuntime/DafnyRuntimeRust/src/lib.rs b/Source/DafnyRuntime/DafnyRuntimeRust/src/lib.rs index 02ddd0b2e88..41120b34d74 100644 --- a/Source/DafnyRuntime/DafnyRuntimeRust/src/lib.rs +++ b/Source/DafnyRuntime/DafnyRuntimeRust/src/lib.rs @@ -372,6 +372,11 @@ impl Into for DafnyInt { self.data.to_i128().unwrap() } } +impl Into for DafnyInt { + fn into(self) -> usize { + self.data.to_usize().unwrap() + } +} impl ToPrimitive for DafnyInt { fn to_i64(&self) -> Option { diff --git a/Source/DafnyRuntime/DafnyRuntimeRust/src/system/mod.rs b/Source/DafnyRuntime/DafnyRuntimeRust/src/system/mod.rs index 953d3640d48..d30d8671ec0 100644 --- a/Source/DafnyRuntime/DafnyRuntimeRust/src/system/mod.rs +++ b/Source/DafnyRuntime/DafnyRuntimeRust/src/system/mod.rs @@ -2,18 +2,25 @@ #![allow(nonstandard_style)] pub mod _System { + pub use crate::DafnyInt; pub use crate::DafnyType; pub use ::std::fmt::Debug; + pub use ::std::fmt::Formatter; + pub use ::std::fmt::Result; pub use crate::DafnyPrint; + pub use ::std::rc::Rc; pub use ::std::cmp::Eq; pub use ::std::hash::Hash; + pub use ::std::hash::Hasher; pub use ::std::default::Default; pub use ::std::convert::AsRef; + pub use crate::SequenceIter; + pub use crate::seq; - pub type nat = crate::DafnyInt; + pub type nat = DafnyInt; #[derive(PartialEq, Clone)] - pub enum Tuple2 { + pub enum Tuple2 { _T2 { _0: T0, _1: T1 @@ -35,20 +42,20 @@ pub mod _System { impl Debug for Tuple2 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple2 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple2::_T2{_0, _1, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -57,8 +64,8 @@ pub mod _System { } impl Tuple2 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>) -> ::std::rc::Rc) -> Tuple2> { - ::std::rc::Rc::new(move |this: Self| -> Tuple2{ + 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 { Tuple2::_T2{_0, _1, } => { Tuple2::_T2 { @@ -76,11 +83,11 @@ pub mod _System { impl Hash for Tuple2 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple2::_T2{_0, _1, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state) }, } } @@ -90,8 +97,8 @@ pub mod _System { for Tuple2 { fn default() -> Tuple2 { Tuple2::_T2 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default() } } } @@ -112,14 +119,14 @@ pub mod _System { impl Debug for Tuple0 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple0 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple0::_T0{} => { write!(_formatter, "")?; @@ -130,8 +137,8 @@ pub mod _System { } impl Tuple0 { - pub fn _AllSingletonConstructors() -> crate::SequenceIter<::std::rc::Rc> { - crate::seq![::std::rc::Rc::new(Tuple0::_T0 {})].iter() + pub fn _AllSingletonConstructors() -> SequenceIter> { + seq![Rc::new(Tuple0::_T0 {})].iter() } } @@ -140,7 +147,7 @@ pub mod _System { impl Hash for Tuple0 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple0::_T0{} => { @@ -164,7 +171,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple1 { + pub enum Tuple1 { _T1 { _0: T0 } @@ -180,18 +187,18 @@ pub mod _System { impl Debug for Tuple1 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple1 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple1::_T1{_0, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -200,8 +207,8 @@ pub mod _System { } impl Tuple1 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>) -> ::std::rc::Rc) -> Tuple1> { - ::std::rc::Rc::new(move |this: Self| -> Tuple1{ + pub fn coerce(f_0: Rc r#__T0 + 'static>) -> Rc) -> Tuple1> { + Rc::new(move |this: Self| -> Tuple1{ match this { Tuple1::_T1{_0, } => { Tuple1::_T1 { @@ -218,10 +225,10 @@ pub mod _System { impl Hash for Tuple1 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple1::_T1{_0, } => { - ::std::hash::Hash::hash(_0, _state) + Hash::hash(_0, _state) }, } } @@ -231,7 +238,7 @@ pub mod _System { for Tuple1 { fn default() -> Tuple1 { Tuple1::_T1 { - _0: ::std::default::Default::default() + _0: Default::default() } } } @@ -244,7 +251,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple3 { + pub enum Tuple3 { _T3 { _0: T0, _1: T1, @@ -272,22 +279,22 @@ pub mod _System { impl Debug for Tuple3 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple3 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple3::_T3{_0, _1, _2, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -296,8 +303,8 @@ pub mod _System { } impl Tuple3 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>) -> ::std::rc::Rc) -> Tuple3> { - ::std::rc::Rc::new(move |this: Self| -> Tuple3{ + 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 { Tuple3::_T3{_0, _1, _2, } => { Tuple3::_T3 { @@ -316,12 +323,12 @@ pub mod _System { impl Hash for Tuple3 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple3::_T3{_0, _1, _2, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state) }, } } @@ -331,9 +338,9 @@ pub mod _System { for Tuple3 { fn default() -> Tuple3 { Tuple3::_T3 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default() } } } @@ -346,7 +353,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple4 { + pub enum Tuple4 { _T4 { _0: T0, _1: T1, @@ -380,24 +387,24 @@ pub mod _System { impl Debug for Tuple4 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple4 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple4::_T4{_0, _1, _2, _3, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -406,8 +413,8 @@ pub mod _System { } impl Tuple4 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>) -> ::std::rc::Rc) -> Tuple4> { - ::std::rc::Rc::new(move |this: Self| -> Tuple4{ + 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 { Tuple4::_T4{_0, _1, _2, _3, } => { Tuple4::_T4 { @@ -427,13 +434,13 @@ pub mod _System { impl Hash for Tuple4 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple4::_T4{_0, _1, _2, _3, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state) }, } } @@ -443,10 +450,10 @@ pub mod _System { for Tuple4 { fn default() -> Tuple4 { Tuple4::_T4 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default() } } } @@ -459,7 +466,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple5 { + pub enum Tuple5 { _T5 { _0: T0, _1: T1, @@ -499,26 +506,26 @@ pub mod _System { impl Debug for Tuple5 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple5 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple5::_T5{_0, _1, _2, _3, _4, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -527,8 +534,8 @@ pub mod _System { } impl Tuple5 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>) -> ::std::rc::Rc) -> Tuple5> { - ::std::rc::Rc::new(move |this: Self| -> Tuple5{ + 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 { Tuple5::_T5{_0, _1, _2, _3, _4, } => { Tuple5::_T5 { @@ -549,14 +556,14 @@ pub mod _System { impl Hash for Tuple5 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple5::_T5{_0, _1, _2, _3, _4, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state) }, } } @@ -566,11 +573,11 @@ pub mod _System { for Tuple5 { fn default() -> Tuple5 { Tuple5::_T5 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default() } } } @@ -583,7 +590,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple6 { + pub enum Tuple6 { _T6 { _0: T0, _1: T1, @@ -629,28 +636,28 @@ pub mod _System { impl Debug for Tuple6 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple6 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple6::_T6{_0, _1, _2, _3, _4, _5, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -659,8 +666,8 @@ pub mod _System { } impl Tuple6 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>) -> ::std::rc::Rc) -> Tuple6> { - ::std::rc::Rc::new(move |this: Self| -> Tuple6{ + 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 { Tuple6::_T6{_0, _1, _2, _3, _4, _5, } => { Tuple6::_T6 { @@ -682,15 +689,15 @@ pub mod _System { impl Hash for Tuple6 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple6::_T6{_0, _1, _2, _3, _4, _5, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state) }, } } @@ -700,12 +707,12 @@ pub mod _System { for Tuple6 { fn default() -> Tuple6 { Tuple6::_T6 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default() } } } @@ -718,7 +725,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple7 { + pub enum Tuple7 { _T7 { _0: T0, _1: T1, @@ -770,30 +777,30 @@ pub mod _System { impl Debug for Tuple7 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple7 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -802,8 +809,8 @@ pub mod _System { } impl Tuple7 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>) -> ::std::rc::Rc) -> Tuple7> { - ::std::rc::Rc::new(move |this: Self| -> Tuple7{ + 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 { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => { Tuple7::_T7 { @@ -826,16 +833,16 @@ pub mod _System { impl Hash for Tuple7 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple7::_T7{_0, _1, _2, _3, _4, _5, _6, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state) }, } } @@ -845,13 +852,13 @@ pub mod _System { for Tuple7 { fn default() -> Tuple7 { Tuple7::_T7 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default() } } } @@ -864,7 +871,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple8 { + pub enum Tuple8 { _T8 { _0: T0, _1: T1, @@ -922,32 +929,32 @@ pub mod _System { impl Debug for Tuple8 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple8 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -956,8 +963,8 @@ pub mod _System { } impl Tuple8 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>) -> ::std::rc::Rc) -> Tuple8> { - ::std::rc::Rc::new(move |this: Self| -> Tuple8{ + 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 { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => { Tuple8::_T8 { @@ -981,17 +988,17 @@ pub mod _System { impl Hash for Tuple8 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple8::_T8{_0, _1, _2, _3, _4, _5, _6, _7, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state) }, } } @@ -1001,14 +1008,14 @@ pub mod _System { for Tuple8 { fn default() -> Tuple8 { Tuple8::_T8 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default() } } } @@ -1021,7 +1028,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple9 { + pub enum Tuple9 { _T9 { _0: T0, _1: T1, @@ -1085,34 +1092,34 @@ pub mod _System { impl Debug for Tuple9 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple9 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -1121,8 +1128,8 @@ pub mod _System { } impl Tuple9 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>) -> ::std::rc::Rc) -> Tuple9> { - ::std::rc::Rc::new(move |this: Self| -> Tuple9{ + 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 { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => { Tuple9::_T9 { @@ -1147,18 +1154,18 @@ pub mod _System { impl Hash for Tuple9 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple9::_T9{_0, _1, _2, _3, _4, _5, _6, _7, _8, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state) }, } } @@ -1168,15 +1175,15 @@ pub mod _System { for Tuple9 { fn default() -> Tuple9 { Tuple9::_T9 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default() } } } @@ -1189,7 +1196,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple10 { + pub enum Tuple10 { _T10 { _0: T0, _1: T1, @@ -1259,36 +1266,36 @@ pub mod _System { impl Debug for Tuple10 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple10 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -1297,8 +1304,8 @@ pub mod _System { } impl Tuple10 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>) -> ::std::rc::Rc) -> Tuple10> { - ::std::rc::Rc::new(move |this: Self| -> Tuple10{ + 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 { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => { Tuple10::_T10 { @@ -1324,19 +1331,19 @@ pub mod _System { impl Hash for Tuple10 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple10::_T10{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state) }, } } @@ -1346,16 +1353,16 @@ pub mod _System { for Tuple10 { fn default() -> Tuple10 { Tuple10::_T10 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default() } } } @@ -1368,7 +1375,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple11 { + pub enum Tuple11 { _T11 { _0: T0, _1: T1, @@ -1444,38 +1451,38 @@ pub mod _System { impl Debug for Tuple11 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple11 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -1484,8 +1491,8 @@ pub mod _System { } impl Tuple11 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>) -> ::std::rc::Rc) -> Tuple11> { - ::std::rc::Rc::new(move |this: Self| -> Tuple11{ + 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 { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => { Tuple11::_T11 { @@ -1512,20 +1519,20 @@ pub mod _System { impl Hash for Tuple11 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple11::_T11{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state) }, } } @@ -1535,17 +1542,17 @@ pub mod _System { for Tuple11 { fn default() -> Tuple11 { Tuple11::_T11 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default() } } } @@ -1558,7 +1565,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple12 { + pub enum Tuple12 { _T12 { _0: T0, _1: T1, @@ -1640,40 +1647,40 @@ pub mod _System { impl Debug for Tuple12 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple12 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + DafnyPrint::fmt_print(_11, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -1682,8 +1689,8 @@ pub mod _System { } impl Tuple12 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>, f_11: ::std::rc::Rc r#__T11 + 'static>) -> ::std::rc::Rc) -> Tuple12> { - ::std::rc::Rc::new(move |this: Self| -> Tuple12{ + 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 { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => { Tuple12::_T12 { @@ -1711,21 +1718,21 @@ pub mod _System { impl Hash for Tuple12 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple12::_T12{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state); - ::std::hash::Hash::hash(_11, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state); + Hash::hash(_11, _state) }, } } @@ -1735,18 +1742,18 @@ pub mod _System { for Tuple12 { fn default() -> Tuple12 { Tuple12::_T12 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default(), - _11: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default(), + _11: Default::default() } } } @@ -1759,7 +1766,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple13 { + pub enum Tuple13 { _T13 { _0: T0, _1: T1, @@ -1847,42 +1854,42 @@ pub mod _System { impl Debug for Tuple13 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple13 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + DafnyPrint::fmt_print(_11, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + DafnyPrint::fmt_print(_12, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -1891,8 +1898,8 @@ pub mod _System { } impl Tuple13 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>, f_11: ::std::rc::Rc r#__T11 + 'static>, f_12: ::std::rc::Rc r#__T12 + 'static>) -> ::std::rc::Rc) -> Tuple13> { - ::std::rc::Rc::new(move |this: Self| -> Tuple13{ + 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 { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => { Tuple13::_T13 { @@ -1921,22 +1928,22 @@ pub mod _System { impl Hash for Tuple13 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple13::_T13{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state); - ::std::hash::Hash::hash(_11, _state); - ::std::hash::Hash::hash(_12, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state); + Hash::hash(_11, _state); + Hash::hash(_12, _state) }, } } @@ -1946,19 +1953,19 @@ pub mod _System { for Tuple13 { fn default() -> Tuple13 { Tuple13::_T13 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default(), - _11: ::std::default::Default::default(), - _12: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default(), + _11: Default::default(), + _12: Default::default() } } } @@ -1971,7 +1978,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple14 { + pub enum Tuple14 { _T14 { _0: T0, _1: T1, @@ -2065,44 +2072,44 @@ pub mod _System { impl Debug for Tuple14 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple14 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + DafnyPrint::fmt_print(_11, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + DafnyPrint::fmt_print(_12, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + DafnyPrint::fmt_print(_13, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -2111,8 +2118,8 @@ pub mod _System { } impl Tuple14 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>, f_11: ::std::rc::Rc r#__T11 + 'static>, f_12: ::std::rc::Rc r#__T12 + 'static>, f_13: ::std::rc::Rc r#__T13 + 'static>) -> ::std::rc::Rc) -> Tuple14> { - ::std::rc::Rc::new(move |this: Self| -> Tuple14{ + 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 { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => { Tuple14::_T14 { @@ -2142,23 +2149,23 @@ pub mod _System { impl Hash for Tuple14 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple14::_T14{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state); - ::std::hash::Hash::hash(_11, _state); - ::std::hash::Hash::hash(_12, _state); - ::std::hash::Hash::hash(_13, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state); + Hash::hash(_11, _state); + Hash::hash(_12, _state); + Hash::hash(_13, _state) }, } } @@ -2168,20 +2175,20 @@ pub mod _System { for Tuple14 { fn default() -> Tuple14 { Tuple14::_T14 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default(), - _11: ::std::default::Default::default(), - _12: ::std::default::Default::default(), - _13: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default(), + _11: Default::default(), + _12: Default::default(), + _13: Default::default() } } } @@ -2194,7 +2201,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple15 { + pub enum Tuple15 { _T15 { _0: T0, _1: T1, @@ -2294,46 +2301,46 @@ pub mod _System { impl Debug for Tuple15 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple15 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + DafnyPrint::fmt_print(_11, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + DafnyPrint::fmt_print(_12, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + DafnyPrint::fmt_print(_13, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + DafnyPrint::fmt_print(_14, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -2342,8 +2349,8 @@ pub mod _System { } impl Tuple15 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>, f_11: ::std::rc::Rc r#__T11 + 'static>, f_12: ::std::rc::Rc r#__T12 + 'static>, f_13: ::std::rc::Rc r#__T13 + 'static>, f_14: ::std::rc::Rc r#__T14 + 'static>) -> ::std::rc::Rc) -> Tuple15> { - ::std::rc::Rc::new(move |this: Self| -> Tuple15{ + 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 { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => { Tuple15::_T15 { @@ -2374,24 +2381,24 @@ pub mod _System { impl Hash for Tuple15 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple15::_T15{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state); - ::std::hash::Hash::hash(_11, _state); - ::std::hash::Hash::hash(_12, _state); - ::std::hash::Hash::hash(_13, _state); - ::std::hash::Hash::hash(_14, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state); + Hash::hash(_11, _state); + Hash::hash(_12, _state); + Hash::hash(_13, _state); + Hash::hash(_14, _state) }, } } @@ -2401,21 +2408,21 @@ pub mod _System { for Tuple15 { fn default() -> Tuple15 { Tuple15::_T15 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default(), - _11: ::std::default::Default::default(), - _12: ::std::default::Default::default(), - _13: ::std::default::Default::default(), - _14: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default(), + _11: Default::default(), + _12: Default::default(), + _13: Default::default(), + _14: Default::default() } } } @@ -2428,7 +2435,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple16 { + pub enum Tuple16 { _T16 { _0: T0, _1: T1, @@ -2534,48 +2541,48 @@ pub mod _System { impl Debug for Tuple16 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple16 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + DafnyPrint::fmt_print(_11, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + DafnyPrint::fmt_print(_12, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + DafnyPrint::fmt_print(_13, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + DafnyPrint::fmt_print(_14, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + DafnyPrint::fmt_print(_15, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -2584,8 +2591,8 @@ pub mod _System { } impl Tuple16 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>, f_11: ::std::rc::Rc r#__T11 + 'static>, f_12: ::std::rc::Rc r#__T12 + 'static>, f_13: ::std::rc::Rc r#__T13 + 'static>, f_14: ::std::rc::Rc r#__T14 + 'static>, f_15: ::std::rc::Rc r#__T15 + 'static>) -> ::std::rc::Rc) -> Tuple16> { - ::std::rc::Rc::new(move |this: Self| -> Tuple16{ + 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 { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => { Tuple16::_T16 { @@ -2617,25 +2624,25 @@ pub mod _System { impl Hash for Tuple16 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple16::_T16{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state); - ::std::hash::Hash::hash(_11, _state); - ::std::hash::Hash::hash(_12, _state); - ::std::hash::Hash::hash(_13, _state); - ::std::hash::Hash::hash(_14, _state); - ::std::hash::Hash::hash(_15, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state); + Hash::hash(_11, _state); + Hash::hash(_12, _state); + Hash::hash(_13, _state); + Hash::hash(_14, _state); + Hash::hash(_15, _state) }, } } @@ -2645,22 +2652,22 @@ pub mod _System { for Tuple16 { fn default() -> Tuple16 { Tuple16::_T16 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default(), - _11: ::std::default::Default::default(), - _12: ::std::default::Default::default(), - _13: ::std::default::Default::default(), - _14: ::std::default::Default::default(), - _15: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default(), + _11: Default::default(), + _12: Default::default(), + _13: Default::default(), + _14: Default::default(), + _15: Default::default() } } } @@ -2673,7 +2680,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple17 { + pub enum Tuple17 { _T17 { _0: T0, _1: T1, @@ -2785,50 +2792,50 @@ pub mod _System { impl Debug for Tuple17 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple17 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + DafnyPrint::fmt_print(_11, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + DafnyPrint::fmt_print(_12, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + DafnyPrint::fmt_print(_13, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + DafnyPrint::fmt_print(_14, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + DafnyPrint::fmt_print(_15, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_16, _formatter, false)?; + DafnyPrint::fmt_print(_16, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -2837,8 +2844,8 @@ pub mod _System { } impl Tuple17 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>, f_11: ::std::rc::Rc r#__T11 + 'static>, f_12: ::std::rc::Rc r#__T12 + 'static>, f_13: ::std::rc::Rc r#__T13 + 'static>, f_14: ::std::rc::Rc r#__T14 + 'static>, f_15: ::std::rc::Rc r#__T15 + 'static>, f_16: ::std::rc::Rc r#__T16 + 'static>) -> ::std::rc::Rc) -> Tuple17> { - ::std::rc::Rc::new(move |this: Self| -> Tuple17{ + 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 { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => { Tuple17::_T17 { @@ -2871,26 +2878,26 @@ pub mod _System { impl Hash for Tuple17 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple17::_T17{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state); - ::std::hash::Hash::hash(_11, _state); - ::std::hash::Hash::hash(_12, _state); - ::std::hash::Hash::hash(_13, _state); - ::std::hash::Hash::hash(_14, _state); - ::std::hash::Hash::hash(_15, _state); - ::std::hash::Hash::hash(_16, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state); + Hash::hash(_11, _state); + Hash::hash(_12, _state); + Hash::hash(_13, _state); + Hash::hash(_14, _state); + Hash::hash(_15, _state); + Hash::hash(_16, _state) }, } } @@ -2900,23 +2907,23 @@ pub mod _System { for Tuple17 { fn default() -> Tuple17 { Tuple17::_T17 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default(), - _11: ::std::default::Default::default(), - _12: ::std::default::Default::default(), - _13: ::std::default::Default::default(), - _14: ::std::default::Default::default(), - _15: ::std::default::Default::default(), - _16: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default(), + _11: Default::default(), + _12: Default::default(), + _13: Default::default(), + _14: Default::default(), + _15: Default::default(), + _16: Default::default() } } } @@ -2929,7 +2936,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple18 { + pub enum Tuple18 { _T18 { _0: T0, _1: T1, @@ -3047,52 +3054,52 @@ pub mod _System { impl Debug for Tuple18 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple18 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + DafnyPrint::fmt_print(_11, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + DafnyPrint::fmt_print(_12, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + DafnyPrint::fmt_print(_13, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + DafnyPrint::fmt_print(_14, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + DafnyPrint::fmt_print(_15, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_16, _formatter, false)?; + DafnyPrint::fmt_print(_16, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_17, _formatter, false)?; + DafnyPrint::fmt_print(_17, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -3101,8 +3108,8 @@ pub mod _System { } impl Tuple18 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>, f_11: ::std::rc::Rc r#__T11 + 'static>, f_12: ::std::rc::Rc r#__T12 + 'static>, f_13: ::std::rc::Rc r#__T13 + 'static>, f_14: ::std::rc::Rc r#__T14 + 'static>, f_15: ::std::rc::Rc r#__T15 + 'static>, f_16: ::std::rc::Rc r#__T16 + 'static>, f_17: ::std::rc::Rc r#__T17 + 'static>) -> ::std::rc::Rc) -> Tuple18> { - ::std::rc::Rc::new(move |this: Self| -> Tuple18{ + 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 { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => { Tuple18::_T18 { @@ -3136,27 +3143,27 @@ pub mod _System { impl Hash for Tuple18 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple18::_T18{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state); - ::std::hash::Hash::hash(_11, _state); - ::std::hash::Hash::hash(_12, _state); - ::std::hash::Hash::hash(_13, _state); - ::std::hash::Hash::hash(_14, _state); - ::std::hash::Hash::hash(_15, _state); - ::std::hash::Hash::hash(_16, _state); - ::std::hash::Hash::hash(_17, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state); + Hash::hash(_11, _state); + Hash::hash(_12, _state); + Hash::hash(_13, _state); + Hash::hash(_14, _state); + Hash::hash(_15, _state); + Hash::hash(_16, _state); + Hash::hash(_17, _state) }, } } @@ -3166,24 +3173,24 @@ pub mod _System { for Tuple18 { fn default() -> Tuple18 { Tuple18::_T18 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default(), - _11: ::std::default::Default::default(), - _12: ::std::default::Default::default(), - _13: ::std::default::Default::default(), - _14: ::std::default::Default::default(), - _15: ::std::default::Default::default(), - _16: ::std::default::Default::default(), - _17: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default(), + _11: Default::default(), + _12: Default::default(), + _13: Default::default(), + _14: Default::default(), + _15: Default::default(), + _16: Default::default(), + _17: Default::default() } } } @@ -3196,7 +3203,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple19 { + pub enum Tuple19 { _T19 { _0: T0, _1: T1, @@ -3320,54 +3327,54 @@ pub mod _System { impl Debug for Tuple19 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple19 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + DafnyPrint::fmt_print(_11, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + DafnyPrint::fmt_print(_12, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + DafnyPrint::fmt_print(_13, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + DafnyPrint::fmt_print(_14, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + DafnyPrint::fmt_print(_15, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_16, _formatter, false)?; + DafnyPrint::fmt_print(_16, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_17, _formatter, false)?; + DafnyPrint::fmt_print(_17, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_18, _formatter, false)?; + DafnyPrint::fmt_print(_18, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -3376,8 +3383,8 @@ pub mod _System { } impl Tuple19 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>, f_11: ::std::rc::Rc r#__T11 + 'static>, f_12: ::std::rc::Rc r#__T12 + 'static>, f_13: ::std::rc::Rc r#__T13 + 'static>, f_14: ::std::rc::Rc r#__T14 + 'static>, f_15: ::std::rc::Rc r#__T15 + 'static>, f_16: ::std::rc::Rc r#__T16 + 'static>, f_17: ::std::rc::Rc r#__T17 + 'static>, f_18: ::std::rc::Rc r#__T18 + 'static>) -> ::std::rc::Rc) -> Tuple19> { - ::std::rc::Rc::new(move |this: Self| -> Tuple19{ + 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 { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => { Tuple19::_T19 { @@ -3412,28 +3419,28 @@ pub mod _System { impl Hash for Tuple19 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple19::_T19{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state); - ::std::hash::Hash::hash(_11, _state); - ::std::hash::Hash::hash(_12, _state); - ::std::hash::Hash::hash(_13, _state); - ::std::hash::Hash::hash(_14, _state); - ::std::hash::Hash::hash(_15, _state); - ::std::hash::Hash::hash(_16, _state); - ::std::hash::Hash::hash(_17, _state); - ::std::hash::Hash::hash(_18, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state); + Hash::hash(_11, _state); + Hash::hash(_12, _state); + Hash::hash(_13, _state); + Hash::hash(_14, _state); + Hash::hash(_15, _state); + Hash::hash(_16, _state); + Hash::hash(_17, _state); + Hash::hash(_18, _state) }, } } @@ -3443,25 +3450,25 @@ pub mod _System { for Tuple19 { fn default() -> Tuple19 { Tuple19::_T19 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default(), - _11: ::std::default::Default::default(), - _12: ::std::default::Default::default(), - _13: ::std::default::Default::default(), - _14: ::std::default::Default::default(), - _15: ::std::default::Default::default(), - _16: ::std::default::Default::default(), - _17: ::std::default::Default::default(), - _18: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default(), + _11: Default::default(), + _12: Default::default(), + _13: Default::default(), + _14: Default::default(), + _15: Default::default(), + _16: Default::default(), + _17: Default::default(), + _18: Default::default() } } } @@ -3474,7 +3481,7 @@ pub mod _System { } #[derive(PartialEq, Clone)] - pub enum Tuple20 { + pub enum Tuple20 { _T20 { _0: T0, _1: T1, @@ -3604,56 +3611,56 @@ pub mod _System { impl Debug for Tuple20 { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { - crate::DafnyPrint::fmt_print(self, f, true) + fn fmt(&self, f: &mut Formatter) -> Result { + DafnyPrint::fmt_print(self, f, true) } } impl DafnyPrint for Tuple20 { - fn fmt_print(&self, _formatter: &mut ::std::fmt::Formatter, _in_seq: bool) -> std::fmt::Result { + fn fmt_print(&self, _formatter: &mut Formatter, _in_seq: bool) -> std::fmt::Result { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => { write!(_formatter, "(")?; - crate::DafnyPrint::fmt_print(_0, _formatter, false)?; + DafnyPrint::fmt_print(_0, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_1, _formatter, false)?; + DafnyPrint::fmt_print(_1, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_2, _formatter, false)?; + DafnyPrint::fmt_print(_2, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_3, _formatter, false)?; + DafnyPrint::fmt_print(_3, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_4, _formatter, false)?; + DafnyPrint::fmt_print(_4, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_5, _formatter, false)?; + DafnyPrint::fmt_print(_5, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_6, _formatter, false)?; + DafnyPrint::fmt_print(_6, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_7, _formatter, false)?; + DafnyPrint::fmt_print(_7, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_8, _formatter, false)?; + DafnyPrint::fmt_print(_8, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_9, _formatter, false)?; + DafnyPrint::fmt_print(_9, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_10, _formatter, false)?; + DafnyPrint::fmt_print(_10, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_11, _formatter, false)?; + DafnyPrint::fmt_print(_11, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_12, _formatter, false)?; + DafnyPrint::fmt_print(_12, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_13, _formatter, false)?; + DafnyPrint::fmt_print(_13, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_14, _formatter, false)?; + DafnyPrint::fmt_print(_14, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_15, _formatter, false)?; + DafnyPrint::fmt_print(_15, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_16, _formatter, false)?; + DafnyPrint::fmt_print(_16, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_17, _formatter, false)?; + DafnyPrint::fmt_print(_17, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_18, _formatter, false)?; + DafnyPrint::fmt_print(_18, _formatter, false)?; write!(_formatter, ", ")?; - crate::DafnyPrint::fmt_print(_19, _formatter, false)?; + DafnyPrint::fmt_print(_19, _formatter, false)?; write!(_formatter, ")")?; Ok(()) }, @@ -3662,8 +3669,8 @@ pub mod _System { } impl Tuple20 { - pub fn coerce(f_0: ::std::rc::Rc r#__T0 + 'static>, f_1: ::std::rc::Rc r#__T1 + 'static>, f_2: ::std::rc::Rc r#__T2 + 'static>, f_3: ::std::rc::Rc r#__T3 + 'static>, f_4: ::std::rc::Rc r#__T4 + 'static>, f_5: ::std::rc::Rc r#__T5 + 'static>, f_6: ::std::rc::Rc r#__T6 + 'static>, f_7: ::std::rc::Rc r#__T7 + 'static>, f_8: ::std::rc::Rc r#__T8 + 'static>, f_9: ::std::rc::Rc r#__T9 + 'static>, f_10: ::std::rc::Rc r#__T10 + 'static>, f_11: ::std::rc::Rc r#__T11 + 'static>, f_12: ::std::rc::Rc r#__T12 + 'static>, f_13: ::std::rc::Rc r#__T13 + 'static>, f_14: ::std::rc::Rc r#__T14 + 'static>, f_15: ::std::rc::Rc r#__T15 + 'static>, f_16: ::std::rc::Rc r#__T16 + 'static>, f_17: ::std::rc::Rc r#__T17 + 'static>, f_18: ::std::rc::Rc r#__T18 + 'static>, f_19: ::std::rc::Rc r#__T19 + 'static>) -> ::std::rc::Rc) -> Tuple20> { - ::std::rc::Rc::new(move |this: Self| -> Tuple20{ + 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 { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => { Tuple20::_T20 { @@ -3699,29 +3706,29 @@ pub mod _System { impl Hash for Tuple20 { - fn hash<_H: ::std::hash::Hasher>(&self, _state: &mut _H) { + fn hash<_H: Hasher>(&self, _state: &mut _H) { match self { Tuple20::_T20{_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, } => { - ::std::hash::Hash::hash(_0, _state); - ::std::hash::Hash::hash(_1, _state); - ::std::hash::Hash::hash(_2, _state); - ::std::hash::Hash::hash(_3, _state); - ::std::hash::Hash::hash(_4, _state); - ::std::hash::Hash::hash(_5, _state); - ::std::hash::Hash::hash(_6, _state); - ::std::hash::Hash::hash(_7, _state); - ::std::hash::Hash::hash(_8, _state); - ::std::hash::Hash::hash(_9, _state); - ::std::hash::Hash::hash(_10, _state); - ::std::hash::Hash::hash(_11, _state); - ::std::hash::Hash::hash(_12, _state); - ::std::hash::Hash::hash(_13, _state); - ::std::hash::Hash::hash(_14, _state); - ::std::hash::Hash::hash(_15, _state); - ::std::hash::Hash::hash(_16, _state); - ::std::hash::Hash::hash(_17, _state); - ::std::hash::Hash::hash(_18, _state); - ::std::hash::Hash::hash(_19, _state) + Hash::hash(_0, _state); + Hash::hash(_1, _state); + Hash::hash(_2, _state); + Hash::hash(_3, _state); + Hash::hash(_4, _state); + Hash::hash(_5, _state); + Hash::hash(_6, _state); + Hash::hash(_7, _state); + Hash::hash(_8, _state); + Hash::hash(_9, _state); + Hash::hash(_10, _state); + Hash::hash(_11, _state); + Hash::hash(_12, _state); + Hash::hash(_13, _state); + Hash::hash(_14, _state); + Hash::hash(_15, _state); + Hash::hash(_16, _state); + Hash::hash(_17, _state); + Hash::hash(_18, _state); + Hash::hash(_19, _state) }, } } @@ -3731,26 +3738,26 @@ pub mod _System { for Tuple20 { fn default() -> Tuple20 { Tuple20::_T20 { - _0: ::std::default::Default::default(), - _1: ::std::default::Default::default(), - _2: ::std::default::Default::default(), - _3: ::std::default::Default::default(), - _4: ::std::default::Default::default(), - _5: ::std::default::Default::default(), - _6: ::std::default::Default::default(), - _7: ::std::default::Default::default(), - _8: ::std::default::Default::default(), - _9: ::std::default::Default::default(), - _10: ::std::default::Default::default(), - _11: ::std::default::Default::default(), - _12: ::std::default::Default::default(), - _13: ::std::default::Default::default(), - _14: ::std::default::Default::default(), - _15: ::std::default::Default::default(), - _16: ::std::default::Default::default(), - _17: ::std::default::Default::default(), - _18: ::std::default::Default::default(), - _19: ::std::default::Default::default() + _0: Default::default(), + _1: Default::default(), + _2: Default::default(), + _3: Default::default(), + _4: Default::default(), + _5: Default::default(), + _6: Default::default(), + _7: Default::default(), + _8: Default::default(), + _9: Default::default(), + _10: Default::default(), + _11: Default::default(), + _12: Default::default(), + _13: Default::default(), + _14: Default::default(), + _15: Default::default(), + _16: Default::default(), + _17: Default::default(), + _18: Default::default(), + _19: Default::default() } } } diff --git a/Source/DafnyRuntime/DafnyRuntimeSystemModule.cs b/Source/DafnyRuntime/DafnyRuntimeSystemModule.cs index c22f67e95f2..2c19c6eacb4 100644 --- a/Source/DafnyRuntime/DafnyRuntimeSystemModule.cs +++ b/Source/DafnyRuntime/DafnyRuntimeSystemModule.cs @@ -503,7 +503,7 @@ public static T[] InitNewArray1(T z, BigInteger size0) { } } } // end of namespace Dafny -internal static class FuncExtensions { +public static class FuncExtensions { public static Func DowncastClone(this Func F, Func ArgConv, Func ResConv) { return arg => ResConv(F(ArgConv(arg))); } diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/datatypes.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/datatypes.dfy index f89e6a2c2fc..ef835701c2e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/datatypes.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/datatypes.dfy @@ -1,10 +1,12 @@ // NONUNIFORM: Demonstration of the use of the external Rust Option<> type // RUN: %baredafny run --target=rs "%s" > "%t" // RUN: %diff "%s.expect" "%t" +// RUN: %baredafny run --target=rs --raw-pointers "%s" > "%t" +// RUN: %diff "%s.expect" "%t" -module {:compile false} {:extern "std"} RustStd { +module {:compile false} {:extern "::std::option"} RustStdOption { // Define the Rust option type - datatype {:extern "option::Option"} {:compile false} {:rust_rc false} Option = + datatype {:extern "Option"} {:compile false} {:rust_rc false} Option = Some({:extern "0"} {:extern_extract "unwrap"} value: T) | None { } } @@ -17,7 +19,7 @@ module RustStdCompare { } module DatatypeTests { - import opened RustStd + import opened RustStdOption import RustStdCompare newtype u8 = x: int | 0 <= x < 255 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/mapsubsets.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/mapsubsets.dfy index c8fa58fd67f..06db986522e 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/mapsubsets.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/rust/mapsubsets.dfy @@ -45,7 +45,7 @@ function LastCharToNat(str: string, digits: map) : (n: nat) } method Main() { - var m := map[1 := 2]; + var m := Map(map[1 := 2]); var s: set> := {{}}; expect |s| == 1; var z := (c => c as CodeUnit)('a');