From 2fe1c552136a36b6cfda019e88defabb87cacf2a Mon Sep 17 00:00:00 2001 From: alex28sh Date: Fri, 12 Jul 2024 15:58:30 +0200 Subject: [PATCH] Nagini Conversion --- .../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 ++- .../Legacy/SynchronousCliCompilation.cs | 20 + 13 files changed, 468 insertions(+), 79 deletions(-) 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