From a59b15d4e0a8e21d6e266fd8e778bcdac285b1c9 Mon Sep 17 00:00:00 2001 From: alex28sh Date: Fri, 12 Jul 2024 15:29:54 +0200 Subject: [PATCH] Nagini Converting --- CODE_OF_CONDUCT.md | 0 CONTRIBUTING.md | 0 DAFNY.ORG.txt | 0 INSTALL.md | 0 LICENSE.txt | 0 Makefile | 0 NOTICES.txt | 0 README.md | 0 RELEASE_NOTES.md | 0 SECURITY.md | 0 Scripts/quicktest.sh | 1 + Source/Dafny.sln | 38 ++ .../Statements/Assignment/LocalVariable.cs | 10 +- Source/DafnyCore/AST/Types/UserDefinedType.cs | 2 +- .../Backends/CSharp/CsharpCodeGenerator.cs | 3 +- .../Backends/Cplusplus/CppCodeGenerator.cs | 2 +- .../Backends/Dafny/DafnyCodeGenerator.cs | 6 +- .../Backends/GoLang/GoCodeGenerator.cs | 6 +- .../Backends/Java/JavaCodeGenerator.cs | 3 +- .../JavaScript/JavaScriptCodeGenerator.cs | 3 +- .../Backends/Python/PythonCodeGenerator.cs | 355 ++++++++++++++++-- .../SinglePassCodeGenerator.Expression.cs | 26 +- .../SinglePassCodeGenerator.Statement.cs | 58 ++- .../SinglePassCodeGenerator.cs | 53 ++- Source/DafnyCore/DafnyCore.csproj | 12 +- .../Legacy/SynchronousCliCompilation.cs | 20 + customBoogie.patch | 0 dotnet-tools.json | 0 28 files changed, 518 insertions(+), 80 deletions(-) mode change 100644 => 100755 CODE_OF_CONDUCT.md mode change 100644 => 100755 CONTRIBUTING.md mode change 100644 => 100755 DAFNY.ORG.txt mode change 100644 => 100755 INSTALL.md mode change 100644 => 100755 LICENSE.txt mode change 100644 => 100755 Makefile mode change 100644 => 100755 NOTICES.txt mode change 100644 => 100755 README.md mode change 100644 => 100755 RELEASE_NOTES.md mode change 100644 => 100755 SECURITY.md mode change 100644 => 100755 customBoogie.patch mode change 100644 => 100755 dotnet-tools.json diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md old mode 100644 new mode 100755 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md old mode 100644 new mode 100755 diff --git a/DAFNY.ORG.txt b/DAFNY.ORG.txt old mode 100644 new mode 100755 diff --git a/INSTALL.md b/INSTALL.md old mode 100644 new mode 100755 diff --git a/LICENSE.txt b/LICENSE.txt old mode 100644 new mode 100755 diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 diff --git a/NOTICES.txt b/NOTICES.txt old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md old mode 100644 new mode 100755 diff --git a/SECURITY.md b/SECURITY.md old mode 100644 new mode 100755 diff --git a/Scripts/quicktest.sh b/Scripts/quicktest.sh index ae8053131..22328f6a9 100755 --- a/Scripts/quicktest.sh +++ b/Scripts/quicktest.sh @@ -63,6 +63,7 @@ $DAFNY build -t:go c.dfy | diff - $tmp || exit 1 ./c | diff - $tmpx || exit 1 (cd c-go; GO111MODULE=auto GOPATH=`pwd` go run src/c.go) | diff - $tmpx || exit 1 echo Building with Python +echo $DAFNY $DAFNY build -t:py c.dfy | diff - $tmp || exit 1 python c-py/c.py | diff - $tmpx || exit 1 echo Building with Rust diff --git a/Source/Dafny.sln b/Source/Dafny.sln index 23297b185..fc8e8b1fa 100644 --- a/Source/Dafny.sln +++ b/Source/Dafny.sln @@ -43,6 +43,32 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DafnyDriver.Test", "DafnyDr EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DafnyCore.Test", "DafnyCore.Test\DafnyCore.Test.csproj", "{33C29F26-A27B-474D-B436-83EA615B09FC}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Boogie", "Boogie", "{60332269-9C5D-465E-8582-01F9B738BD90}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BaseTypes", "..\boogie\Source\BaseTypes\BaseTypes.csproj", "{68721962-0D91-4355-BC94-BE1CCBD30E47}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AbstractInterpretation", "..\boogie\Source\AbstractInterpretation\AbstractInterpretation.csproj", "{2A6B36F4-9F15-459A-8EDB-5BAEED98FE17}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeContractsExtender", "..\boogie\Source\CodeContractsExtender\CodeContractsExtender.csproj", "{09662044-5640-4785-92E3-2F7CDBA4DDB2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Concurrency", "..\boogie\Source\Concurrency\Concurrency.csproj", "{DA8A9BA8-9BBA-4C64-9736-FD967517DCA9}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core", "..\boogie\Source\Core\Core.csproj", "{2BF5ECCA-24B2-4A4B-86B6-D0DB17331109}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExecutionEngine", "..\boogie\Source\ExecutionEngine\ExecutionEngine.csproj", "{0145DC89-7243-41F8-AB3E-F716F04E9BFF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Graph", "..\boogie\Source\Graph\Graph.csproj", "{05DE24BB-D639-40C4-894F-701652F51559}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Houdini", "..\boogie\Source\Houdini\Houdini.csproj", "{51D6B0D1-2D15-40A3-80F4-E32A5C07B0A6}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "..\boogie\Source\Model\Model.csproj", "{D97C23B6-FB4A-4450-930E-58EC83D308A0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SMTLib", "..\boogie\Source\Provers\SMTLib\SMTLib.csproj", "{0EC245EE-54DD-4AE3-9C2E-34E67EE28B9F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VCExpr", "..\boogie\Source\VCExpr\VCExpr.csproj", "{E760E37E-0257-4C96-89C4-722F85BABDBB}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VCGeneration", "..\boogie\Source\VCGeneration\VCGeneration.csproj", "{1EE372AA-4FF9-47FB-9C04-18CBF219F6E8}" +EndProject EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -138,5 +164,17 @@ Global SolutionGuid = {280F572B-D27A-4613-998F-00B6FFE01187} EndGlobalSection GlobalSection(NestedProjects) = preSolution + {68721962-0D91-4355-BC94-BE1CCBD30E47} = {60332269-9C5D-465E-8582-01F9B738BD90} + {2A6B36F4-9F15-459A-8EDB-5BAEED98FE17} = {60332269-9C5D-465E-8582-01F9B738BD90} + {09662044-5640-4785-92E3-2F7CDBA4DDB2} = {60332269-9C5D-465E-8582-01F9B738BD90} + {DA8A9BA8-9BBA-4C64-9736-FD967517DCA9} = {60332269-9C5D-465E-8582-01F9B738BD90} + {2BF5ECCA-24B2-4A4B-86B6-D0DB17331109} = {60332269-9C5D-465E-8582-01F9B738BD90} + {0145DC89-7243-41F8-AB3E-F716F04E9BFF} = {60332269-9C5D-465E-8582-01F9B738BD90} + {05DE24BB-D639-40C4-894F-701652F51559} = {60332269-9C5D-465E-8582-01F9B738BD90} + {51D6B0D1-2D15-40A3-80F4-E32A5C07B0A6} = {60332269-9C5D-465E-8582-01F9B738BD90} + {D97C23B6-FB4A-4450-930E-58EC83D308A0} = {60332269-9C5D-465E-8582-01F9B738BD90} + {0EC245EE-54DD-4AE3-9C2E-34E67EE28B9F} = {60332269-9C5D-465E-8582-01F9B738BD90} + {E760E37E-0257-4C96-89C4-722F85BABDBB} = {60332269-9C5D-465E-8582-01F9B738BD90} + {1EE372AA-4FF9-47FB-9C04-18CBF219F6E8} = {60332269-9C5D-465E-8582-01F9B738BD90} EndGlobalSection EndGlobal diff --git a/Source/DafnyCore/AST/Statements/Assignment/LocalVariable.cs b/Source/DafnyCore/AST/Statements/Assignment/LocalVariable.cs index e90f93964..27967d8e1 100644 --- a/Source/DafnyCore/AST/Statements/Assignment/LocalVariable.cs +++ b/Source/DafnyCore/AST/Statements/Assignment/LocalVariable.cs @@ -80,8 +80,14 @@ public string AssignUniqueName(FreshIdGenerator generator) { sanitizedName ??= $"_{IVariable.CompileNameIdGenerator.FreshNumericId()}_{SanitizedNameShadowable}"; string compileName; - public string CompileName => - compileName ??= SanitizedName; + public string CompileName { + get { + return compileName ??= SanitizedName; + } + set { + compileName = value; + } + } // TODO rename and update comment? Or make it nullable? public readonly Type SyntacticType; // this is the type mentioned in the declaration, if any diff --git a/Source/DafnyCore/AST/Types/UserDefinedType.cs b/Source/DafnyCore/AST/Types/UserDefinedType.cs index cc97c154d..0c07f4dca 100644 --- a/Source/DafnyCore/AST/Types/UserDefinedType.cs +++ b/Source/DafnyCore/AST/Types/UserDefinedType.cs @@ -17,7 +17,7 @@ void ObjectInvariant() { } public readonly Expression NamePath; // either NameSegment or ExprDotName (with the inner expression satisfying this same constraint) - public readonly string Name; + public string Name; [Rep] public string FullName { diff --git a/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs b/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs index 99f4c54c6..5bb11910b 100644 --- a/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs +++ b/Source/DafnyCore/Backends/CSharp/CsharpCodeGenerator.cs @@ -2046,7 +2046,7 @@ protected override void EmitHalt(IToken tok, Expression/*?*/ messageExpr, Concre } protected override ConcreteSyntaxTree EmitForStmt(IToken tok, IVariable loopIndex, bool goingUp, string /*?*/ endVarName, - List body, LList