From 8813a8e6d13a67c8a6ffad5255334af834fabdc7 Mon Sep 17 00:00:00 2001 From: Remy Willems Date: Fri, 7 Jul 2023 16:11:00 +0200 Subject: [PATCH 1/8] Add the compile suffix option --- Source/DafnyCore/AST/Modules/ModuleDefinition.cs | 5 +++-- Source/DafnyCore/Options/CommonOptionBag.cs | 5 +++++ Source/DafnyCore/Options/ICommandSpec.cs | 3 ++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Source/DafnyCore/AST/Modules/ModuleDefinition.cs b/Source/DafnyCore/AST/Modules/ModuleDefinition.cs index 5e53a1961ad..22ab1f784d1 100644 --- a/Source/DafnyCore/AST/Modules/ModuleDefinition.cs +++ b/Source/DafnyCore/AST/Modules/ModuleDefinition.cs @@ -177,12 +177,13 @@ public string SanitizedName { public string GetCompileName(DafnyOptions options) { if (compileName == null) { var externArgs = options.DisallowExterns ? null : Attributes.FindExpressions(this.Attributes, "extern"); + var nonExternSuffix = (options.Get(CommonOptionBag.AddCompileSuffix) ? "_Compile" : ""); if (externArgs != null && 1 <= externArgs.Count && externArgs[0] is StringLiteralExpr) { compileName = (string)((StringLiteralExpr)externArgs[0]).Value; } else if (externArgs != null) { - compileName = Name; + compileName = Name + nonExternSuffix; } else { - compileName = SanitizedName; + compileName = SanitizedName + nonExternSuffix; } } diff --git a/Source/DafnyCore/Options/CommonOptionBag.cs b/Source/DafnyCore/Options/CommonOptionBag.cs index cdd3198788e..94b88939fbb 100644 --- a/Source/DafnyCore/Options/CommonOptionBag.cs +++ b/Source/DafnyCore/Options/CommonOptionBag.cs @@ -9,6 +9,11 @@ namespace Microsoft.Dafny; public class CommonOptionBag { + public static readonly Option AddCompileSuffix = + new("--compile-suffix", "Add the suffix _Compile to module names without :extern") { + IsHidden = true + }; + public static readonly Option ManualLemmaInduction = new("--manual-lemma-induction", "Turn off automatic induction for lemmas."); diff --git a/Source/DafnyCore/Options/ICommandSpec.cs b/Source/DafnyCore/Options/ICommandSpec.cs index e7d570783ae..097bb23bdbc 100644 --- a/Source/DafnyCore/Options/ICommandSpec.cs +++ b/Source/DafnyCore/Options/ICommandSpec.cs @@ -49,7 +49,8 @@ static ICommandSpec() { CommonOptionBag.EnforceDeterminism, CommonOptionBag.OptimizeErasableDatatypeWrapper, CommonOptionBag.TestAssumptions, - DeveloperOptionBag.Bootstrapping + DeveloperOptionBag.Bootstrapping, + CommonOptionBag.AddCompileSuffix, }.Concat(VerificationOptions).ToList(); public static IReadOnlyList