diff --git a/.gitignore b/.gitignore index b1185b6697c..34f20c8c80f 100644 --- a/.gitignore +++ b/.gitignore @@ -84,3 +84,7 @@ Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/**/*.html Source/IntegrationTests/TestFiles/LitTests/LitTest/**/*.dtr /Source/IntegrationTests/TestFiles/LitTests/LitTest/cli/projectFile/libs/usesLibrary-lib /Source/IntegrationTests/TestFiles/LitTests/LitTest/cli/projectFile/libs/usesLibrary.doo +Source/IntegrationTests/TestFiles/LitTests/LitTest/**/*.deps.json +Source/IntegrationTests/TestFiles/LitTests/LitTest/**/*.csproj +/Source/IntegrationTests/TestFiles/LitTests/LitTest/pythonmodule/multimodule/PythonModule2 +/Source/IntegrationTests/TestFiles/LitTests/LitTest/pythonmodule/singlemodule/dafnysource/PythonModule1 diff --git a/Source/DafnyCore/AST/Members/Function.cs b/Source/DafnyCore/AST/Members/Function.cs index 7a901fe1917..84f6940a220 100644 --- a/Source/DafnyCore/AST/Members/Function.cs +++ b/Source/DafnyCore/AST/Members/Function.cs @@ -96,6 +96,19 @@ public TailStatus public readonly Formal Result; public PreType ResultPreType; public readonly Type ResultType; + public Type OriginalResultTypeWithRenamings() { + if (OverriddenFunction == null) { + return ResultType; + } + + Contract.Assert(TypeArgs.Count == OverriddenFunction.TypeArgs.Count); + var renamings = new Dictionary(); + for (var i = 0; i < TypeArgs.Count; i++) { + renamings.Add(OverriddenFunction.TypeArgs[i], new UserDefinedType(tok, TypeArgs[i])); + } + return OverriddenFunction.ResultType.Subst(renamings); + + } public Expression Body; // an extended expression; Body is readonly after construction, except for any kind of rewrite that may take place around the time of resolution public IToken /*?*/ ByMethodTok; // null iff ByMethodBody is null public BlockStmt /*?*/ ByMethodBody; diff --git a/Source/DafnyCore/Backends/Dafny/DafnyCodeGenerator.cs b/Source/DafnyCore/Backends/Dafny/DafnyCodeGenerator.cs index 9f94e1daeb7..572bd8ad845 100644 --- a/Source/DafnyCore/Backends/Dafny/DafnyCodeGenerator.cs +++ b/Source/DafnyCore/Backends/Dafny/DafnyCodeGenerator.cs @@ -2975,8 +2975,8 @@ protected override void EmitNestedMatchExpr(NestedMatchExpr match, bool inLetExp } protected override void TrOptNestedMatchExpr(NestedMatchExpr match, Type resultType, ConcreteSyntaxTree wr, ConcreteSyntaxTree wStmts, - bool inLetExprBody, IVariable accumulatorVar) { - TrExprOpt(match.Flattened, resultType, wr, wStmts, inLetExprBody, accumulatorVar); + bool inLetExprBody, IVariable accumulatorVar, OptimizedExpressionContinuation continuation) { + TrExprOpt(match.Flattened, resultType, wr, wStmts, inLetExprBody, accumulatorVar, continuation); } protected override void EmitNestedMatchStmt(NestedMatchStmt match, ConcreteSyntaxTree writer) { diff --git a/Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs b/Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs index 10616daf190..856bd85ce5d 100644 --- a/Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs +++ b/Source/DafnyCore/Backends/GoLang/GoCodeGenerator.cs @@ -1985,14 +1985,6 @@ protected override void EmitReturn(List outParams, ConcreteSyntaxTree wr EmitReturnWithCoercions(outParams, null, null, wr); } - protected override void EmitReturnExpr(Expression expr, Type resultType, bool inLetExprBody, ConcreteSyntaxTree wr) { - var wStmts = wr.Fork(); - var w = EmitReturnExpr(wr); - var fromType = thisContext == null ? expr.Type : expr.Type.Subst(thisContext.ParentFormalTypeParametersToActuals); - w = EmitCoercionIfNecessary(fromType, resultType, expr.tok, w); - w.Append(Expr(expr, inLetExprBody, wStmts)); - } - protected void EmitReturnWithCoercions(List outParams, List/*?*/ overriddenOutParams, Dictionary/*?*/ typeMap, ConcreteSyntaxTree wr) { wr.Write("return"); var sep = " "; @@ -2488,10 +2480,6 @@ private string IdName(Declaration decl) { protected override string PrefixForForcedCapitalization => "Go_"; - public override Type ResultTypeAsViewedByFunctionBody(Function f) { - return f.Original.ResultType; - } - protected override string IdMemberName(MemberSelectExpr mse) { return Capitalize(mse.MemberName); } diff --git a/Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs b/Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs index 465fc2bad3c..a0860f9a399 100644 --- a/Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs +++ b/Source/DafnyCore/Backends/Java/JavaCodeGenerator.cs @@ -3606,6 +3606,10 @@ protected override void EmitAbsurd(string message, ConcreteSyntaxTree wr) { message = "unexpected control point"; } + // Wrapping an "if (true) { ... }" around the "break" statement is a way to tell the Java compiler not to give + // errors for any (unreachable) code that may follow. + wr = EmitIf(out var guardWriter, false, wr); + guardWriter.Write("true"); wr.WriteLine($"throw new IllegalArgumentException(\"{message}\");"); } @@ -4369,16 +4373,28 @@ protected override void EmitHaltRecoveryStmt(Statement body, string haltMessageV protected override void EmitNestedMatchExpr(NestedMatchExpr match, bool inLetExprBody, ConcreteSyntaxTree output, ConcreteSyntaxTree wStmts) { - EmitExpr(match.Flattened, inLetExprBody, output, wStmts); + if (match.Cases.Count == 0) { + base.EmitNestedMatchExpr(match, inLetExprBody, output, wStmts); + } else { + EmitExpr(match.Flattened, inLetExprBody, output, wStmts); + } } protected override void TrOptNestedMatchExpr(NestedMatchExpr match, Type resultType, ConcreteSyntaxTree wr, ConcreteSyntaxTree wStmts, - bool inLetExprBody, IVariable accumulatorVar) { - TrExprOpt(match.Flattened, resultType, wr, wStmts, inLetExprBody, accumulatorVar); + bool inLetExprBody, IVariable accumulatorVar, OptimizedExpressionContinuation continuation) { + if (match.Cases.Count == 0) { + base.TrOptNestedMatchExpr(match, resultType, wr, wStmts, inLetExprBody, accumulatorVar, continuation); + } else { + TrExprOpt(match.Flattened, resultType, wr, wStmts, inLetExprBody, accumulatorVar, continuation); + } } protected override void EmitNestedMatchStmt(NestedMatchStmt match, ConcreteSyntaxTree writer) { - TrStmt(match.Flattened, writer); + if (match.Cases.Count == 0) { + base.EmitNestedMatchStmt(match, writer); + } else { + TrStmt(match.Flattened, writer); + } } } } diff --git a/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.Expression.cs b/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.Expression.cs index ee1742881e8..22b17815d15 100644 --- a/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.Expression.cs +++ b/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.Expression.cs @@ -704,7 +704,8 @@ private void EmitMatchExpr(MatchExpr e, bool inLetExprBody, ConcreteSyntaxTree w var sourceType = (UserDefinedType)e.Source.Type.NormalizeExpand(); foreach (MatchCaseExpr mc in e.Cases) { var wCase = MatchCasePrelude(source, sourceType, mc.Ctor, mc.Arguments, i, e.Cases.Count, w); - TrExprOpt(mc.Body, mc.Body.Type, wCase, wStmts, inLetExprBody: true, accumulatorVar: null); + var continuation = new OptimizedExpressionContinuation(EmitReturnExpr, false); + TrExprOpt(mc.Body, mc.Body.Type, wCase, wStmts, inLetExprBody: true, accumulatorVar: null, continuation); i++; } } @@ -715,18 +716,19 @@ private void EmitMatchExpr(MatchExpr e, bool inLetExprBody, ConcreteSyntaxTree w protected virtual void EmitNestedMatchExpr(NestedMatchExpr match, bool inLetExprBody, ConcreteSyntaxTree output, ConcreteSyntaxTree wStmts) { var lambdaBody = EmitAppliedLambda(output, wStmts, match.Tok, match.Type); - TrOptNestedMatchExpr(match, match.Type, lambdaBody, wStmts, inLetExprBody, null); + var continuation = new OptimizedExpressionContinuation(EmitReturnExpr, false); + TrOptNestedMatchExpr(match, match.Type, lambdaBody, wStmts, inLetExprBody, null, continuation); } protected virtual void TrOptNestedMatchExpr(NestedMatchExpr match, Type resultType, ConcreteSyntaxTree wr, - ConcreteSyntaxTree wStmts, bool inLetExprBody, IVariable accumulatorVar) { + ConcreteSyntaxTree wStmts, bool inLetExprBody, IVariable accumulatorVar, OptimizedExpressionContinuation continuation) { wStmts = wr.Fork(); - EmitNestedMatchGeneric(match, (caseIndex, caseBody) => { + EmitNestedMatchGeneric(match, continuation.PreventCaseFallThrough, (caseIndex, caseBody) => { var myCase = match.Cases[caseIndex]; - TrExprOpt(myCase.Body, myCase.Body.Type, caseBody, wStmts, inLetExprBody: true, accumulatorVar: null); - }, wr, true); + TrExprOpt(myCase.Body, myCase.Body.Type, caseBody, wStmts, inLetExprBody, accumulatorVar: null, continuation); + }, inLetExprBody, wr); } private ConcreteSyntaxTree EmitAppliedLambda(ConcreteSyntaxTree output, ConcreteSyntaxTree wStmts, diff --git a/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.Statement.cs b/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.Statement.cs index 8ceac0aba42..9094102284e 100644 --- a/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.Statement.cs +++ b/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.Statement.cs @@ -116,13 +116,25 @@ protected void TrStmt(Statement stmt, ConcreteSyntaxTree wr, ConcreteSyntaxTree if (Options.ForbidNondeterminism) { Error(ErrorId.c_nondeterminism_forbidden, s.Rhs.Tok, "nondeterministic assignment forbidden by the --enforce-determinism option", wr); } - } else if (s.Rhs is ExprRhs eRhs && eRhs.Expr.Resolved is FunctionCallExpr fce && IsTailRecursiveByMethodCall(fce)) { - TrTailCallStmt(s.Tok, fce.Function.ByMethodDecl, fce.Receiver, fce.Args, null, wr); - } else { + } else if (s.Rhs is TypeRhs typeRhs) { var lvalue = CreateLvalue(s.Lhs, wr, wStmts); wStmts = wr.Fork(); - var wRhs = EmitAssignment(lvalue, TypeOfLhs(s.Lhs), TypeOfRhs(s.Rhs), wr, assignStmt.Tok); - TrRhs(s.Rhs, wRhs, wStmts); + var wRhs = EmitAssignment(lvalue, TypeOfLhs(s.Lhs), TypeOfRhs(typeRhs), wr, assignStmt.Tok); + TrRhs(typeRhs, wRhs, wStmts); + } else { + var eRhs = (ExprRhs)s.Rhs; + if (eRhs.Expr.Resolved is FunctionCallExpr fce && IsTailRecursiveByMethodCall(fce)) { + TrTailCallStmt(s.Tok, fce.Function.ByMethodDecl, fce.Receiver, fce.Args, wr); + } else { + var lvalue = CreateLvalue(s.Lhs, wr, wStmts); + var doAssignment = (Expression e, Type resultType, bool inLetExprBody, ConcreteSyntaxTree wrAssignment) => { + var wStmtsBeforeAssignment = wrAssignment.Fork(); + var wRhs = EmitAssignment(lvalue, resultType, e.Type, wrAssignment, assignStmt.Tok); + EmitExpr(e, false, wRhs, wStmtsBeforeAssignment); + }; + var continuation = new OptimizedExpressionContinuation(doAssignment, true); + TrExprOpt(eRhs.Expr, TypeOfLhs(s.Lhs), wr, wStmts, false, null, continuation); + } } break; @@ -511,78 +523,91 @@ private void EmitMatchStmt(ConcreteSyntaxTree wr, MatchStmt s) { } protected virtual void EmitNestedMatchStmt(NestedMatchStmt match, ConcreteSyntaxTree writer) { - EmitNestedMatchGeneric(match, (caseIndex, caseBody) => { + EmitNestedMatchGeneric(match, true, (caseIndex, caseBody) => { TrStmtList(match.Cases[caseIndex].Body, caseBody); - }, writer, false); + }, false, writer); } /// - /// - /// match a + /// Given + /// + /// match a /// case X(Y(b),Z(W(c)) => body1 /// case r => body2 + /// + /// If there are no cases, then emit: + /// + /// throw ABSURD; /// - /// var unmatched = true; - /// if (unmatched && a is X) { - /// var x1 = ((X)a).1; - /// if (x1 is Y) { - /// var b = ((Y)x1).1; + /// Else, emit: /// - /// var x2 = ((X)a).2; - /// if (x2 is Z) { - /// var x4 = ((Z)x2).1; - /// if (x4 is W) { - /// var c = ((W)x4).1; - /// body1; + /// BLOCK { + /// { // this defines the scope for any new local variables in the case + /// if (a is X) { + /// var x0 = ((X)a).0; + /// if (x0 is Y) { + /// var b = ((Y)x0).0; + /// + /// var x1 = ((X)a).1; + /// if (x1 is Z) { + /// var xz0 = ((Z)x1).0; + /// if (xz0 is W) { + /// var c = ((W)xz0).0; + /// + /// body1; + /// break BLOCK; + /// } + /// } /// } - /// } + /// } + /// + /// { + /// var r = a; + /// body2; + /// } /// } - /// } - /// if (unmatched) { - /// var r = a; - /// body2; - /// } /// /// - private void EmitNestedMatchGeneric(INestedMatch match, Action emitBody, - ConcreteSyntaxTree output, bool bodyExpected) { + private void EmitNestedMatchGeneric(INestedMatch match, bool preventCaseFallThrough, Action emitBody, + bool inLetExprBody, ConcreteSyntaxTree output) { if (match.Cases.Count == 0) { - if (bodyExpected) { - // the verifier would have proved we never get here; still, we need some code that will compile - EmitAbsurd(null, output); - } + // the verifier would have proved we never get here; still, we need some code that will compile + EmitAbsurd(null, output); } else { string sourceName = ProtectedFreshId("_source"); - DeclareLocalVar(sourceName, match.Source.Type, match.Source.tok, match.Source, false, output); + DeclareLocalVar(sourceName, match.Source.Type, match.Source.tok, match.Source, inLetExprBody, output); - string unmatched = ProtectedFreshId("unmatched"); - DeclareLocalVar(unmatched, Type.Bool, match.Source.Tok, Expression.CreateBoolLiteral(match.Source.Tok, true), false, output); + var label = preventCaseFallThrough ? ProtectedFreshId("match") : null; + if (label != null) { + output = CreateLabeledCode(label, false, output); + } var sourceType = match.Source.Type.NormalizeExpand(); for (var index = 0; index < match.Cases.Count; index++) { var myCase = match.Cases[index]; var lastCase = index == match.Cases.Count - 1; - var result = EmitIf(out var guardWriter, false, output); - guardWriter.Write(unmatched); - var innerWriter = EmitNestedMatchCaseConditions(sourceName, sourceType, myCase.Pat, result, lastCase); + + var caseBlock = EmitBlock(output); + var innerWriter = EmitNestedMatchCaseConditions(sourceName, sourceType, myCase.Pat, caseBlock, lastCase); Coverage.Instrument(myCase.Tok, "case body", innerWriter); - EmitAssignment(unmatched, Type.Bool, False, Type.Bool, innerWriter); emitBody(index, innerWriter); - } - - if (bodyExpected) { - EmitAbsurd(null, output); + if (label != null && !lastCase) { + EmitBreak(label, innerWriter); + } } } } - private ConcreteSyntaxTree EmitNestedMatchCaseConditions(string sourceName, - Type sourceType, + private ConcreteSyntaxTree EmitNestedMatchCaseConditions(string sourceName, Type sourceType, ExtendedPattern pattern, ConcreteSyntaxTree writer, bool lastCase) { var litExpression = MatchFlattener.GetLiteralExpressionFromPattern(pattern); if (litExpression != null) { + if (lastCase) { + return writer; + } + var thenWriter = EmitIf(out var guardWriter, false, writer); CompileBinOp(BinaryExpr.ResolvedOpcode.EqCommon, sourceType, litExpression.Type, pattern.Tok, Type.Bool, out var opString, out var preOpString, out var postOpString, out var callString, out var staticCallString, @@ -591,22 +616,25 @@ private ConcreteSyntaxTree EmitNestedMatchCaseConditions(string sourceName, var right = new ConcreteSyntaxTree(); EmitExpr(litExpression, false, right, writer); EmitBinaryExprUsingConcreteSyntax(guardWriter, Type.Bool, preOpString, opString, new LineSegment(sourceName), right, callString, staticCallString, postOpString); - writer = thenWriter; + return thenWriter; + } else if (pattern is IdPattern idPattern) { - if (idPattern.BoundVar != null) { - var boundVar = idPattern.BoundVar; - if (boundVar.Tok.val.StartsWith(IdPattern.WildcardString)) { - return writer; - } + if (idPattern.BoundVar == null) { + return EmitNestedMatchStmtCaseConstructor(sourceName, sourceType, idPattern, writer, lastCase); + } + var boundVar = idPattern.BoundVar; + if (!boundVar.Tok.val.StartsWith(IdPattern.WildcardString)) { var valueWriter = DeclareLocalVar(IdName(boundVar), boundVar.Type, idPattern.Tok, writer); valueWriter.Write(sourceName); - return writer; - } else { - writer = EmitNestedMatchStmtCaseConstructor(sourceName, sourceType, idPattern, writer, lastCase); } + return writer; } else if (pattern is DisjunctivePattern disjunctivePattern) { + if (lastCase) { + return writer; + } + string disjunctiveMatch = ProtectedFreshId("disjunctiveMatch"); DeclareLocalVar(disjunctiveMatch, Type.Bool, disjunctivePattern.Tok, Expression.CreateBoolLiteral(disjunctivePattern.Tok, false), false, writer); foreach (var alternative in disjunctivePattern.Alternatives) { @@ -615,11 +643,11 @@ private ConcreteSyntaxTree EmitNestedMatchCaseConditions(string sourceName, } writer = EmitIf(out var guardWriter, false, writer); guardWriter.Write(disjunctiveMatch); + return writer; + } else { throw new Exception(); } - - return writer; } private ConcreteSyntaxTree EmitNestedMatchStmtCaseConstructor(string sourceName, Type sourceType, diff --git a/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.cs b/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.cs index 5a13748cd56..798ccae90ca 100644 --- a/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.cs +++ b/Source/DafnyCore/Backends/SinglePassCodeGenerator/SinglePassCodeGenerator.cs @@ -574,12 +574,13 @@ protected virtual void EmitSetterParameter(ConcreteSyntaxTree wr) { } protected abstract void EmitPrintStmt(ConcreteSyntaxTree wr, Expression arg); protected abstract void EmitReturn(List outParams, ConcreteSyntaxTree wr); - protected virtual void EmitReturnExpr(Expression expr, Type resultType, bool inLetExprBody, ConcreteSyntaxTree wr) { // emits "return ;" for function bodies + protected void EmitReturnExpr(Expression expr, Type resultType, bool inLetExprBody, ConcreteSyntaxTree wr) { // emits "return ;" for function bodies var wStmts = wr.Fork(); - var w = EmitReturnExpr(wr); - w = EmitCoercionIfNecessary(expr.Type, resultType, expr.tok, w); - w = EmitDowncastIfNecessary(expr.Type, resultType, expr.tok, w); - EmitExpr(expr, inLetExprBody, w, wStmts); + wr = EmitReturnExpr(wr); + var fromType = thisContext == null ? expr.Type : expr.Type.Subst(thisContext.ParentFormalTypeParametersToActuals); + wr = EmitCoercionIfNecessary(fromType, resultType, expr.tok, wr); + wr = EmitDowncastIfNecessary(fromType, resultType, expr.tok, wr); + EmitExpr(expr, inLetExprBody, wr, wStmts); } protected virtual void EmitReturnExpr(string returnExpr, ConcreteSyntaxTree wr) { // emits "return ;" for function bodies var w = EmitReturnExpr(wr); @@ -2749,16 +2750,12 @@ private void CompileFunction(Function f, IClassWriter cw, bool lookasideBody) { Coverage.Instrument(f.Body.tok, $"entry to function {f.FullName}", w); Contract.Assert(enclosingFunction == null); enclosingFunction = f; - CompileReturnBody(f.Body, ResultTypeAsViewedByFunctionBody(f), w, accVar); + CompileReturnBody(f.Body, f.OriginalResultTypeWithRenamings(), w, accVar); Contract.Assert(enclosingFunction == f); enclosingFunction = null; } } - public virtual Type ResultTypeAsViewedByFunctionBody(Function f) { - return f.ResultType; - } - public const string STATIC_ARGS_NAME = "args"; private void CompileMethod(Program program, Method m, IClassWriter cw, bool lookasideBody) { @@ -2875,7 +2872,7 @@ void TrCasePatternOpt(CasePattern pat, Expression rhs, Action(CasePattern pat, Expression rhs, Action Continuation, bool PreventCaseFallThrough); + /// /// This method compiles "expr" into a statement context of the target. This typically means that, for example, Dafny let-bound variables can /// be compiled into local variables in the target code, and that Dafny if-then-else expressions can be compiled into if statements in the @@ -2932,11 +2931,12 @@ void TrCasePatternOpt(CasePattern pat, Expression rhs, Action - protected void TrExprOpt(Expression expr, Type resultType, ConcreteSyntaxTree wr, ConcreteSyntaxTree wStmts, bool inLetExprBody, [CanBeNull] IVariable accumulatorVar) { + protected void TrExprOpt(Expression expr, Type resultType, ConcreteSyntaxTree wr, ConcreteSyntaxTree wStmts, bool inLetExprBody, + [CanBeNull] IVariable accumulatorVar, OptimizedExpressionContinuation continuation) { Contract.Requires(expr != null); Contract.Requires(wr != null); - Contract.Requires(resultType != null); Contract.Requires(accumulatorVar == null || (enclosingFunction != null && enclosingFunction.IsAccumulatorTailRecursive)); + Contract.Requires(continuation != null); expr = expr.Resolved; if (expr is LetExpr) { @@ -2948,37 +2948,37 @@ protected void TrExprOpt(Expression expr, Type resultType, ConcreteSyntaxTree wr TrCasePatternOpt(lhs, e.RHSs[i], wr, inLetExprBody); } } - TrExprOpt(e.Body, resultType, wr, wStmts, inLetExprBody, accumulatorVar); + TrExprOpt(e.Body, resultType, wr, wStmts, inLetExprBody, accumulatorVar, continuation); } else { // We haven't optimized the other cases, so fallback to normal compilation - EmitReturnExpr(e, resultType, inLetExprBody, wr); + continuation.Continuation(e, resultType, inLetExprBody, wr); } } else if (expr is ITEExpr) { var e = (ITEExpr)expr; switch (e.HowToCompile) { case ITEExpr.ITECompilation.CompileJustThenBranch: - TrExprOpt(e.Thn, resultType, wr, wStmts, inLetExprBody, accumulatorVar); + TrExprOpt(e.Thn, resultType, wr, wStmts, inLetExprBody, accumulatorVar, continuation); break; case ITEExpr.ITECompilation.CompileJustElseBranch: - TrExprOpt(e.Els, resultType, wr, wStmts, inLetExprBody, accumulatorVar); + TrExprOpt(e.Els, resultType, wr, wStmts, inLetExprBody, accumulatorVar, continuation); break; case ITEExpr.ITECompilation.CompileBothBranches: var thn = EmitIf(out var guardWriter, true, wr); EmitExpr(e.Test, inLetExprBody, guardWriter, wStmts); Coverage.Instrument(e.Thn.tok, "then branch", thn); - TrExprOpt(e.Thn, resultType, thn, wStmts, inLetExprBody, accumulatorVar); + TrExprOpt(e.Thn, resultType, thn, wStmts, inLetExprBody, accumulatorVar, continuation); ConcreteSyntaxTree els = wr; if (!(e.Els is ITEExpr { HowToCompile: ITEExpr.ITECompilation.CompileBothBranches })) { els = EmitBlock(wr); Coverage.Instrument(e.Thn.tok, "else branch", els); } - TrExprOpt(e.Els, resultType, els, wStmts, inLetExprBody, accumulatorVar); + TrExprOpt(e.Els, resultType, els, wStmts, inLetExprBody, accumulatorVar, continuation); break; } } else if (expr is NestedMatchExpr nestedMatchExpr) { - TrOptNestedMatchExpr(nestedMatchExpr, resultType, wr, wStmts, inLetExprBody, accumulatorVar); + TrOptNestedMatchExpr(nestedMatchExpr, resultType, wr, wStmts, inLetExprBody, accumulatorVar, continuation); } else if (expr is MatchExpr) { var e = (MatchExpr)expr; // var _source = E; @@ -3003,69 +3003,20 @@ protected void TrExprOpt(Expression expr, Type resultType, ConcreteSyntaxTree wr var sourceType = (UserDefinedType)e.Source.Type.NormalizeExpand(); foreach (MatchCaseExpr mc in e.Cases) { var w = MatchCasePrelude(source, sourceType, mc.Ctor, mc.Arguments, i, e.Cases.Count, wr); - TrExprOpt(mc.Body, resultType, w, wStmts, inLetExprBody, accumulatorVar); + TrExprOpt(mc.Body, resultType, w, wStmts, inLetExprBody, accumulatorVar, continuation); i++; } } } else if (expr is StmtExpr) { var e = (StmtExpr)expr; - TrExprOpt(e.E, resultType, wr, wStmts, inLetExprBody, accumulatorVar); + TrExprOpt(e.E, resultType, wr, wStmts, inLetExprBody, accumulatorVar, continuation); } else if (expr is FunctionCallExpr fce && fce.Function == enclosingFunction && enclosingFunction.IsTailRecursive) { var e = fce; // compile call as tail-recursive - - // assign the actual in-parameters to temporary variables - var inTmps = new List(); - var inTypes = new List(); - if (!e.Function.IsStatic) { - string inTmp = ProtectedFreshId("_in"); - inTmps.Add(inTmp); - inTypes.Add(null); - DeclareLocalVar(inTmp, null, null, e.Receiver, inLetExprBody, wr); - } - for (int i = 0; i < e.Function.Ins.Count; i++) { - Formal p = e.Function.Ins[i]; - if (!p.IsGhost) { - string inTmp = ProtectedFreshId("_in"); - inTmps.Add(inTmp); - inTypes.Add(e.Args[i].Type); - DeclareLocalVar(inTmp, e.Args[i].Type, p.tok, e.Args[i], inLetExprBody, wr); - } - } - // Now, assign to the formals - int n = 0; - if (!e.Function.IsStatic) { - ConcreteSyntaxTree wRHS = EmitAssignment(IdentLvalue("_this"), null, null, wr, e.tok); - if (thisContext == null) { - wRHS = wr; - } else { - var instantiatedType = e.Receiver.Type.Subst(thisContext.ParentFormalTypeParametersToActuals); - - var contextType = UserDefinedType.FromTopLevelDecl(e.tok, thisContext); - if (contextType.ResolvedClass is ClassLikeDecl { NonNullTypeDecl: { } } cls) { - contextType = UserDefinedType.FromTopLevelDecl(e.tok, cls.NonNullTypeDecl); - } - - wRHS = EmitCoercionIfNecessary(instantiatedType, contextType, e.tok, wRHS); - } - EmitIdentifier(inTmps[n], wRHS); - EndStmt(wr); - n++; - } - foreach (var p in e.Function.Ins) { - if (!p.IsGhost) { - EmitIdentifier( - inTmps[n], - EmitAssignment(IdentLvalue(IdName(p)), p.Type, inTypes[n], wr, e.tok) - ); - n++; - } - } - Contract.Assert(n == inTmps.Count); - // finally, the jump back to the head of the function - EmitJumpToTailCallStart(wr); + Contract.Assert(!inLetExprBody); // a tail call had better not sit inside a target-code lambda + TrTailCall(e.tok, e.Function.IsStatic, e.Function.Ins, e.Receiver, e.Args, wr); } else if (expr is BinaryExpr bin && bin.AccumulatesForTailRecursion != BinaryExpr.AccumulationOperand.None @@ -3096,7 +3047,7 @@ protected void TrExprOpt(Expression expr, Type resultType, ConcreteSyntaxTree wr } var wRhs = EmitAssignment(VariableLvalue(accumulatorVar), enclosingFunction.ResultType, enclosingFunction.ResultType, wr, expr.tok); EmitExpr(rhs, false, wRhs, wStmts); - TrExprOpt(tailTerm, resultType, wr, wStmts, inLetExprBody, accumulatorVar); + TrExprOpt(tailTerm, resultType, wr, wStmts, inLetExprBody, accumulatorVar, continuation); } else { // We haven't optimized any other cases, so fallback to normal compilation @@ -3138,7 +3089,8 @@ protected void TrExprOpt(Expression expr, Type resultType, ConcreteSyntaxTree wr } else { Contract.Assert(accumulatorVar == null); } - EmitReturnExpr(expr, resultType, inLetExprBody, wr); + + continuation.Continuation(expr, resultType, inLetExprBody, wr); } } @@ -3149,7 +3101,8 @@ void CompileReturnBody(Expression body, Type resultType, ConcreteSyntaxTree wr, Contract.Requires(accumulatorVar == null || (enclosingFunction != null && enclosingFunction.IsAccumulatorTailRecursive)); copyInstrWriters.Push(wr.Fork()); var wStmts = wr.Fork(); - TrExprOpt(body.Resolved, resultType, wr, wStmts, false, accumulatorVar); + var continuation = new OptimizedExpressionContinuation(EmitReturnExpr, false); + TrExprOpt(body.Resolved, resultType, wr, wStmts, false, accumulatorVar, continuation); copyInstrWriters.Pop(); } @@ -4373,13 +4326,18 @@ private static Type TypeOfRhs(AssignmentRhs rhs) { } } + /// + /// Emit translation of a call statement. + /// The "receiverReplacement" parameter is allowed to be "null". It must be null for tail recursive calls. + /// protected virtual void TrCallStmt(CallStmt s, string receiverReplacement, ConcreteSyntaxTree wr, ConcreteSyntaxTree wStmts, ConcreteSyntaxTree wStmtsAfterCall) { Contract.Requires(s != null); Contract.Assert(s.Method != null); // follows from the fact that stmt has been successfully resolved if (s.Method == enclosingMethod && enclosingMethod.IsTailRecursive) { // compile call as tail-recursive - TrTailCallStmt(s.Tok, s.Method, s.Receiver, s.Args, receiverReplacement, wr); + Contract.Assert(receiverReplacement == null); // "receiverReplacement" is expected to be "null" for tail recursive calls + TrTailCallStmt(s.Tok, s.Method, s.Receiver, s.Args, wr); } else { // compile call as a regular call var lvalues = new List(); // contains an entry for each non-ghost formal out-parameter, but the entry is null if the actual out-parameter is ghost @@ -4575,29 +4533,30 @@ protected virtual void TrCallStmt(CallStmt s, string receiverReplacement, Concre } } - void TrTailCallStmt(IToken tok, Method method, Expression receiver, List args, string receiverReplacement, ConcreteSyntaxTree wr) { + void TrTailCallStmt(IToken tok, Method method, Expression receiver, List args, ConcreteSyntaxTree wr) { Contract.Requires(tok != null); Contract.Requires(method != null); Contract.Requires(receiver != null); Contract.Requires(args != null); Contract.Requires(method.IsTailRecursive); Contract.Requires(wr != null); + TrTailCall(tok, method.IsStatic, method.Ins, receiver, args, wr); + } + void TrTailCall(IToken tok, bool isStatic, List inParameters, Expression receiver, List args, ConcreteSyntaxTree wr) { // assign the actual in-parameters to temporary variables var inTmps = new List(); - var inTypes = new List(); - if (receiverReplacement != null) { - // TODO: What to do here? When does this happen, what does it mean? - } else if (!method.IsStatic) { - string inTmp = ProtectedFreshId("_in"); + var inTypes = new List(); + if (!isStatic) { + var inTmp = ProtectedFreshId("_in"); inTmps.Add(inTmp); inTypes.Add(null); DeclareLocalVar(inTmp, null, null, receiver, false, wr); } - for (int i = 0; i < method.Ins.Count; i++) { - Formal p = method.Ins[i]; + for (int i = 0; i < inParameters.Count; i++) { + var p = inParameters[i]; if (!p.IsGhost) { - string inTmp = ProtectedFreshId("_in"); + var inTmp = ProtectedFreshId("_in"); inTmps.Add(inTmp); inTypes.Add(args[i].Type); DeclareLocalVar(inTmp, args[i].Type, p.tok, args[i], false, wr); @@ -4605,7 +4564,7 @@ void TrTailCallStmt(IToken tok, Method method, Expression receiver, List dtor_TypeArg_a0 { } public abstract _IType DowncastClone(); public DAST._IType Replace(Dafny.IMap mapping) { - var _pat_let_tv23 = mapping; - var _pat_let_tv24 = mapping; - var _pat_let_tv25 = mapping; - var _pat_let_tv26 = mapping; - var _pat_let_tv27 = mapping; - var _pat_let_tv28 = mapping; - var _pat_let_tv29 = mapping; - var _pat_let_tv30 = mapping; - var _pat_let_tv31 = mapping; - var _pat_let_tv32 = mapping; - var _pat_let_tv33 = mapping; - var _pat_let_tv34 = mapping; - var _pat_let_tv35 = mapping; if ((mapping).Contains(this)) { return Dafny.Map.Select(mapping,this); } else { DAST._IType _source25 = this; - bool unmatched25 = true; - if (unmatched25) { + { if (_source25.is_UserDefined) { DAST._IResolvedType _761_resolved = _source25.dtor_resolved; - unmatched25 = false; - return DAST.Type.create_UserDefined((_761_resolved).Replace(_pat_let_tv23)); + return DAST.Type.create_UserDefined((_761_resolved).Replace(mapping)); } } - if (unmatched25) { + { if (_source25.is_Tuple) { Dafny.ISequence _762_arguments = _source25.dtor_Tuple_a0; - unmatched25 = false; return DAST.Type.create_Tuple(Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Dafny.ISequence, Func>>((_763_mapping, _764_arguments) => ((System.Func)((_765_t) => { return (_765_t).Replace(_763_mapping); -})))(_pat_let_tv24, _762_arguments), _762_arguments)); +})))(mapping, _762_arguments), _762_arguments)); } } - if (unmatched25) { + { if (_source25.is_Array) { DAST._IType _766_element = _source25.dtor_element; BigInteger _767_dims = _source25.dtor_dims; - unmatched25 = false; - return DAST.Type.create_Array((_766_element).Replace(_pat_let_tv25), _767_dims); + return DAST.Type.create_Array((_766_element).Replace(mapping), _767_dims); } } - if (unmatched25) { + { if (_source25.is_Seq) { DAST._IType _768_element = _source25.dtor_element; - unmatched25 = false; - return DAST.Type.create_Seq((_768_element).Replace(_pat_let_tv26)); + return DAST.Type.create_Seq((_768_element).Replace(mapping)); } } - if (unmatched25) { + { if (_source25.is_Set) { DAST._IType _769_element = _source25.dtor_element; - unmatched25 = false; - return DAST.Type.create_Set((_769_element).Replace(_pat_let_tv27)); + return DAST.Type.create_Set((_769_element).Replace(mapping)); } } - if (unmatched25) { + { if (_source25.is_Multiset) { DAST._IType _770_element = _source25.dtor_element; - unmatched25 = false; - return DAST.Type.create_Multiset((_770_element).Replace(_pat_let_tv28)); + return DAST.Type.create_Multiset((_770_element).Replace(mapping)); } } - if (unmatched25) { + { if (_source25.is_Map) { DAST._IType _771_key = _source25.dtor_key; DAST._IType _772_value = _source25.dtor_value; - unmatched25 = false; - return DAST.Type.create_Map((_771_key).Replace(_pat_let_tv29), (_772_value).Replace(_pat_let_tv30)); + return DAST.Type.create_Map((_771_key).Replace(mapping), (_772_value).Replace(mapping)); } } - if (unmatched25) { + { if (_source25.is_SetBuilder) { DAST._IType _773_element = _source25.dtor_element; - unmatched25 = false; - return DAST.Type.create_SetBuilder((_773_element).Replace(_pat_let_tv31)); + return DAST.Type.create_SetBuilder((_773_element).Replace(mapping)); } } - if (unmatched25) { + { if (_source25.is_MapBuilder) { DAST._IType _774_key = _source25.dtor_key; DAST._IType _775_value = _source25.dtor_value; - unmatched25 = false; - return DAST.Type.create_MapBuilder((_774_key).Replace(_pat_let_tv32), (_775_value).Replace(_pat_let_tv33)); + return DAST.Type.create_MapBuilder((_774_key).Replace(mapping), (_775_value).Replace(mapping)); } } - if (unmatched25) { + { if (_source25.is_Arrow) { Dafny.ISequence _776_args = _source25.dtor_args; DAST._IType _777_result = _source25.dtor_result; - unmatched25 = false; return DAST.Type.create_Arrow(Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Dafny.ISequence, Func>>((_778_mapping, _779_args) => ((System.Func)((_780_t) => { return (_780_t).Replace(_778_mapping); -})))(_pat_let_tv34, _776_args), _776_args), (_777_result).Replace(_pat_let_tv35)); +})))(mapping, _776_args), _776_args), (_777_result).Replace(mapping)); } } - if (unmatched25) { - bool disjunctiveMatch0 = false; - disjunctiveMatch0 = true; - disjunctiveMatch0 = true; - disjunctiveMatch0 = true; - disjunctiveMatch0 = true; - if (disjunctiveMatch0) { - unmatched25 = false; - return this; - } + { + return this; } - throw new System.Exception("unexpected control point"); } } } @@ -2326,26 +2293,21 @@ public Dafny.ISequence dtor_extendedTypes { } } public DAST._IResolvedType Replace(Dafny.IMap mapping) { - var _pat_let_tv36 = mapping; return DAST.ResolvedType.create((this).dtor_path, Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func>>((_781_mapping) => ((System.Func)((_782_t) => { return (_782_t).Replace(_781_mapping); })))(mapping), (this).dtor_typeArgs), ((System.Func)(() => { DAST._IResolvedTypeBase _source26 = (this).dtor_kind; - bool unmatched26 = true; - if (unmatched26) { + { if (_source26.is_Newtype) { DAST._IType _783_baseType = _source26.dtor_baseType; DAST._INewtypeRange _784_range = _source26.dtor_range; bool _785_erase = _source26.dtor_erase; - unmatched26 = false; - return DAST.ResolvedTypeBase.create_Newtype((_783_baseType).Replace(_pat_let_tv36), _784_range, _785_erase); + return DAST.ResolvedTypeBase.create_Newtype((_783_baseType).Replace(mapping), _784_range, _785_erase); } } - if (unmatched26) { - unmatched26 = false; + { return (this).dtor_kind; } - throw new System.Exception("unexpected control point"); }))(), (this).dtor_attributes, (this).dtor_properMethods, Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Func>>((_786_mapping) => ((System.Func)((_787_t) => { return (_787_t).Replace(_786_mapping); })))(mapping), (this).dtor_extendedTypes)); diff --git a/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs b/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs index 66c86a7bedd..c43b40450cc 100644 --- a/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs +++ b/Source/DafnyCore/GeneratedFromDafny/DCOMP.cs @@ -133,41 +133,30 @@ public static bool is__idiomatic__rust__id(Dafny.ISequence i) { } public static Std.Wrappers._IOption TraitTypeContainingMethodAux(Dafny.ISequence rs, Dafny.ISequence dafnyName) { - var _pat_let_tv136 = dafnyName; - var _pat_let_tv137 = rs; - var _pat_let_tv138 = dafnyName; if ((new BigInteger((rs).Count)).Sign == 0) { return Std.Wrappers.Option.create_None(); } else { Std.Wrappers._IOption _1121_res = ((System.Func>)(() => { DAST._IType _source51 = (rs).Select(BigInteger.Zero); - bool unmatched51 = true; - if (unmatched51) { + { if (_source51.is_UserDefined) { DAST._IResolvedType _1122_resolvedType = _source51.dtor_resolved; - unmatched51 = false; - return DCOMP.__default.TraitTypeContainingMethod(_1122_resolvedType, _pat_let_tv136); + return DCOMP.__default.TraitTypeContainingMethod(_1122_resolvedType, dafnyName); } } - if (unmatched51) { - unmatched51 = false; + { return Std.Wrappers.Option.create_None(); } - throw new System.Exception("unexpected control point"); }))(); Std.Wrappers._IOption _source52 = _1121_res; - bool unmatched52 = true; - if (unmatched52) { + { if (_source52.is_Some) { - unmatched52 = false; return _1121_res; } } - if (unmatched52) { - unmatched52 = false; - return DCOMP.__default.TraitTypeContainingMethodAux((_pat_let_tv137).Drop(BigInteger.One), _pat_let_tv138); + { + return DCOMP.__default.TraitTypeContainingMethodAux((rs).Drop(BigInteger.One), dafnyName); } - throw new System.Exception("unexpected control point"); } } public static Std.Wrappers._IOption TraitTypeContainingMethod(DAST._IResolvedType r, Dafny.ISequence dafnyName) @@ -797,61 +786,60 @@ public RAST._IMod GenModule(DAST._IModule mod, Dafny.ISequence _1136_generated = Dafny.Sequence.Empty; DAST._IModuleItem _source53 = (body).Select(_1135_i); - bool unmatched53 = true; - if (unmatched53) { + { if (_source53.is_Module) { DAST._IModule _1137_m = _source53.dtor_Module_a0; - unmatched53 = false; RAST._IMod _1138_mm; RAST._IMod _out16; _out16 = (this).GenModule(_1137_m, containingPath); _1138_mm = _out16; _1136_generated = Dafny.Sequence.FromElements(RAST.ModDecl.create_ModDecl(_1138_mm)); + goto after_match1; } } - if (unmatched53) { + { if (_source53.is_Class) { DAST._IClass _1139_c = _source53.dtor_Class_a0; - unmatched53 = false; Dafny.ISequence _out17; _out17 = (this).GenClass(_1139_c, Dafny.Sequence>.Concat(containingPath, Dafny.Sequence>.FromElements((_1139_c).dtor_name))); _1136_generated = _out17; + goto after_match1; } } - if (unmatched53) { + { if (_source53.is_Trait) { DAST._ITrait _1140_t = _source53.dtor_Trait_a0; - unmatched53 = false; Dafny.ISequence _out18; _out18 = (this).GenTrait(_1140_t, containingPath); _1136_generated = _out18; + goto after_match1; } } - if (unmatched53) { + { if (_source53.is_Newtype) { DAST._INewtype _1141_n = _source53.dtor_Newtype_a0; - unmatched53 = false; Dafny.ISequence _out19; _out19 = (this).GenNewtype(_1141_n); _1136_generated = _out19; + goto after_match1; } } - if (unmatched53) { + { if (_source53.is_SynonymType) { DAST._ISynonymType _1142_s = _source53.dtor_SynonymType_a0; - unmatched53 = false; Dafny.ISequence _out20; _out20 = (this).GenSynonymType(_1142_s); _1136_generated = _out20; + goto after_match1; } } - if (unmatched53) { + { DAST._IDatatype _1143_d = _source53.dtor_Datatype_a0; - unmatched53 = false; Dafny.ISequence _out21; _out21 = (this).GenDatatype(_1143_d); _1136_generated = _out21; } + after_match1: ; s = Dafny.Sequence.Concat(s, _1136_generated); } return s; @@ -862,7 +850,11 @@ public void GenTypeParam(DAST._ITypeArgDecl tp, out DAST._IType typeArg, out RAS typeParam = RAST.TypeParamDecl.Default(); typeArg = DAST.Type.create_TypeArg((tp).dtor_name); Dafny.ISequence _1144_genTpConstraint; - _1144_genTpConstraint = ((((tp).dtor_bounds).Contains(DAST.TypeArgBound.create_SupportsEquality())) ? (Dafny.Sequence.FromElements(RAST.__default.DafnyTypeEq)) : (Dafny.Sequence.FromElements(RAST.__default.DafnyType))); + if (((tp).dtor_bounds).Contains(DAST.TypeArgBound.create_SupportsEquality())) { + _1144_genTpConstraint = Dafny.Sequence.FromElements(RAST.__default.DafnyTypeEq); + } else { + _1144_genTpConstraint = Dafny.Sequence.FromElements(RAST.__default.DafnyType); + } if (((tp).dtor_bounds).Contains(DAST.TypeArgBound.create_SupportsDefault())) { _1144_genTpConstraint = Dafny.Sequence.Concat(_1144_genTpConstraint, Dafny.Sequence.FromElements(((RAST.__default.std__type).MSel(Dafny.Sequence.UnicodeFromString("default"))).MSel(Dafny.Sequence.UnicodeFromString("Default")))); } @@ -942,11 +934,9 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _1160_fieldRustName = DCOMP.__default.escapeName(((_1158_field).dtor_formal).dtor_name); _1155_fields = Dafny.Sequence.Concat(_1155_fields, Dafny.Sequence.FromElements(RAST.Field.create(RAST.Visibility.create_PUB(), RAST.Formal.create(_1160_fieldRustName, _1159_fieldType)))); Std.Wrappers._IOption _source54 = (_1158_field).dtor_defaultValue; - bool unmatched54 = true; - if (unmatched54) { + { if (_source54.is_Some) { DAST._IExpression _1161_e = _source54.dtor_value; - unmatched54 = false; { RAST._IExpr _1162_expr; DCOMP._IOwnership _1163___v48; @@ -960,10 +950,10 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _1164___v49 = _out32; _1156_fieldInits = Dafny.Sequence.Concat(_1156_fieldInits, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(_1160_fieldRustName, _1162_expr))); } + goto after_match2; } } - if (unmatched54) { - unmatched54 = false; + { { RAST._IExpr _1165_default; _1165_default = RAST.__default.std__Default__default; @@ -973,6 +963,7 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _1156_fieldInits = Dafny.Sequence.Concat(_1156_fieldInits, Dafny.Sequence.FromElements(RAST.AssignIdentifier.create(_1160_fieldRustName, _1165_default))); } } + after_match2: ; } BigInteger _hi8 = new BigInteger(((c).dtor_typeParams).Count); for (BigInteger _1166_typeParamI = BigInteger.Zero; _1166_typeParamI < _hi8; _1166_typeParamI++) { @@ -1017,15 +1008,13 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) DAST._IType _1178_superClass; _1178_superClass = ((c).dtor_superClasses).Select(_1177_i); DAST._IType _source55 = _1178_superClass; - bool unmatched55 = true; - if (unmatched55) { + { if (_source55.is_UserDefined) { DAST._IResolvedType resolved0 = _source55.dtor_resolved; Dafny.ISequence> _1179_traitPath = resolved0.dtor_path; Dafny.ISequence _1180_typeArgs = resolved0.dtor_typeArgs; DAST._IResolvedTypeBase kind0 = resolved0.dtor_kind; if (kind0.is_Trait) { - unmatched55 = false; { RAST._IType _1181_pathStr; RAST._IType _out39; @@ -1047,12 +1036,13 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(_1185_x)); s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_1152_rTypeParamsDecls, ((RAST.__default.dafny__runtime__type).MSel((this).Upcast)).Apply(Dafny.Sequence.FromElements(RAST.Type.create_DynType(_1184_traitType))), RAST.Type.create_TypeApp(_1176_genSelfPath, _1151_rTypeParams), _1153_whereConstraints, Dafny.Sequence.FromElements(RAST.ImplMember.create_ImplMemberMacro(((RAST.__default.dafny__runtime).MSel((this).UpcastFnMacro)).Apply1(RAST.Expr.create_ExprFromType(RAST.Type.create_DynType(_1184_traitType))))))))); } + goto after_match3; } } } - if (unmatched55) { - unmatched55 = false; + { } + after_match3: ; } return s; } @@ -1128,20 +1118,19 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _1204_constrainedTypeParams = RAST.TypeParamDecl.ToStringMultiple(_1202_rTypeParamsDecls, Dafny.Sequence.Concat(RAST.__default.IND, RAST.__default.IND)); RAST._IType _1205_underlyingType = RAST.Type.Default(); Std.Wrappers._IOption _source56 = DCOMP.COMP.NewtypeToRustType((c).dtor_base, (c).dtor_range); - bool unmatched56 = true; - if (unmatched56) { + { if (_source56.is_Some) { RAST._IType _1206_v = _source56.dtor_value; - unmatched56 = false; _1205_underlyingType = _1206_v; + goto after_match4; } } - if (unmatched56) { - unmatched56 = false; + { RAST._IType _out51; _out51 = (this).GenType((c).dtor_base, DCOMP.GenTypeContext.@default()); _1205_underlyingType = _out51; } + after_match4: ; DAST._IType _1207_resultingType; _1207_resultingType = DAST.Type.create_UserDefined(DAST.ResolvedType.create(Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements(), DAST.ResolvedTypeBase.create_Newtype((c).dtor_base, (c).dtor_range, false), (c).dtor_attributes, Dafny.Sequence>.FromElements(), Dafny.Sequence.FromElements())); Dafny.ISequence _1208_newtypeName; @@ -1150,14 +1139,16 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) RAST._IExpr _1209_fnBody; _1209_fnBody = RAST.Expr.create_Identifier(_1208_newtypeName); Std.Wrappers._IOption _source57 = (c).dtor_witnessExpr; - bool unmatched57 = true; - if (unmatched57) { + { if (_source57.is_Some) { DAST._IExpression _1210_e = _source57.dtor_value; - unmatched57 = false; { DAST._IExpression _1211_e; - _1211_e = ((object.Equals((c).dtor_base, _1207_resultingType)) ? (_1210_e) : (DAST.Expression.create_Convert(_1210_e, (c).dtor_base, _1207_resultingType))); + if (object.Equals((c).dtor_base, _1207_resultingType)) { + _1211_e = _1210_e; + } else { + _1211_e = DAST.Expression.create_Convert(_1210_e, (c).dtor_base, _1207_resultingType); + } RAST._IExpr _1212_eStr; DCOMP._IOwnership _1213___v55; Dafny.ISet> _1214___v56; @@ -1170,28 +1161,27 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _1214___v56 = _out54; _1209_fnBody = (_1209_fnBody).Apply1(_1212_eStr); } + goto after_match5; } } - if (unmatched57) { - unmatched57 = false; + { { _1209_fnBody = (_1209_fnBody).Apply1(RAST.__default.std__Default__default); } } + after_match5: ; RAST._IImplMember _1215_body; _1215_body = RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PRIV(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("default"), Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some(RAST.Type.create_SelfOwned()), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(_1209_fnBody))); Std.Wrappers._IOption _source58 = (c).dtor_constraint; - bool unmatched58 = true; - if (unmatched58) { + { if (_source58.is_None) { - unmatched58 = false; + goto after_match6; } } - if (unmatched58) { + { DAST._INewtypeConstraint value8 = _source58.dtor_value; DAST._IFormal _1216_formal = value8.dtor_variable; Dafny.ISequence _1217_constraintStmts = value8.dtor_constraintStmts; - unmatched58 = false; RAST._IExpr _1218_rStmts; Dafny.ISet> _1219___v57; DCOMP._IEnvironment _1220_newEnv; @@ -1208,6 +1198,7 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _1221_rFormals = _out58; s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_Impl(_1202_rTypeParamsDecls, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_1208_newtypeName), _1201_rTypeParams), _1203_whereConstraints, Dafny.Sequence.FromElements(RAST.ImplMember.create_FnDecl(RAST.Visibility.create_PUB(), RAST.Fn.create(Dafny.Sequence.UnicodeFromString("is"), Dafny.Sequence.FromElements(), _1221_rFormals, Std.Wrappers.Option.create_Some(RAST.Type.create_Bool()), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(_1218_rStmts)))))))); } + after_match6: ; s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_1202_rTypeParamsDecls, RAST.__default.DefaultTrait, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_1208_newtypeName), _1201_rTypeParams), _1203_whereConstraints, Dafny.Sequence.FromElements(_1215_body))))); s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(RAST.ModDecl.create_ImplDecl(RAST.Impl.create_ImplFor(_1202_rTypeParamsDecls, RAST.__default.DafnyPrint, RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_1208_newtypeName), _1201_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(_1202_rTypeParamsDecls, RAST.__default.RawType(Dafny.Sequence.UnicodeFromString("::std::ops::Deref")), RAST.Type.create_TypeApp(RAST.Type.create_TIdentifier(_1208_newtypeName), _1201_rTypeParams), Dafny.Sequence.UnicodeFromString(""), Dafny.Sequence.FromElements(RAST.ImplMember.create_RawImplMember(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("type Target = "), (_1205_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.__default.SelfBorrowed).MSel(Dafny.Sequence.UnicodeFromString("Target"))), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("&self.0")))))))))); @@ -1239,11 +1230,9 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _1228_resultingType = _out63; s = Dafny.Sequence.FromElements(RAST.ModDecl.create_TypeDecl(RAST.TypeSynonym.create(Dafny.Sequence>.FromElements(), _1227_synonymTypeName, _1224_rTypeParamsDecls, _1228_resultingType))); Std.Wrappers._IOption _source59 = (c).dtor_witnessExpr; - bool unmatched59 = true; - if (unmatched59) { + { if (_source59.is_Some) { DAST._IExpression _1229_e = _source59.dtor_value; - unmatched59 = false; { RAST._IExpr _1230_rStmts; Dafny.ISet> _1231___v58; @@ -1269,113 +1258,98 @@ public bool IsSameResolvedType(DAST._IResolvedType r1, DAST._IResolvedType r2) _1236_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(_1236_constantName, Dafny.Sequence.FromElements(), Dafny.Sequence.FromElements(), Std.Wrappers.Option.create_Some(_1228_resultingType), Dafny.Sequence.UnicodeFromString(""), Std.Wrappers.Option.create_Some((_1230_rStmts).Then(_1233_rExpr))))))); } + goto after_match7; } } - if (unmatched59) { - unmatched59 = false; + { } + after_match7: ; return s; } public bool TypeIsEq(DAST._IType t) { DAST._IType _source60 = t; - bool unmatched60 = true; - if (unmatched60) { + { if (_source60.is_UserDefined) { - unmatched60 = false; return true; } } - if (unmatched60) { + { if (_source60.is_Tuple) { Dafny.ISequence _1237_ts = _source60.dtor_Tuple_a0; - unmatched60 = false; return Dafny.Helpers.Id, bool>>((_1238_ts) => Dafny.Helpers.Quantifier((_1238_ts).UniqueElements, true, (((_forall_var_5) => { DAST._IType _1239_t = (DAST._IType)_forall_var_5; return !((_1238_ts).Contains(_1239_t)) || ((this).TypeIsEq(_1239_t)); }))))(_1237_ts); } } - if (unmatched60) { + { if (_source60.is_Array) { DAST._IType _1240_t = _source60.dtor_element; - unmatched60 = false; return (this).TypeIsEq(_1240_t); } } - if (unmatched60) { + { if (_source60.is_Seq) { DAST._IType _1241_t = _source60.dtor_element; - unmatched60 = false; return (this).TypeIsEq(_1241_t); } } - if (unmatched60) { + { if (_source60.is_Set) { DAST._IType _1242_t = _source60.dtor_element; - unmatched60 = false; return (this).TypeIsEq(_1242_t); } } - if (unmatched60) { + { if (_source60.is_Multiset) { DAST._IType _1243_t = _source60.dtor_element; - unmatched60 = false; return (this).TypeIsEq(_1243_t); } } - if (unmatched60) { + { if (_source60.is_Map) { DAST._IType _1244_k = _source60.dtor_key; DAST._IType _1245_v = _source60.dtor_value; - unmatched60 = false; return ((this).TypeIsEq(_1244_k)) && ((this).TypeIsEq(_1245_v)); } } - if (unmatched60) { + { if (_source60.is_SetBuilder) { DAST._IType _1246_t = _source60.dtor_element; - unmatched60 = false; return (this).TypeIsEq(_1246_t); } } - if (unmatched60) { + { if (_source60.is_MapBuilder) { DAST._IType _1247_k = _source60.dtor_key; DAST._IType _1248_v = _source60.dtor_value; - unmatched60 = false; return ((this).TypeIsEq(_1247_k)) && ((this).TypeIsEq(_1248_v)); } } - if (unmatched60) { + { if (_source60.is_Arrow) { - unmatched60 = false; return false; } } - if (unmatched60) { + { if (_source60.is_Primitive) { - unmatched60 = false; return true; } } - if (unmatched60) { + { if (_source60.is_Passthrough) { - unmatched60 = false; return true; } } - if (unmatched60) { + { if (_source60.is_TypeArg) { Dafny.ISequence _1249_i = _source60.dtor_TypeArg_a0; - unmatched60 = false; return true; } } - if (unmatched60) { - unmatched60 = false; + { return true; } - throw new System.Exception("unexpected control point"); } public bool DatatypeIsEq(DAST._IDatatype c) { return (!((c).dtor_isCo)) && (Dafny.Helpers.Id>((_1250_c) => Dafny.Helpers.Quantifier(((_1250_c).dtor_ctors).UniqueElements, true, (((_forall_var_6) => { @@ -1575,7 +1549,9 @@ public bool DatatypeIsEq(DAST._IDatatype c) { goto continue0; } DAST._ITypeArgDecl _1307_coerceTypeParam; - _1307_coerceTypeParam = Dafny.Helpers.Let(_1303_typeParam, _pat_let9_0 => Dafny.Helpers.Let(_pat_let9_0, _1308_dt__update__tmp_h0 => Dafny.Helpers.Let, DAST._ITypeArgDecl>(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_T"), Std.Strings.__default.OfNat(_1302_typeI)), _pat_let10_0 => Dafny.Helpers.Let, DAST._ITypeArgDecl>(_pat_let10_0, _1309_dt__update_hname_h0 => DAST.TypeArgDecl.create(_1309_dt__update_hname_h0, (_1308_dt__update__tmp_h0).dtor_bounds, (_1308_dt__update__tmp_h0).dtor_variance))))); + DAST._ITypeArgDecl _1308_dt__update__tmp_h0 = _1303_typeParam; + Dafny.ISequence _1309_dt__update_hname_h0 = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_T"), Std.Strings.__default.OfNat(_1302_typeI)); + _1307_coerceTypeParam = DAST.TypeArgDecl.create(_1309_dt__update_hname_h0, (_1308_dt__update__tmp_h0).dtor_bounds, (_1308_dt__update__tmp_h0).dtor_variance); DAST._IType _1310_coerceTypeArg; RAST._ITypeParamDecl _1311_rCoerceTypeParamDecl; DAST._IType _out81; @@ -1618,7 +1594,11 @@ public bool DatatypeIsEq(DAST._IDatatype c) { Dafny.ISequence _1321_ctorMatch; _1321_ctorMatch = DCOMP.__default.escapeName((_1320_ctor).dtor_name); Dafny.ISequence _1322_modulePrefix; - _1322_modulePrefix = ((((((c).dtor_enclosingModule))).Equals(Dafny.Sequence.UnicodeFromString("_module"))) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat((((c).dtor_enclosingModule)), Dafny.Sequence.UnicodeFromString(".")))); + if (((((c).dtor_enclosingModule))).Equals(Dafny.Sequence.UnicodeFromString("_module"))) { + _1322_modulePrefix = Dafny.Sequence.UnicodeFromString(""); + } else { + _1322_modulePrefix = Dafny.Sequence.Concat((((c).dtor_enclosingModule)), Dafny.Sequence.UnicodeFromString(".")); + } Dafny.ISequence _1323_ctorName; _1323_ctorName = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1322_modulePrefix, ((c).dtor_name)), Dafny.Sequence.UnicodeFromString(".")), ((_1320_ctor).dtor_name)); if (((new BigInteger((_1323_ctorName).Count)) >= (new BigInteger(13))) && (((_1323_ctorName).Subsequence(BigInteger.Zero, new BigInteger(13))).Equals(Dafny.Sequence.UnicodeFromString("_System.Tuple")))) { @@ -1650,7 +1630,11 @@ public bool DatatypeIsEq(DAST._IDatatype c) { if (_1327_isNumeric) { _1332_fieldName = Std.Wrappers.Option>.GetOr((_1330_dtor).dtor_callName, Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("v"), Std.Strings.__default.OfNat(_1329_j))); } - _1325_hashRhs = (((_1333_formalType).is_Arrow) ? ((_1325_hashRhs).Then(((RAST.Expr.create_LiteralInt(Dafny.Sequence.UnicodeFromString("0"))).Sel(Dafny.Sequence.UnicodeFromString("hash"))).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_state"))))) : ((_1325_hashRhs).Then(((RAST.Expr.create_Identifier(_1332_fieldName)).Sel(Dafny.Sequence.UnicodeFromString("hash"))).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_state")))))); + if ((_1333_formalType).is_Arrow) { + _1325_hashRhs = (_1325_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 { + _1325_hashRhs = (_1325_hashRhs).Then(((RAST.Expr.create_Identifier(_1332_fieldName)).Sel(Dafny.Sequence.UnicodeFromString("hash"))).Apply1(RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("_state")))); + } _1328_ctorMatchInner = Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1328_ctorMatchInner, ((_1327_isNumeric) ? (_1332_fieldName) : (_1331_patternName))), Dafny.Sequence.UnicodeFromString(", ")); if ((_1329_j).Sign == 1) { _1324_printRhs = (_1324_printRhs).Then(RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("write!(_formatter, \", \")?"))); @@ -1748,7 +1732,13 @@ public static RAST._IType GenPath(Dafny.ISequence> p r = RAST.Type.create_SelfOwned(); return r; } else { - r = ((((((p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("std"))) ? (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString(""))) : (((((((p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("_System"))) ? (RAST.__default.dafny__runtime__type) : (RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("super")))))); + if (((((p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("std"))) { + r = RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("")); + } else if (((((p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("_System"))) { + r = RAST.__default.dafny__runtime__type; + } else { + r = RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("super")); + } BigInteger _hi22 = new BigInteger((p).Count); for (BigInteger _1354_i = BigInteger.Zero; _1354_i < _hi22; _1354_i++) { r = (r).MSel(DCOMP.__default.escapeName(((p).Select(_1354_i)))); @@ -1763,7 +1753,13 @@ public static RAST._IExpr GenPathExpr(Dafny.ISequence.UnicodeFromString("std"))) ? (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString(""))) : (((((((p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("_System"))) ? (RAST.__default.dafny__runtime) : (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("super")))))); + if (((((p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("std"))) { + r = RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("")); + } else if (((((p).Select(BigInteger.Zero)))).Equals(Dafny.Sequence.UnicodeFromString("_System"))) { + r = RAST.__default.dafny__runtime; + } else { + r = RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("super")); + } BigInteger _hi23 = new BigInteger((p).Count); for (BigInteger _1355_i = BigInteger.Zero; _1355_i < _hi23; _1355_i++) { r = (r).MSel(DCOMP.__default.escapeName(((p).Select(_1355_i)))); @@ -1792,11 +1788,9 @@ public RAST._IType GenType(DAST._IType c, DCOMP._IGenTypeContext genTypeContext) { RAST._IType s = RAST.Type.Default(); DAST._IType _source61 = c; - bool unmatched61 = true; - if (unmatched61) { + { if (_source61.is_UserDefined) { DAST._IResolvedType _1358_resolved = _source61.dtor_resolved; - unmatched61 = false; { RAST._IType _1359_t; RAST._IType _out86; @@ -1804,32 +1798,30 @@ public RAST._IType GenType(DAST._IType c, DCOMP._IGenTypeContext genTypeContext) _1359_t = _out86; Dafny.ISequence _1360_typeArgs; Dafny.ISequence _out87; - _out87 = (this).GenTypeArgs((_1358_resolved).dtor_typeArgs, Dafny.Helpers.Let(genTypeContext, _pat_let11_0 => Dafny.Helpers.Let(_pat_let11_0, _1361_dt__update__tmp_h0 => Dafny.Helpers.Let(false, _pat_let12_0 => Dafny.Helpers.Let(_pat_let12_0, _1362_dt__update_hforTraitParents_h0 => DCOMP.GenTypeContext.create((_1361_dt__update__tmp_h0).dtor_inBinding, (_1361_dt__update__tmp_h0).dtor_inFn, _1362_dt__update_hforTraitParents_h0)))))); + _out87 = (this).GenTypeArgs((_1358_resolved).dtor_typeArgs, Dafny.Helpers.Let(genTypeContext, _pat_let9_0 => Dafny.Helpers.Let(_pat_let9_0, _1361_dt__update__tmp_h0 => Dafny.Helpers.Let(false, _pat_let10_0 => Dafny.Helpers.Let(_pat_let10_0, _1362_dt__update_hforTraitParents_h0 => DCOMP.GenTypeContext.create((_1361_dt__update__tmp_h0).dtor_inBinding, (_1361_dt__update__tmp_h0).dtor_inFn, _1362_dt__update_hforTraitParents_h0)))))); _1360_typeArgs = _out87; s = RAST.Type.create_TypeApp(_1359_t, _1360_typeArgs); DAST._IResolvedTypeBase _source62 = (_1358_resolved).dtor_kind; - bool unmatched62 = true; - if (unmatched62) { + { if (_source62.is_Class) { - unmatched62 = false; { s = (this).Object(s); } + goto after_match9; } } - if (unmatched62) { + { if (_source62.is_Datatype) { - unmatched62 = false; { if ((this).IsRcWrapped((_1358_resolved).dtor_attributes)) { s = RAST.__default.Rc(s); } } + goto after_match9; } } - if (unmatched62) { + { if (_source62.is_Trait) { - unmatched62 = false; { if (((_1358_resolved).dtor_path).Equals(Dafny.Sequence>.FromElements(Dafny.Sequence.UnicodeFromString("_System"), Dafny.Sequence.UnicodeFromString("object")))) { s = ((RAST.__default.std__type).MSel(Dafny.Sequence.UnicodeFromString("any"))).MSel(Dafny.Sequence.UnicodeFromString("Any")); @@ -1838,48 +1830,48 @@ public RAST._IType GenType(DAST._IType c, DCOMP._IGenTypeContext genTypeContext) s = (this).Object(RAST.Type.create_DynType(s)); } } + goto after_match9; } } - if (unmatched62) { + { DAST._IType _1363_t = _source62.dtor_baseType; DAST._INewtypeRange _1364_range = _source62.dtor_range; bool _1365_erased = _source62.dtor_erase; - unmatched62 = false; { if (_1365_erased) { Std.Wrappers._IOption _source63 = DCOMP.COMP.NewtypeToRustType(_1363_t, _1364_range); - bool unmatched63 = true; - if (unmatched63) { + { if (_source63.is_Some) { RAST._IType _1366_v = _source63.dtor_value; - unmatched63 = false; s = _1366_v; + goto after_match10; } } - if (unmatched63) { - unmatched63 = false; + { } + after_match10: ; } } } + after_match9: ; } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_Object) { - unmatched61 = false; { s = ((RAST.__default.std__type).MSel(Dafny.Sequence.UnicodeFromString("any"))).MSel(Dafny.Sequence.UnicodeFromString("Any")); if (!((genTypeContext).dtor_forTraitParents)) { s = (this).Object(RAST.Type.create_DynType(s)); } } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_Tuple) { Dafny.ISequence _1367_types = _source61.dtor_Tuple_a0; - unmatched61 = false; { Dafny.ISequence _1368_args; _1368_args = Dafny.Sequence.FromElements(); @@ -1888,27 +1880,31 @@ public RAST._IType GenType(DAST._IType c, DCOMP._IGenTypeContext genTypeContext) while ((_1369_i) < (new BigInteger((_1367_types).Count))) { RAST._IType _1370_generated; RAST._IType _out88; - _out88 = (this).GenType((_1367_types).Select(_1369_i), Dafny.Helpers.Let(genTypeContext, _pat_let13_0 => Dafny.Helpers.Let(_pat_let13_0, _1371_dt__update__tmp_h1 => Dafny.Helpers.Let(false, _pat_let14_0 => Dafny.Helpers.Let(_pat_let14_0, _1372_dt__update_hforTraitParents_h1 => DCOMP.GenTypeContext.create((_1371_dt__update__tmp_h1).dtor_inBinding, (_1371_dt__update__tmp_h1).dtor_inFn, _1372_dt__update_hforTraitParents_h1)))))); + _out88 = (this).GenType((_1367_types).Select(_1369_i), Dafny.Helpers.Let(genTypeContext, _pat_let11_0 => Dafny.Helpers.Let(_pat_let11_0, _1371_dt__update__tmp_h1 => Dafny.Helpers.Let(false, _pat_let12_0 => Dafny.Helpers.Let(_pat_let12_0, _1372_dt__update_hforTraitParents_h1 => DCOMP.GenTypeContext.create((_1371_dt__update__tmp_h1).dtor_inBinding, (_1371_dt__update__tmp_h1).dtor_inFn, _1372_dt__update_hforTraitParents_h1)))))); _1370_generated = _out88; _1368_args = Dafny.Sequence.Concat(_1368_args, Dafny.Sequence.FromElements(_1370_generated)); _1369_i = (_1369_i) + (BigInteger.One); } - s = (((new BigInteger((_1367_types).Count)) <= (RAST.__default.MAX__TUPLE__SIZE)) ? (RAST.Type.create_TupleType(_1368_args)) : (RAST.__default.SystemTupleType(_1368_args))); + if ((new BigInteger((_1367_types).Count)) <= (RAST.__default.MAX__TUPLE__SIZE)) { + s = RAST.Type.create_TupleType(_1368_args); + } else { + s = RAST.__default.SystemTupleType(_1368_args); + } } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_Array) { DAST._IType _1373_element = _source61.dtor_element; BigInteger _1374_dims = _source61.dtor_dims; - unmatched61 = false; { if ((_1374_dims) > (new BigInteger(16))) { s = RAST.__default.RawType(Dafny.Sequence.UnicodeFromString("Array of dimensions greater than 16")); } else { RAST._IType _1375_elem; RAST._IType _out89; - _out89 = (this).GenType(_1373_element, Dafny.Helpers.Let(genTypeContext, _pat_let15_0 => Dafny.Helpers.Let(_pat_let15_0, _1376_dt__update__tmp_h2 => Dafny.Helpers.Let(false, _pat_let16_0 => Dafny.Helpers.Let(_pat_let16_0, _1377_dt__update_hforTraitParents_h2 => DCOMP.GenTypeContext.create((_1376_dt__update__tmp_h2).dtor_inBinding, (_1376_dt__update__tmp_h2).dtor_inFn, _1377_dt__update_hforTraitParents_h2)))))); + _out89 = (this).GenType(_1373_element, Dafny.Helpers.Let(genTypeContext, _pat_let13_0 => Dafny.Helpers.Let(_pat_let13_0, _1376_dt__update__tmp_h2 => Dafny.Helpers.Let(false, _pat_let14_0 => Dafny.Helpers.Let(_pat_let14_0, _1377_dt__update_hforTraitParents_h2 => DCOMP.GenTypeContext.create((_1376_dt__update__tmp_h2).dtor_inBinding, (_1376_dt__update__tmp_h2).dtor_inFn, _1377_dt__update_hforTraitParents_h2)))))); _1375_elem = _out89; if ((_1374_dims) == (BigInteger.One)) { s = RAST.Type.create_Array(_1375_elem, Std.Wrappers.Option>.create_None()); @@ -1921,56 +1917,56 @@ public RAST._IType GenType(DAST._IType c, DCOMP._IGenTypeContext genTypeContext) } } } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_Seq) { DAST._IType _1379_element = _source61.dtor_element; - unmatched61 = false; { RAST._IType _1380_elem; RAST._IType _out90; - _out90 = (this).GenType(_1379_element, Dafny.Helpers.Let(genTypeContext, _pat_let17_0 => Dafny.Helpers.Let(_pat_let17_0, _1381_dt__update__tmp_h3 => Dafny.Helpers.Let(false, _pat_let18_0 => Dafny.Helpers.Let(_pat_let18_0, _1382_dt__update_hforTraitParents_h3 => DCOMP.GenTypeContext.create((_1381_dt__update__tmp_h3).dtor_inBinding, (_1381_dt__update__tmp_h3).dtor_inFn, _1382_dt__update_hforTraitParents_h3)))))); + _out90 = (this).GenType(_1379_element, Dafny.Helpers.Let(genTypeContext, _pat_let15_0 => Dafny.Helpers.Let(_pat_let15_0, _1381_dt__update__tmp_h3 => Dafny.Helpers.Let(false, _pat_let16_0 => Dafny.Helpers.Let(_pat_let16_0, _1382_dt__update_hforTraitParents_h3 => DCOMP.GenTypeContext.create((_1381_dt__update__tmp_h3).dtor_inBinding, (_1381_dt__update__tmp_h3).dtor_inFn, _1382_dt__update_hforTraitParents_h3)))))); _1380_elem = _out90; s = RAST.Type.create_TypeApp((RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("Sequence")), Dafny.Sequence.FromElements(_1380_elem)); } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_Set) { DAST._IType _1383_element = _source61.dtor_element; - unmatched61 = false; { RAST._IType _1384_elem; RAST._IType _out91; - _out91 = (this).GenType(_1383_element, Dafny.Helpers.Let(genTypeContext, _pat_let19_0 => Dafny.Helpers.Let(_pat_let19_0, _1385_dt__update__tmp_h4 => Dafny.Helpers.Let(false, _pat_let20_0 => Dafny.Helpers.Let(_pat_let20_0, _1386_dt__update_hforTraitParents_h4 => DCOMP.GenTypeContext.create((_1385_dt__update__tmp_h4).dtor_inBinding, (_1385_dt__update__tmp_h4).dtor_inFn, _1386_dt__update_hforTraitParents_h4)))))); + _out91 = (this).GenType(_1383_element, Dafny.Helpers.Let(genTypeContext, _pat_let17_0 => Dafny.Helpers.Let(_pat_let17_0, _1385_dt__update__tmp_h4 => Dafny.Helpers.Let(false, _pat_let18_0 => Dafny.Helpers.Let(_pat_let18_0, _1386_dt__update_hforTraitParents_h4 => DCOMP.GenTypeContext.create((_1385_dt__update__tmp_h4).dtor_inBinding, (_1385_dt__update__tmp_h4).dtor_inFn, _1386_dt__update_hforTraitParents_h4)))))); _1384_elem = _out91; s = RAST.Type.create_TypeApp((RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("Set")), Dafny.Sequence.FromElements(_1384_elem)); } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_Multiset) { DAST._IType _1387_element = _source61.dtor_element; - unmatched61 = false; { RAST._IType _1388_elem; RAST._IType _out92; - _out92 = (this).GenType(_1387_element, Dafny.Helpers.Let(genTypeContext, _pat_let21_0 => Dafny.Helpers.Let(_pat_let21_0, _1389_dt__update__tmp_h5 => Dafny.Helpers.Let(false, _pat_let22_0 => Dafny.Helpers.Let(_pat_let22_0, _1390_dt__update_hforTraitParents_h5 => DCOMP.GenTypeContext.create((_1389_dt__update__tmp_h5).dtor_inBinding, (_1389_dt__update__tmp_h5).dtor_inFn, _1390_dt__update_hforTraitParents_h5)))))); + _out92 = (this).GenType(_1387_element, Dafny.Helpers.Let(genTypeContext, _pat_let19_0 => Dafny.Helpers.Let(_pat_let19_0, _1389_dt__update__tmp_h5 => Dafny.Helpers.Let(false, _pat_let20_0 => Dafny.Helpers.Let(_pat_let20_0, _1390_dt__update_hforTraitParents_h5 => DCOMP.GenTypeContext.create((_1389_dt__update__tmp_h5).dtor_inBinding, (_1389_dt__update__tmp_h5).dtor_inFn, _1390_dt__update_hforTraitParents_h5)))))); _1388_elem = _out92; s = RAST.Type.create_TypeApp((RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("Multiset")), Dafny.Sequence.FromElements(_1388_elem)); } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_Map) { DAST._IType _1391_key = _source61.dtor_key; DAST._IType _1392_value = _source61.dtor_value; - unmatched61 = false; { RAST._IType _1393_keyType; RAST._IType _out93; - _out93 = (this).GenType(_1391_key, Dafny.Helpers.Let(genTypeContext, _pat_let23_0 => Dafny.Helpers.Let(_pat_let23_0, _1394_dt__update__tmp_h6 => Dafny.Helpers.Let(false, _pat_let24_0 => Dafny.Helpers.Let(_pat_let24_0, _1395_dt__update_hforTraitParents_h6 => DCOMP.GenTypeContext.create((_1394_dt__update__tmp_h6).dtor_inBinding, (_1394_dt__update__tmp_h6).dtor_inFn, _1395_dt__update_hforTraitParents_h6)))))); + _out93 = (this).GenType(_1391_key, Dafny.Helpers.Let(genTypeContext, _pat_let21_0 => Dafny.Helpers.Let(_pat_let21_0, _1394_dt__update__tmp_h6 => Dafny.Helpers.Let(false, _pat_let22_0 => Dafny.Helpers.Let(_pat_let22_0, _1395_dt__update_hforTraitParents_h6 => DCOMP.GenTypeContext.create((_1394_dt__update__tmp_h6).dtor_inBinding, (_1394_dt__update__tmp_h6).dtor_inFn, _1395_dt__update_hforTraitParents_h6)))))); _1393_keyType = _out93; RAST._IType _1396_valueType; RAST._IType _out94; @@ -1978,17 +1974,17 @@ public RAST._IType GenType(DAST._IType c, DCOMP._IGenTypeContext genTypeContext) _1396_valueType = _out94; s = RAST.Type.create_TypeApp((RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("Map")), Dafny.Sequence.FromElements(_1393_keyType, _1396_valueType)); } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_MapBuilder) { DAST._IType _1397_key = _source61.dtor_key; DAST._IType _1398_value = _source61.dtor_value; - unmatched61 = false; { RAST._IType _1399_keyType; RAST._IType _out95; - _out95 = (this).GenType(_1397_key, Dafny.Helpers.Let(genTypeContext, _pat_let25_0 => Dafny.Helpers.Let(_pat_let25_0, _1400_dt__update__tmp_h7 => Dafny.Helpers.Let(false, _pat_let26_0 => Dafny.Helpers.Let(_pat_let26_0, _1401_dt__update_hforTraitParents_h7 => DCOMP.GenTypeContext.create((_1400_dt__update__tmp_h7).dtor_inBinding, (_1400_dt__update__tmp_h7).dtor_inFn, _1401_dt__update_hforTraitParents_h7)))))); + _out95 = (this).GenType(_1397_key, Dafny.Helpers.Let(genTypeContext, _pat_let23_0 => Dafny.Helpers.Let(_pat_let23_0, _1400_dt__update__tmp_h7 => Dafny.Helpers.Let(false, _pat_let24_0 => Dafny.Helpers.Let(_pat_let24_0, _1401_dt__update_hforTraitParents_h7 => DCOMP.GenTypeContext.create((_1400_dt__update__tmp_h7).dtor_inBinding, (_1400_dt__update__tmp_h7).dtor_inFn, _1401_dt__update_hforTraitParents_h7)))))); _1399_keyType = _out95; RAST._IType _1402_valueType; RAST._IType _out96; @@ -1996,26 +1992,26 @@ public RAST._IType GenType(DAST._IType c, DCOMP._IGenTypeContext genTypeContext) _1402_valueType = _out96; s = RAST.Type.create_TypeApp((RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("MapBuilder")), Dafny.Sequence.FromElements(_1399_keyType, _1402_valueType)); } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_SetBuilder) { DAST._IType _1403_elem = _source61.dtor_element; - unmatched61 = false; { RAST._IType _1404_elemType; RAST._IType _out97; - _out97 = (this).GenType(_1403_elem, Dafny.Helpers.Let(genTypeContext, _pat_let27_0 => Dafny.Helpers.Let(_pat_let27_0, _1405_dt__update__tmp_h8 => Dafny.Helpers.Let(false, _pat_let28_0 => Dafny.Helpers.Let(_pat_let28_0, _1406_dt__update_hforTraitParents_h8 => DCOMP.GenTypeContext.create((_1405_dt__update__tmp_h8).dtor_inBinding, (_1405_dt__update__tmp_h8).dtor_inFn, _1406_dt__update_hforTraitParents_h8)))))); + _out97 = (this).GenType(_1403_elem, Dafny.Helpers.Let(genTypeContext, _pat_let25_0 => Dafny.Helpers.Let(_pat_let25_0, _1405_dt__update__tmp_h8 => Dafny.Helpers.Let(false, _pat_let26_0 => Dafny.Helpers.Let(_pat_let26_0, _1406_dt__update_hforTraitParents_h8 => DCOMP.GenTypeContext.create((_1405_dt__update__tmp_h8).dtor_inBinding, (_1405_dt__update__tmp_h8).dtor_inFn, _1406_dt__update_hforTraitParents_h8)))))); _1404_elemType = _out97; s = RAST.Type.create_TypeApp((RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("SetBuilder")), Dafny.Sequence.FromElements(_1404_elemType)); } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_Arrow) { Dafny.ISequence _1407_args = _source61.dtor_args; DAST._IType _1408_result = _source61.dtor_result; - unmatched61 = false; { Dafny.ISequence _1409_argTypes; _1409_argTypes = Dafny.Sequence.FromElements(); @@ -2024,7 +2020,7 @@ public RAST._IType GenType(DAST._IType c, DCOMP._IGenTypeContext genTypeContext) while ((_1410_i) < (new BigInteger((_1407_args).Count))) { RAST._IType _1411_generated; RAST._IType _out98; - _out98 = (this).GenType((_1407_args).Select(_1410_i), Dafny.Helpers.Let(genTypeContext, _pat_let29_0 => Dafny.Helpers.Let(_pat_let29_0, _1412_dt__update__tmp_h9 => Dafny.Helpers.Let(false, _pat_let30_0 => Dafny.Helpers.Let(_pat_let30_0, _1413_dt__update_hforTraitParents_h9 => Dafny.Helpers.Let(true, _pat_let31_0 => Dafny.Helpers.Let(_pat_let31_0, _1414_dt__update_hinFn_h0 => DCOMP.GenTypeContext.create((_1412_dt__update__tmp_h9).dtor_inBinding, _1414_dt__update_hinFn_h0, _1413_dt__update_hforTraitParents_h9)))))))); + _out98 = (this).GenType((_1407_args).Select(_1410_i), Dafny.Helpers.Let(genTypeContext, _pat_let27_0 => Dafny.Helpers.Let(_pat_let27_0, _1412_dt__update__tmp_h9 => Dafny.Helpers.Let(false, _pat_let28_0 => Dafny.Helpers.Let(_pat_let28_0, _1413_dt__update_hforTraitParents_h9 => Dafny.Helpers.Let(true, _pat_let29_0 => Dafny.Helpers.Let(_pat_let29_0, _1414_dt__update_hinFn_h0 => DCOMP.GenTypeContext.create((_1412_dt__update__tmp_h9).dtor_inBinding, _1414_dt__update_hinFn_h0, _1413_dt__update_hforTraitParents_h9)))))))); _1411_generated = _out98; _1409_argTypes = Dafny.Sequence.Concat(_1409_argTypes, Dafny.Sequence.FromElements(RAST.Type.create_Borrowed(_1411_generated))); _1410_i = (_1410_i) + (BigInteger.One); @@ -2035,59 +2031,59 @@ public RAST._IType GenType(DAST._IType c, DCOMP._IGenTypeContext genTypeContext) _1415_resultType = _out99; s = RAST.__default.Rc(RAST.Type.create_DynType(RAST.Type.create_FnType(_1409_argTypes, _1415_resultType))); } + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_TypeArg) { Dafny.ISequence _h90 = _source61.dtor_TypeArg_a0; Dafny.ISequence _1416_name = _h90; - unmatched61 = false; s = RAST.Type.create_TIdentifier(DCOMP.__default.escapeName(_1416_name)); + goto after_match8; } } - if (unmatched61) { + { if (_source61.is_Primitive) { DAST._IPrimitive _1417_p = _source61.dtor_Primitive_a0; - unmatched61 = false; { DAST._IPrimitive _source64 = _1417_p; - bool unmatched64 = true; - if (unmatched64) { + { if (_source64.is_Int) { - unmatched64 = false; s = (RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("DafnyInt")); + goto after_match11; } } - if (unmatched64) { + { if (_source64.is_Real) { - unmatched64 = false; s = (RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("BigRational")); + goto after_match11; } } - if (unmatched64) { + { if (_source64.is_String) { - unmatched64 = false; s = RAST.Type.create_TypeApp((RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("Sequence")), Dafny.Sequence.FromElements((RAST.__default.dafny__runtime__type).MSel((this).DafnyChar))); + goto after_match11; } } - if (unmatched64) { + { if (_source64.is_Bool) { - unmatched64 = false; s = RAST.Type.create_Bool(); + goto after_match11; } } - if (unmatched64) { - unmatched64 = false; + { s = (RAST.__default.dafny__runtime__type).MSel((this).DafnyChar); } + after_match11: ; } + goto after_match8; } } - if (unmatched61) { + { Dafny.ISequence _1418_v = _source61.dtor_Passthrough_a0; - unmatched61 = false; s = RAST.__default.RawType(_1418_v); } + after_match8: ; return s; } public bool EnclosingIsTrait(DAST._IType tpe) { @@ -2102,17 +2098,13 @@ public void GenClassImplBody(Dafny.ISequence body, bool forTrait, BigInteger _hi25 = new BigInteger((body).Count); for (BigInteger _1419_i = BigInteger.Zero; _1419_i < _hi25; _1419_i++) { DAST._IMethod _source65 = (body).Select(_1419_i); - bool unmatched65 = true; - if (unmatched65) { + { DAST._IMethod _1420_m = _source65; - unmatched65 = false; { Std.Wrappers._IOption>> _source66 = (_1420_m).dtor_overridingPath; - bool unmatched66 = true; - if (unmatched66) { + { if (_source66.is_Some) { Dafny.ISequence> _1421_p = _source66.dtor_value; - unmatched66 = false; { Dafny.ISequence _1422_existing; _1422_existing = Dafny.Sequence.FromElements(); @@ -2129,10 +2121,10 @@ public void GenClassImplBody(Dafny.ISequence body, bool forTrait, _1422_existing = Dafny.Sequence.Concat(_1422_existing, Dafny.Sequence.FromElements(_1423_genMethod)); traitBodies = Dafny.Map>, Dafny.ISequence>.Merge(traitBodies, Dafny.Map>, Dafny.ISequence>.FromElements(new Dafny.Pair>, Dafny.ISequence>(_1421_p, _1422_existing))); } + goto after_match13; } } - if (unmatched66) { - unmatched66 = false; + { { RAST._IImplMember _1424_generated; RAST._IImplMember _out101; @@ -2141,8 +2133,10 @@ public void GenClassImplBody(Dafny.ISequence body, bool forTrait, s = Dafny.Sequence.Concat(s, Dafny.Sequence.FromElements(_1424_generated)); } } + after_match13: ; } } + after_match12: ; } } public Dafny.ISequence GenParams(Dafny.ISequence @params) @@ -2196,28 +2190,27 @@ public RAST._IImplMember GenMethod(DAST._IMethod m, bool forTrait, DAST._IType e if ((m).dtor_outVarsAreUninitFieldsToAssign) { _1437_selfId = Dafny.Sequence.UnicodeFromString("this"); } - var _pat_let_tv139 = enclosingTypeParams; - var _pat_let_tv140 = enclosingType; + var _pat_let_tv2 = enclosingTypeParams; DAST._IType _1438_instanceType; - _1438_instanceType = ((System.Func)(() => { - DAST._IType _source67 = enclosingType; - bool unmatched67 = true; - if (unmatched67) { - if (_source67.is_UserDefined) { - DAST._IResolvedType _1439_r = _source67.dtor_resolved; - unmatched67 = false; - return DAST.Type.create_UserDefined(Dafny.Helpers.Let(_1439_r, _pat_let32_0 => Dafny.Helpers.Let(_pat_let32_0, _1440_dt__update__tmp_h0 => Dafny.Helpers.Let, DAST._IResolvedType>(_pat_let_tv139, _pat_let33_0 => Dafny.Helpers.Let, DAST._IResolvedType>(_pat_let33_0, _1441_dt__update_htypeArgs_h0 => DAST.ResolvedType.create((_1440_dt__update__tmp_h0).dtor_path, _1441_dt__update_htypeArgs_h0, (_1440_dt__update__tmp_h0).dtor_kind, (_1440_dt__update__tmp_h0).dtor_attributes, (_1440_dt__update__tmp_h0).dtor_properMethods, (_1440_dt__update__tmp_h0).dtor_extendedTypes)))))); - } - } - if (unmatched67) { - unmatched67 = false; - return _pat_let_tv140; + DAST._IType _source67 = enclosingType; + { + if (_source67.is_UserDefined) { + DAST._IResolvedType _1439_r = _source67.dtor_resolved; + _1438_instanceType = DAST.Type.create_UserDefined(Dafny.Helpers.Let(_1439_r, _pat_let30_0 => Dafny.Helpers.Let(_pat_let30_0, _1440_dt__update__tmp_h0 => Dafny.Helpers.Let, DAST._IResolvedType>(_pat_let_tv2, _pat_let31_0 => Dafny.Helpers.Let, DAST._IResolvedType>(_pat_let31_0, _1441_dt__update_htypeArgs_h0 => DAST.ResolvedType.create((_1440_dt__update__tmp_h0).dtor_path, _1441_dt__update_htypeArgs_h0, (_1440_dt__update__tmp_h0).dtor_kind, (_1440_dt__update__tmp_h0).dtor_attributes, (_1440_dt__update__tmp_h0).dtor_properMethods, (_1440_dt__update__tmp_h0).dtor_extendedTypes)))))); + goto after_match14; } - throw new System.Exception("unexpected control point"); - }))(); + } + { + _1438_instanceType = enclosingType; + } + after_match14: ; if (forTrait) { RAST._IFormal _1442_selfFormal; - _1442_selfFormal = (((m).dtor_wasFunction) ? (RAST.Formal.selfBorrowed) : (RAST.Formal.selfBorrowedMut)); + if ((m).dtor_wasFunction) { + _1442_selfFormal = RAST.Formal.selfBorrowed; + } else { + _1442_selfFormal = RAST.Formal.selfBorrowedMut; + } _1428_params = Dafny.Sequence.Concat(Dafny.Sequence.FromElements(_1442_selfFormal), _1428_params); } else { RAST._IType _1443_tpe; @@ -2258,7 +2251,11 @@ public RAST._IImplMember GenMethod(DAST._IMethod m, bool forTrait, DAST._IType e _1445_typeI = (_1445_typeI) + (BigInteger.One); } RAST._IVisibility _1447_visibility; - _1447_visibility = ((forTrait) ? (RAST.Visibility.create_PRIV()) : (RAST.Visibility.create_PUB())); + if (forTrait) { + _1447_visibility = RAST.Visibility.create_PRIV(); + } else { + _1447_visibility = RAST.Visibility.create_PUB(); + } Dafny.ISequence _1448_typeParamsFiltered; _1448_typeParamsFiltered = Dafny.Sequence.FromElements(); BigInteger _hi28 = new BigInteger(((m).dtor_typeParams).Count); @@ -2281,8 +2278,9 @@ public RAST._IImplMember GenMethod(DAST._IMethod m, bool forTrait, DAST._IType e (this).GenTypeParam((_1448_typeParamsFiltered).Select(_1452_i), out _out106, out _out107); _1453_typeArg = _out106; _1454_rTypeParamDecl = _out107; - var _pat_let_tv141 = _1454_rTypeParamDecl; - _1454_rTypeParamDecl = Dafny.Helpers.Let(_1454_rTypeParamDecl, _pat_let34_0 => Dafny.Helpers.Let(_pat_let34_0, _1455_dt__update__tmp_h1 => Dafny.Helpers.Let, RAST._ITypeParamDecl>(Dafny.Sequence.Concat((_pat_let_tv141).dtor_constraints, Dafny.Sequence.FromElements(((RAST.__default.std__type).MSel(Dafny.Sequence.UnicodeFromString("default"))).MSel(Dafny.Sequence.UnicodeFromString("Default")))), _pat_let35_0 => Dafny.Helpers.Let, RAST._ITypeParamDecl>(_pat_let35_0, _1456_dt__update_hconstraints_h0 => RAST.TypeParamDecl.create((_1455_dt__update__tmp_h1).dtor_content, _1456_dt__update_hconstraints_h0))))); + RAST._ITypeParamDecl _1455_dt__update__tmp_h1 = _1454_rTypeParamDecl; + Dafny.ISequence _1456_dt__update_hconstraints_h0 = Dafny.Sequence.Concat((_1454_rTypeParamDecl).dtor_constraints, Dafny.Sequence.FromElements(((RAST.__default.std__type).MSel(Dafny.Sequence.UnicodeFromString("default"))).MSel(Dafny.Sequence.UnicodeFromString("Default")))); + _1454_rTypeParamDecl = RAST.TypeParamDecl.create((_1455_dt__update__tmp_h1).dtor_content, _1456_dt__update_hconstraints_h0); _1451_typeParams = Dafny.Sequence.Concat(_1451_typeParams, Dafny.Sequence.FromElements(_1454_rTypeParamDecl)); } } @@ -2298,11 +2296,9 @@ public RAST._IImplMember GenMethod(DAST._IMethod m, bool forTrait, DAST._IType e Std.Wrappers._IOption>> _1462_earlyReturn; _1462_earlyReturn = Std.Wrappers.Option>>.create_None(); Std.Wrappers._IOption>> _source68 = (m).dtor_outVars; - bool unmatched68 = true; - if (unmatched68) { + { if (_source68.is_Some) { Dafny.ISequence> _1463_outVars = _source68.dtor_value; - unmatched68 = false; { if ((m).dtor_outVarsAreUninitFieldsToAssign) { _1462_earlyReturn = Std.Wrappers.Option>>.create_Some(Dafny.Sequence>.FromElements()); @@ -2333,18 +2329,23 @@ public RAST._IImplMember GenMethod(DAST._IMethod m, bool forTrait, DAST._IType e _1472_outName = DCOMP.__default.escapeName((_1470_outVar)); _1429_paramNames = Dafny.Sequence>.Concat(_1429_paramNames, Dafny.Sequence>.FromElements(_1472_outName)); RAST._IType _1473_outMaybeType; - _1473_outMaybeType = (((_1471_outType).CanReadWithoutClone()) ? (_1471_outType) : (RAST.__default.MaybePlaceboType(_1471_outType))); + if ((_1471_outType).CanReadWithoutClone()) { + _1473_outMaybeType = _1471_outType; + } else { + _1473_outMaybeType = RAST.__default.MaybePlaceboType(_1471_outType); + } _1430_paramTypes = Dafny.Map, RAST._IType>.Update(_1430_paramTypes, _1472_outName, _1473_outMaybeType); _1468_tupleArgs = Dafny.Sequence>.Concat(_1468_tupleArgs, Dafny.Sequence>.FromElements(_1472_outName)); } _1462_earlyReturn = Std.Wrappers.Option>>.create_Some(_1468_tupleArgs); } } + goto after_match15; } } - if (unmatched68) { - unmatched68 = false; + { } + after_match15: ; _1458_env = DCOMP.Environment.create(Dafny.Sequence>.Concat(_1460_preAssignNames, _1429_paramNames), Dafny.Map, RAST._IType>.Merge(_1461_preAssignTypes, _1430_paramTypes)); RAST._IExpr _1474_body; Dafny.ISet> _1475___v69; @@ -2382,42 +2383,40 @@ public void GenStmts(Dafny.ISequence stmts, DCOMP._ISelfInfo s DAST._IStatement _1480_stmt; _1480_stmt = (_1479_stmts).Select(_1478_i); DAST._IStatement _source69 = _1480_stmt; - bool unmatched69 = true; - if (unmatched69) { + { if (_source69.is_DeclareVar) { Dafny.ISequence _1481_name = _source69.dtor_name; DAST._IType _1482_optType = _source69.dtor_typ; Std.Wrappers._IOption maybeValue0 = _source69.dtor_maybeValue; if (maybeValue0.is_None) { - unmatched69 = false; if (((_1478_i) + (BigInteger.One)) < (new BigInteger((_1479_stmts).Count))) { DAST._IStatement _source70 = (_1479_stmts).Select((_1478_i) + (BigInteger.One)); - bool unmatched70 = true; - if (unmatched70) { + { if (_source70.is_Assign) { DAST._IAssignLhs lhs0 = _source70.dtor_lhs; if (lhs0.is_Ident) { Dafny.ISequence ident0 = lhs0.dtor_ident; Dafny.ISequence _1483_name2 = ident0; DAST._IExpression _1484_rhs = _source70.dtor_value; - unmatched70 = false; if (object.Equals(_1483_name2, _1481_name)) { _1479_stmts = Dafny.Sequence.Concat(Dafny.Sequence.Concat((_1479_stmts).Subsequence(BigInteger.Zero, _1478_i), Dafny.Sequence.FromElements(DAST.Statement.create_DeclareVar(_1481_name, _1482_optType, Std.Wrappers.Option.create_Some(_1484_rhs)))), (_1479_stmts).Drop((_1478_i) + (new BigInteger(2)))); _1480_stmt = (_1479_stmts).Select(_1478_i); } + goto after_match17; } } } - if (unmatched70) { - unmatched70 = false; + { } + after_match17: ; } + goto after_match16; } } } - if (unmatched69) { - unmatched69 = false; + { } + after_match16: ; RAST._IExpr _1485_stmtExpr; Dafny.ISet> _1486_recIdents; DCOMP._IEnvironment _1487_newEnv2; @@ -2430,19 +2429,18 @@ public void GenStmts(Dafny.ISequence stmts, DCOMP._ISelfInfo s _1487_newEnv2 = _out114; newEnv = _1487_newEnv2; DAST._IStatement _source71 = _1480_stmt; - bool unmatched71 = true; - if (unmatched71) { + { if (_source71.is_DeclareVar) { Dafny.ISequence _1488_name = _source71.dtor_name; - unmatched71 = false; { _1477_declarations = Dafny.Set>.Union(_1477_declarations, Dafny.Set>.FromElements(DCOMP.__default.escapeName(_1488_name))); } + goto after_match18; } } - if (unmatched71) { - unmatched71 = false; + { } + after_match18: ; readIdents = Dafny.Set>.Union(readIdents, Dafny.Set>.Difference(_1486_recIdents, _1477_declarations)); generated = (generated).Then(_1485_stmtExpr); _1478_i = (_1478_i) + (BigInteger.One); @@ -2461,12 +2459,10 @@ public void GenAssignLhs(DAST._IAssignLhs lhs, RAST._IExpr rhs, DCOMP._ISelfInfo newEnv = DCOMP.Environment.Default(); newEnv = env; DAST._IAssignLhs _source72 = lhs; - bool unmatched72 = true; - if (unmatched72) { + { if (_source72.is_Ident) { Dafny.ISequence ident1 = _source72.dtor_ident; Dafny.ISequence _1489_id = ident1; - unmatched72 = false; { Dafny.ISequence _1490_idRust; _1490_idRust = DCOMP.__default.escapeName(_1489_id); @@ -2478,13 +2474,13 @@ public void GenAssignLhs(DAST._IAssignLhs lhs, RAST._IExpr rhs, DCOMP._ISelfInfo readIdents = Dafny.Set>.FromElements(_1490_idRust); needsIIFE = false; } + goto after_match19; } } - if (unmatched72) { + { if (_source72.is_Select) { DAST._IExpression _1491_on = _source72.dtor_expr; Dafny.ISequence _1492_field = _source72.dtor_field; - unmatched72 = false; { Dafny.ISequence _1493_fieldName; _1493_fieldName = DCOMP.__default.escapeName(_1492_field); @@ -2499,9 +2495,8 @@ public void GenAssignLhs(DAST._IAssignLhs lhs, RAST._IExpr rhs, DCOMP._ISelfInfo _1495_onOwned = _out116; _1496_recIdents = _out117; RAST._IExpr _source73 = _1494_onExpr; - bool unmatched73 = true; - if (unmatched73) { - bool disjunctiveMatch11 = false; + { + bool disjunctiveMatch10 = false; if (_source73.is_Call) { RAST._IExpr obj2 = _source73.dtor_obj; if (obj2.is_Select) { @@ -2511,7 +2506,7 @@ public void GenAssignLhs(DAST._IAssignLhs lhs, RAST._IExpr rhs, DCOMP._ISelfInfo if (object.Equals(name11, Dafny.Sequence.UnicodeFromString("this"))) { Dafny.ISequence name12 = obj2.dtor_name; if (object.Equals(name12, Dafny.Sequence.UnicodeFromString("clone"))) { - disjunctiveMatch11 = true; + disjunctiveMatch10 = true; } } } @@ -2520,7 +2515,7 @@ public void GenAssignLhs(DAST._IAssignLhs lhs, RAST._IExpr rhs, DCOMP._ISelfInfo if (_source73.is_Identifier) { Dafny.ISequence name13 = _source73.dtor_name; if (object.Equals(name13, Dafny.Sequence.UnicodeFromString("this"))) { - disjunctiveMatch11 = true; + disjunctiveMatch10 = true; } } if (_source73.is_UnaryOp) { @@ -2530,13 +2525,12 @@ public void GenAssignLhs(DAST._IAssignLhs lhs, RAST._IExpr rhs, DCOMP._ISelfInfo if (underlying4.is_Identifier) { Dafny.ISequence name14 = underlying4.dtor_name; if (object.Equals(name14, Dafny.Sequence.UnicodeFromString("this"))) { - disjunctiveMatch11 = true; + disjunctiveMatch10 = true; } } } } - if (disjunctiveMatch11) { - unmatched73 = false; + if (disjunctiveMatch10) { Dafny.ISequence _1497_isAssignedVar; _1497_isAssignedVar = DCOMP.__default.AddAssignedPrefix(_1493_fieldName); if (((newEnv).dtor_names).Contains(_1497_isAssignedVar)) { @@ -2546,24 +2540,25 @@ public void GenAssignLhs(DAST._IAssignLhs lhs, RAST._IExpr rhs, DCOMP._ISelfInfo (this).error = Std.Wrappers.Option>.create_Some(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("Unespected field to assign whose isAssignedVar is not in the environment: "), _1497_isAssignedVar)); generated = RAST.__default.AssignMember(RAST.Expr.create_RawExpr((this.error).dtor_value), _1493_fieldName, rhs); } + goto after_match20; } } - if (unmatched73) { - unmatched73 = false; + { if (!object.Equals(_1494_onExpr, RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("self")))) { _1494_onExpr = ((this).modify__macro).Apply1(_1494_onExpr); } generated = RAST.__default.AssignMember(_1494_onExpr, _1493_fieldName, rhs); } + after_match20: ; readIdents = _1496_recIdents; needsIIFE = false; } + goto after_match19; } } - if (unmatched72) { + { DAST._IExpression _1498_on = _source72.dtor_expr; Dafny.ISequence _1499_indices = _source72.dtor_indices; - unmatched72 = false; { RAST._IExpr _1500_onExpr; DCOMP._IOwnership _1501_onOwned; @@ -2604,14 +2599,15 @@ public void GenAssignLhs(DAST._IAssignLhs lhs, RAST._IExpr rhs, DCOMP._ISelfInfo } RAST._IExpr _1510_rhs; _1510_rhs = rhs; - var _pat_let_tv142 = env; - if (((_1500_onExpr).IsLhsIdentifier()) && (Dafny.Helpers.Let, bool>((_1500_onExpr).LhsIdentifierName(), _pat_let36_0 => Dafny.Helpers.Let, bool>(_pat_let36_0, _1511_name => (true) && (Dafny.Helpers.Let, bool>((_pat_let_tv142).GetType(_1511_name), _pat_let37_0 => Dafny.Helpers.Let, bool>(_pat_let37_0, _1512_tpe => ((_1512_tpe).is_Some) && (((_1512_tpe).dtor_value).IsUninitArray())))))))) { + var _pat_let_tv3 = env; + if (((_1500_onExpr).IsLhsIdentifier()) && (Dafny.Helpers.Let, bool>((_1500_onExpr).LhsIdentifierName(), _pat_let32_0 => Dafny.Helpers.Let, bool>(_pat_let32_0, _1511_name => (true) && (Dafny.Helpers.Let, bool>((_pat_let_tv3).GetType(_1511_name), _pat_let33_0 => Dafny.Helpers.Let, bool>(_pat_let33_0, _1512_tpe => ((_1512_tpe).is_Some) && (((_1512_tpe).dtor_value).IsUninitArray())))))))) { _1510_rhs = RAST.__default.MaybeUninitNew(_1510_rhs); } generated = (_1503_r).Then(RAST.Expr.create_Assign(Std.Wrappers.Option.create_Some(RAST.AssignLhs.create_Index(_1500_onExpr, _1504_indicesExpr)), _1510_rhs)); needsIIFE = true; } } + after_match19: ; } public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IEnvironment env, bool isLast, Std.Wrappers._IOption>> earlyReturn, out RAST._IExpr generated, out Dafny.ISet> readIdents, out DCOMP._IEnvironment newEnv) { @@ -2619,11 +2615,9 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE readIdents = Dafny.Set>.Empty; newEnv = DCOMP.Environment.Default(); DAST._IStatement _source74 = stmt; - bool unmatched74 = true; - if (unmatched74) { + { if (_source74.is_ConstructorNewSeparator) { Dafny.ISequence _1513_fields = _source74.dtor_fields; - unmatched74 = false; { generated = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); readIdents = Dafny.Set>.FromElements(); @@ -2657,16 +2651,16 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE } } } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_DeclareVar) { Dafny.ISequence _1522_name = _source74.dtor_name; DAST._IType _1523_typ = _source74.dtor_typ; Std.Wrappers._IOption maybeValue1 = _source74.dtor_maybeValue; if (maybeValue1.is_Some) { DAST._IExpression _1524_expression = maybeValue1.dtor_value; - unmatched74 = false; { RAST._IType _1525_tpe; RAST._IType _out128; @@ -2697,21 +2691,25 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE _1529_recIdents = _out131; } readIdents = _1529_recIdents; - _1525_tpe = (((_1524_expression).is_NewUninitArray) ? ((_1525_tpe).TypeAtInitialization()) : (_1525_tpe)); + if ((_1524_expression).is_NewUninitArray) { + _1525_tpe = (_1525_tpe).TypeAtInitialization(); + } else { + _1525_tpe = _1525_tpe; + } generated = RAST.Expr.create_DeclareVar(RAST.DeclareType.create_MUT(), DCOMP.__default.escapeName(_1522_name), Std.Wrappers.Option.create_Some(_1525_tpe), Std.Wrappers.Option.create_Some(_1528_expr)); newEnv = (env).AddAssigned(DCOMP.__default.escapeName(_1522_name), _1525_tpe); } } + goto after_match21; } } } - if (unmatched74) { + { if (_source74.is_DeclareVar) { Dafny.ISequence _1531_name = _source74.dtor_name; DAST._IType _1532_typ = _source74.dtor_typ; Std.Wrappers._IOption maybeValue2 = _source74.dtor_maybeValue; if (maybeValue2.is_None) { - unmatched74 = false; { DAST._IStatement _1533_newStmt; _1533_newStmt = DAST.Statement.create_DeclareVar(_1531_name, _1532_typ, Std.Wrappers.Option.create_Some(DAST.Expression.create_InitializationValue(_1532_typ))); @@ -2723,14 +2721,14 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE readIdents = _out133; newEnv = _out134; } + goto after_match21; } } } - if (unmatched74) { + { if (_source74.is_Assign) { DAST._IAssignLhs _1534_lhs = _source74.dtor_lhs; DAST._IExpression _1535_expression = _source74.dtor_value; - unmatched74 = false; { RAST._IExpr _1536_exprGen; DCOMP._IOwnership _1537___v82; @@ -2780,14 +2778,14 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE } readIdents = Dafny.Set>.Union(_1545_recIdents, _1538_exprIdents); } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_If) { DAST._IExpression _1547_cond = _source74.dtor_cond; Dafny.ISequence _1548_thnDafny = _source74.dtor_thn; Dafny.ISequence _1549_elsDafny = _source74.dtor_els; - unmatched74 = false; { RAST._IExpr _1550_cond; DCOMP._IOwnership _1551___v83; @@ -2827,13 +2825,13 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE newEnv = env; generated = RAST.Expr.create_IfExpr(_1550_cond, _1554_thn, _1557_els); } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_Labeled) { Dafny.ISequence _1560_lbl = _source74.dtor_lbl; Dafny.ISequence _1561_body = _source74.dtor_body; - unmatched74 = false; { RAST._IExpr _1562_body; Dafny.ISet> _1563_bodyIdents; @@ -2849,13 +2847,13 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE generated = RAST.Expr.create_Labelled(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("label_"), _1560_lbl), RAST.Expr.create_Loop(Std.Wrappers.Option.create_None(), RAST.Expr.create_StmtExpr(_1562_body, RAST.Expr.create_Break(Std.Wrappers.Option>.create_None())))); newEnv = env; } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_While) { DAST._IExpression _1565_cond = _source74.dtor_cond; Dafny.ISequence _1566_body = _source74.dtor_body; - unmatched74 = false; { RAST._IExpr _1567_cond; DCOMP._IOwnership _1568___v84; @@ -2882,15 +2880,15 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE readIdents = Dafny.Set>.Union(readIdents, _1571_bodyIdents); generated = RAST.Expr.create_Loop(Std.Wrappers.Option.create_Some(_1567_cond), _1570_bodyExpr); } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_Foreach) { Dafny.ISequence _1573_boundName = _source74.dtor_boundName; DAST._IType _1574_boundType = _source74.dtor_boundType; DAST._IExpression _1575_overExpr = _source74.dtor_over; Dafny.ISequence _1576_body = _source74.dtor_body; - unmatched74 = false; { RAST._IExpr _1577_over; DCOMP._IOwnership _1578___v85; @@ -2926,39 +2924,38 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE newEnv = env; generated = RAST.Expr.create_For(_1581_boundRName, _1577_over, _1582_bodyExpr); } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_Break) { Std.Wrappers._IOption> _1585_toLabel = _source74.dtor_toLabel; - unmatched74 = false; { Std.Wrappers._IOption> _source75 = _1585_toLabel; - bool unmatched75 = true; - if (unmatched75) { + { if (_source75.is_Some) { Dafny.ISequence _1586_lbl = _source75.dtor_value; - unmatched75 = false; { generated = RAST.Expr.create_Break(Std.Wrappers.Option>.create_Some(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("label_"), _1586_lbl))); } + goto after_match22; } } - if (unmatched75) { - unmatched75 = false; + { { generated = RAST.Expr.create_Break(Std.Wrappers.Option>.create_None()); } } + after_match22: ; readIdents = Dafny.Set>.FromElements(); newEnv = env; } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_TailRecursive) { Dafny.ISequence _1587_body = _source74.dtor_body; - unmatched74 = false; { generated = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("")); if (!object.Equals(selfIdent, DCOMP.SelfInfo.create_NoSelf())) { @@ -3009,26 +3006,26 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE readIdents = _1598_bodyIdents; generated = (generated).Then(RAST.Expr.create_Labelled(Dafny.Sequence.UnicodeFromString("TAIL_CALL_START"), RAST.Expr.create_Loop(Std.Wrappers.Option.create_None(), _1597_bodyExpr))); } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_JumpTailCallStart) { - unmatched74 = false; { generated = RAST.Expr.create_Continue(Std.Wrappers.Option>.create_Some(Dafny.Sequence.UnicodeFromString("TAIL_CALL_START"))); readIdents = Dafny.Set>.FromElements(); newEnv = env; } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_Call) { DAST._IExpression _1600_on = _source74.dtor_on; DAST._ICallName _1601_name = _source74.dtor_callName; Dafny.ISequence _1602_typeArgs = _source74.dtor_typeArgs; Dafny.ISequence _1603_args = _source74.dtor_args; Std.Wrappers._IOption>> _1604_maybeOutVars = _source74.dtor_outs; - unmatched74 = false; { Dafny.ISequence _1605_argExprs; Dafny.ISet> _1606_recIdents; @@ -3045,14 +3042,12 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE _1608_fullNameQualifier = _out179; readIdents = _1606_recIdents; Std.Wrappers._IOption _source76 = _1608_fullNameQualifier; - bool unmatched76 = true; - if (unmatched76) { + { if (_source76.is_Some) { DAST._IResolvedType value9 = _source76.dtor_value; Dafny.ISequence> _1609_path = value9.dtor_path; Dafny.ISequence _1610_onTypeArgs = value9.dtor_typeArgs; DAST._IResolvedTypeBase _1611_base = value9.dtor_kind; - unmatched76 = false; RAST._IExpr _1612_fullPath; RAST._IExpr _out180; _out180 = DCOMP.COMP.GenPathExpr(_1609_path); @@ -3085,10 +3080,10 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE readIdents = Dafny.Set>.Union(readIdents, _1616_recIdents); } generated = ((((_1612_fullPath).ApplyType(_1613_onTypeExprs)).MSel(DCOMP.__default.escapeName((_1601_name).dtor_name))).ApplyType(_1607_typeExprs)).Apply(Dafny.Sequence.Concat(Dafny.Sequence.FromElements(_1614_onExpr), _1605_argExprs)); + goto after_match23; } } - if (unmatched76) { - unmatched76 = false; + { RAST._IExpr _1617_onExpr; DCOMP._IOwnership _1618___v94; Dafny.ISet> _1619_enclosingIdents; @@ -3101,62 +3096,49 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE _1619_enclosingIdents = _out190; readIdents = Dafny.Set>.Union(readIdents, _1619_enclosingIdents); Dafny.ISequence _1620_renderedName; - _1620_renderedName = ((System.Func>)(() => { - DAST._ICallName _source77 = _1601_name; - bool unmatched77 = true; - if (unmatched77) { - if (_source77.is_CallName) { - Dafny.ISequence _1621_name = _source77.dtor_name; - unmatched77 = false; - return DCOMP.__default.escapeName(_1621_name); - } + DAST._ICallName _source77 = _1601_name; + { + if (_source77.is_CallName) { + Dafny.ISequence _1621_name = _source77.dtor_name; + _1620_renderedName = DCOMP.__default.escapeName(_1621_name); + goto after_match24; } - if (unmatched77) { - bool disjunctiveMatch12 = false; - if (_source77.is_MapBuilderAdd) { - disjunctiveMatch12 = true; - } - if (_source77.is_SetBuilderAdd) { - disjunctiveMatch12 = true; - } - if (disjunctiveMatch12) { - unmatched77 = false; - return Dafny.Sequence.UnicodeFromString("add"); - } + } + { + bool disjunctiveMatch11 = false; + if (_source77.is_MapBuilderAdd) { + disjunctiveMatch11 = true; } - if (unmatched77) { - bool disjunctiveMatch13 = false; - disjunctiveMatch13 = true; - disjunctiveMatch13 = true; - if (disjunctiveMatch13) { - unmatched77 = false; - return Dafny.Sequence.UnicodeFromString("build"); - } + if (_source77.is_SetBuilderAdd) { + disjunctiveMatch11 = true; } - throw new System.Exception("unexpected control point"); - }))(); + if (disjunctiveMatch11) { + _1620_renderedName = Dafny.Sequence.UnicodeFromString("add"); + goto after_match24; + } + } + { + _1620_renderedName = Dafny.Sequence.UnicodeFromString("build"); + } + after_match24: ; DAST._IExpression _source78 = _1600_on; - bool unmatched78 = true; - if (unmatched78) { + { if (_source78.is_Companion) { - unmatched78 = false; { _1617_onExpr = (_1617_onExpr).MSel(_1620_renderedName); } + goto after_match25; } } - if (unmatched78) { - unmatched78 = false; + { { if (!object.Equals(_1617_onExpr, RAST.__default.self)) { DAST._ICallName _source79 = _1601_name; - bool unmatched79 = true; - if (unmatched79) { + { if (_source79.is_CallName) { Std.Wrappers._IOption onType0 = _source79.dtor_onType; if (onType0.is_Some) { DAST._IType _1622_tpe = onType0.dtor_value; - unmatched79 = false; RAST._IType _1623_typ; RAST._IType _out191; _out191 = (this).GenType(_1622_tpe, DCOMP.GenTypeContext.@default()); @@ -3164,18 +3146,21 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE if (((_1623_typ).IsObjectOrPointer()) && (!object.Equals(_1617_onExpr, RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("self"))))) { _1617_onExpr = ((this).modify__macro).Apply1(_1617_onExpr); } + goto after_match26; } } } - if (unmatched79) { - unmatched79 = false; + { } + after_match26: ; } _1617_onExpr = (_1617_onExpr).Sel(_1620_renderedName); } } + after_match25: ; generated = ((_1617_onExpr).ApplyType(_1607_typeExprs)).Apply(_1605_argExprs); } + after_match23: ; if (((_1604_maybeOutVars).is_Some) && ((new BigInteger(((_1604_maybeOutVars).dtor_value).Count)) == (BigInteger.One))) { Dafny.ISequence _1624_outVar; _1624_outVar = DCOMP.__default.escapeName((((_1604_maybeOutVars).dtor_value).Select(BigInteger.Zero))); @@ -3206,12 +3191,12 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE } newEnv = env; } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_Return) { DAST._IExpression _1631_exprDafny = _source74.dtor_expr; - unmatched74 = false; { RAST._IExpr _1632_expr; DCOMP._IOwnership _1633___v105; @@ -3231,23 +3216,21 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE } newEnv = env; } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_EarlyReturn) { - unmatched74 = false; { Std.Wrappers._IOption>> _source80 = earlyReturn; - bool unmatched80 = true; - if (unmatched80) { + { if (_source80.is_None) { - unmatched80 = false; generated = RAST.Expr.create_Return(Std.Wrappers.Option.create_None()); + goto after_match27; } } - if (unmatched80) { + { Dafny.ISequence> _1635_rustIdents = _source80.dtor_value; - unmatched80 = false; Dafny.ISequence _1636_tupleArgs; _1636_tupleArgs = Dafny.Sequence.FromElements(); BigInteger _hi36 = new BigInteger((_1635_rustIdents).Count); @@ -3270,24 +3253,25 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE generated = RAST.Expr.create_Return(Std.Wrappers.Option.create_Some(RAST.Expr.create_Tuple(_1636_tupleArgs))); } } + after_match27: ; readIdents = Dafny.Set>.FromElements(); newEnv = env; } + goto after_match21; } } - if (unmatched74) { + { if (_source74.is_Halt) { - unmatched74 = false; { generated = (RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("panic!"))).Apply1(RAST.Expr.create_LiteralString(Dafny.Sequence.UnicodeFromString("Halt"), false, false)); readIdents = Dafny.Set>.FromElements(); newEnv = env; } + goto after_match21; } } - if (unmatched74) { + { DAST._IExpression _1641_e = _source74.dtor_Print_a0; - unmatched74 = false; { RAST._IExpr _1642_printedExpr; DCOMP._IOwnership _1643_recOwnership; @@ -3304,82 +3288,69 @@ public void GenStmt(DAST._IStatement stmt, DCOMP._ISelfInfo selfIdent, DCOMP._IE newEnv = env; } } + after_match21: ; } public static Std.Wrappers._IOption NewtypeToRustType(DAST._IType @base, DAST._INewtypeRange range) { DAST._INewtypeRange _source81 = range; - bool unmatched81 = true; - if (unmatched81) { + { if (_source81.is_NoRange) { - unmatched81 = false; return Std.Wrappers.Option.create_None(); } } - if (unmatched81) { + { if (_source81.is_U8) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_U8()); } } - if (unmatched81) { + { if (_source81.is_U16) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_U16()); } } - if (unmatched81) { + { if (_source81.is_U32) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_U32()); } } - if (unmatched81) { + { if (_source81.is_U64) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_U64()); } } - if (unmatched81) { + { if (_source81.is_U128) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_U128()); } } - if (unmatched81) { + { if (_source81.is_I8) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_I8()); } } - if (unmatched81) { + { if (_source81.is_I16) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_I16()); } } - if (unmatched81) { + { if (_source81.is_I32) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_I32()); } } - if (unmatched81) { + { if (_source81.is_I64) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_I64()); } } - if (unmatched81) { + { if (_source81.is_I128) { - unmatched81 = false; return Std.Wrappers.Option.create_Some(RAST.Type.create_I128()); } } - if (unmatched81) { - unmatched81 = false; + { return Std.Wrappers.Option.create_None(); } - throw new System.Exception("unexpected control point"); } public void FromOwned(RAST._IExpr r, DCOMP._IOwnership expectedOwnership, out RAST._IExpr @out, out DCOMP._IOwnership resultingOwnership) { @@ -3451,13 +3422,11 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = DCOMP.Ownership.Default(); readIdents = Dafny.Set>.Empty; DAST._IExpression _source82 = e; - bool unmatched82 = true; - if (unmatched82) { + { if (_source82.is_Literal) { DAST._ILiteral _h170 = _source82.dtor_Literal_a0; if (_h170.is_BoolLiteral) { bool _1645_b = _h170.dtor_BoolLiteral_a0; - unmatched82 = false; { RAST._IExpr _out205; DCOMP._IOwnership _out206; @@ -3467,24 +3436,22 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match28; } } } - if (unmatched82) { + { if (_source82.is_Literal) { DAST._ILiteral _h171 = _source82.dtor_Literal_a0; if (_h171.is_IntLiteral) { Dafny.ISequence _1646_i = _h171.dtor_IntLiteral_a0; DAST._IType _1647_t = _h171.dtor_IntLiteral_a1; - unmatched82 = false; { DAST._IType _source83 = _1647_t; - bool unmatched83 = true; - if (unmatched83) { + { if (_source83.is_Primitive) { DAST._IPrimitive _h70 = _source83.dtor_Primitive_a0; if (_h70.is_Int) { - unmatched83 = false; { if ((new BigInteger((_1646_i).Count)) <= (new BigInteger(4))) { r = ((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("int!"))).Apply1(RAST.Expr.create_LiteralInt(_1646_i)); @@ -3492,12 +3459,12 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM r = ((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("int!"))).Apply1(RAST.Expr.create_LiteralString(_1646_i, true, false)); } } + goto after_match29; } } } - if (unmatched83) { + { DAST._IType _1648_o = _source83; - unmatched83 = false; { RAST._IType _1649_genType; RAST._IType _out207; @@ -3506,6 +3473,7 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM r = RAST.Expr.create_TypeAscription(RAST.Expr.create_RawExpr(_1646_i), _1649_genType); } } + after_match29: ; RAST._IExpr _out208; DCOMP._IOwnership _out209; (this).FromOwned(r, expectedOwnership, out _out208, out _out209); @@ -3514,34 +3482,32 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match28; } } } - if (unmatched82) { + { if (_source82.is_Literal) { DAST._ILiteral _h172 = _source82.dtor_Literal_a0; if (_h172.is_DecLiteral) { Dafny.ISequence _1650_n = _h172.dtor_DecLiteral_a0; Dafny.ISequence _1651_d = _h172.dtor_DecLiteral_a1; DAST._IType _1652_t = _h172.dtor_DecLiteral_a2; - unmatched82 = false; { DAST._IType _source84 = _1652_t; - bool unmatched84 = true; - if (unmatched84) { + { if (_source84.is_Primitive) { DAST._IPrimitive _h71 = _source84.dtor_Primitive_a0; if (_h71.is_Real) { - unmatched84 = false; { 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\""), _1650_n), Dafny.Sequence.UnicodeFromString("\", 10).unwrap(), ::dafny_runtime::BigInt::parse_bytes(b\"")), _1651_d), Dafny.Sequence.UnicodeFromString("\", 10).unwrap())")))); } + goto after_match30; } } } - if (unmatched84) { + { DAST._IType _1653_o = _source84; - unmatched84 = false; { RAST._IType _1654_genType; RAST._IType _out210; @@ -3550,6 +3516,7 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM 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("("), _1650_n), Dafny.Sequence.UnicodeFromString(".0 / ")), _1651_d), Dafny.Sequence.UnicodeFromString(".0")), Dafny.Sequence.UnicodeFromString(")"))), _1654_genType); } } + after_match30: ; RAST._IExpr _out211; DCOMP._IOwnership _out212; (this).FromOwned(r, expectedOwnership, out _out211, out _out212); @@ -3558,16 +3525,16 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match28; } } } - if (unmatched82) { + { if (_source82.is_Literal) { DAST._ILiteral _h173 = _source82.dtor_Literal_a0; if (_h173.is_StringLiteral) { Dafny.ISequence _1655_l = _h173.dtor_StringLiteral_a0; bool _1656_verbatim = _h173.dtor_verbatim; - unmatched82 = false; { r = ((RAST.__default.dafny__runtime).MSel((this).string__of)).Apply1(RAST.Expr.create_LiteralString(_1655_l, false, _1656_verbatim)); RAST._IExpr _out213; @@ -3578,15 +3545,15 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match28; } } } - if (unmatched82) { + { if (_source82.is_Literal) { DAST._ILiteral _h174 = _source82.dtor_Literal_a0; if (_h174.is_CharLiteralUTF16) { BigInteger _1657_c = _h174.dtor_CharLiteralUTF16_a0; - unmatched82 = false; { r = RAST.Expr.create_LiteralInt(Std.Strings.__default.OfNat(_1657_c)); r = RAST.Expr.create_TypeAscription(r, RAST.Type.create_U16()); @@ -3599,15 +3566,15 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match28; } } } - if (unmatched82) { + { if (_source82.is_Literal) { DAST._ILiteral _h175 = _source82.dtor_Literal_a0; if (_h175.is_CharLiteral) { Dafny.Rune _1658_c = _h175.dtor_CharLiteral_a0; - unmatched82 = false; { r = RAST.Expr.create_LiteralInt(Std.Strings.__default.OfNat(new BigInteger((_1658_c).Value))); if (!((this).UnicodeChars)) { @@ -3624,13 +3591,13 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match28; } } } - if (unmatched82) { + { DAST._ILiteral _h176 = _source82.dtor_Literal_a0; DAST._IType _1659_tpe = _h176.dtor_Null_a0; - unmatched82 = false; { RAST._IType _1660_tpeGen; RAST._IType _out219; @@ -3650,6 +3617,7 @@ public void GenExprLiteral(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM return ; } } + after_match28: ; } public void GenExprBinary(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnvironment env, DCOMP._IOwnership expectedOwnership, out RAST._IExpr r, out DCOMP._IOwnership resultingOwnership, out Dafny.ISet> readIdents) { @@ -3662,160 +3630,160 @@ public void GenExprBinary(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP DAST._IExpression _1663_rExpr = _let_tmp_rhs54.dtor_right; DAST.Format._IBinaryOpFormat _1664_format = _let_tmp_rhs54.dtor_format2; bool _1665_becomesLeftCallsRight; - _1665_becomesLeftCallsRight = ((System.Func)(() => { - DAST._IBinOp _source85 = _1661_op; - bool unmatched85 = true; - if (unmatched85) { - bool disjunctiveMatch14 = false; - if (_source85.is_SetMerge) { - disjunctiveMatch14 = true; - } - if (_source85.is_SetSubtraction) { - disjunctiveMatch14 = true; - } - if (_source85.is_SetIntersection) { - disjunctiveMatch14 = true; - } - if (_source85.is_SetDisjoint) { - disjunctiveMatch14 = true; - } - if (_source85.is_MapMerge) { - disjunctiveMatch14 = true; - } - if (_source85.is_MapSubtraction) { - disjunctiveMatch14 = true; - } - if (_source85.is_MultisetMerge) { - disjunctiveMatch14 = true; - } - if (_source85.is_MultisetSubtraction) { - disjunctiveMatch14 = true; - } - if (_source85.is_MultisetIntersection) { - disjunctiveMatch14 = true; - } - if (_source85.is_MultisetDisjoint) { - disjunctiveMatch14 = true; - } - if (_source85.is_Concat) { - disjunctiveMatch14 = true; - } - if (disjunctiveMatch14) { - unmatched85 = false; - return true; - } + DAST._IBinOp _source85 = _1661_op; + { + bool disjunctiveMatch12 = false; + if (_source85.is_SetMerge) { + disjunctiveMatch12 = true; } - if (unmatched85) { - unmatched85 = false; - return false; + if (_source85.is_SetSubtraction) { + disjunctiveMatch12 = true; } - throw new System.Exception("unexpected control point"); - }))(); - bool _1666_becomesRightCallsLeft; - _1666_becomesRightCallsLeft = ((System.Func)(() => { - DAST._IBinOp _source86 = _1661_op; - bool unmatched86 = true; - if (unmatched86) { - if (_source86.is_In) { - unmatched86 = false; - return true; - } + if (_source85.is_SetIntersection) { + disjunctiveMatch12 = true; } - if (unmatched86) { - unmatched86 = false; - return false; + if (_source85.is_SetDisjoint) { + disjunctiveMatch12 = true; } - throw new System.Exception("unexpected control point"); - }))(); - bool _1667_becomesCallLeftRight; - _1667_becomesCallLeftRight = ((System.Func)(() => { - DAST._IBinOp _source87 = _1661_op; - bool unmatched87 = true; - if (unmatched87) { - if (_source87.is_Eq) { - bool referential0 = _source87.dtor_referential; - if ((referential0) == (true)) { - unmatched87 = false; - return false; - } - } + if (_source85.is_MapMerge) { + disjunctiveMatch12 = true; } - if (unmatched87) { - if (_source87.is_SetMerge) { - unmatched87 = false; - return true; - } + if (_source85.is_MapSubtraction) { + disjunctiveMatch12 = true; } - if (unmatched87) { - if (_source87.is_SetSubtraction) { - unmatched87 = false; - return true; - } + if (_source85.is_MultisetMerge) { + disjunctiveMatch12 = true; } - if (unmatched87) { - if (_source87.is_SetIntersection) { - unmatched87 = false; - return true; - } + if (_source85.is_MultisetSubtraction) { + disjunctiveMatch12 = true; } - if (unmatched87) { - if (_source87.is_SetDisjoint) { - unmatched87 = false; - return true; - } + if (_source85.is_MultisetIntersection) { + disjunctiveMatch12 = true; } - if (unmatched87) { - if (_source87.is_MapMerge) { - unmatched87 = false; - return true; - } + if (_source85.is_MultisetDisjoint) { + disjunctiveMatch12 = true; } - if (unmatched87) { - if (_source87.is_MapSubtraction) { - unmatched87 = false; - return true; - } + if (_source85.is_Concat) { + disjunctiveMatch12 = true; } - if (unmatched87) { - if (_source87.is_MultisetMerge) { - unmatched87 = false; - return true; - } + if (disjunctiveMatch12) { + _1665_becomesLeftCallsRight = true; + goto after_match31; } - if (unmatched87) { - if (_source87.is_MultisetSubtraction) { - unmatched87 = false; - return true; - } + } + { + _1665_becomesLeftCallsRight = false; + } + after_match31: ; + bool _1666_becomesRightCallsLeft; + DAST._IBinOp _source86 = _1661_op; + { + if (_source86.is_In) { + _1666_becomesRightCallsLeft = true; + goto after_match32; } - if (unmatched87) { - if (_source87.is_MultisetIntersection) { - unmatched87 = false; - return true; + } + { + _1666_becomesRightCallsLeft = false; + } + after_match32: ; + bool _1667_becomesCallLeftRight; + DAST._IBinOp _source87 = _1661_op; + { + if (_source87.is_Eq) { + bool referential0 = _source87.dtor_referential; + if ((referential0) == (true)) { + _1667_becomesCallLeftRight = false; + goto after_match33; } } - if (unmatched87) { - if (_source87.is_MultisetDisjoint) { - unmatched87 = false; - return true; - } + } + { + if (_source87.is_SetMerge) { + _1667_becomesCallLeftRight = true; + goto after_match33; } - if (unmatched87) { - if (_source87.is_Concat) { - unmatched87 = false; - return true; - } + } + { + if (_source87.is_SetSubtraction) { + _1667_becomesCallLeftRight = true; + goto after_match33; } - if (unmatched87) { - unmatched87 = false; - return false; + } + { + if (_source87.is_SetIntersection) { + _1667_becomesCallLeftRight = true; + goto after_match33; } - throw new System.Exception("unexpected control point"); - }))(); + } + { + if (_source87.is_SetDisjoint) { + _1667_becomesCallLeftRight = true; + goto after_match33; + } + } + { + if (_source87.is_MapMerge) { + _1667_becomesCallLeftRight = true; + goto after_match33; + } + } + { + if (_source87.is_MapSubtraction) { + _1667_becomesCallLeftRight = true; + goto after_match33; + } + } + { + if (_source87.is_MultisetMerge) { + _1667_becomesCallLeftRight = true; + goto after_match33; + } + } + { + if (_source87.is_MultisetSubtraction) { + _1667_becomesCallLeftRight = true; + goto after_match33; + } + } + { + if (_source87.is_MultisetIntersection) { + _1667_becomesCallLeftRight = true; + goto after_match33; + } + } + { + if (_source87.is_MultisetDisjoint) { + _1667_becomesCallLeftRight = true; + goto after_match33; + } + } + { + if (_source87.is_Concat) { + _1667_becomesCallLeftRight = true; + goto after_match33; + } + } + { + _1667_becomesCallLeftRight = false; + } + after_match33: ; DCOMP._IOwnership _1668_expectedLeftOwnership; - _1668_expectedLeftOwnership = ((_1665_becomesLeftCallsRight) ? (DCOMP.Ownership.create_OwnershipAutoBorrowed()) : ((((_1666_becomesRightCallsLeft) || (_1667_becomesCallLeftRight)) ? (DCOMP.Ownership.create_OwnershipBorrowed()) : (DCOMP.Ownership.create_OwnershipOwned())))); + if (_1665_becomesLeftCallsRight) { + _1668_expectedLeftOwnership = DCOMP.Ownership.create_OwnershipAutoBorrowed(); + } else if ((_1666_becomesRightCallsLeft) || (_1667_becomesCallLeftRight)) { + _1668_expectedLeftOwnership = DCOMP.Ownership.create_OwnershipBorrowed(); + } else { + _1668_expectedLeftOwnership = DCOMP.Ownership.create_OwnershipOwned(); + } DCOMP._IOwnership _1669_expectedRightOwnership; - _1669_expectedRightOwnership = (((_1665_becomesLeftCallsRight) || (_1667_becomesCallLeftRight)) ? (DCOMP.Ownership.create_OwnershipBorrowed()) : (((_1666_becomesRightCallsLeft) ? (DCOMP.Ownership.create_OwnershipAutoBorrowed()) : (DCOMP.Ownership.create_OwnershipOwned())))); + if ((_1665_becomesLeftCallsRight) || (_1667_becomesCallLeftRight)) { + _1669_expectedRightOwnership = DCOMP.Ownership.create_OwnershipBorrowed(); + } else if (_1666_becomesRightCallsLeft) { + _1669_expectedRightOwnership = DCOMP.Ownership.create_OwnershipAutoBorrowed(); + } else { + _1669_expectedRightOwnership = DCOMP.Ownership.create_OwnershipOwned(); + } RAST._IExpr _1670_left; DCOMP._IOwnership _1671___v112; Dafny.ISet> _1672_recIdentsL; @@ -3837,159 +3805,155 @@ public void GenExprBinary(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP _1674___v113 = _out226; _1675_recIdentsR = _out227; DAST._IBinOp _source88 = _1661_op; - bool unmatched88 = true; - if (unmatched88) { + { if (_source88.is_In) { - unmatched88 = false; { r = ((_1673_right).Sel(Dafny.Sequence.UnicodeFromString("contains"))).Apply1(_1670_left); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_SeqProperPrefix) { - unmatched88 = false; r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<"), _1670_left, _1673_right, _1664_format); + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_SeqPrefix) { - unmatched88 = false; r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<="), _1670_left, _1673_right, _1664_format); + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_SetMerge) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("merge"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_SetSubtraction) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("subtract"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_SetIntersection) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("intersect"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_Subset) { - unmatched88 = false; { r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<="), _1670_left, _1673_right, _1664_format); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_ProperSubset) { - unmatched88 = false; { r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<"), _1670_left, _1673_right, _1664_format); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_SetDisjoint) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("disjoint"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_MapMerge) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("merge"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_MapSubtraction) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("subtract"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_MultisetMerge) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("merge"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_MultisetSubtraction) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("subtract"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_MultisetIntersection) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("intersect"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_Submultiset) { - unmatched88 = false; { r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<="), _1670_left, _1673_right, _1664_format); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_ProperSubmultiset) { - unmatched88 = false; { r = RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<"), _1670_left, _1673_right, _1664_format); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_MultisetDisjoint) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("disjoint"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { + { if (_source88.is_Concat) { - unmatched88 = false; { r = ((_1670_left).Sel(Dafny.Sequence.UnicodeFromString("concat"))).Apply1(_1673_right); } + goto after_match34; } } - if (unmatched88) { - unmatched88 = false; + { { if ((DCOMP.COMP.OpTable).Contains(_1661_op)) { r = RAST.Expr.create_BinaryOp(Dafny.Map>.Select(DCOMP.COMP.OpTable,_1661_op), _1670_left, _1673_right, _1664_format); } else { DAST._IBinOp _source89 = _1661_op; - bool unmatched89 = true; - if (unmatched89) { + { if (_source89.is_Eq) { bool _1676_referential = _source89.dtor_referential; - unmatched89 = false; { if (_1676_referential) { if (((this).ObjectType).is_RawPointers) { @@ -4008,34 +3972,36 @@ public void GenExprBinary(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP } } } + goto after_match35; } } - if (unmatched89) { + { if (_source89.is_EuclidianDiv) { - unmatched89 = false; { r = (RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("::dafny_runtime::euclidian_division"))).Apply(Dafny.Sequence.FromElements(_1670_left, _1673_right)); } + goto after_match35; } } - if (unmatched89) { + { if (_source89.is_EuclidianMod) { - unmatched89 = false; { r = (RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("::dafny_runtime::euclidian_modulo"))).Apply(Dafny.Sequence.FromElements(_1670_left, _1673_right)); } + goto after_match35; } } - if (unmatched89) { + { Dafny.ISequence _1677_op = _source89.dtor_Passthrough_a0; - unmatched89 = false; { r = RAST.Expr.create_BinaryOp(_1677_op, _1670_left, _1673_right, _1664_format); } } + after_match35: ; } } } + after_match34: ; RAST._IExpr _out228; DCOMP._IOwnership _out229; (this).FromOwned(r, expectedOwnership, out _out228, out _out229); @@ -4079,21 +4045,19 @@ public void GenExprConvertToNewtype(DAST._IExpression e, DCOMP._ISelfInfo selfId _1692_recIdents = _out232; readIdents = _1692_recIdents; Std.Wrappers._IOption _source90 = _1689_nativeToType; - bool unmatched90 = true; - if (unmatched90) { + { if (_source90.is_Some) { RAST._IType _1693_v = _source90.dtor_value; - unmatched90 = false; r = ((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("truncate!"))).Apply(Dafny.Sequence.FromElements(_1690_recursiveGen, RAST.Expr.create_ExprFromType(_1693_v))); RAST._IExpr _out233; DCOMP._IOwnership _out234; (this).FromOwned(r, expectedOwnership, out _out233, out _out234); r = _out233; resultingOwnership = _out234; + goto after_match36; } } - if (unmatched90) { - unmatched90 = false; + { if (_1685_erase) { r = _1690_recursiveGen; } else { @@ -4109,11 +4073,11 @@ public void GenExprConvertToNewtype(DAST._IExpression e, DCOMP._ISelfInfo selfId r = _out236; resultingOwnership = _out237; } + after_match36: ; } else { if ((_1689_nativeToType).is_Some) { DAST._IType _source91 = _1679_fromTpe; - bool unmatched91 = true; - if (unmatched91) { + { if (_source91.is_UserDefined) { DAST._IResolvedType resolved1 = _source91.dtor_resolved; DAST._IResolvedTypeBase kind1 = resolved1.dtor_kind; @@ -4122,7 +4086,6 @@ public void GenExprConvertToNewtype(DAST._IExpression e, DCOMP._ISelfInfo selfId DAST._INewtypeRange _1696_range0 = kind1.dtor_range; bool _1697_erase0 = kind1.dtor_erase; Dafny.ISequence _1698_attributes0 = resolved1.dtor_attributes; - unmatched91 = false; { Std.Wrappers._IOption _1699_nativeFromType; _1699_nativeFromType = DCOMP.COMP.NewtypeToRustType(_1695_b0, _1696_range0); @@ -4146,12 +4109,13 @@ public void GenExprConvertToNewtype(DAST._IExpression e, DCOMP._ISelfInfo selfId return ; } } + goto after_match37; } } } - if (unmatched91) { - unmatched91 = false; + { } + after_match37: ; if (object.Equals(_1679_fromTpe, DAST.Type.create_Primitive(DAST.Primitive.create_Char()))) { RAST._IExpr _1703_recursiveGen; DCOMP._IOwnership _1704_recOwned; @@ -4216,11 +4180,9 @@ public void GenExprConvertFromNewtype(DAST._IExpression e, DCOMP._ISelfInfo self _1720_recIdents = _out253; readIdents = _1720_recIdents; Std.Wrappers._IOption _source92 = _1717_nativeFromType; - bool unmatched92 = true; - if (unmatched92) { + { if (_source92.is_Some) { RAST._IType _1721_v = _source92.dtor_value; - unmatched92 = false; RAST._IType _1722_toTpeRust; RAST._IType _out254; _out254 = (this).GenType(_1708_toTpe, DCOMP.GenTypeContext.@default()); @@ -4231,10 +4193,10 @@ public void GenExprConvertFromNewtype(DAST._IExpression e, DCOMP._ISelfInfo self (this).FromOwned(r, expectedOwnership, out _out255, out _out256); r = _out255; resultingOwnership = _out256; + goto after_match38; } } - if (unmatched92) { - unmatched92 = false; + { if (_1713_erase) { r = _1718_recursiveGen; } else { @@ -4246,6 +4208,7 @@ public void GenExprConvertFromNewtype(DAST._IExpression e, DCOMP._ISelfInfo self r = _out257; resultingOwnership = _out258; } + after_match38: ; } else { if ((_1717_nativeFromType).is_Some) { if (object.Equals(_1708_toTpe, DAST.Type.create_Primitive(DAST.Primitive.create_Char()))) { @@ -4511,8 +4474,7 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM readIdents = _1775_recIdents; } else { _System._ITuple2 _source93 = _System.Tuple2.create(_1771_fromTpe, _1772_toTpe); - bool unmatched93 = true; - if (unmatched93) { + { DAST._IType _10 = _source93.dtor__1; if (_10.is_UserDefined) { DAST._IResolvedType resolved2 = _10.dtor_resolved; @@ -4522,7 +4484,6 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM DAST._INewtypeRange _1777_range = kind2.dtor_range; bool _1778_erase = kind2.dtor_erase; Dafny.ISequence _1779_attributes = resolved2.dtor_attributes; - unmatched93 = false; { RAST._IExpr _out289; DCOMP._IOwnership _out290; @@ -4532,10 +4493,11 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = _out290; readIdents = _out291; } + goto after_match39; } } } - if (unmatched93) { + { DAST._IType _00 = _source93.dtor__0; if (_00.is_UserDefined) { DAST._IResolvedType resolved3 = _00.dtor_resolved; @@ -4545,7 +4507,6 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM DAST._INewtypeRange _1781_range = kind3.dtor_range; bool _1782_erase = kind3.dtor_erase; Dafny.ISequence _1783_attributes = resolved3.dtor_attributes; - unmatched93 = false; { RAST._IExpr _out292; DCOMP._IOwnership _out293; @@ -4555,10 +4516,11 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = _out293; readIdents = _out294; } + goto after_match39; } } } - if (unmatched93) { + { DAST._IType _01 = _source93.dtor__0; if (_01.is_Primitive) { DAST._IPrimitive _h72 = _01.dtor_Primitive_a0; @@ -4567,7 +4529,6 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM if (_11.is_Primitive) { DAST._IPrimitive _h73 = _11.dtor_Primitive_a0; if (_h73.is_Real) { - unmatched93 = false; { RAST._IExpr _1784_recursiveGen; DCOMP._IOwnership _1785___v137; @@ -4587,12 +4548,13 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = _out299; readIdents = _1786_recIdents; } + goto after_match39; } } } } } - if (unmatched93) { + { DAST._IType _02 = _source93.dtor__0; if (_02.is_Primitive) { DAST._IPrimitive _h74 = _02.dtor_Primitive_a0; @@ -4601,7 +4563,6 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM if (_12.is_Primitive) { DAST._IPrimitive _h75 = _12.dtor_Primitive_a0; if (_h75.is_Int) { - unmatched93 = false; { RAST._IExpr _1787_recursiveGen; DCOMP._IOwnership _1788___v138; @@ -4621,19 +4582,19 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = _out304; readIdents = _1789_recIdents; } + goto after_match39; } } } } } - if (unmatched93) { + { DAST._IType _03 = _source93.dtor__0; if (_03.is_Primitive) { DAST._IPrimitive _h76 = _03.dtor_Primitive_a0; if (_h76.is_Int) { DAST._IType _13 = _source93.dtor__1; if (_13.is_Passthrough) { - unmatched93 = false; { RAST._IType _1790_rhsType; RAST._IType _out305; @@ -4657,18 +4618,18 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = _out310; readIdents = _1793_recIdents; } + goto after_match39; } } } } - if (unmatched93) { + { DAST._IType _04 = _source93.dtor__0; if (_04.is_Passthrough) { DAST._IType _14 = _source93.dtor__1; if (_14.is_Primitive) { DAST._IPrimitive _h77 = _14.dtor_Primitive_a0; if (_h77.is_Int) { - unmatched93 = false; { RAST._IType _1794_rhsType; RAST._IType _out311; @@ -4692,11 +4653,12 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = _out316; readIdents = _1797_recIdents; } + goto after_match39; } } } } - if (unmatched93) { + { DAST._IType _05 = _source93.dtor__0; if (_05.is_Primitive) { DAST._IPrimitive _h78 = _05.dtor_Primitive_a0; @@ -4705,7 +4667,6 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM if (_15.is_Primitive) { DAST._IPrimitive _h79 = _15.dtor_Primitive_a0; if (_h79.is_Char) { - unmatched93 = false; { RAST._IType _1798_rhsType; RAST._IType _out317; @@ -4729,12 +4690,13 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = _out322; readIdents = _1801_recIdents; } + goto after_match39; } } } } } - if (unmatched93) { + { DAST._IType _06 = _source93.dtor__0; if (_06.is_Primitive) { DAST._IPrimitive _h710 = _06.dtor_Primitive_a0; @@ -4743,7 +4705,6 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM if (_16.is_Primitive) { DAST._IPrimitive _h711 = _16.dtor_Primitive_a0; if (_h711.is_Int) { - unmatched93 = false; { RAST._IType _1802_rhsType; RAST._IType _out323; @@ -4767,17 +4728,17 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = _out328; readIdents = _1805_recIdents; } + goto after_match39; } } } } } - if (unmatched93) { + { DAST._IType _07 = _source93.dtor__0; if (_07.is_Passthrough) { DAST._IType _17 = _source93.dtor__1; if (_17.is_Passthrough) { - unmatched93 = false; { RAST._IExpr _1806_recursiveGen; DCOMP._IOwnership _1807___v147; @@ -4801,11 +4762,11 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM resultingOwnership = _out334; readIdents = _1808_recIdents; } + goto after_match39; } } } - if (unmatched93) { - unmatched93 = false; + { { RAST._IExpr _out335; DCOMP._IOwnership _out336; @@ -4816,6 +4777,7 @@ public void GenExprConvert(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOM readIdents = _out337; } } + after_match39: ; } return ; } @@ -4828,7 +4790,11 @@ public void GenIdent(Dafny.ISequence rName, DCOMP._ISelfInfo selfIde Std.Wrappers._IOption _1810_tpe; _1810_tpe = (env).GetType(rName); Std.Wrappers._IOption _1811_placeboOpt; - _1811_placeboOpt = (((_1810_tpe).is_Some) ? (((_1810_tpe).dtor_value).ExtractMaybePlacebo()) : (Std.Wrappers.Option.create_None())); + if ((_1810_tpe).is_Some) { + _1811_placeboOpt = ((_1810_tpe).dtor_value).ExtractMaybePlacebo(); + } else { + _1811_placeboOpt = Std.Wrappers.Option.create_None(); + } bool _1812_currentlyBorrowed; _1812_currentlyBorrowed = (env).IsBorrowed(rName); bool _1813_noNeedOfClone; @@ -4840,7 +4806,11 @@ public void GenIdent(Dafny.ISequence rName, DCOMP._ISelfInfo selfIde _1810_tpe = Std.Wrappers.Option.create_Some((_1811_placeboOpt).dtor_value); } if (object.Equals(expectedOwnership, DCOMP.Ownership.create_OwnershipAutoBorrowed())) { - resultingOwnership = ((_1812_currentlyBorrowed) ? (DCOMP.Ownership.create_OwnershipBorrowed()) : (DCOMP.Ownership.create_OwnershipOwned())); + if (_1812_currentlyBorrowed) { + resultingOwnership = DCOMP.Ownership.create_OwnershipBorrowed(); + } else { + resultingOwnership = DCOMP.Ownership.create_OwnershipOwned(); + } } else if (object.Equals(expectedOwnership, DCOMP.Ownership.create_OwnershipBorrowedMut())) { if ((rName).Equals(Dafny.Sequence.UnicodeFromString("self"))) { resultingOwnership = DCOMP.Ownership.create_OwnershipBorrowedMut(); @@ -4856,21 +4826,17 @@ public void GenIdent(Dafny.ISequence rName, DCOMP._ISelfInfo selfIde bool _1814_needObjectFromRef; _1814_needObjectFromRef = ((((selfIdent).is_ThisTyped) && ((selfIdent).IsSelf())) && (((selfIdent).dtor_rSelfName).Equals(rName))) && (((System.Func)(() => { DAST._IType _source94 = (selfIdent).dtor_dafnyType; - bool unmatched94 = true; - if (unmatched94) { + { if (_source94.is_UserDefined) { DAST._IResolvedType resolved4 = _source94.dtor_resolved; DAST._IResolvedTypeBase _1815_base = resolved4.dtor_kind; Dafny.ISequence _1816_attributes = resolved4.dtor_attributes; - unmatched94 = false; return ((_1815_base).is_Class) || ((_1815_base).is_Trait); } } - if (unmatched94) { - unmatched94 = false; + { return false; } - throw new System.Exception("unexpected control point"); }))()); if (_1814_needObjectFromRef) { r = ((((RAST.__default.dafny__runtime).MSel(Dafny.Sequence.UnicodeFromString("Object"))).ApplyType(Dafny.Sequence.FromElements(RAST.__default.RawType(Dafny.Sequence.UnicodeFromString("_"))))).MSel(Dafny.Sequence.UnicodeFromString("from_ref"))).Apply(Dafny.Sequence.FromElements(r)); @@ -4951,8 +4917,7 @@ public void GenArgs(DCOMP._ISelfInfo selfIdent, DAST._ICallName name, Dafny.ISeq typeExprs = Dafny.Sequence.Concat(typeExprs, Dafny.Sequence.FromElements(_1826_typeExpr)); } DAST._ICallName _source95 = name; - bool unmatched95 = true; - if (unmatched95) { + { if (_source95.is_CallName) { Dafny.ISequence _1827_nameIdent = _source95.dtor_name; Std.Wrappers._IOption onType1 = _source95.dtor_onType; @@ -4960,7 +4925,6 @@ public void GenArgs(DCOMP._ISelfInfo selfIdent, DAST._ICallName name, Dafny.ISeq DAST._IType value10 = onType1.dtor_value; if (value10.is_UserDefined) { DAST._IResolvedType _1828_resolvedType = value10.dtor_resolved; - unmatched95 = false; if ((((_1828_resolvedType).dtor_kind).is_Trait) || (Dafny.Helpers.Id, bool>>((_1829_resolvedType, _1830_nameIdent) => Dafny.Helpers.Quantifier>(((_1829_resolvedType).dtor_properMethods).UniqueElements, true, (((_forall_var_8) => { Dafny.ISequence _1831_m = (Dafny.ISequence)_forall_var_8; return !(((_1829_resolvedType).dtor_properMethods).Contains(_1831_m)) || (!object.Equals((_1831_m), _1830_nameIdent)); @@ -4969,14 +4933,15 @@ public void GenArgs(DCOMP._ISelfInfo selfIdent, DAST._ICallName name, Dafny.ISeq } else { fullNameQualifier = Std.Wrappers.Option.create_None(); } + goto after_match40; } } } } - if (unmatched95) { - unmatched95 = false; + { fullNameQualifier = Std.Wrappers.Option.create_None(); } + after_match40: ; if ((((((fullNameQualifier).is_Some) && ((selfIdent).is_ThisTyped)) && (((selfIdent).dtor_dafnyType).is_UserDefined)) && ((this).IsSameResolvedType(((selfIdent).dtor_dafnyType).dtor_resolved, (fullNameQualifier).dtor_value))) && (!((this).HasExternAttributeRenamingModule(((fullNameQualifier).dtor_value).dtor_attributes)))) { fullNameQualifier = Std.Wrappers.Option.create_None(); } @@ -4987,10 +4952,8 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = DCOMP.Ownership.Default(); readIdents = Dafny.Set>.Empty; DAST._IExpression _source96 = e; - bool unmatched96 = true; - if (unmatched96) { + { if (_source96.is_Literal) { - unmatched96 = false; RAST._IExpr _out343; DCOMP._IOwnership _out344; Dafny.ISet> _out345; @@ -4998,12 +4961,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv r = _out343; resultingOwnership = _out344; readIdents = _out345; + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Ident) { Dafny.ISequence _1832_name = _source96.dtor_name; - unmatched96 = false; { RAST._IExpr _out346; DCOMP._IOwnership _out347; @@ -5013,13 +4976,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out347; readIdents = _out348; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Companion) { Dafny.ISequence> _1833_path = _source96.dtor_Companion_a0; Dafny.ISequence _1834_typeArgs = _source96.dtor_typeArgs; - unmatched96 = false; { RAST._IExpr _out349; _out349 = DCOMP.COMP.GenPathExpr(_1833_path); @@ -5051,12 +5014,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_InitializationValue) { DAST._IType _1838_typ = _source96.dtor_typ; - unmatched96 = false; { RAST._IType _1839_typExpr; RAST._IType _out353; @@ -5075,12 +5038,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Tuple) { Dafny.ISequence _1840_values = _source96.dtor_Tuple_a0; - unmatched96 = false; { Dafny.ISequence _1841_exprs; _1841_exprs = Dafny.Sequence.FromElements(); @@ -5100,7 +5063,11 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv _1841_exprs = Dafny.Sequence.Concat(_1841_exprs, Dafny.Sequence.FromElements(_1843_recursiveGen)); readIdents = Dafny.Set>.Union(readIdents, _1845_recIdents); } - r = (((new BigInteger((_1840_values).Count)) <= (RAST.__default.MAX__TUPLE__SIZE)) ? (RAST.Expr.create_Tuple(_1841_exprs)) : (RAST.__default.SystemTuple(_1841_exprs))); + if ((new BigInteger((_1840_values).Count)) <= (RAST.__default.MAX__TUPLE__SIZE)) { + r = RAST.Expr.create_Tuple(_1841_exprs); + } else { + r = RAST.__default.SystemTuple(_1841_exprs); + } RAST._IExpr _out359; DCOMP._IOwnership _out360; (this).FromOwned(r, expectedOwnership, out _out359, out _out360); @@ -5108,14 +5075,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out360; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_New) { Dafny.ISequence> _1846_path = _source96.dtor_path; Dafny.ISequence _1847_typeArgs = _source96.dtor_typeArgs; Dafny.ISequence _1848_args = _source96.dtor_args; - unmatched96 = false; { RAST._IExpr _out361; _out361 = DCOMP.COMP.GenPathExpr(_1846_path); @@ -5160,13 +5127,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out367; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_NewUninitArray) { Dafny.ISequence _1857_dims = _source96.dtor_dims; DAST._IType _1858_typ = _source96.dtor_typ; - unmatched96 = false; { if ((new BigInteger(16)) < (new BigInteger((_1857_dims).Count))) { Dafny.ISequence _1859_msg; @@ -5214,12 +5181,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv r = _out372; resultingOwnership = _out373; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_ArrayIndexToInt) { DAST._IExpression _1867_underlying = _source96.dtor_value; - unmatched96 = false; { RAST._IExpr _1868_recursiveGen; DCOMP._IOwnership _1869___v162; @@ -5239,13 +5206,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv r = _out377; resultingOwnership = _out378; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_FinalizeNewArray) { DAST._IExpression _1871_underlying = _source96.dtor_value; DAST._IType _1872_typ = _source96.dtor_typ; - unmatched96 = false; { RAST._IType _1873_tpe; RAST._IType _out379; @@ -5285,16 +5252,16 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv r = _out383; resultingOwnership = _out384; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_DatatypeValue) { DAST._IResolvedType _1879_datatypeType = _source96.dtor_datatypeType; Dafny.ISequence _1880_typeArgs = _source96.dtor_typeArgs; Dafny.ISequence _1881_variant = _source96.dtor_variant; bool _1882_isCo = _source96.dtor_isCo; Dafny.ISequence<_System._ITuple2, DAST._IExpression>> _1883_values = _source96.dtor_contents; - unmatched96 = false; { RAST._IExpr _out385; _out385 = DCOMP.COMP.GenPathExpr((_1879_datatypeType).dtor_path); @@ -5377,11 +5344,11 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out394; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Convert) { - unmatched96 = false; { RAST._IExpr _out395; DCOMP._IOwnership _out396; @@ -5391,13 +5358,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out396; readIdents = _out397; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_SeqConstruct) { DAST._IExpression _1900_length = _source96.dtor_length; DAST._IExpression _1901_expr = _source96.dtor_elem; - unmatched96 = false; { RAST._IExpr _1902_recursiveGen; DCOMP._IOwnership _1903___v169; @@ -5428,13 +5395,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out405; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_SeqValue) { Dafny.ISequence _1908_exprs = _source96.dtor_elements; DAST._IType _1909_typ = _source96.dtor_typ; - unmatched96 = false; { readIdents = Dafny.Set>.FromElements(); RAST._IType _1910_genTpe; @@ -5471,12 +5438,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out411; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_SetValue) { Dafny.ISequence _1916_exprs = _source96.dtor_elements; - unmatched96 = false; { Dafny.ISequence _1917_generatedValues; _1917_generatedValues = Dafny.Sequence.FromElements(); @@ -5506,12 +5473,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out416; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_MultisetValue) { Dafny.ISequence _1922_exprs = _source96.dtor_elements; - unmatched96 = false; { Dafny.ISequence _1923_generatedValues; _1923_generatedValues = Dafny.Sequence.FromElements(); @@ -5541,12 +5508,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out421; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_ToMultiset) { DAST._IExpression _1928_expr = _source96.dtor_ToMultiset_a0; - unmatched96 = false; { RAST._IExpr _1929_recursiveGen; DCOMP._IOwnership _1930___v174; @@ -5567,12 +5534,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out426; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_MapValue) { Dafny.ISequence<_System._ITuple2> _1932_mapElems = _source96.dtor_mapElems; - unmatched96 = false; { Dafny.ISequence<_System._ITuple2> _1933_generatedValues; _1933_generatedValues = Dafny.Sequence<_System._ITuple2>.FromElements(); @@ -5623,14 +5590,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out434; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_SeqUpdate) { DAST._IExpression _1944_expr = _source96.dtor_expr; DAST._IExpression _1945_index = _source96.dtor_indexExpr; DAST._IExpression _1946_value = _source96.dtor_value; - unmatched96 = false; { RAST._IExpr _1947_exprR; DCOMP._IOwnership _1948___v177; @@ -5671,14 +5638,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = Dafny.Set>.Union(Dafny.Set>.Union(_1949_exprIdents, _1952_indexIdents), _1955_valueIdents); return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_MapUpdate) { DAST._IExpression _1956_expr = _source96.dtor_expr; DAST._IExpression _1957_index = _source96.dtor_indexExpr; DAST._IExpression _1958_value = _source96.dtor_value; - unmatched96 = false; { RAST._IExpr _1959_exprR; DCOMP._IOwnership _1960___v178; @@ -5719,19 +5686,17 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = Dafny.Set>.Union(Dafny.Set>.Union(_1961_exprIdents, _1964_indexIdents), _1967_valueIdents); return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_This) { - unmatched96 = false; { DCOMP._ISelfInfo _source97 = selfIdent; - bool unmatched97 = true; - if (unmatched97) { + { if (_source97.is_ThisTyped) { Dafny.ISequence _1968_id = _source97.dtor_rSelfName; DAST._IType _1969_dafnyType = _source97.dtor_dafnyType; - unmatched97 = false; { RAST._IExpr _out457; DCOMP._IOwnership _out458; @@ -5741,11 +5706,11 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out458; readIdents = _out459; } + goto after_match42; } } - if (unmatched97) { + { DCOMP._ISelfInfo _1970_None = _source97; - unmatched97 = false; { r = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("panic!(\"this outside of a method\")")); RAST._IExpr _out460; @@ -5756,16 +5721,17 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = Dafny.Set>.FromElements(); } } + after_match42: ; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Ite) { DAST._IExpression _1971_cond = _source96.dtor_cond; DAST._IExpression _1972_t = _source96.dtor_thn; DAST._IExpression _1973_f = _source96.dtor_els; - unmatched96 = false; { RAST._IExpr _1974_cond; DCOMP._IOwnership _1975___v179; @@ -5806,15 +5772,15 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = Dafny.Set>.Union(Dafny.Set>.Union(_1976_recIdentsCond, _1982_recIdentsT), _1979_recIdentsF); return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_UnOp) { DAST._IUnaryOp unOp0 = _source96.dtor_unOp; if (unOp0.is_Not) { DAST._IExpression _1983_e = _source96.dtor_expr; DAST.Format._IUnaryOpFormat _1984_format = _source96.dtor_format1; - unmatched96 = false; { RAST._IExpr _1985_recursiveGen; DCOMP._IOwnership _1986___v181; @@ -5835,16 +5801,16 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _1987_recIdents; return ; } + goto after_match41; } } } - if (unmatched96) { + { if (_source96.is_UnOp) { DAST._IUnaryOp unOp1 = _source96.dtor_unOp; if (unOp1.is_BitwiseNot) { DAST._IExpression _1988_e = _source96.dtor_expr; DAST.Format._IUnaryOpFormat _1989_format = _source96.dtor_format1; - unmatched96 = false; { RAST._IExpr _1990_recursiveGen; DCOMP._IOwnership _1991___v182; @@ -5865,16 +5831,16 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _1992_recIdents; return ; } + goto after_match41; } } } - if (unmatched96) { + { if (_source96.is_UnOp) { DAST._IUnaryOp unOp2 = _source96.dtor_unOp; if (unOp2.is_Cardinality) { DAST._IExpression _1993_e = _source96.dtor_expr; DAST.Format._IUnaryOpFormat _1994_format = _source96.dtor_format1; - unmatched96 = false; { RAST._IExpr _1995_recursiveGen; DCOMP._IOwnership _1996_recOwned; @@ -5895,12 +5861,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _1997_recIdents; return ; } + goto after_match41; } } } - if (unmatched96) { + { if (_source96.is_BinOp) { - unmatched96 = false; RAST._IExpr _out488; DCOMP._IOwnership _out489; Dafny.ISet> _out490; @@ -5908,15 +5874,15 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv r = _out488; resultingOwnership = _out489; readIdents = _out490; + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_ArrayLen) { DAST._IExpression _1998_expr = _source96.dtor_expr; DAST._IType _1999_exprType = _source96.dtor_exprType; BigInteger _2000_dim = _source96.dtor_dim; bool _2001_native = _source96.dtor_native; - unmatched96 = false; { RAST._IExpr _2002_recursiveGen; DCOMP._IOwnership _2003___v187; @@ -5961,12 +5927,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _2004_recIdents; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_MapKeys) { DAST._IExpression _2008_expr = _source96.dtor_expr; - unmatched96 = false; { RAST._IExpr _2009_recursiveGen; DCOMP._IOwnership _2010___v188; @@ -5987,12 +5953,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out501; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_MapValues) { DAST._IExpression _2012_expr = _source96.dtor_expr; - unmatched96 = false; { RAST._IExpr _2013_recursiveGen; DCOMP._IOwnership _2014___v189; @@ -6013,16 +5979,16 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out506; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_SelectFn) { DAST._IExpression _2016_on = _source96.dtor_expr; Dafny.ISequence _2017_field = _source96.dtor_field; bool _2018_isDatatype = _source96.dtor_onDatatype; bool _2019_isStatic = _source96.dtor_isStatic; BigInteger _2020_arity = _source96.dtor_arity; - unmatched96 = false; { RAST._IExpr _2021_onExpr; DCOMP._IOwnership _2022_onOwned; @@ -6080,9 +6046,10 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _2023_recIdents; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Select) { DAST._IExpression expr0 = _source96.dtor_expr; if (expr0.is_Companion) { @@ -6092,7 +6059,6 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv bool _2033_isConstant = _source96.dtor_isConstant; bool _2034_isDatatype = _source96.dtor_onDatatype; DAST._IType _2035_fieldType = _source96.dtor_fieldType; - unmatched96 = false; { RAST._IExpr _2036_onExpr; DCOMP._IOwnership _2037_onOwned; @@ -6113,17 +6079,17 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _2038_recIdents; return ; } + goto after_match41; } } } - if (unmatched96) { + { if (_source96.is_Select) { DAST._IExpression _2039_on = _source96.dtor_expr; Dafny.ISequence _2040_field = _source96.dtor_field; bool _2041_isConstant = _source96.dtor_isConstant; bool _2042_isDatatype = _source96.dtor_onDatatype; DAST._IType _2043_fieldType = _source96.dtor_fieldType; - unmatched96 = false; { if (_2042_isDatatype) { RAST._IExpr _2044_onExpr; @@ -6161,8 +6127,7 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv r = _2048_onExpr; if (!object.Equals(_2048_onExpr, RAST.__default.self)) { RAST._IExpr _source98 = _2048_onExpr; - bool unmatched98 = true; - if (unmatched98) { + { if (_source98.is_UnaryOp) { Dafny.ISequence op15 = _source98.dtor_op1; if (object.Equals(op15, Dafny.Sequence.UnicodeFromString("&"))) { @@ -6170,16 +6135,16 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv if (underlying5.is_Identifier) { Dafny.ISequence name15 = underlying5.dtor_name; if (object.Equals(name15, Dafny.Sequence.UnicodeFromString("this"))) { - unmatched98 = false; r = RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("this")); + goto after_match43; } } } } } - if (unmatched98) { - unmatched98 = false; + { } + after_match43: ; if (((this).ObjectType).is_RcMut) { r = (r).Clone(); } @@ -6199,14 +6164,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv } return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Index) { DAST._IExpression _2051_on = _source96.dtor_expr; DAST._ICollKind _2052_collKind = _source96.dtor_collKind; Dafny.ISequence _2053_indices = _source96.dtor_indices; - unmatched96 = false; { RAST._IExpr _2054_onExpr; DCOMP._IOwnership _2055_onOwned; @@ -6270,15 +6235,15 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out538; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_IndexRange) { DAST._IExpression _2065_on = _source96.dtor_expr; bool _2066_isArray = _source96.dtor_isArray; Std.Wrappers._IOption _2067_low = _source96.dtor_low; Std.Wrappers._IOption _2068_high = _source96.dtor_high; - unmatched96 = false; { RAST._IExpr _2069_onExpr; DCOMP._IOwnership _2070_onOwned; @@ -6292,15 +6257,23 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv _2071_recIdents = _out541; readIdents = _2071_recIdents; Dafny.ISequence _2072_methodName; - _2072_methodName = (((_2067_low).is_Some) ? ((((_2068_high).is_Some) ? (Dafny.Sequence.UnicodeFromString("slice")) : (Dafny.Sequence.UnicodeFromString("drop")))) : ((((_2068_high).is_Some) ? (Dafny.Sequence.UnicodeFromString("take")) : (Dafny.Sequence.UnicodeFromString(""))))); + if ((_2067_low).is_Some) { + if ((_2068_high).is_Some) { + _2072_methodName = Dafny.Sequence.UnicodeFromString("slice"); + } else { + _2072_methodName = Dafny.Sequence.UnicodeFromString("drop"); + } + } else if ((_2068_high).is_Some) { + _2072_methodName = Dafny.Sequence.UnicodeFromString("take"); + } else { + _2072_methodName = Dafny.Sequence.UnicodeFromString(""); + } Dafny.ISequence _2073_arguments; _2073_arguments = Dafny.Sequence.FromElements(); Std.Wrappers._IOption _source99 = _2067_low; - bool unmatched99 = true; - if (unmatched99) { + { if (_source99.is_Some) { DAST._IExpression _2074_l = _source99.dtor_value; - unmatched99 = false; { RAST._IExpr _2075_lExpr; DCOMP._IOwnership _2076___v192; @@ -6315,17 +6288,16 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv _2073_arguments = Dafny.Sequence.Concat(_2073_arguments, Dafny.Sequence.FromElements(_2075_lExpr)); readIdents = Dafny.Set>.Union(readIdents, _2077_recIdentsL); } + goto after_match44; } } - if (unmatched99) { - unmatched99 = false; + { } + after_match44: ; Std.Wrappers._IOption _source100 = _2068_high; - bool unmatched100 = true; - if (unmatched100) { + { if (_source100.is_Some) { DAST._IExpression _2078_h = _source100.dtor_value; - unmatched100 = false; { RAST._IExpr _2079_hExpr; DCOMP._IOwnership _2080___v193; @@ -6340,11 +6312,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv _2073_arguments = Dafny.Sequence.Concat(_2073_arguments, Dafny.Sequence.FromElements(_2079_hExpr)); readIdents = Dafny.Set>.Union(readIdents, _2081_recIdentsH); } + goto after_match45; } } - if (unmatched100) { - unmatched100 = false; + { } + after_match45: ; r = _2069_onExpr; if (_2066_isArray) { if (!(_2072_methodName).Equals(Dafny.Sequence.UnicodeFromString(""))) { @@ -6363,14 +6336,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out549; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_TupleSelect) { DAST._IExpression _2082_on = _source96.dtor_expr; BigInteger _2083_idx = _source96.dtor_index; DAST._IType _2084_fieldType = _source96.dtor_fieldType; - unmatched96 = false; { RAST._IExpr _2085_onExpr; DCOMP._IOwnership _2086_onOwnership; @@ -6385,19 +6358,18 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv Dafny.ISequence _2088_selName; _2088_selName = Std.Strings.__default.OfNat(_2083_idx); DAST._IType _source101 = _2084_fieldType; - bool unmatched101 = true; - if (unmatched101) { + { if (_source101.is_Tuple) { Dafny.ISequence _2089_tps = _source101.dtor_Tuple_a0; - unmatched101 = false; if (((_2084_fieldType).is_Tuple) && ((new BigInteger((_2089_tps).Count)) > (RAST.__default.MAX__TUPLE__SIZE))) { _2088_selName = Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("_"), _2088_selName); } + goto after_match46; } } - if (unmatched101) { - unmatched101 = false; + { } + after_match46: ; r = ((_2085_onExpr).Sel(_2088_selName)).Clone(); RAST._IExpr _out553; DCOMP._IOwnership _out554; @@ -6407,15 +6379,15 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _2087_recIdents; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Call) { DAST._IExpression _2090_on = _source96.dtor_on; DAST._ICallName _2091_name = _source96.dtor_callName; Dafny.ISequence _2092_typeArgs = _source96.dtor_typeArgs; Dafny.ISequence _2093_args = _source96.dtor_args; - unmatched96 = false; { Dafny.ISequence _2094_argExprs; Dafny.ISet> _2095_recIdents; @@ -6432,14 +6404,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv _2097_fullNameQualifier = _out558; readIdents = _2095_recIdents; Std.Wrappers._IOption _source102 = _2097_fullNameQualifier; - bool unmatched102 = true; - if (unmatched102) { + { if (_source102.is_Some) { DAST._IResolvedType value11 = _source102.dtor_value; Dafny.ISequence> _2098_path = value11.dtor_path; Dafny.ISequence _2099_onTypeArgs = value11.dtor_typeArgs; DAST._IResolvedTypeBase _2100_base = value11.dtor_kind; - unmatched102 = false; RAST._IExpr _2101_fullPath; RAST._IExpr _out559; _out559 = DCOMP.COMP.GenPathExpr(_2098_path); @@ -6477,10 +6447,10 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv (this).FromOwned(r, expectedOwnership, out _out567, out _out568); r = _out567; resultingOwnership = _out568; + goto after_match47; } } - if (unmatched102) { - unmatched102 = false; + { RAST._IExpr _2106_onExpr; DCOMP._IOwnership _2107___v199; Dafny.ISet> _2108_recIdents; @@ -6493,62 +6463,49 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv _2108_recIdents = _out571; readIdents = Dafny.Set>.Union(readIdents, _2108_recIdents); Dafny.ISequence _2109_renderedName; - _2109_renderedName = ((System.Func>)(() => { - DAST._ICallName _source103 = _2091_name; - bool unmatched103 = true; - if (unmatched103) { - if (_source103.is_CallName) { - Dafny.ISequence _2110_ident = _source103.dtor_name; - unmatched103 = false; - return DCOMP.__default.escapeName(_2110_ident); - } + DAST._ICallName _source103 = _2091_name; + { + if (_source103.is_CallName) { + Dafny.ISequence _2110_ident = _source103.dtor_name; + _2109_renderedName = DCOMP.__default.escapeName(_2110_ident); + goto after_match48; } - if (unmatched103) { - bool disjunctiveMatch15 = false; - if (_source103.is_MapBuilderAdd) { - disjunctiveMatch15 = true; - } - if (_source103.is_SetBuilderAdd) { - disjunctiveMatch15 = true; - } - if (disjunctiveMatch15) { - unmatched103 = false; - return Dafny.Sequence.UnicodeFromString("add"); - } + } + { + bool disjunctiveMatch13 = false; + if (_source103.is_MapBuilderAdd) { + disjunctiveMatch13 = true; } - if (unmatched103) { - bool disjunctiveMatch16 = false; - disjunctiveMatch16 = true; - disjunctiveMatch16 = true; - if (disjunctiveMatch16) { - unmatched103 = false; - return Dafny.Sequence.UnicodeFromString("build"); - } + if (_source103.is_SetBuilderAdd) { + disjunctiveMatch13 = true; + } + if (disjunctiveMatch13) { + _2109_renderedName = Dafny.Sequence.UnicodeFromString("add"); + goto after_match48; } - throw new System.Exception("unexpected control point"); - }))(); + } + { + _2109_renderedName = Dafny.Sequence.UnicodeFromString("build"); + } + after_match48: ; DAST._IExpression _source104 = _2090_on; - bool unmatched104 = true; - if (unmatched104) { + { if (_source104.is_Companion) { - unmatched104 = false; { _2106_onExpr = (_2106_onExpr).MSel(_2109_renderedName); } + goto after_match49; } } - if (unmatched104) { - unmatched104 = false; + { { if (!object.Equals(_2106_onExpr, RAST.__default.self)) { DAST._ICallName _source105 = _2091_name; - bool unmatched105 = true; - if (unmatched105) { + { if (_source105.is_CallName) { Std.Wrappers._IOption onType2 = _source105.dtor_onType; if (onType2.is_Some) { DAST._IType _2111_tpe = onType2.dtor_value; - unmatched105 = false; RAST._IType _2112_typ; RAST._IType _out572; _out572 = (this).GenType(_2111_tpe, DCOMP.GenTypeContext.@default()); @@ -6556,16 +6513,18 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv if ((_2112_typ).IsObjectOrPointer()) { _2106_onExpr = ((this).read__macro).Apply1(_2106_onExpr); } + goto after_match50; } } } - if (unmatched105) { - unmatched105 = false; + { } + after_match50: ; } _2106_onExpr = (_2106_onExpr).Sel(_2109_renderedName); } } + after_match49: ; r = ((_2106_onExpr).ApplyType(_2096_typeExprs)).Apply(_2094_argExprs); RAST._IExpr _out573; DCOMP._IOwnership _out574; @@ -6574,15 +6533,16 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out574; return ; } + after_match47: ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Lambda) { Dafny.ISequence _2113_paramsDafny = _source96.dtor_params; DAST._IType _2114_retType = _source96.dtor_retType; Dafny.ISequence _2115_body = _source96.dtor_body; - unmatched96 = false; { Dafny.ISequence _2116_params; Dafny.ISequence _out575; @@ -6666,14 +6626,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out584; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_BetaRedex) { Dafny.ISequence<_System._ITuple2> _2134_values = _source96.dtor_values; DAST._IType _2135_retType = _source96.dtor_retType; DAST._IExpression _2136_expr = _source96.dtor_expr; - unmatched96 = false; { Dafny.ISequence> _2137_paramNames; _2137_paramNames = Dafny.Sequence>.FromElements(); @@ -6739,15 +6699,15 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out594; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_IIFE) { Dafny.ISequence _2154_name = _source96.dtor_ident; DAST._IType _2155_tpe = _source96.dtor_typ; DAST._IExpression _2156_value = _source96.dtor_value; DAST._IExpression _2157_iifeBody = _source96.dtor_iifeBody; - unmatched96 = false; { RAST._IExpr _2158_valueGen; DCOMP._IOwnership _2159___v214; @@ -6783,13 +6743,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out603; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_Apply) { DAST._IExpression _2165_func = _source96.dtor_expr; Dafny.ISequence _2166_args = _source96.dtor_args; - unmatched96 = false; { RAST._IExpr _2167_funcExpr; DCOMP._IOwnership _2168___v216; @@ -6827,14 +6787,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out611; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_TypeTest) { DAST._IExpression _2175_on = _source96.dtor_on; Dafny.ISequence> _2176_dType = _source96.dtor_dType; Dafny.ISequence _2177_variant = _source96.dtor_variant; - unmatched96 = false; { RAST._IExpr _2178_exprGen; DCOMP._IOwnership _2179___v217; @@ -6859,11 +6819,11 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _2180_recIdents; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_BoolBoundedPool) { - unmatched96 = false; { r = RAST.Expr.create_RawExpr(Dafny.Sequence.UnicodeFromString("[false, true]")); RAST._IExpr _out618; @@ -6874,12 +6834,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_SetBoundedPool) { DAST._IExpression _2182_of = _source96.dtor_of; - unmatched96 = false; { RAST._IExpr _2183_exprGen; DCOMP._IOwnership _2184___v218; @@ -6900,13 +6860,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _2185_recIdents; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_SeqBoundedPool) { DAST._IExpression _2186_of = _source96.dtor_of; bool _2187_includeDuplicates = _source96.dtor_includeDuplicates; - unmatched96 = false; { RAST._IExpr _2188_exprGen; DCOMP._IOwnership _2189___v219; @@ -6930,12 +6890,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _2190_recIdents; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_MapBoundedPool) { DAST._IExpression _2191_of = _source96.dtor_of; - unmatched96 = false; { RAST._IExpr _2192_exprGen; DCOMP._IOwnership _2193___v220; @@ -6955,14 +6915,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv r = _out633; resultingOwnership = _out634; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_IntRange) { DAST._IExpression _2195_lo = _source96.dtor_lo; DAST._IExpression _2196_hi = _source96.dtor_hi; bool _2197_up = _source96.dtor_up; - unmatched96 = false; { RAST._IExpr _2198_lo; DCOMP._IOwnership _2199___v221; @@ -6997,13 +6957,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = Dafny.Set>.Union(_2200_recIdentsLo, _2203_recIdentsHi); return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_UnboundedIntRange) { DAST._IExpression _2204_start = _source96.dtor_start; bool _2205_up = _source96.dtor_up; - unmatched96 = false; { RAST._IExpr _2206_start; DCOMP._IOwnership _2207___v223; @@ -7028,13 +6988,13 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = _2208_recIdentStart; return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_MapBuilder) { DAST._IType _2209_keyType = _source96.dtor_keyType; DAST._IType _2210_valueType = _source96.dtor_valueType; - unmatched96 = false; { RAST._IType _2211_kType; RAST._IType _out648; @@ -7053,12 +7013,12 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv readIdents = Dafny.Set>.FromElements(); return ; } + goto after_match41; } } - if (unmatched96) { + { if (_source96.is_SetBuilder) { DAST._IType _2213_elemType = _source96.dtor_elemType; - unmatched96 = false; { RAST._IType _2214_eType; RAST._IType _out652; @@ -7073,14 +7033,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out654; return ; } + goto after_match41; } } - if (unmatched96) { + { DAST._IType _2215_elemType = _source96.dtor_elemType; DAST._IExpression _2216_collection = _source96.dtor_collection; bool _2217_is__forall = _source96.dtor_is__forall; DAST._IExpression _2218_lambda = _source96.dtor_lambda; - unmatched96 = false; { RAST._IType _2219_tpe; RAST._IType _out655; @@ -7108,13 +7068,14 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv _2225_newFormals = Dafny.Sequence.FromElements(); BigInteger _hi51 = new BigInteger((_2224_formals).Count); for (BigInteger _2226_i = BigInteger.Zero; _2226_i < _hi51; _2226_i++) { - var _pat_let_tv143 = _2223_extraAttributes; - var _pat_let_tv144 = _2224_formals; - _2225_newFormals = Dafny.Sequence.Concat(_2225_newFormals, Dafny.Sequence.FromElements(Dafny.Helpers.Let((_2224_formals).Select(_2226_i), _pat_let38_0 => Dafny.Helpers.Let(_pat_let38_0, _2227_dt__update__tmp_h0 => Dafny.Helpers.Let, DAST._IFormal>(Dafny.Sequence.Concat(_pat_let_tv143, ((_pat_let_tv144).Select(_2226_i)).dtor_attributes), _pat_let39_0 => Dafny.Helpers.Let, DAST._IFormal>(_pat_let39_0, _2228_dt__update_hattributes_h0 => DAST.Formal.create((_2227_dt__update__tmp_h0).dtor_name, (_2227_dt__update__tmp_h0).dtor_typ, _2228_dt__update_hattributes_h0))))))); + var _pat_let_tv4 = _2223_extraAttributes; + var _pat_let_tv5 = _2224_formals; + _2225_newFormals = Dafny.Sequence.Concat(_2225_newFormals, Dafny.Sequence.FromElements(Dafny.Helpers.Let((_2224_formals).Select(_2226_i), _pat_let34_0 => Dafny.Helpers.Let(_pat_let34_0, _2227_dt__update__tmp_h0 => Dafny.Helpers.Let, DAST._IFormal>(Dafny.Sequence.Concat(_pat_let_tv4, ((_pat_let_tv5).Select(_2226_i)).dtor_attributes), _pat_let35_0 => Dafny.Helpers.Let, DAST._IFormal>(_pat_let35_0, _2228_dt__update_hattributes_h0 => DAST.Formal.create((_2227_dt__update__tmp_h0).dtor_name, (_2227_dt__update__tmp_h0).dtor_typ, _2228_dt__update_hattributes_h0))))))); } - var _pat_let_tv145 = _2225_newFormals; DAST._IExpression _2229_newLambda; - _2229_newLambda = Dafny.Helpers.Let(_2218_lambda, _pat_let40_0 => Dafny.Helpers.Let(_pat_let40_0, _2230_dt__update__tmp_h1 => Dafny.Helpers.Let, DAST._IExpression>(_pat_let_tv145, _pat_let41_0 => Dafny.Helpers.Let, DAST._IExpression>(_pat_let41_0, _2231_dt__update_hparams_h0 => DAST.Expression.create_Lambda(_2231_dt__update_hparams_h0, (_2230_dt__update__tmp_h1).dtor_retType, (_2230_dt__update__tmp_h1).dtor_body))))); + DAST._IExpression _2230_dt__update__tmp_h1 = _2218_lambda; + Dafny.ISequence _2231_dt__update_hparams_h0 = _2225_newFormals; + _2229_newLambda = DAST.Expression.create_Lambda(_2231_dt__update_hparams_h0, (_2230_dt__update__tmp_h1).dtor_retType, (_2230_dt__update__tmp_h1).dtor_body); RAST._IExpr _2232_lambdaGen; DCOMP._IOwnership _2233___v225; Dafny.ISet> _2234_recLambdaIdents; @@ -7126,7 +7087,11 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv _2233___v225 = _out660; _2234_recLambdaIdents = _out661; Dafny.ISequence _2235_fn; - _2235_fn = ((_2217_is__forall) ? (Dafny.Sequence.UnicodeFromString("all")) : (Dafny.Sequence.UnicodeFromString("any"))); + if (_2217_is__forall) { + _2235_fn = Dafny.Sequence.UnicodeFromString("all"); + } else { + _2235_fn = Dafny.Sequence.UnicodeFromString("any"); + } r = ((_2220_collectionGen).Sel(_2235_fn)).Apply1(((_2232_lambdaGen).Sel(Dafny.Sequence.UnicodeFromString("as_ref"))).Apply(Dafny.Sequence.FromElements())); readIdents = Dafny.Set>.Union(_2222_recIdents, _2234_recLambdaIdents); } else { @@ -7141,6 +7106,7 @@ public void GenExpr(DAST._IExpression e, DCOMP._ISelfInfo selfIdent, DCOMP._IEnv resultingOwnership = _out663; } } + after_match41: ; } public Dafny.ISequence Compile(Dafny.ISequence p) { diff --git a/Source/DafnyCore/GeneratedFromDafny/RAST.cs b/Source/DafnyCore/GeneratedFromDafny/RAST.cs index d6cec2e8b57..c8a5fe19bfd 100644 --- a/Source/DafnyCore/GeneratedFromDafny/RAST.cs +++ b/Source/DafnyCore/GeneratedFromDafny/RAST.cs @@ -302,28 +302,20 @@ public Dafny.ISequence dtor_body { } public abstract _IMod DowncastClone(); public Dafny.ISequence _ToString(Dafny.ISequence ind) { - var _pat_let_tv37 = ind; - var _pat_let_tv38 = ind; - var _pat_let_tv39 = ind; - var _pat_let_tv40 = ind; RAST._IMod _source27 = this; - bool unmatched27 = true; - if (unmatched27) { + { if (_source27.is_ExternMod) { Dafny.ISequence _791_name = _source27.dtor_name; - unmatched27 = false; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("pub mod "), _791_name), Dafny.Sequence.UnicodeFromString(";")); } } - if (unmatched27) { + { Dafny.ISequence _792_name = _source27.dtor_name; Dafny.ISequence _793_body = _source27.dtor_body; - unmatched27 = false; - 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("pub mod "), _792_name), Dafny.Sequence.UnicodeFromString(" {")), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv37), RAST.__default.IND), RAST.__default.SeqToString(_793_body, Dafny.Helpers.Id, Func>>>((_794_ind) => ((System.Func>)((_795_modDecl) => { + 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("pub mod "), _792_name), Dafny.Sequence.UnicodeFromString(" {")), Dafny.Sequence.UnicodeFromString("\n")), ind), RAST.__default.IND), RAST.__default.SeqToString(_793_body, Dafny.Helpers.Id, Func>>>((_794_ind) => ((System.Func>)((_795_modDecl) => { return (_795_modDecl)._ToString(Dafny.Sequence.Concat(_794_ind, RAST.__default.IND)); - })))(_pat_let_tv38), Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n\n"), _pat_let_tv39), RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv40), Dafny.Sequence.UnicodeFromString("}")); + })))(ind), Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n\n"), ind), RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } - throw new System.Exception("unexpected control point"); } } public class Mod_Mod : Mod { @@ -1948,107 +1940,85 @@ public Std.Wrappers._IOption> dtor_size { } public abstract _IType DowncastClone(); public RAST._IType Replace(Dafny.IMap mapping) { - var _pat_let_tv41 = mapping; - var _pat_let_tv42 = mapping; - var _pat_let_tv43 = mapping; - var _pat_let_tv44 = mapping; - var _pat_let_tv45 = mapping; - var _pat_let_tv46 = mapping; - var _pat_let_tv47 = mapping; - var _pat_let_tv48 = mapping; - var _pat_let_tv49 = mapping; - var _pat_let_tv50 = mapping; - var _pat_let_tv51 = mapping; - var _pat_let_tv52 = mapping; - var _pat_let_tv53 = mapping; - var _pat_let_tv54 = mapping; - var _pat_let_tv55 = mapping; if ((mapping).Contains(this)) { return Dafny.Map.Select(mapping,this); } else { RAST._IType _source28 = this; - bool unmatched28 = true; - if (unmatched28) { + { if (_source28.is_SelfOwned) { - unmatched28 = false; return this; } } - if (unmatched28) { - bool disjunctiveMatch1 = false; + { + bool disjunctiveMatch0 = false; if (_source28.is_U8) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_U16) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_U32) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_U64) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_U128) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_I8) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_I16) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_I32) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_I64) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_I128) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } if (_source28.is_Bool) { - disjunctiveMatch1 = true; + disjunctiveMatch0 = true; } - if (disjunctiveMatch1) { - unmatched28 = false; + if (disjunctiveMatch0) { return this; } } - if (unmatched28) { + { if (_source28.is_TIdentifier) { - unmatched28 = false; return this; } } - if (unmatched28) { + { if (_source28.is_TMemberSelect) { RAST._IType _816_base = _source28.dtor_base; Dafny.ISequence _817_name = _source28.dtor_name; - unmatched28 = false; RAST._IType _818_dt__update__tmp_h0 = this; - RAST._IType _819_dt__update_hbase_h0 = (_816_base).Replace(_pat_let_tv41); + RAST._IType _819_dt__update_hbase_h0 = (_816_base).Replace(mapping); return RAST.Type.create_TMemberSelect(_819_dt__update_hbase_h0, (_818_dt__update__tmp_h0).dtor_name); } } - if (unmatched28) { + { if (_source28.is_TypeApp) { RAST._IType _820_baseName = _source28.dtor_baseName; Dafny.ISequence _821_arguments = _source28.dtor_arguments; - unmatched28 = false; RAST._IType _822_dt__update__tmp_h1 = this; Dafny.ISequence _823_dt__update_harguments_h0 = Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Dafny.ISequence, Func>>((_824_mapping, _825_arguments) => ((System.Func)((_826_t) => { return (_826_t).Replace(_824_mapping); - })))(_pat_let_tv42, _821_arguments), _821_arguments); - RAST._IType _827_dt__update_hbaseName_h0 = (_820_baseName).Replace(_pat_let_tv43); + })))(mapping, _821_arguments), _821_arguments); + RAST._IType _827_dt__update_hbaseName_h0 = (_820_baseName).Replace(mapping); return RAST.Type.create_TypeApp(_827_dt__update_hbaseName_h0, _823_dt__update_harguments_h0); } } - if (unmatched28) { + { if (_source28.is_Borrowed) { RAST._IType _828_underlying = _source28.dtor_underlying; - unmatched28 = false; RAST._IType _829_dt__update__tmp_h2 = this; - RAST._IType _830_dt__update_hunderlying_h0 = (_828_underlying).Replace(_pat_let_tv44); + RAST._IType _830_dt__update_hunderlying_h0 = (_828_underlying).Replace(mapping); if ((_829_dt__update__tmp_h2).is_Borrowed) { return RAST.Type.create_Borrowed(_830_dt__update_hunderlying_h0); } else if ((_829_dt__update__tmp_h2).is_BorrowedMut) { @@ -2066,12 +2036,11 @@ public RAST._IType Replace(Dafny.IMap mapping) { } } } - if (unmatched28) { + { if (_source28.is_BorrowedMut) { RAST._IType _831_underlying = _source28.dtor_underlying; - unmatched28 = false; RAST._IType _832_dt__update__tmp_h3 = this; - RAST._IType _833_dt__update_hunderlying_h1 = (_831_underlying).Replace(_pat_let_tv45); + RAST._IType _833_dt__update_hunderlying_h1 = (_831_underlying).Replace(mapping); if ((_832_dt__update__tmp_h3).is_Borrowed) { return RAST.Type.create_Borrowed(_833_dt__update_hunderlying_h1); } else if ((_832_dt__update__tmp_h3).is_BorrowedMut) { @@ -2089,12 +2058,11 @@ public RAST._IType Replace(Dafny.IMap mapping) { } } } - if (unmatched28) { + { if (_source28.is_Pointer) { RAST._IType _834_underlying = _source28.dtor_underlying; - unmatched28 = false; RAST._IType _835_dt__update__tmp_h4 = this; - RAST._IType _836_dt__update_hunderlying_h2 = (_834_underlying).Replace(_pat_let_tv46); + RAST._IType _836_dt__update_hunderlying_h2 = (_834_underlying).Replace(mapping); if ((_835_dt__update__tmp_h4).is_Borrowed) { return RAST.Type.create_Borrowed(_836_dt__update_hunderlying_h2); } else if ((_835_dt__update__tmp_h4).is_BorrowedMut) { @@ -2112,12 +2080,11 @@ public RAST._IType Replace(Dafny.IMap mapping) { } } } - if (unmatched28) { + { if (_source28.is_PointerMut) { RAST._IType _837_underlying = _source28.dtor_underlying; - unmatched28 = false; RAST._IType _838_dt__update__tmp_h5 = this; - RAST._IType _839_dt__update_hunderlying_h3 = (_837_underlying).Replace(_pat_let_tv47); + RAST._IType _839_dt__update_hunderlying_h3 = (_837_underlying).Replace(mapping); if ((_838_dt__update__tmp_h5).is_Borrowed) { return RAST.Type.create_Borrowed(_839_dt__update_hunderlying_h3); } else if ((_838_dt__update__tmp_h5).is_BorrowedMut) { @@ -2135,12 +2102,11 @@ public RAST._IType Replace(Dafny.IMap mapping) { } } } - if (unmatched28) { + { if (_source28.is_ImplType) { RAST._IType _840_underlying = _source28.dtor_underlying; - unmatched28 = false; RAST._IType _841_dt__update__tmp_h6 = this; - RAST._IType _842_dt__update_hunderlying_h4 = (_840_underlying).Replace(_pat_let_tv48); + RAST._IType _842_dt__update_hunderlying_h4 = (_840_underlying).Replace(mapping); if ((_841_dt__update__tmp_h6).is_Borrowed) { return RAST.Type.create_Borrowed(_842_dt__update_hunderlying_h4); } else if ((_841_dt__update__tmp_h6).is_BorrowedMut) { @@ -2158,12 +2124,11 @@ public RAST._IType Replace(Dafny.IMap mapping) { } } } - if (unmatched28) { + { if (_source28.is_DynType) { RAST._IType _843_underlying = _source28.dtor_underlying; - unmatched28 = false; RAST._IType _844_dt__update__tmp_h7 = this; - RAST._IType _845_dt__update_hunderlying_h5 = (_843_underlying).Replace(_pat_let_tv49); + RAST._IType _845_dt__update_hunderlying_h5 = (_843_underlying).Replace(mapping); if ((_844_dt__update__tmp_h7).is_Borrowed) { return RAST.Type.create_Borrowed(_845_dt__update_hunderlying_h5); } else if ((_844_dt__update__tmp_h7).is_BorrowedMut) { @@ -2181,14 +2146,13 @@ public RAST._IType Replace(Dafny.IMap mapping) { } } } - if (unmatched28) { + { if (_source28.is_TupleType) { Dafny.ISequence _846_arguments = _source28.dtor_arguments; - unmatched28 = false; RAST._IType _847_dt__update__tmp_h8 = this; Dafny.ISequence _848_dt__update_harguments_h1 = Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Dafny.ISequence, Func>>((_849_mapping, _850_arguments) => ((System.Func)((_851_t) => { return (_851_t).Replace(_849_mapping); - })))(_pat_let_tv50, _846_arguments), _846_arguments); + })))(mapping, _846_arguments), _846_arguments); if ((_847_dt__update__tmp_h8).is_TypeApp) { return RAST.Type.create_TypeApp((_847_dt__update__tmp_h8).dtor_baseName, _848_dt__update_harguments_h1); } else if ((_847_dt__update__tmp_h8).is_TupleType) { @@ -2198,36 +2162,33 @@ public RAST._IType Replace(Dafny.IMap mapping) { } } } - if (unmatched28) { + { if (_source28.is_FnType) { Dafny.ISequence _852_arguments = _source28.dtor_arguments; RAST._IType _853_returnType = _source28.dtor_returnType; - unmatched28 = false; RAST._IType _854_dt__update__tmp_h9 = this; - RAST._IType _855_dt__update_hreturnType_h0 = (_853_returnType).Replace(_pat_let_tv51); + RAST._IType _855_dt__update_hreturnType_h0 = (_853_returnType).Replace(mapping); Dafny.ISequence _856_dt__update_harguments_h2 = Std.Collections.Seq.__default.Map(Dafny.Helpers.Id, Dafny.ISequence, Func>>((_857_mapping, _858_arguments) => ((System.Func)((_859_t) => { return (_859_t).Replace(_857_mapping); - })))(_pat_let_tv52, _852_arguments), _852_arguments); + })))(mapping, _852_arguments), _852_arguments); return RAST.Type.create_FnType(_856_dt__update_harguments_h2, _855_dt__update_hreturnType_h0); } } - if (unmatched28) { + { if (_source28.is_IntersectionType) { RAST._IType _860_left = _source28.dtor_left; RAST._IType _861_right = _source28.dtor_right; - unmatched28 = false; RAST._IType _862_dt__update__tmp_h10 = this; - RAST._IType _863_dt__update_hright_h0 = (_861_right).Replace(_pat_let_tv53); - RAST._IType _864_dt__update_hleft_h0 = (_860_left).Replace(_pat_let_tv54); + RAST._IType _863_dt__update_hright_h0 = (_861_right).Replace(mapping); + RAST._IType _864_dt__update_hleft_h0 = (_860_left).Replace(mapping); return RAST.Type.create_IntersectionType(_864_dt__update_hleft_h0, _863_dt__update_hright_h0); } } - if (unmatched28) { + { RAST._IType _865_underlying = _source28.dtor_underlying; Std.Wrappers._IOption> _866_size = _source28.dtor_size; - unmatched28 = false; RAST._IType _867_dt__update__tmp_h11 = this; - RAST._IType _868_dt__update_hunderlying_h6 = (_865_underlying).Replace(_pat_let_tv55); + RAST._IType _868_dt__update_hunderlying_h6 = (_865_underlying).Replace(mapping); if ((_867_dt__update__tmp_h11).is_Borrowed) { return RAST.Type.create_Borrowed(_868_dt__update_hunderlying_h6); } else if ((_867_dt__update__tmp_h11).is_BorrowedMut) { @@ -2244,7 +2205,6 @@ public RAST._IType Replace(Dafny.IMap mapping) { return RAST.Type.create_Array(_868_dt__update_hunderlying_h6, (_867_dt__update__tmp_h11).dtor_size); } } - throw new System.Exception("unexpected control point"); } } public bool CanReadWithoutClone() { @@ -2258,12 +2218,10 @@ public bool IsRcOrBorrowedRc() { } public Std.Wrappers._IOption ExtractMaybePlacebo() { RAST._IType _source29 = this; - bool unmatched29 = true; - if (unmatched29) { + { if (_source29.is_TypeApp) { RAST._IType _869_wrapper = _source29.dtor_baseName; Dafny.ISequence _870_arguments = _source29.dtor_arguments; - unmatched29 = false; if (((object.Equals(_869_wrapper, RAST.Type.create_TIdentifier(Dafny.Sequence.UnicodeFromString("MaybePlacebo")))) || (object.Equals(_869_wrapper, (RAST.__default.dafny__runtime__type).MSel(Dafny.Sequence.UnicodeFromString("MaybePlacebo"))))) && ((new BigInteger((_870_arguments).Count)) == (BigInteger.One))) { return Std.Wrappers.Option.create_Some((_870_arguments).Select(BigInteger.Zero)); } else { @@ -2271,11 +2229,9 @@ public bool IsRcOrBorrowedRc() { } } } - if (unmatched29) { - unmatched29 = false; + { return Std.Wrappers.Option.create_None(); } - throw new System.Exception("unexpected control point"); } public Std.Wrappers._IOption ExtractMaybeUninitArrayElement() { if ((this).IsObjectOrPointer()) { @@ -2292,200 +2248,158 @@ public bool IsRcOrBorrowedRc() { } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - var _pat_let_tv56 = ind; - var _pat_let_tv57 = ind; - var _pat_let_tv58 = ind; - var _pat_let_tv59 = ind; - var _pat_let_tv60 = ind; - var _pat_let_tv61 = ind; - var _pat_let_tv62 = ind; - var _pat_let_tv63 = ind; - var _pat_let_tv64 = ind; - var _pat_let_tv65 = ind; - var _pat_let_tv66 = ind; - var _pat_let_tv67 = ind; - var _pat_let_tv68 = ind; - var _pat_let_tv69 = ind; - var _pat_let_tv70 = ind; RAST._IType _source30 = this; - bool unmatched30 = true; - if (unmatched30) { + { if (_source30.is_Bool) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("bool"); } } - if (unmatched30) { + { if (_source30.is_TIdentifier) { Dafny.ISequence _872_underlying = _source30.dtor_name; - unmatched30 = false; return _872_underlying; } } - if (unmatched30) { + { if (_source30.is_TMemberSelect) { RAST._IType _873_underlying = _source30.dtor_base; Dafny.ISequence _874_name = _source30.dtor_name; - unmatched30 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat((_873_underlying)._ToString(_pat_let_tv56), Dafny.Sequence.UnicodeFromString("::")), _874_name); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat((_873_underlying)._ToString(ind), Dafny.Sequence.UnicodeFromString("::")), _874_name); } } - if (unmatched30) { + { if (_source30.is_Borrowed) { RAST._IType _875_underlying = _source30.dtor_underlying; - unmatched30 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("&"), (_875_underlying)._ToString(_pat_let_tv57)); + return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("&"), (_875_underlying)._ToString(ind)); } } - if (unmatched30) { + { if (_source30.is_BorrowedMut) { RAST._IType _876_underlying = _source30.dtor_underlying; - unmatched30 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("&mut "), (_876_underlying)._ToString(_pat_let_tv58)); + return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("&mut "), (_876_underlying)._ToString(ind)); } } - if (unmatched30) { + { if (_source30.is_Pointer) { RAST._IType _877_underlying = _source30.dtor_underlying; - unmatched30 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("*const "), (_877_underlying)._ToString(_pat_let_tv59)); + return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("*const "), (_877_underlying)._ToString(ind)); } } - if (unmatched30) { + { if (_source30.is_PointerMut) { RAST._IType _878_underlying = _source30.dtor_underlying; - unmatched30 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("*mut "), (_878_underlying)._ToString(_pat_let_tv60)); + return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("*mut "), (_878_underlying)._ToString(ind)); } } - if (unmatched30) { + { if (_source30.is_ImplType) { RAST._IType _879_underlying = _source30.dtor_underlying; - unmatched30 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("impl "), (_879_underlying)._ToString(_pat_let_tv61)); + return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("impl "), (_879_underlying)._ToString(ind)); } } - if (unmatched30) { + { if (_source30.is_DynType) { RAST._IType _880_underlying = _source30.dtor_underlying; - unmatched30 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("dyn "), (_880_underlying)._ToString(_pat_let_tv62)); + return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("dyn "), (_880_underlying)._ToString(ind)); } } - if (unmatched30) { + { if (_source30.is_FnType) { Dafny.ISequence _881_arguments = _source30.dtor_arguments; RAST._IType _882_returnType = _source30.dtor_returnType; - unmatched30 = false; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("::std::ops::Fn("), RAST.__default.SeqToString(_881_arguments, Dafny.Helpers.Id, Func>>>((_883_ind) => ((System.Func>)((_884_arg) => { return (_884_arg)._ToString(Dafny.Sequence.Concat(_883_ind, RAST.__default.IND)); - })))(_pat_let_tv63), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(") -> ")), (_882_returnType)._ToString(Dafny.Sequence.Concat(_pat_let_tv64, RAST.__default.IND))); + })))(ind), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(") -> ")), (_882_returnType)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))); } } - if (unmatched30) { + { if (_source30.is_IntersectionType) { RAST._IType _885_left = _source30.dtor_left; RAST._IType _886_right = _source30.dtor_right; - unmatched30 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat((_885_left)._ToString(_pat_let_tv65), Dafny.Sequence.UnicodeFromString(" + ")), (_886_right)._ToString(_pat_let_tv66)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat((_885_left)._ToString(ind), Dafny.Sequence.UnicodeFromString(" + ")), (_886_right)._ToString(ind)); } } - if (unmatched30) { + { if (_source30.is_TupleType) { Dafny.ISequence _887_args = _source30.dtor_arguments; - unmatched30 = false; if ((_887_args).Equals(Dafny.Sequence.FromElements())) { return Dafny.Sequence.UnicodeFromString("()"); } else { return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("("), RAST.__default.SeqToString(_887_args, Dafny.Helpers.Id, Func>>>((_888_ind) => ((System.Func>)((_889_arg) => { return (_889_arg)._ToString(Dafny.Sequence.Concat(_888_ind, RAST.__default.IND)); - })))(_pat_let_tv67), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(")")); + })))(ind), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(")")); } } } - if (unmatched30) { + { if (_source30.is_TypeApp) { RAST._IType _890_base = _source30.dtor_baseName; Dafny.ISequence _891_args = _source30.dtor_arguments; - unmatched30 = false; - return Dafny.Sequence.Concat((_890_base)._ToString(_pat_let_tv68), (((_891_args).Equals(Dafny.Sequence.FromElements())) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("<"), RAST.__default.SeqToString(_891_args, Dafny.Helpers.Id, Func>>>((_892_ind) => ((System.Func>)((_893_arg) => { + return Dafny.Sequence.Concat((_890_base)._ToString(ind), (((_891_args).Equals(Dafny.Sequence.FromElements())) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("<"), RAST.__default.SeqToString(_891_args, Dafny.Helpers.Id, Func>>>((_892_ind) => ((System.Func>)((_893_arg) => { return (_893_arg)._ToString(Dafny.Sequence.Concat(_892_ind, RAST.__default.IND)); - })))(_pat_let_tv69), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(">"))))); + })))(ind), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(">"))))); } } - if (unmatched30) { + { if (_source30.is_SelfOwned) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("Self"); } } - if (unmatched30) { + { if (_source30.is_U8) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("u8"); } } - if (unmatched30) { + { if (_source30.is_U16) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("u16"); } } - if (unmatched30) { + { if (_source30.is_U32) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("u32"); } } - if (unmatched30) { + { if (_source30.is_U64) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("u64"); } } - if (unmatched30) { + { if (_source30.is_U128) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("u128"); } } - if (unmatched30) { + { if (_source30.is_I8) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("i8"); } } - if (unmatched30) { + { if (_source30.is_I16) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("i16"); } } - if (unmatched30) { + { if (_source30.is_I32) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("i32"); } } - if (unmatched30) { + { if (_source30.is_I64) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("i64"); } } - if (unmatched30) { + { if (_source30.is_I128) { - unmatched30 = false; return Dafny.Sequence.UnicodeFromString("i128"); } } - if (unmatched30) { + { RAST._IType _894_underlying = _source30.dtor_underlying; Std.Wrappers._IOption> _895_size = _source30.dtor_size; - unmatched30 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("["), (_894_underlying)._ToString(_pat_let_tv70)), (((_895_size).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("; "), (_895_size).dtor_value)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString("]")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("["), (_894_underlying)._ToString(ind)), (((_895_size).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("; "), (_895_size).dtor_value)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString("]")); } - throw new System.Exception("unexpected control point"); } public RAST._IType MSel(Dafny.ISequence name) { return RAST.Type.create_TMemberSelect(this, name); @@ -2498,27 +2412,22 @@ public RAST._IType Apply(Dafny.ISequence args) { } public RAST._IType ToOwned() { RAST._IType _source31 = this; - bool unmatched31 = true; - if (unmatched31) { + { if (_source31.is_Borrowed) { RAST._IType _896_x = _source31.dtor_underlying; - unmatched31 = false; return _896_x; } } - if (unmatched31) { + { if (_source31.is_BorrowedMut) { RAST._IType _897_x = _source31.dtor_underlying; - unmatched31 = false; return _897_x; } } - if (unmatched31) { + { RAST._IType _898_x = _source31; - unmatched31 = false; return _898_x; } - throw new System.Exception("unexpected control point"); } public RAST._IExpr ToNullExpr() { if ((this).IsObject()) { @@ -2585,8 +2494,7 @@ public bool IsUninitArray() { } public bool IsObject() { RAST._IType _source32 = this; - bool unmatched32 = true; - if (unmatched32) { + { if (_source32.is_TypeApp) { RAST._IType baseName0 = _source32.dtor_baseName; if (baseName0.is_TMemberSelect) { @@ -2601,7 +2509,6 @@ public bool IsObject() { Dafny.ISequence name2 = baseName0.dtor_name; if (object.Equals(name2, Dafny.Sequence.UnicodeFromString("Object"))) { Dafny.ISequence _907_elems1 = _source32.dtor_arguments; - unmatched32 = false; return (new BigInteger((_907_elems1).Count)) == (BigInteger.One); } } @@ -2611,11 +2518,9 @@ public bool IsObject() { } } } - if (unmatched32) { - unmatched32 = false; + { return false; } - throw new System.Exception("unexpected control point"); } public bool IsPointer() { return ((this).is_Pointer) || ((this).is_PointerMut); @@ -2628,28 +2533,20 @@ public RAST._IType ObjectOrPointerUnderlying() { return (this).dtor_underlying; } else { RAST._IType _source33 = this; - bool unmatched33 = true; - if (unmatched33) { + { RAST._IType baseName1 = _source33.dtor_baseName; RAST._IType base2 = baseName1.dtor_base; RAST._IType base3 = base2.dtor_base; Dafny.ISequence name3 = base3.dtor_name; - if (object.Equals(name3, Dafny.Sequence.UnicodeFromString(""))) { - Dafny.ISequence name4 = base2.dtor_name; - if (object.Equals(name4, Dafny.Sequence.UnicodeFromString("dafny_runtime"))) { - Dafny.ISequence _908_elems1 = _source33.dtor_arguments; - unmatched33 = false; - return (_908_elems1).Select(BigInteger.Zero); - } - } + Dafny.ISequence name4 = base2.dtor_name; + Dafny.ISequence _908_elems1 = _source33.dtor_arguments; + return (_908_elems1).Select(BigInteger.Zero); } - throw new System.Exception("unexpected control point"); } } public bool IsBuiltinCollection() { RAST._IType _source34 = this; - bool unmatched34 = true; - if (unmatched34) { + { if (_source34.is_TypeApp) { RAST._IType baseName2 = _source34.dtor_baseName; if (baseName2.is_TMemberSelect) { @@ -2663,7 +2560,6 @@ public bool IsBuiltinCollection() { if (object.Equals(name6, Dafny.Sequence.UnicodeFromString("dafny_runtime"))) { Dafny.ISequence _909_tpe = baseName2.dtor_name; Dafny.ISequence _910_elems1 = _source34.dtor_arguments; - unmatched34 = false; return (((((_909_tpe).Equals(Dafny.Sequence.UnicodeFromString("Set"))) || ((_909_tpe).Equals(Dafny.Sequence.UnicodeFromString("Sequence")))) || ((_909_tpe).Equals(Dafny.Sequence.UnicodeFromString("Multiset")))) && ((new BigInteger((_910_elems1).Count)) == (BigInteger.One))) || (((_909_tpe).Equals(Dafny.Sequence.UnicodeFromString("Map"))) && ((new BigInteger((_910_elems1).Count)) == (new BigInteger(2)))); } } @@ -2672,35 +2568,26 @@ public bool IsBuiltinCollection() { } } } - if (unmatched34) { - unmatched34 = false; + { return false; } - throw new System.Exception("unexpected control point"); } public RAST._IType GetBuiltinCollectionElement() { RAST._IType _source35 = this; - bool unmatched35 = true; - if (unmatched35) { + { RAST._IType baseName3 = _source35.dtor_baseName; RAST._IType base6 = baseName3.dtor_base; RAST._IType base7 = base6.dtor_base; Dafny.ISequence name7 = base7.dtor_name; - if (object.Equals(name7, Dafny.Sequence.UnicodeFromString(""))) { - Dafny.ISequence name8 = base6.dtor_name; - if (object.Equals(name8, Dafny.Sequence.UnicodeFromString("dafny_runtime"))) { - Dafny.ISequence _911_tpe = baseName3.dtor_name; - Dafny.ISequence _912_elems = _source35.dtor_arguments; - unmatched35 = false; - if ((_911_tpe).Equals(Dafny.Sequence.UnicodeFromString("Map"))) { - return (_912_elems).Select(BigInteger.One); - } else { - return (_912_elems).Select(BigInteger.Zero); - } - } + Dafny.ISequence name8 = base6.dtor_name; + Dafny.ISequence _911_tpe = baseName3.dtor_name; + Dafny.ISequence _912_elems = _source35.dtor_arguments; + if ((_911_tpe).Equals(Dafny.Sequence.UnicodeFromString("Map"))) { + return (_912_elems).Select(BigInteger.One); + } else { + return (_912_elems).Select(BigInteger.Zero); } } - throw new System.Exception("unexpected control point"); } public bool IsRc() { return (((this).is_TypeApp) && (object.Equals((this).dtor_baseName, RAST.__default.RcType))) && ((new BigInteger(((this).dtor_arguments).Count)) == (BigInteger.One)); @@ -5150,8 +5037,7 @@ public bool NoExtraSemicolonAfter() { } public RAST._IExpr Optimize() { RAST._IExpr _source36 = this; - bool unmatched36 = true; - if (unmatched36) { + { if (_source36.is_UnaryOp) { Dafny.ISequence op10 = _source36.dtor_op1; if (object.Equals(op10, Dafny.Sequence.UnicodeFromString("!"))) { @@ -5164,7 +5050,6 @@ public RAST._IExpr Optimize() { DAST.Format._IBinaryOpFormat _930_format = underlying0.dtor_format2; DAST.Format._IUnaryOpFormat format0 = _source36.dtor_format; if (format0.is_CombineFormat) { - unmatched36 = false; return RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("!="), _928_left, _929_right, DAST.Format.BinaryOpFormat.create_NoFormat()); } } @@ -5172,7 +5057,7 @@ public RAST._IExpr Optimize() { } } } - if (unmatched36) { + { if (_source36.is_UnaryOp) { Dafny.ISequence op11 = _source36.dtor_op1; if (object.Equals(op11, Dafny.Sequence.UnicodeFromString("!"))) { @@ -5186,7 +5071,6 @@ public RAST._IExpr Optimize() { if (format20.is_NoFormat) { DAST.Format._IUnaryOpFormat format1 = _source36.dtor_format; if (format1.is_CombineFormat) { - unmatched36 = false; return RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString(">="), _931_left, _932_right, DAST.Format.BinaryOpFormat.create_NoFormat()); } } @@ -5195,7 +5079,7 @@ public RAST._IExpr Optimize() { } } } - if (unmatched36) { + { if (_source36.is_UnaryOp) { Dafny.ISequence op12 = _source36.dtor_op1; if (object.Equals(op12, Dafny.Sequence.UnicodeFromString("!"))) { @@ -5209,7 +5093,6 @@ public RAST._IExpr Optimize() { if (format21.is_ReverseFormat) { DAST.Format._IUnaryOpFormat format2 = _source36.dtor_format; if (format2.is_CombineFormat) { - unmatched36 = false; return RAST.Expr.create_BinaryOp(Dafny.Sequence.UnicodeFromString("<="), _934_right, _933_left, DAST.Format.BinaryOpFormat.create_NoFormat()); } } @@ -5218,7 +5101,7 @@ public RAST._IExpr Optimize() { } } } - if (unmatched36) { + { if (_source36.is_Call) { RAST._IExpr obj0 = _source36.dtor_obj; if (obj0.is_MemberSelect) { @@ -5226,7 +5109,6 @@ public RAST._IExpr Optimize() { Dafny.ISequence name9 = obj0.dtor_name; if (object.Equals(name9, Dafny.Sequence.UnicodeFromString("truncate!"))) { Dafny.ISequence _936_args = _source36.dtor_arguments; - unmatched36 = false; if (((!object.Equals(_935_r, RAST.__default.dafny__runtime)) && (!object.Equals(_935_r, RAST.__default.@global))) || ((new BigInteger((_936_args).Count)) != (new BigInteger(2)))) { return this; } else { @@ -5238,8 +5120,7 @@ public RAST._IExpr Optimize() { RAST._IType _939_tpe = (_938_tpeExpr).dtor_tpe; if (((((((((((_939_tpe).is_U8) || ((_939_tpe).is_U16)) || ((_939_tpe).is_U32)) || ((_939_tpe).is_U64)) || ((_939_tpe).is_U128)) || ((_939_tpe).is_I8)) || ((_939_tpe).is_I16)) || ((_939_tpe).is_I32)) || ((_939_tpe).is_I64)) || ((_939_tpe).is_I128)) { RAST._IExpr _source37 = _937_expr; - bool unmatched37 = true; - if (unmatched37) { + { if (_source37.is_Call) { RAST._IExpr obj1 = _source37.dtor_obj; if (obj1.is_MemberSelect) { @@ -5247,29 +5128,23 @@ public RAST._IExpr Optimize() { Dafny.ISequence name10 = obj1.dtor_name; if (object.Equals(name10, Dafny.Sequence.UnicodeFromString("int!"))) { Dafny.ISequence _941_args = _source37.dtor_arguments; - unmatched37 = false; if (((new BigInteger((_941_args).Count)) == (BigInteger.One)) && ((object.Equals(_940_base, RAST.__default.dafny__runtime)) || (object.Equals(_940_base, RAST.__default.@global)))) { RAST._IExpr _source38 = (_941_args).Select(BigInteger.Zero); - bool unmatched38 = true; - if (unmatched38) { + { if (_source38.is_LiteralInt) { Dafny.ISequence _942_number = _source38.dtor_value; - unmatched38 = false; return RAST.Expr.create_LiteralInt(_942_number); } } - if (unmatched38) { + { if (_source38.is_LiteralString) { Dafny.ISequence _943_number = _source38.dtor_value; - unmatched38 = false; return RAST.Expr.create_LiteralInt(_943_number); } } - if (unmatched38) { - unmatched38 = false; + { return this; } - throw new System.Exception("unexpected control point"); } else { return this; } @@ -5277,11 +5152,9 @@ public RAST._IExpr Optimize() { } } } - if (unmatched37) { - unmatched37 = false; + { return this; } - throw new System.Exception("unexpected control point"); } else { return this; } @@ -5291,7 +5164,7 @@ public RAST._IExpr Optimize() { } } } - if (unmatched36) { + { if (_source36.is_StmtExpr) { RAST._IExpr stmt0 = _source36.dtor_stmt; if (stmt0.is_DeclareVar) { @@ -5309,7 +5182,6 @@ public RAST._IExpr Optimize() { Std.Wrappers._IOption _947_name2 = stmt1.dtor_names; RAST._IExpr _948_rhs = stmt1.dtor_rhs; RAST._IExpr _949_last = rhs0.dtor_rhs; - unmatched36 = false; if (object.Equals(_947_name2, Std.Wrappers.Option.create_Some(RAST.AssignLhs.create_LocalVar(_945_name)))) { RAST._IExpr _950_rewriting = RAST.Expr.create_StmtExpr(RAST.Expr.create_DeclareVar(_944_mod, _945_name, Std.Wrappers.Option.create_Some(_946_tpe), Std.Wrappers.Option.create_Some(_948_rhs)), _949_last); return _950_rewriting; @@ -5323,7 +5195,7 @@ public RAST._IExpr Optimize() { } } } - if (unmatched36) { + { if (_source36.is_StmtExpr) { RAST._IExpr stmt2 = _source36.dtor_stmt; if (stmt2.is_IfExpr) { @@ -5348,7 +5220,6 @@ public RAST._IExpr Optimize() { Dafny.ISequence content1 = els0.dtor_content; if (object.Equals(content1, Dafny.Sequence.UnicodeFromString(""))) { RAST._IExpr _955_last = _source36.dtor_rhs; - unmatched36 = false; RAST._IExpr _956_rewriting = RAST.Expr.create_StmtExpr((RAST.Expr.create_Identifier(Dafny.Sequence.UnicodeFromString("assert_eq!"))).Apply(Dafny.Sequence.FromElements(_951_a, _952_b)), _955_last); return _956_rewriting; } @@ -5362,11 +5233,9 @@ public RAST._IExpr Optimize() { } } } - if (unmatched36) { - unmatched36 = false; + { return this; } - throw new System.Exception("unexpected control point"); } public bool LeftRequiresParentheses(RAST._IExpr left) { return ((this).printingInfo).NeedParenthesesForLeft((left).printingInfo); @@ -5390,19 +5259,15 @@ public bool RightRequiresParentheses(RAST._IExpr right) { } public Std.Wrappers._IOption> RightMostIdentifier() { RAST._IExpr _source39 = this; - bool unmatched39 = true; - if (unmatched39) { + { if (_source39.is_MemberSelect) { Dafny.ISequence _957_id = _source39.dtor_name; - unmatched39 = false; return Std.Wrappers.Option>.create_Some(_957_id); } } - if (unmatched39) { - unmatched39 = false; + { return Std.Wrappers.Option>.create_None(); } - throw new System.Exception("unexpected control point"); } public static Dafny.ISequence MaxHashes(Dafny.ISequence s, Dafny.ISequence currentHashes, Dafny.ISequence mostHashes) { @@ -5449,94 +5314,28 @@ public bool RightRequiresParentheses(RAST._IExpr right) { } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - var _pat_let_tv71 = ind; - var _pat_let_tv72 = ind; - var _pat_let_tv73 = ind; - var _pat_let_tv74 = ind; - var _pat_let_tv75 = ind; - var _pat_let_tv76 = ind; - var _pat_let_tv77 = ind; - var _pat_let_tv78 = ind; - var _pat_let_tv79 = ind; - var _pat_let_tv80 = ind; - var _pat_let_tv81 = ind; - var _pat_let_tv82 = ind; - var _pat_let_tv83 = ind; - var _pat_let_tv84 = ind; - var _pat_let_tv85 = ind; - var _pat_let_tv86 = ind; - var _pat_let_tv87 = ind; - var _pat_let_tv88 = ind; - var _pat_let_tv89 = ind; - var _pat_let_tv90 = ind; - var _pat_let_tv91 = ind; - var _pat_let_tv92 = ind; - var _pat_let_tv93 = ind; - var _pat_let_tv94 = ind; - var _pat_let_tv95 = ind; - var _pat_let_tv96 = ind; - var _pat_let_tv97 = ind; - var _pat_let_tv98 = ind; - var _pat_let_tv99 = ind; - var _pat_let_tv100 = ind; - var _pat_let_tv101 = ind; - var _pat_let_tv102 = ind; - var _pat_let_tv103 = ind; - var _pat_let_tv104 = ind; - var _pat_let_tv105 = ind; - var _pat_let_tv106 = ind; - var _pat_let_tv107 = ind; - var _pat_let_tv108 = ind; - var _pat_let_tv109 = ind; - var _pat_let_tv110 = ind; - var _pat_let_tv111 = ind; - var _pat_let_tv112 = ind; - var _pat_let_tv113 = ind; - var _pat_let_tv114 = ind; - var _pat_let_tv115 = ind; - var _pat_let_tv116 = ind; - var _pat_let_tv117 = ind; - var _pat_let_tv118 = ind; - var _pat_let_tv119 = ind; - var _pat_let_tv120 = ind; - var _pat_let_tv121 = ind; - var _pat_let_tv122 = ind; - var _pat_let_tv123 = ind; - var _pat_let_tv124 = ind; - var _pat_let_tv125 = ind; - var _pat_let_tv126 = ind; - var _pat_let_tv127 = ind; - var _pat_let_tv128 = ind; - var _pat_let_tv129 = ind; - var _pat_let_tv130 = ind; - var _pat_let_tv131 = ind; RAST._IExpr _source40 = (this).Optimize(); - bool unmatched40 = true; - if (unmatched40) { + { if (_source40.is_Identifier) { Dafny.ISequence _959_name = _source40.dtor_name; - unmatched40 = false; return _959_name; } } - if (unmatched40) { + { if (_source40.is_ExprFromType) { RAST._IType _960_t = _source40.dtor_tpe; - unmatched40 = false; - return (_960_t)._ToString(_pat_let_tv71); + return (_960_t)._ToString(ind); } } - if (unmatched40) { + { if (_source40.is_LiteralInt) { Dafny.ISequence _961_number = _source40.dtor_value; - unmatched40 = false; return _961_number; } } - if (unmatched40) { + { if (_source40.is_LiteralBool) { bool _962_b = _source40.dtor_bvalue; - unmatched40 = false; if (_962_b) { return Dafny.Sequence.UnicodeFromString("true"); } else { @@ -5544,111 +5343,101 @@ public bool RightRequiresParentheses(RAST._IExpr right) { } } } - if (unmatched40) { + { if (_source40.is_LiteralString) { Dafny.ISequence _963_characters = _source40.dtor_value; bool _964_binary = _source40.dtor_binary; bool _965_verbatim = _source40.dtor_verbatim; - unmatched40 = false; Dafny.ISequence _966_hashes = ((_965_verbatim) ? (Dafny.Sequence.Concat(RAST.Expr.MaxHashes(_963_characters, Dafny.Sequence.UnicodeFromString(""), Dafny.Sequence.UnicodeFromString("")), Dafny.Sequence.UnicodeFromString("#"))) : (Dafny.Sequence.UnicodeFromString(""))); return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(((_964_binary) ? (Dafny.Sequence.UnicodeFromString("b")) : (Dafny.Sequence.UnicodeFromString(""))), ((_965_verbatim) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("r"), _966_hashes)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString("\"")), ((_965_verbatim) ? (RAST.Expr.RemoveDoubleQuotes(_963_characters)) : (_963_characters))), Dafny.Sequence.UnicodeFromString("\"")), _966_hashes); } } - if (unmatched40) { + { if (_source40.is_Match) { RAST._IExpr _967_matchee = _source40.dtor_matchee; Dafny.ISequence _968_cases = _source40.dtor_cases; - unmatched40 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("match "), (_967_matchee)._ToString(Dafny.Sequence.Concat(_pat_let_tv72, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString(_968_cases, Dafny.Helpers.Id, Func>>>((_969_ind) => ((System.Func>)((_970_c) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("match "), (_967_matchee)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString(_968_cases, Dafny.Helpers.Id, Func>>>((_969_ind) => ((System.Func>)((_970_c) => { return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _969_ind), RAST.__default.IND), (_970_c)._ToString(Dafny.Sequence.Concat(_969_ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(",")); - })))(_pat_let_tv73), Dafny.Sequence.UnicodeFromString(""))), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv74), Dafny.Sequence.UnicodeFromString("}")); + })))(ind), Dafny.Sequence.UnicodeFromString(""))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } } - if (unmatched40) { + { if (_source40.is_StmtExpr) { RAST._IExpr _971_stmt = _source40.dtor_stmt; RAST._IExpr _972_rhs = _source40.dtor_rhs; - unmatched40 = false; if (((_971_stmt).is_RawExpr) && (((_971_stmt).dtor_content).Equals(Dafny.Sequence.UnicodeFromString("")))) { - return (_972_rhs)._ToString(_pat_let_tv75); + return (_972_rhs)._ToString(ind); } else { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_971_stmt)._ToString(_pat_let_tv76), (((_971_stmt).NoExtraSemicolonAfter()) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.UnicodeFromString(";")))), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv77), (_972_rhs)._ToString(_pat_let_tv78)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_971_stmt)._ToString(ind), (((_971_stmt).NoExtraSemicolonAfter()) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.UnicodeFromString(";")))), Dafny.Sequence.UnicodeFromString("\n")), ind), (_972_rhs)._ToString(ind)); } } } - if (unmatched40) { + { if (_source40.is_Block) { RAST._IExpr _973_underlying = _source40.dtor_underlying; - unmatched40 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("{\n"), _pat_let_tv79), RAST.__default.IND), (_973_underlying)._ToString(Dafny.Sequence.Concat(_pat_let_tv80, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv81), 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("{\n"), ind), RAST.__default.IND), (_973_underlying)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } } - if (unmatched40) { + { if (_source40.is_IfExpr) { RAST._IExpr _974_cond = _source40.dtor_cond; RAST._IExpr _975_thn = _source40.dtor_thn; RAST._IExpr _976_els = _source40.dtor_els; - unmatched40 = false; - 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 "), (_974_cond)._ToString(Dafny.Sequence.Concat(_pat_let_tv82, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {\n")), _pat_let_tv83), RAST.__default.IND), (_975_thn)._ToString(Dafny.Sequence.Concat(_pat_let_tv84, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv85), Dafny.Sequence.UnicodeFromString("}")), ((object.Equals(_976_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"), _pat_let_tv86), RAST.__default.IND), (_976_els)._ToString(Dafny.Sequence.Concat(_pat_let_tv87, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv88), Dafny.Sequence.UnicodeFromString("}"))))); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("if "), (_974_cond)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {\n")), ind), RAST.__default.IND), (_975_thn)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")), ((object.Equals(_976_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), (_976_els)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}"))))); } } - if (unmatched40) { + { if (_source40.is_StructBuild) { RAST._IExpr _977_name = _source40.dtor_underlying; Dafny.ISequence _978_assignments = _source40.dtor_assignments; - unmatched40 = false; if (((new BigInteger((_978_assignments).Count)).Sign == 1) && ((((_978_assignments).Select(BigInteger.Zero)).dtor_identifier).Equals(Dafny.Sequence.UnicodeFromString("0")))) { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_977_name)._ToString(_pat_let_tv89), Dafny.Sequence.UnicodeFromString(" (")), RAST.__default.SeqToString(_978_assignments, Dafny.Helpers.Id, Func>>>((_979_ind) => ((System.Func>)((_980_assignment) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_977_name)._ToString(ind), Dafny.Sequence.UnicodeFromString(" (")), RAST.__default.SeqToString(_978_assignments, Dafny.Helpers.Id, Func>>>((_979_ind) => ((System.Func>)((_980_assignment) => { return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _979_ind), RAST.__default.IND), ((_980_assignment).dtor_rhs)._ToString(Dafny.Sequence.Concat(_979_ind, RAST.__default.IND))); - })))(_pat_let_tv90), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_978_assignments).Count)) > (BigInteger.One)) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _pat_let_tv91)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(")")); + })))(ind), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_978_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((_977_name)._ToString(_pat_let_tv92), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString(_978_assignments, Dafny.Helpers.Id, Func>>>((_981_ind) => ((System.Func>)((_982_assignment) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat((_977_name)._ToString(ind), Dafny.Sequence.UnicodeFromString(" {")), RAST.__default.SeqToString(_978_assignments, Dafny.Helpers.Id, Func>>>((_981_ind) => ((System.Func>)((_982_assignment) => { return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _981_ind), RAST.__default.IND), (_982_assignment)._ToString(Dafny.Sequence.Concat(_981_ind, RAST.__default.IND))); - })))(_pat_let_tv93), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_978_assignments).Count)).Sign == 1) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _pat_let_tv94)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString("}")); + })))(ind), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_978_assignments).Count)).Sign == 1) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString("}")); } } } - if (unmatched40) { + { if (_source40.is_Tuple) { Dafny.ISequence _983_arguments = _source40.dtor_arguments; - unmatched40 = false; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("("), RAST.__default.SeqToString(_983_arguments, Dafny.Helpers.Id, Func>>>((_984_ind) => ((System.Func>)((_985_arg) => { return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _984_ind), RAST.__default.IND), (_985_arg)._ToString(Dafny.Sequence.Concat(_984_ind, RAST.__default.IND))); - })))(_pat_let_tv95), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_983_arguments).Count)).Sign == 1) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), _pat_let_tv96)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(")")); + })))(ind), Dafny.Sequence.UnicodeFromString(","))), (((new BigInteger((_983_arguments).Count)).Sign == 1) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind)) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(")")); } } - if (unmatched40) { + { if (_source40.is_UnaryOp) { Dafny.ISequence _986_op = _source40.dtor_op1; RAST._IExpr _987_underlying = _source40.dtor_underlying; DAST.Format._IUnaryOpFormat _988_format = _source40.dtor_format; - unmatched40 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs41 = ((((this).printingInfo).NeedParenthesesFor((_987_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 _989_leftP = _let_tmp_rhs41.dtor__0; Dafny.ISequence _990_rightP = _let_tmp_rhs41.dtor__1; Dafny.ISequence _991_leftOp = ((((_986_op).Equals(Dafny.Sequence.UnicodeFromString("&mut"))) && (!(_989_leftP).Equals(Dafny.Sequence.UnicodeFromString("(")))) ? (Dafny.Sequence.Concat(_986_op, Dafny.Sequence.UnicodeFromString(" "))) : ((((_986_op).Equals(Dafny.Sequence.UnicodeFromString("?"))) ? (Dafny.Sequence.UnicodeFromString("")) : (_986_op)))); Dafny.ISequence _992_rightOp = (((_986_op).Equals(Dafny.Sequence.UnicodeFromString("?"))) ? (_986_op) : (Dafny.Sequence.UnicodeFromString(""))); - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_991_leftOp, _989_leftP), (_987_underlying)._ToString(_pat_let_tv97)), _990_rightP), _992_rightOp); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_991_leftOp, _989_leftP), (_987_underlying)._ToString(ind)), _990_rightP), _992_rightOp); } } - if (unmatched40) { + { if (_source40.is_TypeAscription) { RAST._IExpr _993_left = _source40.dtor_left; RAST._IType _994_tpe = _source40.dtor_tpe; - unmatched40 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs42 = (this).LeftParentheses(_993_left); Dafny.ISequence _995_leftLeftP = _let_tmp_rhs42.dtor__0; Dafny.ISequence _996_leftRightP = _let_tmp_rhs42.dtor__1; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_995_leftLeftP, (_993_left)._ToString(RAST.__default.IND)), _996_leftRightP), Dafny.Sequence.UnicodeFromString(" as ")), (_994_tpe)._ToString(RAST.__default.IND)); } } - if (unmatched40) { + { if (_source40.is_BinaryOp) { Dafny.ISequence _997_op2 = _source40.dtor_op2; RAST._IExpr _998_left = _source40.dtor_left; RAST._IExpr _999_right = _source40.dtor_right; DAST.Format._IBinaryOpFormat _1000_format = _source40.dtor_format2; - unmatched40 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs43 = (this).LeftParentheses(_998_left); Dafny.ISequence _1001_leftLeftP = _let_tmp_rhs43.dtor__0; Dafny.ISequence _1002_leftRighP = _let_tmp_rhs43.dtor__1; @@ -5656,307 +5445,267 @@ public bool RightRequiresParentheses(RAST._IExpr right) { Dafny.ISequence _1003_rightLeftP = _let_tmp_rhs44.dtor__0; Dafny.ISequence _1004_rightRightP = _let_tmp_rhs44.dtor__1; Dafny.ISequence _1005_opRendered = Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" "), _997_op2), Dafny.Sequence.UnicodeFromString(" ")); - Dafny.ISequence _1006_indLeft = (((_1001_leftLeftP).Equals(Dafny.Sequence.UnicodeFromString("("))) ? (Dafny.Sequence.Concat(_pat_let_tv98, RAST.__default.IND)) : (_pat_let_tv99)); - Dafny.ISequence _1007_indRight = (((_1003_rightLeftP).Equals(Dafny.Sequence.UnicodeFromString("("))) ? (Dafny.Sequence.Concat(_pat_let_tv100, RAST.__default.IND)) : (_pat_let_tv101)); + Dafny.ISequence _1006_indLeft = (((_1001_leftLeftP).Equals(Dafny.Sequence.UnicodeFromString("("))) ? (Dafny.Sequence.Concat(ind, RAST.__default.IND)) : (ind)); + Dafny.ISequence _1007_indRight = (((_1003_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(_1001_leftLeftP, (_998_left)._ToString(_1006_indLeft)), _1002_leftRighP), _1005_opRendered), _1003_rightLeftP), (_999_right)._ToString(_1007_indRight)), _1004_rightRightP); } } - if (unmatched40) { + { if (_source40.is_DeclareVar) { RAST._IDeclareType _1008_declareType = _source40.dtor_declareType; Dafny.ISequence _1009_name = _source40.dtor_name; Std.Wrappers._IOption _1010_optType = _source40.dtor_optType; Std.Wrappers._IOption _1011_optExpr = _source40.dtor_optRhs; - unmatched40 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("let "), ((object.Equals(_1008_declareType, RAST.DeclareType.create_MUT())) ? (Dafny.Sequence.UnicodeFromString("mut ")) : (Dafny.Sequence.UnicodeFromString("")))), _1009_name), (((_1010_optType).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(": "), ((_1010_optType).dtor_value)._ToString(Dafny.Sequence.Concat(_pat_let_tv102, RAST.__default.IND)))) : (Dafny.Sequence.UnicodeFromString("")))), (((_1011_optExpr).is_Some) ? (Dafny.Helpers.Let, Dafny.ISequence>(((_1011_optExpr).dtor_value)._ToString(Dafny.Sequence.Concat(_pat_let_tv103, RAST.__default.IND)), _pat_let7_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let7_0, _1012_optExprString => (((_1012_optExprString).Equals(Dafny.Sequence.UnicodeFromString(""))) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("= /*issue with empty RHS*/"), ((((_1011_optExpr).dtor_value).is_RawExpr) ? (Dafny.Sequence.UnicodeFromString("Empty Raw expr")) : (((((_1011_optExpr).dtor_value).is_LiteralString) ? (Dafny.Sequence.UnicodeFromString("Empty string literal")) : (((((_1011_optExpr).dtor_value).is_LiteralInt) ? (Dafny.Sequence.UnicodeFromString("Empty int literal")) : (Dafny.Sequence.UnicodeFromString("Another case"))))))))) : (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" = "), _1012_optExprString)))))) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(";")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("let "), ((object.Equals(_1008_declareType, RAST.DeclareType.create_MUT())) ? (Dafny.Sequence.UnicodeFromString("mut ")) : (Dafny.Sequence.UnicodeFromString("")))), _1009_name), (((_1010_optType).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(": "), ((_1010_optType).dtor_value)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)))) : (Dafny.Sequence.UnicodeFromString("")))), (((_1011_optExpr).is_Some) ? (Dafny.Helpers.Let, Dafny.ISequence>(((_1011_optExpr).dtor_value)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)), _pat_let7_0 => Dafny.Helpers.Let, Dafny.ISequence>(_pat_let7_0, _1012_optExprString => (((_1012_optExprString).Equals(Dafny.Sequence.UnicodeFromString(""))) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("= /*issue with empty RHS*/"), ((((_1011_optExpr).dtor_value).is_RawExpr) ? (Dafny.Sequence.UnicodeFromString("Empty Raw expr")) : (((((_1011_optExpr).dtor_value).is_LiteralString) ? (Dafny.Sequence.UnicodeFromString("Empty string literal")) : (((((_1011_optExpr).dtor_value).is_LiteralInt) ? (Dafny.Sequence.UnicodeFromString("Empty int literal")) : (Dafny.Sequence.UnicodeFromString("Another case"))))))))) : (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" = "), _1012_optExprString)))))) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(";")); } } - if (unmatched40) { + { if (_source40.is_Assign) { Std.Wrappers._IOption _1013_names = _source40.dtor_names; RAST._IExpr _1014_expr = _source40.dtor_rhs; - unmatched40 = false; Dafny.ISequence _1015_lhs = ((System.Func>)(() => { Std.Wrappers._IOption _source41 = _1013_names; - bool unmatched41 = true; - if (unmatched41) { + { if (_source41.is_Some) { RAST._IAssignLhs value0 = _source41.dtor_value; if (value0.is_LocalVar) { Dafny.ISequence _1016_name = value0.dtor_name; - unmatched41 = false; return Dafny.Sequence.Concat(_1016_name, Dafny.Sequence.UnicodeFromString(" = ")); } } } - if (unmatched41) { + { if (_source41.is_Some) { RAST._IAssignLhs value1 = _source41.dtor_value; if (value1.is_SelectMember) { RAST._IExpr _1017_member = value1.dtor_on; Dafny.ISequence _1018_field = value1.dtor_field; - unmatched41 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs45 = (RAST.Expr.create_Select(_1017_member, _1018_field)).LeftParentheses(_1017_member); Dafny.ISequence _1019_leftP = _let_tmp_rhs45.dtor__0; Dafny.ISequence _1020_rightP = _let_tmp_rhs45.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1019_leftP, (_1017_member)._ToString(_pat_let_tv104)), _1020_rightP), Dafny.Sequence.UnicodeFromString(".")), _1018_field), Dafny.Sequence.UnicodeFromString(" = ")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1019_leftP, (_1017_member)._ToString(ind)), _1020_rightP), Dafny.Sequence.UnicodeFromString(".")), _1018_field), Dafny.Sequence.UnicodeFromString(" = ")); } } } - if (unmatched41) { + { if (_source41.is_Some) { RAST._IAssignLhs value2 = _source41.dtor_value; if (value2.is_ExtractTuple) { Dafny.ISequence> _1021_names = value2.dtor_names; - unmatched41 = false; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("("), RAST.__default.SeqToString>(_1021_names, ((System.Func, Dafny.ISequence>)((_1022_name) => { return _1022_name; })), Dafny.Sequence.UnicodeFromString(","))), Dafny.Sequence.UnicodeFromString(") = ")); } } } - if (unmatched41) { + { if (_source41.is_Some) { RAST._IAssignLhs value3 = _source41.dtor_value; if (value3.is_Index) { RAST._IExpr _1023_e = value3.dtor_expr; Dafny.ISequence _1024_indices = value3.dtor_indices; - unmatched41 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs46 = (RAST.Expr.create_Call(_1023_e, _1024_indices)).LeftParentheses(_1023_e); Dafny.ISequence _1025_leftP = _let_tmp_rhs46.dtor__0; Dafny.ISequence _1026_rightP = _let_tmp_rhs46.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1025_leftP, (_1023_e)._ToString(_pat_let_tv105)), _1026_rightP), Dafny.Sequence.UnicodeFromString("[")), RAST.__default.SeqToString(_1024_indices, Dafny.Helpers.Id, Func>>>((_1027_ind) => ((System.Func>)((_1028_index) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1025_leftP, (_1023_e)._ToString(ind)), _1026_rightP), Dafny.Sequence.UnicodeFromString("[")), RAST.__default.SeqToString(_1024_indices, Dafny.Helpers.Id, Func>>>((_1027_ind) => ((System.Func>)((_1028_index) => { return (_1028_index)._ToString(Dafny.Sequence.Concat(_1027_ind, RAST.__default.IND)); - })))(_pat_let_tv106), Dafny.Sequence.UnicodeFromString("]["))), Dafny.Sequence.UnicodeFromString("] = ")); + })))(ind), Dafny.Sequence.UnicodeFromString("]["))), Dafny.Sequence.UnicodeFromString("] = ")); } } } - if (unmatched41) { - unmatched41 = false; + { return Dafny.Sequence.UnicodeFromString("_ = "); } - throw new System.Exception("unexpected control point"); }))(); - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1015_lhs, (_1014_expr)._ToString(Dafny.Sequence.Concat(_pat_let_tv107, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(";")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1015_lhs, (_1014_expr)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(";")); } } - if (unmatched40) { + { if (_source40.is_Labelled) { Dafny.ISequence _1029_name = _source40.dtor_lbl; RAST._IExpr _1030_underlying = _source40.dtor_underlying; - unmatched40 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("'"), _1029_name), Dafny.Sequence.UnicodeFromString(": ")), (_1030_underlying)._ToString(_pat_let_tv108)); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("'"), _1029_name), Dafny.Sequence.UnicodeFromString(": ")), (_1030_underlying)._ToString(ind)); } } - if (unmatched40) { + { if (_source40.is_Break) { Std.Wrappers._IOption> _1031_optLbl = _source40.dtor_optLbl; - unmatched40 = false; Std.Wrappers._IOption> _source42 = _1031_optLbl; - bool unmatched42 = true; - if (unmatched42) { + { if (_source42.is_Some) { Dafny.ISequence _1032_lbl = _source42.dtor_value; - unmatched42 = false; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("break '"), _1032_lbl), Dafny.Sequence.UnicodeFromString(";")); } } - if (unmatched42) { - unmatched42 = false; + { return Dafny.Sequence.UnicodeFromString("break;"); } - throw new System.Exception("unexpected control point"); } } - if (unmatched40) { + { if (_source40.is_Continue) { Std.Wrappers._IOption> _1033_optLbl = _source40.dtor_optLbl; - unmatched40 = false; Std.Wrappers._IOption> _source43 = _1033_optLbl; - bool unmatched43 = true; - if (unmatched43) { + { if (_source43.is_Some) { Dafny.ISequence _1034_lbl = _source43.dtor_value; - unmatched43 = false; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("continue '"), _1034_lbl), Dafny.Sequence.UnicodeFromString(";")); } } - if (unmatched43) { - unmatched43 = false; + { return Dafny.Sequence.UnicodeFromString("continue;"); } - throw new System.Exception("unexpected control point"); } } - if (unmatched40) { + { if (_source40.is_Loop) { Std.Wrappers._IOption _1035_optCond = _source40.dtor_optCond; RAST._IExpr _1036_underlying = _source40.dtor_underlying; - unmatched40 = false; 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 _source44 = _1035_optCond; - bool unmatched44 = true; - if (unmatched44) { + { if (_source44.is_None) { - unmatched44 = false; return Dafny.Sequence.UnicodeFromString("loop"); } } - if (unmatched44) { + { RAST._IExpr _1037_c = _source44.dtor_value; - unmatched44 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("while "), (_1037_c)._ToString(Dafny.Sequence.Concat(_pat_let_tv109, RAST.__default.IND))); + return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("while "), (_1037_c)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))); } - throw new System.Exception("unexpected control point"); - }))(), Dafny.Sequence.UnicodeFromString(" {\n")), _pat_let_tv110), RAST.__default.IND), (_1036_underlying)._ToString(Dafny.Sequence.Concat(_pat_let_tv111, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv112), Dafny.Sequence.UnicodeFromString("}")); + }))(), Dafny.Sequence.UnicodeFromString(" {\n")), ind), RAST.__default.IND), (_1036_underlying)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } } - if (unmatched40) { + { if (_source40.is_For) { Dafny.ISequence _1038_name = _source40.dtor_name; RAST._IExpr _1039_range = _source40.dtor_range; RAST._IExpr _1040_body = _source40.dtor_body; - unmatched40 = false; - 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 "), _1038_name), Dafny.Sequence.UnicodeFromString(" in ")), (_1039_range)._ToString(Dafny.Sequence.Concat(_pat_let_tv113, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {\n")), _pat_let_tv114), RAST.__default.IND), (_1040_body)._ToString(Dafny.Sequence.Concat(_pat_let_tv115, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv116), Dafny.Sequence.UnicodeFromString("}")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("for "), _1038_name), Dafny.Sequence.UnicodeFromString(" in ")), (_1039_range)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString(" {\n")), ind), RAST.__default.IND), (_1040_body)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } } - if (unmatched40) { + { if (_source40.is_Return) { Std.Wrappers._IOption _1041_optExpr = _source40.dtor_optExpr; - unmatched40 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("return"), (((_1041_optExpr).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" "), ((_1041_optExpr).dtor_value)._ToString(Dafny.Sequence.Concat(_pat_let_tv117, RAST.__default.IND)))) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(";")); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("return"), (((_1041_optExpr).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" "), ((_1041_optExpr).dtor_value)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND)))) : (Dafny.Sequence.UnicodeFromString("")))), Dafny.Sequence.UnicodeFromString(";")); } } - if (unmatched40) { + { if (_source40.is_CallType) { RAST._IExpr _1042_expr = _source40.dtor_obj; Dafny.ISequence _1043_tpes = _source40.dtor_typeParameters; - unmatched40 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs47 = (this).LeftParentheses(_1042_expr); Dafny.ISequence _1044_leftP = _let_tmp_rhs47.dtor__0; Dafny.ISequence _1045_rightP = _let_tmp_rhs47.dtor__1; if ((_1043_tpes).Equals(Dafny.Sequence.FromElements())) { - return (_1042_expr)._ToString(_pat_let_tv118); + return (_1042_expr)._ToString(ind); } else { - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1044_leftP, (_1042_expr)._ToString(_pat_let_tv119)), _1045_rightP), Dafny.Sequence.UnicodeFromString("::<")), RAST.__default.SeqToString(_1043_tpes, Dafny.Helpers.Id, Func>>>((_1046_ind) => ((System.Func>)((_1047_tpe) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1044_leftP, (_1042_expr)._ToString(ind)), _1045_rightP), Dafny.Sequence.UnicodeFromString("::<")), RAST.__default.SeqToString(_1043_tpes, Dafny.Helpers.Id, Func>>>((_1046_ind) => ((System.Func>)((_1047_tpe) => { return (_1047_tpe)._ToString(Dafny.Sequence.Concat(_1046_ind, RAST.__default.IND)); - })))(_pat_let_tv120), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(">")); + })))(ind), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(">")); } } } - if (unmatched40) { + { if (_source40.is_Call) { RAST._IExpr _1048_expr = _source40.dtor_obj; Dafny.ISequence _1049_args = _source40.dtor_arguments; - unmatched40 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs48 = (this).LeftParentheses(_1048_expr); Dafny.ISequence _1050_leftP = _let_tmp_rhs48.dtor__0; Dafny.ISequence _1051_rightP = _let_tmp_rhs48.dtor__1; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs49 = ((System.Func<_System._ITuple2, Dafny.ISequence>>)(() => { Std.Wrappers._IOption> _source45 = (_1048_expr).RightMostIdentifier(); - bool unmatched45 = true; - if (unmatched45) { - bool disjunctiveMatch2 = false; + { + bool disjunctiveMatch1 = false; if (_source45.is_Some) { Dafny.ISequence value4 = _source45.dtor_value; if (object.Equals(value4, Dafny.Sequence.UnicodeFromString("seq!"))) { - disjunctiveMatch2 = true; + disjunctiveMatch1 = true; } } if (_source45.is_Some) { Dafny.ISequence value5 = _source45.dtor_value; if (object.Equals(value5, Dafny.Sequence.UnicodeFromString("map!"))) { - disjunctiveMatch2 = true; + disjunctiveMatch1 = true; } } - if (disjunctiveMatch2) { - unmatched45 = false; + if (disjunctiveMatch1) { return _System.Tuple2, Dafny.ISequence>.create(Dafny.Sequence.UnicodeFromString("["), Dafny.Sequence.UnicodeFromString("]")); } } - if (unmatched45) { - bool disjunctiveMatch3 = false; + { + bool disjunctiveMatch2 = false; if (_source45.is_Some) { Dafny.ISequence value6 = _source45.dtor_value; if (object.Equals(value6, Dafny.Sequence.UnicodeFromString("set!"))) { - disjunctiveMatch3 = true; + disjunctiveMatch2 = true; } } if (_source45.is_Some) { Dafny.ISequence value7 = _source45.dtor_value; if (object.Equals(value7, Dafny.Sequence.UnicodeFromString("multiset!"))) { - disjunctiveMatch3 = true; + disjunctiveMatch2 = true; } } - if (disjunctiveMatch3) { - unmatched45 = false; + if (disjunctiveMatch2) { return _System.Tuple2, Dafny.ISequence>.create(Dafny.Sequence.UnicodeFromString("{"), Dafny.Sequence.UnicodeFromString("}")); } } - if (unmatched45) { - unmatched45 = false; + { return _System.Tuple2, Dafny.ISequence>.create(Dafny.Sequence.UnicodeFromString("("), Dafny.Sequence.UnicodeFromString(")")); } - throw new System.Exception("unexpected control point"); }))(); Dafny.ISequence _1052_leftCallP = _let_tmp_rhs49.dtor__0; Dafny.ISequence _1053_rightCallP = _let_tmp_rhs49.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1050_leftP, (_1048_expr)._ToString(_pat_let_tv121)), _1051_rightP), _1052_leftCallP), RAST.__default.SeqToString(_1049_args, Dafny.Helpers.Id, Func>>>((_1054_ind) => ((System.Func>)((_1055_arg) => { + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1050_leftP, (_1048_expr)._ToString(ind)), _1051_rightP), _1052_leftCallP), RAST.__default.SeqToString(_1049_args, Dafny.Helpers.Id, Func>>>((_1054_ind) => ((System.Func>)((_1055_arg) => { return (_1055_arg)._ToString(Dafny.Sequence.Concat(_1054_ind, RAST.__default.IND)); - })))(_pat_let_tv122), Dafny.Sequence.UnicodeFromString(", "))), _1053_rightCallP); + })))(ind), Dafny.Sequence.UnicodeFromString(", "))), _1053_rightCallP); } } - if (unmatched40) { + { if (_source40.is_Select) { RAST._IExpr _1056_expression = _source40.dtor_obj; Dafny.ISequence _1057_name = _source40.dtor_name; - unmatched40 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs50 = (this).LeftParentheses(_1056_expression); Dafny.ISequence _1058_leftP = _let_tmp_rhs50.dtor__0; Dafny.ISequence _1059_rightP = _let_tmp_rhs50.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1058_leftP, (_1056_expression)._ToString(_pat_let_tv123)), _1059_rightP), Dafny.Sequence.UnicodeFromString(".")), _1057_name); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1058_leftP, (_1056_expression)._ToString(ind)), _1059_rightP), Dafny.Sequence.UnicodeFromString(".")), _1057_name); } } - if (unmatched40) { + { if (_source40.is_SelectIndex) { RAST._IExpr _1060_expression = _source40.dtor_obj; RAST._IExpr _1061_range = _source40.dtor_range; - unmatched40 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs51 = (this).LeftParentheses(_1060_expression); Dafny.ISequence _1062_leftP = _let_tmp_rhs51.dtor__0; Dafny.ISequence _1063_rightP = _let_tmp_rhs51.dtor__1; - Dafny.ISequence _1064_rangeStr = (_1061_range)._ToString(Dafny.Sequence.Concat(_pat_let_tv124, RAST.__default.IND)); - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1062_leftP, (_1060_expression)._ToString(_pat_let_tv125)), _1063_rightP), Dafny.Sequence.UnicodeFromString("[")), _1064_rangeStr), Dafny.Sequence.UnicodeFromString("]")); + Dafny.ISequence _1064_rangeStr = (_1061_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(_1062_leftP, (_1060_expression)._ToString(ind)), _1063_rightP), Dafny.Sequence.UnicodeFromString("[")), _1064_rangeStr), Dafny.Sequence.UnicodeFromString("]")); } } - if (unmatched40) { + { if (_source40.is_MemberSelect) { RAST._IExpr _1065_expression = _source40.dtor_obj; Dafny.ISequence _1066_name = _source40.dtor_name; - unmatched40 = false; _System._ITuple2, Dafny.ISequence> _let_tmp_rhs52 = (this).LeftParentheses(_1065_expression); Dafny.ISequence _1067_leftP = _let_tmp_rhs52.dtor__0; Dafny.ISequence _1068_rightP = _let_tmp_rhs52.dtor__1; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1067_leftP, (_1065_expression)._ToString(_pat_let_tv126)), _1068_rightP), Dafny.Sequence.UnicodeFromString("::")), _1066_name); + return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(_1067_leftP, (_1065_expression)._ToString(ind)), _1068_rightP), Dafny.Sequence.UnicodeFromString("::")), _1066_name); } } - if (unmatched40) { + { if (_source40.is_Lambda) { Dafny.ISequence _1069_params = _source40.dtor_params; Std.Wrappers._IOption _1070_retType = _source40.dtor_retType; RAST._IExpr _1071_body = _source40.dtor_body; - unmatched40 = false; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("move |"), RAST.__default.SeqToString(_1069_params, Dafny.Helpers.Id, Func>>>((_1072_ind) => ((System.Func>)((_1073_arg) => { return (_1073_arg)._ToString(_1072_ind); - })))(_pat_let_tv127), Dafny.Sequence.UnicodeFromString(","))), Dafny.Sequence.UnicodeFromString("| ")), (((_1070_retType).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("-> "), ((_1070_retType).dtor_value)._ToString(_pat_let_tv128))) : (Dafny.Sequence.UnicodeFromString("")))), ((((_1070_retType).is_Some) && (!((_1071_body).is_Block))) ? ((RAST.Expr.create_Block(_1071_body))._ToString(_pat_let_tv129)) : ((_1071_body)._ToString(_pat_let_tv130)))); + })))(ind), Dafny.Sequence.UnicodeFromString(","))), Dafny.Sequence.UnicodeFromString("| ")), (((_1070_retType).is_Some) ? (Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("-> "), ((_1070_retType).dtor_value)._ToString(ind))) : (Dafny.Sequence.UnicodeFromString("")))), ((((_1070_retType).is_Some) && (!((_1071_body).is_Block))) ? ((RAST.Expr.create_Block(_1071_body))._ToString(ind)) : ((_1071_body)._ToString(ind)))); } } - if (unmatched40) { + { RAST._IExpr _1074_r = _source40; - unmatched40 = false; - return RAST.__default.AddIndent((_1074_r).dtor_content, _pat_let_tv131); + return RAST.__default.AddIndent((_1074_r).dtor_content, ind); } - throw new System.Exception("unexpected control point"); } public RAST._IExpr Then(RAST._IExpr rhs2) { if ((this).is_StmtExpr) { @@ -6006,307 +5755,270 @@ public RAST._IExpr Clone() { } public RAST._IPrintingInfo printingInfo { get { RAST._IExpr _source46 = this; - bool unmatched46 = true; - if (unmatched46) { + { if (_source46.is_RawExpr) { - unmatched46 = false; return RAST.PrintingInfo.create_UnknownPrecedence(); } } - if (unmatched46) { + { if (_source46.is_ExprFromType) { - unmatched46 = false; return RAST.PrintingInfo.create_Precedence(BigInteger.One); } } - if (unmatched46) { + { if (_source46.is_Identifier) { - unmatched46 = false; return RAST.PrintingInfo.create_Precedence(BigInteger.One); } } - if (unmatched46) { + { if (_source46.is_LiteralInt) { - unmatched46 = false; return RAST.PrintingInfo.create_Precedence(BigInteger.One); } } - if (unmatched46) { + { if (_source46.is_LiteralBool) { - unmatched46 = false; return RAST.PrintingInfo.create_Precedence(BigInteger.One); } } - if (unmatched46) { + { if (_source46.is_LiteralString) { - unmatched46 = false; return RAST.PrintingInfo.create_Precedence(BigInteger.One); } } - if (unmatched46) { + { if (_source46.is_UnaryOp) { Dafny.ISequence _1076_op = _source46.dtor_op1; RAST._IExpr _1077_underlying = _source46.dtor_underlying; DAST.Format._IUnaryOpFormat _1078_format = _source46.dtor_format; - unmatched46 = false; Dafny.ISequence _source47 = _1076_op; - bool unmatched47 = true; - if (unmatched47) { + { if (object.Equals(_source47, Dafny.Sequence.UnicodeFromString("?"))) { - unmatched47 = false; return RAST.PrintingInfo.create_SuffixPrecedence(new BigInteger(5)); } } - if (unmatched47) { - bool disjunctiveMatch4 = false; + { + bool disjunctiveMatch3 = false; if (object.Equals(_source47, Dafny.Sequence.UnicodeFromString("-"))) { - disjunctiveMatch4 = true; + disjunctiveMatch3 = true; } if (object.Equals(_source47, Dafny.Sequence.UnicodeFromString("*"))) { - disjunctiveMatch4 = true; + disjunctiveMatch3 = true; } if (object.Equals(_source47, Dafny.Sequence.UnicodeFromString("!"))) { - disjunctiveMatch4 = true; + disjunctiveMatch3 = true; } if (object.Equals(_source47, Dafny.Sequence.UnicodeFromString("&"))) { - disjunctiveMatch4 = true; + disjunctiveMatch3 = true; } if (object.Equals(_source47, Dafny.Sequence.UnicodeFromString("&mut"))) { - disjunctiveMatch4 = true; + disjunctiveMatch3 = true; } - if (disjunctiveMatch4) { - unmatched47 = false; + if (disjunctiveMatch3) { return RAST.PrintingInfo.create_Precedence(new BigInteger(6)); } } - if (unmatched47) { - unmatched47 = false; + { return RAST.PrintingInfo.create_UnknownPrecedence(); } - throw new System.Exception("unexpected control point"); } } - if (unmatched46) { + { if (_source46.is_Select) { RAST._IExpr _1079_underlying = _source46.dtor_obj; Dafny.ISequence _1080_name = _source46.dtor_name; - unmatched46 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(2), RAST.Associativity.create_LeftToRight()); } } - if (unmatched46) { + { if (_source46.is_SelectIndex) { RAST._IExpr _1081_underlying = _source46.dtor_obj; RAST._IExpr _1082_range = _source46.dtor_range; - unmatched46 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(2), RAST.Associativity.create_LeftToRight()); } } - if (unmatched46) { + { if (_source46.is_MemberSelect) { RAST._IExpr _1083_underlying = _source46.dtor_obj; Dafny.ISequence _1084_name = _source46.dtor_name; - unmatched46 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(2), RAST.Associativity.create_LeftToRight()); } } - if (unmatched46) { + { if (_source46.is_CallType) { - unmatched46 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(2), RAST.Associativity.create_LeftToRight()); } } - if (unmatched46) { + { if (_source46.is_Call) { - unmatched46 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(2), RAST.Associativity.create_LeftToRight()); } } - if (unmatched46) { + { if (_source46.is_TypeAscription) { RAST._IExpr _1085_left = _source46.dtor_left; RAST._IType _1086_tpe = _source46.dtor_tpe; - unmatched46 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(10), RAST.Associativity.create_LeftToRight()); } } - if (unmatched46) { + { if (_source46.is_BinaryOp) { Dafny.ISequence _1087_op2 = _source46.dtor_op2; RAST._IExpr _1088_left = _source46.dtor_left; RAST._IExpr _1089_right = _source46.dtor_right; DAST.Format._IBinaryOpFormat _1090_format = _source46.dtor_format2; - unmatched46 = false; Dafny.ISequence _source48 = _1087_op2; - bool unmatched48 = true; - if (unmatched48) { - bool disjunctiveMatch5 = false; + { + bool disjunctiveMatch4 = false; if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("*"))) { - disjunctiveMatch5 = true; + disjunctiveMatch4 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("/"))) { - disjunctiveMatch5 = true; + disjunctiveMatch4 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("%"))) { - disjunctiveMatch5 = true; + disjunctiveMatch4 = true; } - if (disjunctiveMatch5) { - unmatched48 = false; + if (disjunctiveMatch4) { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(20), RAST.Associativity.create_LeftToRight()); } } - if (unmatched48) { - bool disjunctiveMatch6 = false; + { + bool disjunctiveMatch5 = false; if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("+"))) { - disjunctiveMatch6 = true; + disjunctiveMatch5 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("-"))) { - disjunctiveMatch6 = true; + disjunctiveMatch5 = true; } - if (disjunctiveMatch6) { - unmatched48 = false; + if (disjunctiveMatch5) { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(30), RAST.Associativity.create_LeftToRight()); } } - if (unmatched48) { - bool disjunctiveMatch7 = false; + { + bool disjunctiveMatch6 = false; if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("<<"))) { - disjunctiveMatch7 = true; + disjunctiveMatch6 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString(">>"))) { - disjunctiveMatch7 = true; + disjunctiveMatch6 = true; } - if (disjunctiveMatch7) { - unmatched48 = false; + if (disjunctiveMatch6) { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(40), RAST.Associativity.create_LeftToRight()); } } - if (unmatched48) { + { if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("&"))) { - unmatched48 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(50), RAST.Associativity.create_LeftToRight()); } } - if (unmatched48) { + { if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("^"))) { - unmatched48 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(60), RAST.Associativity.create_LeftToRight()); } } - if (unmatched48) { + { if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("|"))) { - unmatched48 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(70), RAST.Associativity.create_LeftToRight()); } } - if (unmatched48) { - bool disjunctiveMatch8 = false; + { + bool disjunctiveMatch7 = false; if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("=="))) { - disjunctiveMatch8 = true; + disjunctiveMatch7 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("!="))) { - disjunctiveMatch8 = true; + disjunctiveMatch7 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("<"))) { - disjunctiveMatch8 = true; + disjunctiveMatch7 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString(">"))) { - disjunctiveMatch8 = true; + disjunctiveMatch7 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("<="))) { - disjunctiveMatch8 = true; + disjunctiveMatch7 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString(">="))) { - disjunctiveMatch8 = true; + disjunctiveMatch7 = true; } - if (disjunctiveMatch8) { - unmatched48 = false; + if (disjunctiveMatch7) { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(80), RAST.Associativity.create_RequiresParentheses()); } } - if (unmatched48) { + { if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("&&"))) { - unmatched48 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(90), RAST.Associativity.create_LeftToRight()); } } - if (unmatched48) { + { if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("||"))) { - unmatched48 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(100), RAST.Associativity.create_LeftToRight()); } } - if (unmatched48) { - bool disjunctiveMatch9 = false; + { + bool disjunctiveMatch8 = false; if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString(".."))) { - disjunctiveMatch9 = true; + disjunctiveMatch8 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("..="))) { - disjunctiveMatch9 = true; + disjunctiveMatch8 = true; } - if (disjunctiveMatch9) { - unmatched48 = false; + if (disjunctiveMatch8) { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(110), RAST.Associativity.create_RequiresParentheses()); } } - if (unmatched48) { - bool disjunctiveMatch10 = false; + { + bool disjunctiveMatch9 = false; if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("+="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("-="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("*="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("/="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("%="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("&="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("|="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("^="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString("<<="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } if (object.Equals(_source48, Dafny.Sequence.UnicodeFromString(">>="))) { - disjunctiveMatch10 = true; + disjunctiveMatch9 = true; } - if (disjunctiveMatch10) { - unmatched48 = false; + if (disjunctiveMatch9) { return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(110), RAST.Associativity.create_RightToLeft()); } } - if (unmatched48) { - unmatched48 = false; + { return RAST.PrintingInfo.create_PrecedenceAssociativity(BigInteger.Zero, RAST.Associativity.create_RequiresParentheses()); } - throw new System.Exception("unexpected control point"); } } - if (unmatched46) { + { if (_source46.is_Lambda) { - unmatched46 = false; return RAST.PrintingInfo.create_PrecedenceAssociativity(new BigInteger(300), RAST.Associativity.create_LeftToRight()); } } - if (unmatched46) { - unmatched46 = false; + { return RAST.PrintingInfo.create_UnknownPrecedence(); } - throw new System.Exception("unexpected control point"); } } } public class Expr_RawExpr : Expr { @@ -7341,42 +7053,30 @@ public Std.Wrappers._IOption dtor_body { } } public Dafny.ISequence _ToString(Dafny.ISequence ind) { - var _pat_let_tv132 = ind; - var _pat_let_tv133 = ind; - var _pat_let_tv134 = ind; - var _pat_let_tv135 = ind; return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("fn "), (this).dtor_name), RAST.TypeParamDecl.ToStringMultiple((this).dtor_typeParams, ind)), Dafny.Sequence.UnicodeFromString("(")), RAST.__default.SeqToString((this).dtor_formals, Dafny.Helpers.Id, Func>>>((_1091_ind) => ((System.Func>)((_1092_formal) => { return (_1092_formal)._ToString(_1091_ind); })))(ind), Dafny.Sequence.UnicodeFromString(", "))), Dafny.Sequence.UnicodeFromString(")")), ((System.Func>)(() => { Std.Wrappers._IOption _source49 = (this).dtor_returnType; - bool unmatched49 = true; - if (unmatched49) { + { if (_source49.is_Some) { RAST._IType _1093_t = _source49.dtor_value; - unmatched49 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" -> "), (_1093_t)._ToString(_pat_let_tv132)); + return Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" -> "), (_1093_t)._ToString(ind)); } } - if (unmatched49) { - unmatched49 = false; + { return Dafny.Sequence.UnicodeFromString(""); } - throw new System.Exception("unexpected control point"); }))()), ((((this).dtor_where).Equals(Dafny.Sequence.UnicodeFromString(""))) ? (Dafny.Sequence.UnicodeFromString("")) : (Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString("\n"), ind), RAST.__default.IND), (this).dtor_where)))), ((System.Func>)(() => { Std.Wrappers._IOption _source50 = (this).dtor_body; - bool unmatched50 = true; - if (unmatched50) { + { if (_source50.is_None) { - unmatched50 = false; return Dafny.Sequence.UnicodeFromString(";"); } } - if (unmatched50) { + { RAST._IExpr _1094_body = _source50.dtor_value; - unmatched50 = false; - return Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.Concat(Dafny.Sequence.UnicodeFromString(" {\n"), _pat_let_tv133), RAST.__default.IND), (_1094_body)._ToString(Dafny.Sequence.Concat(_pat_let_tv134, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), _pat_let_tv135), 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(" {\n"), ind), RAST.__default.IND), (_1094_body)._ToString(Dafny.Sequence.Concat(ind, RAST.__default.IND))), Dafny.Sequence.UnicodeFromString("\n")), ind), Dafny.Sequence.UnicodeFromString("}")); } - throw new System.Exception("unexpected control point"); }))()); } } diff --git a/Source/DafnyCore/GeneratedFromDafny/Std_Wrappers.cs b/Source/DafnyCore/GeneratedFromDafny/Std_Wrappers.cs index c93d46b98b5..fbcdc9cf5cf 100644 --- a/Source/DafnyCore/GeneratedFromDafny/Std_Wrappers.cs +++ b/Source/DafnyCore/GeneratedFromDafny/Std_Wrappers.cs @@ -67,55 +67,40 @@ public T Extract() { return (this).dtor_value; } public static T GetOr(Std.Wrappers._IOption _this, T @default) { - var _pat_let_tv0 = @default; Std.Wrappers._IOption _source0 = _this; - bool unmatched0 = true; - if (unmatched0) { + { if (_source0.is_Some) { T v = _source0.dtor_value; - unmatched0 = false; return v; } } - if (unmatched0) { - unmatched0 = false; - return _pat_let_tv0; + { + return @default; } - throw new System.Exception("unexpected control point"); } public Std.Wrappers._IResult ToResult<__E>(__E error) { - var _pat_let_tv1 = error; Std.Wrappers._IOption _source1 = this; - bool unmatched1 = true; - if (unmatched1) { + { if (_source1.is_Some) { T v = _source1.dtor_value; - unmatched1 = false; return Std.Wrappers.Result.create_Success(v); } } - if (unmatched1) { - unmatched1 = false; - return Std.Wrappers.Result.create_Failure(_pat_let_tv1); + { + return Std.Wrappers.Result.create_Failure(error); } - throw new System.Exception("unexpected control point"); } public Std.Wrappers._IOutcome<__E> ToOutcome<__E>(__E error) { - var _pat_let_tv2 = error; Std.Wrappers._IOption _source2 = this; - bool unmatched2 = true; - if (unmatched2) { + { if (_source2.is_Some) { T v = _source2.dtor_value; - unmatched2 = false; return Std.Wrappers.Outcome<__E>.create_Pass(); } } - if (unmatched2) { - unmatched2 = false; - return Std.Wrappers.Outcome<__E>.create_Fail(_pat_let_tv2); + { + return Std.Wrappers.Outcome<__E>.create_Fail(error); } - throw new System.Exception("unexpected control point"); } public static __FC Map<__FC>(Std.Wrappers._IOption _this, Func, __FC> rewrap) { return Dafny.Helpers.Id, __FC>>(rewrap)(_this); @@ -222,77 +207,59 @@ public R Extract() { return (this).dtor_value; } public static R GetOr(Std.Wrappers._IResult _this, R @default) { - var _pat_let_tv3 = @default; Std.Wrappers._IResult _source3 = _this; - bool unmatched3 = true; - if (unmatched3) { + { if (_source3.is_Success) { R s = _source3.dtor_value; - unmatched3 = false; return s; } } - if (unmatched3) { + { E e = _source3.dtor_error; - unmatched3 = false; - return _pat_let_tv3; + return @default; } - throw new System.Exception("unexpected control point"); } public Std.Wrappers._IOption ToOption() { Std.Wrappers._IResult _source4 = this; - bool unmatched4 = true; - if (unmatched4) { + { if (_source4.is_Success) { R s = _source4.dtor_value; - unmatched4 = false; return Std.Wrappers.Option.create_Some(s); } } - if (unmatched4) { + { E _10_e = _source4.dtor_error; - unmatched4 = false; return Std.Wrappers.Option.create_None(); } - throw new System.Exception("unexpected control point"); } public Std.Wrappers._IOutcome ToOutcome() { Std.Wrappers._IResult _source5 = this; - bool unmatched5 = true; - if (unmatched5) { + { if (_source5.is_Success) { R _11_s = _source5.dtor_value; - unmatched5 = false; return Std.Wrappers.Outcome.create_Pass(); } } - if (unmatched5) { + { E _12_e = _source5.dtor_error; - unmatched5 = false; return Std.Wrappers.Outcome.create_Fail(_12_e); } - throw new System.Exception("unexpected control point"); } public static __FC Map<__FC>(Std.Wrappers._IResult _this, Func, __FC> rewrap) { return Dafny.Helpers.Id, __FC>>(rewrap)(_this); } public static Std.Wrappers._IResult MapFailure<__NewE>(Std.Wrappers._IResult _this, Func reWrap) { - var _pat_let_tv4 = reWrap; Std.Wrappers._IResult _source6 = _this; - bool unmatched6 = true; - if (unmatched6) { + { if (_source6.is_Success) { R _13_s = _source6.dtor_value; - unmatched6 = false; return Std.Wrappers.Result.create_Success(_13_s); } } - if (unmatched6) { + { E _14_e = _source6.dtor_error; - unmatched6 = false; - return Std.Wrappers.Result.create_Failure(Dafny.Helpers.Id>(_pat_let_tv4)(_14_e)); + return Std.Wrappers.Result.create_Failure(Dafny.Helpers.Id>(reWrap)(_14_e)); } - throw new System.Exception("unexpected control point"); } } public class Result_Success : Result { @@ -391,60 +358,44 @@ public Std.Wrappers._IOutcome PropagateFailure() { return this; } public Std.Wrappers._IOption<__R> ToOption<__R>(__R r) { - var _pat_let_tv5 = r; Std.Wrappers._IOutcome _source7 = this; - bool unmatched7 = true; - if (unmatched7) { + { if (_source7.is_Pass) { - unmatched7 = false; - return Std.Wrappers.Option<__R>.create_Some(_pat_let_tv5); + return Std.Wrappers.Option<__R>.create_Some(r); } } - if (unmatched7) { + { E _15_e = _source7.dtor_error; - unmatched7 = false; return Std.Wrappers.Option<__R>.create_None(); } - throw new System.Exception("unexpected control point"); } public Std.Wrappers._IResult<__R, E> ToResult<__R>(__R r) { - var _pat_let_tv6 = r; Std.Wrappers._IOutcome _source8 = this; - bool unmatched8 = true; - if (unmatched8) { + { if (_source8.is_Pass) { - unmatched8 = false; - return Std.Wrappers.Result<__R, E>.create_Success(_pat_let_tv6); + return Std.Wrappers.Result<__R, E>.create_Success(r); } } - if (unmatched8) { + { E _16_e = _source8.dtor_error; - unmatched8 = false; return Std.Wrappers.Result<__R, E>.create_Failure(_16_e); } - throw new System.Exception("unexpected control point"); } public static __FC Map<__FC>(Std.Wrappers._IOutcome _this, Func, __FC> rewrap) { return Dafny.Helpers.Id, __FC>>(rewrap)(_this); } public static Std.Wrappers._IResult<__T, __NewE> MapFailure<__T, __NewE>(Std.Wrappers._IOutcome _this, Func rewrap, __T @default) { - var _pat_let_tv7 = @default; - var _pat_let_tv8 = rewrap; Std.Wrappers._IOutcome _source9 = _this; - bool unmatched9 = true; - if (unmatched9) { + { if (_source9.is_Pass) { - unmatched9 = false; - return Std.Wrappers.Result<__T, __NewE>.create_Success(_pat_let_tv7); + return Std.Wrappers.Result<__T, __NewE>.create_Success(@default); } } - if (unmatched9) { + { E _17_e = _source9.dtor_error; - unmatched9 = false; - return Std.Wrappers.Result<__T, __NewE>.create_Failure(Dafny.Helpers.Id>(_pat_let_tv8)(_17_e)); + return Std.Wrappers.Result<__T, __NewE>.create_Failure(Dafny.Helpers.Id>(rewrap)(_17_e)); } - throw new System.Exception("unexpected control point"); } public static Std.Wrappers._IOutcome Need(bool condition, E error) { diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/CovariantCollections.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/CovariantCollections.dfy index 6dd73ee7fea..0063bb92c02 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/CovariantCollections.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/comp/CovariantCollections.dfy @@ -342,7 +342,8 @@ method Downcasts() { s, s' := DowncastM2(m); // cast in, cast out s := var v: set := m; v; // regression test -- this once tripped up the compilation to Java, whereas the next line had not s' := var u: set := var v: set := m; v; u; - var eq := s == m && m == s; + var s'' := DowncastFunction(a, b); // regression test -- the same error was later discovered in top-level function bodies + var eq := s == m && m == s && s == s''; print eq, "\n"; // true s := FId(m); // cast in @@ -367,6 +368,12 @@ method Create(a: T, b: T) returns (m: set, n: multiset, o: seq, p: m p := map[a := b, b := a]; } +function DowncastFunction(a: Integer, b: Integer): set { + var m: set := {a, b}; + var v: set := m; + v +} + function DowncastF(s: set): set { s } method DowncastM(s: set) returns (r: set) ensures r == s diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868.dfy index a5b424ee52e..df3753fe200 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868.dfy @@ -9,6 +9,9 @@ method Main() { print WoahThat'sDeepToo(AA("i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix", "x"), "555"), "\n"; print "Recur: ", recur.Follow0(A, 12, 80), "\n"; // 116 (that is, 80 + 12*(2 + 1) print "Recur: ", recur.Follow1(A, 12, 80), "\n"; // 116 (that is, 80 + 12*(2 + 1) + var w := DeepAssignment(25); + print w, "\n"; // 25 + MatchExpressions.Test(); } method NotOptimized(s: string) returns (r: int) { @@ -163,3 +166,128 @@ datatype Option<+T> = None | Some(value: T) { value } } + +method DeepAssignment(x: int) returns (r: int) { + r := + var x0 := x; + var x1 := x0; + var x2 := x1; + var x3 := x2; + var x4 := x3; + var x5 := x4; + var x6 := x5; + var x7 := x6; + if x0 == x7 then + var y0 := x; + var y1 := y0; + y1 + else + var y2 := x; + var y3 := y2; + y3; + return r; +} + +module MatchExpressions { + datatype Color = Red | Green | Blue + datatype AB = A | B + datatype ABC = AA | BB | CC + + method Test() { + M(Green); + N(Red); + var r := O(Blue, 10); + print r, "\n"; // 12 + P(7, 2); + label L: { + var abc := 0; + break L; + } + print TailRecursive(A, 19), " ", AutoAccumulator(A, 19), "\n"; // 6 25 + print LastCaseIsDisjunctive(BB), "\n"; // 22 + print F(A, 12, 80), "\n"; // 80 + print "It's done\n"; + } + + method M(c: Color) { + var x := match c + case Red => 5 + case Green => 7 + case Blue => 11; + print x, "\n"; // 5 + } + + method N(c: Color) + requires c == Red + { + var x := match c + case Red => 5; + print x, "\n"; // 5 + } + + method O(c: Color, y: int) returns (r: int) + requires 0 <= y + { + if y < 0 { + // unreachable + var x: int := match c; + } + r := 12; + } + + method P(s: int, t: int) + requires t == 0 || t == 2 + { + var x: int := match s + case 0 => 100 + case 2 => 200 + case _ => 400; + var y: int := match t + case 0 => 60 + case 2 => 80; + if t == 1 { + // unreachable + var z: int := match s + t; + } + print x, " ", y, "\n"; // 400 80 + } + + function TailRecursive(o: AB, n: nat): int { + if n == 0 then 6 else + match o + case A | B => TailRecursive(o, n - 1) + } + + function AutoAccumulator(o: AB, n: nat): int { + if n == 0 then 6 else + match o + case A | B => AutoAccumulator(o, n - 1) + 1 + } + + function LastCaseIsDisjunctive(o: ABC): int { + match o + case CC => + 777 + case AA | BB => + 22 + } + + function F(o: AB, n: nat, m: int): int + { + if n == 0 then + m + else if n == 1 then + var ff := () => match o { // for Java, make sure o is copied + case A => 20 + case B => 999 + }; + var s := ff(); + F(o, n - 1, m) + else + var u := match o { + case A => 20 + case B => 999 + }; + F(o, n - 1, m) + } +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868.dfy.expect index 71f58061f67..883c085d988 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868.dfy.expect @@ -4,3 +4,12 @@ Option.Some(['4', '2']) Option.Some(['x']) Recur: 116 Recur: 116 +25 +7 +5 +12 +400 80 +6 25 +22 +80 +It's done diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868b.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868b.dfy index 7d58d9ce524..69b0295513c 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868b.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-3868b.dfy @@ -51,3 +51,27 @@ datatype Option<+T> = None | Some(value: T) { value } } + +// The following method includes an assignment whose RHS is a deeply nested expression. +// We optimize such assignments, too. By including this test here, we make sure the Java +// we generate doesn't contain any occurrences of "Let(". +method DeepAssignment(x: int) returns (r: int) { + r := + var x0 := x; + var x1 := x0; + var x2 := x1; + var x3 := x2; + var x4 := x3; + var x5 := x4; + var x6 := x5; + var x7 := x6; + if x0 == x7 then + var y0 := x; + var y1 := y0; + y1 + else + var y2 := x; + var y3 := y2; + y3; + return r; +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy new file mode 100644 index 00000000000..52ae2d329a5 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy @@ -0,0 +1,55 @@ +// RUN: %testDafnyForEachCompiler "%s" + +// Note, these tests seem to be specific to the old type system. With the new type system, +// assignments that, in some way, involve a conversion from Number to Integer require an +// explicit "as" type conversion. + +method Main() { + var n: set := {}; + var s: set; + s := DoItWithAssignment(n); + print |s|, " "; + s := DoItWithPlainLet(n); + print |s|, " "; + s := DoItWithOptimizedLet(n); + print |s|, " "; + s := DoItViaFunctionBodyResult(n); + print |s|, "\n"; +} + +trait Number { + const value: int +} + +class Integer extends Number { + constructor(value: int) { + this.value := value; + } +} + +method DoItWithAssignment(numbers: set) returns (integers00: set) + requires |numbers| == 0 +{ + integers00 := numbers; +} + +function DoItWithPlainLet(numbers: set): set + requires |numbers| == 0 +{ + {} + + var integers11: set := numbers; + integers11 +} + +function DoItWithOptimizedLet(numbers: set): set + requires |numbers| == 0 +{ + var integers22: set := numbers; + integers22 +} + +function DoItViaFunctionBodyResult(numbers: set): set + requires |numbers| == 0 +{ + numbers +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy.expect new file mode 100644 index 00000000000..6a20ce40185 --- /dev/null +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/git-issues/git-issue-5597.dfy.expect @@ -0,0 +1 @@ +0 0 0 0 diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatterns.dfy b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatterns.dfy index 8a4b0f8b75f..ab52479f90f 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatterns.dfy +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatterns.dfy @@ -123,6 +123,30 @@ method Main() { var b6 := F2(A); var b7 := F2(B); expect 1 == b0 == b1 == b2 == b3 == b4 == b5 == b6 == b7; + + MoreOrTests.Test(); print "OK\n"; } + +module MoreOrTests { + datatype Dt = A | B | C | D | E | F | G + + method Test() { + M(A); + M(B); + M(C); + M(D); + M(E); + M(F); + M(G); + } + + method M(d: Dt) { + match d + case A | B => print "AB\n"; + case C => print "C\n"; + case D | E => print "DE\n"; + case F | G => print "FG\n"; + } +} diff --git a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatterns.dfy.expect b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatterns.dfy.expect index d86bac9de59..225f08e4fcb 100644 --- a/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatterns.dfy.expect +++ b/Source/IntegrationTests/TestFiles/LitTests/LitTest/patterns/OrPatterns.dfy.expect @@ -1 +1,8 @@ +AB +AB +C +DE +DE +FG +FG OK diff --git a/docs/dev/news/5589.fix b/docs/dev/news/5589.fix new file mode 100644 index 00000000000..1af9c03533a --- /dev/null +++ b/docs/dev/news/5589.fix @@ -0,0 +1 @@ +Optimize the compilation of single-LHS assignment statements to allow the RHS to be a deeply nested expression. This solves a problem in compiling to Java, since `javac` does not deal gracefully with nested lambda expressions. \ No newline at end of file