Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Regenerate Libraries #464

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions src/Simulation/CsharpGeneration/RewriteStep.fs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,22 @@ type Emitter() =
let context = CodegenContext.Create (compilation, step.AssemblyConstants)
let allSources = GetSourceFiles.Apply compilation.Namespaces

for source in allSources |> Seq.filter context.GenerateCodeForSource do
let content = SimulationCode.generate source context
CompilationLoader.GeneratedFile(source, dir, ".g.cs", content) |> ignore
for source in allSources |> Seq.filter (not << context.GenerateCodeForSource) do
let content = SimulationCode.loadedViaTestNames source context
if content <> null then CompilationLoader.GeneratedFile(source, dir, ".dll.g.cs", content) |> ignore
let isExe =
match context.assemblyConstants.TryGetValue AssemblyConstants.QsharpOutputType with
| true, outputType -> outputType = AssemblyConstants.QsharpExe
| _ -> false

if isExe then
Copy link
Contributor

@bettinaheim bettinaheim Dec 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic for determining whether to emit C# for a particular source (whether source code or an assembly reference) is handled by GenerateCodeForSource. Please adapt it there rather than adding an additional branching here.

for source in allSources do
let content = SimulationCode.generate source context
CompilationLoader.GeneratedFile(source, dir, ".g.cs", content) |> ignore
else
for source in allSources |> Seq.filter context.GenerateCodeForSource do
let content = SimulationCode.generate source context
CompilationLoader.GeneratedFile(source, dir, ".g.cs", content) |> ignore
for source in allSources |> Seq.filter (not << context.GenerateCodeForSource) do
let content = SimulationCode.loadedViaTestNames source context
if content <> null then CompilationLoader.GeneratedFile(source, dir, ".dll.g.cs", content) |> ignore

if not compilation.EntryPoints.IsEmpty then
let callable = context.allCallables.[Seq.exactlyOne compilation.EntryPoints]
Expand Down
2 changes: 2 additions & 0 deletions src/Simulation/QsharpCore/Diagnostics/Dump.qs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace Microsoft.Quantum.Diagnostics {
/// one-dimensional array of complex numbers, in which each element represents
/// the amplitudes of the probability of measuring the corresponding state.
function DumpMachine<'T> (location : 'T) : Unit {
body intrinsic;
}

/// # Summary
Expand Down Expand Up @@ -56,6 +57,7 @@ namespace Microsoft.Quantum.Diagnostics {
/// If the given qubits are entangled with some other qubit and their
/// state can't be separated, it just reports that the qubits are entangled.
function DumpRegister<'T> (location : 'T, qubits : Qubit[]) : Unit {
body intrinsic;
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">

<PropertyGroup>
<OutputType>Library</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<CsharpGeneration>false</CsharpGeneration>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">

<PropertyGroup>
<OutputType>Library</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.13.2011.802-alpha">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand Down