From 36f1ad192c06d5fad5b712a879f487d585627d67 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Wed, 26 Feb 2020 17:53:07 -0800 Subject: [PATCH 1/4] renaming options --- .../Core/ExpressionTransformation.fs | 8 ++++---- src/QsCompiler/Core/NamespaceTransformation.fs | 6 +++--- src/QsCompiler/Core/StatementTransformation.fs | 10 +++++----- src/QsCompiler/Core/TransformationOptions.fs | 18 +++++++++--------- src/QsCompiler/Core/TypeTransformation.fs | 4 ++-- 5 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/QsCompiler/Core/ExpressionTransformation.fs b/src/QsCompiler/Core/ExpressionTransformation.fs index 3c530ad83d..d4bcb1ad9b 100644 --- a/src/QsCompiler/Core/ExpressionTransformation.fs +++ b/src/QsCompiler/Core/ExpressionTransformation.fs @@ -20,7 +20,7 @@ type private ExpressionKind = type ExpressionKindTransformationBase internal (options : TransformationOptions, _internal_) = let missingTransformation name _ = new InvalidOperationException(sprintf "No %s transformation has been specified." name) |> raise - let Node = if options.DisableRebuild then Walk else Fold + let Node = if options.Rebuild then Fold else Walk member val internal TypeTransformationHandle = missingTransformation "type" with get, set member val internal ExpressionTransformationHandle = missingTransformation "expression" with get, set @@ -280,7 +280,7 @@ type ExpressionKindTransformationBase internal (options : TransformationOptions, abstract member OnExpressionKind : ExpressionKind -> ExpressionKind default this.OnExpressionKind kind = - if options.Disable then kind else + if not options.Enable then kind else let transformed = kind |> function | Identifier (sym, tArgs) -> this.OnIdentifier (sym, tArgs) | CallLikeExpression (method,arg) -> this.OnCallLikeExpression (method, arg) @@ -333,7 +333,7 @@ type ExpressionKindTransformationBase internal (options : TransformationOptions, and ExpressionTransformationBase internal (options : TransformationOptions, _internal_) = let missingTransformation name _ = new InvalidOperationException(sprintf "No %s transformation has been specified." name) |> raise - let Node = if options.DisableRebuild then Walk else Fold + let Node = if options.Rebuild then Fold else Walk member val internal TypeTransformationHandle = missingTransformation "type" with get, set member val internal ExpressionKindTransformationHandle = missingTransformation "expression kind" with get, set @@ -386,7 +386,7 @@ and ExpressionTransformationBase internal (options : TransformationOptions, _int abstract member OnTypedExpression : TypedExpression -> TypedExpression default this.OnTypedExpression (ex : TypedExpression) = - if options.Disable then ex else + if not options.Enable then ex else let range = this.OnRangeInformation ex.Range let typeParamResolutions = this.OnTypeParamResolutions ex.TypeParameterResolutions let kind = this.ExpressionKinds.OnExpressionKind ex.Expression diff --git a/src/QsCompiler/Core/NamespaceTransformation.fs b/src/QsCompiler/Core/NamespaceTransformation.fs index 670913bef7..471d6bf6d0 100644 --- a/src/QsCompiler/Core/NamespaceTransformation.fs +++ b/src/QsCompiler/Core/NamespaceTransformation.fs @@ -18,7 +18,7 @@ type QsArgumentTuple = QsTuple> type NamespaceTransformationBase internal (options : TransformationOptions, _internal_) = let missingTransformation name _ = new InvalidOperationException(sprintf "No %s transformation has been specified." name) |> raise - let Node = if options.DisableRebuild then Walk else Fold + let Node = if options.Rebuild then Fold else Walk member val internal StatementTransformationHandle = missingTransformation "statement" with get, set member this.Statements = this.StatementTransformationHandle() @@ -212,14 +212,14 @@ type NamespaceTransformationBase internal (options : TransformationOptions, _int abstract member OnNamespaceElement : QsNamespaceElement -> QsNamespaceElement default this.OnNamespaceElement element = - if options.Disable then element else + if not options.Enable then element else match element with | QsCustomType t -> t |> this.OnTypeDeclaration |> QsCustomType | QsCallable c -> c |> this.OnCallableDeclaration |> QsCallable abstract member OnNamespace : QsNamespace -> QsNamespace default this.OnNamespace ns = - if options.Disable then ns else + if not options.Enable then ns else let name = ns.Name let doc = ns.Documentation.AsEnumerable().SelectMany(fun entry -> entry |> Seq.map (fun doc -> entry.Key, this.OnDocumentation doc)).ToLookup(fst, snd) diff --git a/src/QsCompiler/Core/StatementTransformation.fs b/src/QsCompiler/Core/StatementTransformation.fs index 40a155da8c..83e5d98ce1 100644 --- a/src/QsCompiler/Core/StatementTransformation.fs +++ b/src/QsCompiler/Core/StatementTransformation.fs @@ -15,7 +15,7 @@ open Microsoft.Quantum.QsCompiler.Transformations.Core.Utils type StatementKindTransformationBase internal (options : TransformationOptions, _internal_) = let missingTransformation name _ = new InvalidOperationException(sprintf "No %s transformation has been specified." name) |> raise - let Node = if options.DisableRebuild then Walk else Fold + let Node = if options.Rebuild then Fold else Walk member val internal ExpressionTransformationHandle = missingTransformation "expression" with get, set member val internal StatementTransformationHandle = missingTransformation "statement" with get, set @@ -162,7 +162,7 @@ type StatementKindTransformationBase internal (options : TransformationOptions, abstract member OnStatementKind : QsStatementKind -> QsStatementKind default this.OnStatementKind kind = - if options.Disable then kind else + if not options.Enable then kind else let transformed = kind |> function | QsExpressionStatement ex -> this.OnExpressionStatement ex | QsReturnStatement ex -> this.OnReturnStatement ex @@ -182,7 +182,7 @@ type StatementKindTransformationBase internal (options : TransformationOptions, and StatementTransformationBase internal (options : TransformationOptions, _internal_) = let missingTransformation name _ = new InvalidOperationException(sprintf "No %s transformation has been specified." name) |> raise - let Node = if options.DisableRebuild then Walk else Fold + let Node = if options.Rebuild then Fold else Walk member val internal ExpressionTransformationHandle = missingTransformation "expression" with get, set member val internal StatementKindTransformationHandle = missingTransformation "statement kind" with get, set @@ -229,7 +229,7 @@ and StatementTransformationBase internal (options : TransformationOptions, _inte abstract member OnStatement : QsStatement -> QsStatement default this.OnStatement stm = - if options.Disable then stm else + if not options.Enable then stm else let location = this.OnLocation stm.Location let comments = stm.Comments let kind = this.StatementKinds.OnStatementKind stm.Statement @@ -238,7 +238,7 @@ and StatementTransformationBase internal (options : TransformationOptions, _inte abstract member OnScope : QsScope -> QsScope default this.OnScope scope = - if options.Disable then scope else + if not options.Enable then scope else let parentSymbols = this.OnLocalDeclarations scope.KnownSymbols let statements = scope.Statements |> Seq.map this.OnStatement |> ImmutableArray.CreateRange QsScope.New |> Node.BuildOr scope (statements, parentSymbols) diff --git a/src/QsCompiler/Core/TransformationOptions.fs b/src/QsCompiler/Core/TransformationOptions.fs index c7876976e8..1fff425bbd 100644 --- a/src/QsCompiler/Core/TransformationOptions.fs +++ b/src/QsCompiler/Core/TransformationOptions.fs @@ -5,14 +5,14 @@ namespace Microsoft.Quantum.QsCompiler.Transformations.Core /// Used to configure the behavior of the default implementations for transformations. -type TransformationOptions = { +type TransformationOptions = internal { /// Disables the transformation at the transformation root, /// meaning the transformation won't recur into leaf nodes or subnodes. - Disable : bool + Enable : bool /// Indicates that the transformation is used to walk the syntax tree, but does not modify any of the nodes. /// If set to true, the nodes will not be rebuilt during the transformation. /// Setting this to true constitutes a promise that the return value of all methods will be ignored. - DisableRebuild : bool + Rebuild : bool } with @@ -20,23 +20,23 @@ type TransformationOptions = { /// The transformation will recur into leaf and subnodes, /// and all nodes will be rebuilt upon transformation. static member Default = { - Disable = false - DisableRebuild = false + Enable = true + Rebuild = true } /// Disables the transformation at the transformation root, /// meaning the transformation won't recur into leaf nodes or subnodes. static member Disabled = { - Disable = true - DisableRebuild = false + Enable = false + Rebuild = true } /// Indicates that the transformation is used to walk the syntax tree, but does not modify any of the nodes. /// All nodes will be traversed recursively, but the nodes will not be rebuilt. /// Setting this option constitutes a promise that the return value of all methods will be ignored. static member NoRebuild = { - Disable = false - DisableRebuild = true + Enable = true + Rebuild = false } diff --git a/src/QsCompiler/Core/TypeTransformation.fs b/src/QsCompiler/Core/TypeTransformation.fs index 90696145c1..8737747695 100644 --- a/src/QsCompiler/Core/TypeTransformation.fs +++ b/src/QsCompiler/Core/TypeTransformation.fs @@ -16,7 +16,7 @@ type private ExpressionType = type TypeTransformationBase(options : TransformationOptions) = - let Node = if options.DisableRebuild then Walk else Fold + let Node = if options.Rebuild then Fold else Walk new () = new TypeTransformationBase(TransformationOptions.Default) @@ -112,7 +112,7 @@ type TypeTransformationBase(options : TransformationOptions) = // transformation root called on each node member this.OnType (t : ResolvedType) = - if options.Disable then t else + if not options.Enable then t else let transformed = t.Resolution |> function | ExpressionType.UnitType -> this.OnUnitType () | ExpressionType.Operation ((it, ot), fs) -> this.OnOperation ((it, ot), fs) From d7cd0f13af52dbca16c5a52bef4793c25faa8e33 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Wed, 26 Feb 2020 17:54:00 -0800 Subject: [PATCH 2/4] to be reverted --- QsCompiler.sln | 15 --------------- src/QsCompiler/Tests.Compiler/ExecutionTests.fs | 4 ++-- .../Tests.Compiler/Tests.Compiler.fsproj | 3 --- 3 files changed, 2 insertions(+), 20 deletions(-) diff --git a/QsCompiler.sln b/QsCompiler.sln index 7a330f37f1..f7ee3f64dc 100644 --- a/QsCompiler.sln +++ b/QsCompiler.sln @@ -34,8 +34,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Simulation", "Simulation", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Simulation", "src\QsCompiler\TestTargets\Simulation\Target\Simulation.csproj", "{D50583DF-FBEF-45EF-B523-70B2CDBE1DD1}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example", "src\QsCompiler\TestTargets\Simulation\Example\Example.csproj", "{2E331781-F7ED-4EF1-8451-896636C6D93A}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{D2E36476-A65F-4310-9C4C-B721BCC47B00}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library1", "src\QsCompiler\TestTargets\Libraries\Library1\Library1.csproj", "{DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F}" @@ -222,18 +220,6 @@ Global {D50583DF-FBEF-45EF-B523-70B2CDBE1DD1}.Release|x64.Build.0 = Release|Any CPU {D50583DF-FBEF-45EF-B523-70B2CDBE1DD1}.Release|x86.ActiveCfg = Release|Any CPU {D50583DF-FBEF-45EF-B523-70B2CDBE1DD1}.Release|x86.Build.0 = Release|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|x64.ActiveCfg = Debug|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|x64.Build.0 = Debug|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|x86.ActiveCfg = Debug|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|x86.Build.0 = Debug|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|Any CPU.Build.0 = Release|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|x64.ActiveCfg = Release|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|x64.Build.0 = Release|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|x86.ActiveCfg = Release|Any CPU - {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|x86.Build.0 = Release|Any CPU {DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F}.Debug|Any CPU.Build.0 = Debug|Any CPU {DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -268,7 +254,6 @@ Global {256A6275-FC7F-42E9-9931-BC6EA6D0F31A} = {B4A9484D-31FC-4A27-9E26-4C8DE3E02D77} {76BA96DA-DC1E-4315-A3ED-5F0700A79812} = {6077A717-50BF-4F87-B439-CA549AF6A4AE} {D50583DF-FBEF-45EF-B523-70B2CDBE1DD1} = {76BA96DA-DC1E-4315-A3ED-5F0700A79812} - {2E331781-F7ED-4EF1-8451-896636C6D93A} = {76BA96DA-DC1E-4315-A3ED-5F0700A79812} {D2E36476-A65F-4310-9C4C-B721BCC47B00} = {6077A717-50BF-4F87-B439-CA549AF6A4AE} {DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F} = {D2E36476-A65F-4310-9C4C-B721BCC47B00} EndGlobalSection diff --git a/src/QsCompiler/Tests.Compiler/ExecutionTests.fs b/src/QsCompiler/Tests.Compiler/ExecutionTests.fs index a4a4db38cd..e123951e62 100644 --- a/src/QsCompiler/Tests.Compiler/ExecutionTests.fs +++ b/src/QsCompiler/Tests.Compiler/ExecutionTests.fs @@ -40,7 +40,7 @@ type ExecutionTests (output:ITestOutputHelper) = AssertEqual expectedOutput out - [] + //[] member this.``Specialization Generation for Conjugations`` () = ExecuteAndCompareOutput "ConjugationsInBody" " @@ -139,7 +139,7 @@ type ExecutionTests (output:ITestOutputHelper) = " - [] + //[] member this.``Referencing Projects and Packages`` () = ExecuteAndCompareOutput "PackageAndProjectReference" " diff --git a/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj b/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj index b7f2118e59..48dadf392e 100644 --- a/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj +++ b/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj @@ -157,9 +157,6 @@ - - false - From e978b5062229c4f49dc2c29043221892ebdfe204 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Wed, 26 Feb 2020 19:26:47 -0800 Subject: [PATCH 3/4] Revert "to be reverted" This reverts commit d7cd0f13af52dbca16c5a52bef4793c25faa8e33. --- QsCompiler.sln | 15 +++++++++++++++ src/QsCompiler/Tests.Compiler/ExecutionTests.fs | 4 ++-- .../Tests.Compiler/Tests.Compiler.fsproj | 3 +++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/QsCompiler.sln b/QsCompiler.sln index f7ee3f64dc..7a330f37f1 100644 --- a/QsCompiler.sln +++ b/QsCompiler.sln @@ -34,6 +34,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Simulation", "Simulation", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Simulation", "src\QsCompiler\TestTargets\Simulation\Target\Simulation.csproj", "{D50583DF-FBEF-45EF-B523-70B2CDBE1DD1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Example", "src\QsCompiler\TestTargets\Simulation\Example\Example.csproj", "{2E331781-F7ED-4EF1-8451-896636C6D93A}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Libraries", "Libraries", "{D2E36476-A65F-4310-9C4C-B721BCC47B00}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Library1", "src\QsCompiler\TestTargets\Libraries\Library1\Library1.csproj", "{DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F}" @@ -220,6 +222,18 @@ Global {D50583DF-FBEF-45EF-B523-70B2CDBE1DD1}.Release|x64.Build.0 = Release|Any CPU {D50583DF-FBEF-45EF-B523-70B2CDBE1DD1}.Release|x86.ActiveCfg = Release|Any CPU {D50583DF-FBEF-45EF-B523-70B2CDBE1DD1}.Release|x86.Build.0 = Release|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|x64.ActiveCfg = Debug|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|x64.Build.0 = Debug|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|x86.ActiveCfg = Debug|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Debug|x86.Build.0 = Debug|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|Any CPU.Build.0 = Release|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|x64.ActiveCfg = Release|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|x64.Build.0 = Release|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|x86.ActiveCfg = Release|Any CPU + {2E331781-F7ED-4EF1-8451-896636C6D93A}.Release|x86.Build.0 = Release|Any CPU {DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F}.Debug|Any CPU.Build.0 = Debug|Any CPU {DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -254,6 +268,7 @@ Global {256A6275-FC7F-42E9-9931-BC6EA6D0F31A} = {B4A9484D-31FC-4A27-9E26-4C8DE3E02D77} {76BA96DA-DC1E-4315-A3ED-5F0700A79812} = {6077A717-50BF-4F87-B439-CA549AF6A4AE} {D50583DF-FBEF-45EF-B523-70B2CDBE1DD1} = {76BA96DA-DC1E-4315-A3ED-5F0700A79812} + {2E331781-F7ED-4EF1-8451-896636C6D93A} = {76BA96DA-DC1E-4315-A3ED-5F0700A79812} {D2E36476-A65F-4310-9C4C-B721BCC47B00} = {6077A717-50BF-4F87-B439-CA549AF6A4AE} {DDAA35BF-7BFC-431F-9F7E-182F01DAEB3F} = {D2E36476-A65F-4310-9C4C-B721BCC47B00} EndGlobalSection diff --git a/src/QsCompiler/Tests.Compiler/ExecutionTests.fs b/src/QsCompiler/Tests.Compiler/ExecutionTests.fs index e123951e62..a4a4db38cd 100644 --- a/src/QsCompiler/Tests.Compiler/ExecutionTests.fs +++ b/src/QsCompiler/Tests.Compiler/ExecutionTests.fs @@ -40,7 +40,7 @@ type ExecutionTests (output:ITestOutputHelper) = AssertEqual expectedOutput out - //[] + [] member this.``Specialization Generation for Conjugations`` () = ExecuteAndCompareOutput "ConjugationsInBody" " @@ -139,7 +139,7 @@ type ExecutionTests (output:ITestOutputHelper) = " - //[] + [] member this.``Referencing Projects and Packages`` () = ExecuteAndCompareOutput "PackageAndProjectReference" " diff --git a/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj b/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj index 48dadf392e..b7f2118e59 100644 --- a/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj +++ b/src/QsCompiler/Tests.Compiler/Tests.Compiler.fsproj @@ -157,6 +157,9 @@ + + false + From 2a82e8001bf54090ce6533b0e3a2e042b11c2057 Mon Sep 17 00:00:00 2001 From: Bettina Heim Date: Wed, 26 Feb 2020 19:29:14 -0800 Subject: [PATCH 4/4] correct package nrs --- src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj | 2 +- src/QsCompiler/TestTargets/Simulation/Example/Example.csproj | 2 +- src/QsCompiler/TestTargets/Simulation/Target/Simulation.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj b/src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj index 72dbc58f20..4b95b74dce 100644 --- a/src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj +++ b/src/QsCompiler/TestTargets/Libraries/Library1/Library1.csproj @@ -7,7 +7,7 @@ - + diff --git a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj index 2af5587230..79ff1984b2 100644 --- a/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj +++ b/src/QsCompiler/TestTargets/Simulation/Example/Example.csproj @@ -1,4 +1,4 @@ - + Detailed diff --git a/src/QsCompiler/TestTargets/Simulation/Target/Simulation.csproj b/src/QsCompiler/TestTargets/Simulation/Target/Simulation.csproj index 358ecdad77..65781cd08e 100644 --- a/src/QsCompiler/TestTargets/Simulation/Target/Simulation.csproj +++ b/src/QsCompiler/TestTargets/Simulation/Target/Simulation.csproj @@ -12,7 +12,7 @@ - +