Skip to content
This repository was archived by the owner on Jan 12, 2024. It is now read-only.
Merged
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
4 changes: 2 additions & 2 deletions src/Simulation/CsharpGeneration/Context.fs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module internal DeclarationLocations =
type TransformationState() =

member val internal CurrentSource = null with get, set
member val internal DeclarationLocations = new List<NonNullable<string> * (int * int)>()
member val internal DeclarationLocations = new List<NonNullable<string> * Position>()

type NamespaceTransformation(parent : SyntaxTreeTransformation<TransformationState>) =
inherit NamespaceTransformation<TransformationState>(parent)
Expand Down Expand Up @@ -60,7 +60,7 @@ type CodegenContext = {
allQsElements : IEnumerable<QsNamespace>
allUdts : ImmutableDictionary<QsQualifiedName,QsCustomType>
allCallables : ImmutableDictionary<QsQualifiedName,QsCallable>
declarationPositions : ImmutableDictionary<NonNullable<string>, ImmutableSortedSet<int * int>>
declarationPositions : ImmutableDictionary<NonNullable<string>, ImmutableSortedSet<Position>>
byName : ImmutableDictionary<NonNullable<string>,(NonNullable<string>*QsCallable) list>
current : QsQualifiedName option
signature : ResolvedSignature option
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<ItemGroup>
<PackageReference Update="FSharp.Core" Version="4.7.0" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.11.2006.3017-alpha" />
<PackageReference Include="Microsoft.Quantum.Compiler" Version="0.12.2007.1709-alpha" />
</ItemGroup>

<ItemGroup>
Expand Down
10 changes: 5 additions & 5 deletions src/Simulation/CsharpGeneration/SimulationCode.fs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ module SimulationCode =
override this.OnStatement (node:QsStatement) =
match node.Location with
| Value loc ->
let (current, _) = loc.Offset
let current = loc.Offset.Line
parent.LineNumber <- parent.StartLine |> Option.map (fun start -> start + current + 1) // The Q# compiler reports 0-based line numbers.
| Null ->
parent.LineNumber <- None // auto-generated statement; the line number will be set to the specialization declaration
Expand Down Expand Up @@ -839,7 +839,7 @@ module SimulationCode =
override this.OnSpecializationDeclaration (sp : QsSpecialization) =
count <- 0
match sp.Location with
| Value location -> parent.StartLine <- Some (location.Offset |> fst)
| Value location -> parent.StartLine <- Some location.Offset.Line
| Null -> parent.StartLine <- None // TODO: we may need to have the means to know which original declaration the code came from
base.OnSpecializationDeclaration sp

Expand Down Expand Up @@ -1003,12 +1003,12 @@ module SimulationCode =
| Null -> []
| Value location -> [
// since the line numbers throughout the generated code are 1-based, let's also choose them 1-based here
let startLine = fst location.Offset + 1
let startLine = location.Offset.Line + 1
let endLine =
match context.declarationPositions.TryGetValue sp.SourceFile with
| true, startPositions ->
let index = startPositions.IndexOf location.Offset
if index + 1 >= startPositions.Count then -1 else fst startPositions.[index + 1] + 1
if index + 1 >= startPositions.Count then -1 else startPositions.[index + 1].Line + 1
//TODO: diagnostics.
| false, _ -> startLine
``attribute`` None (``ident`` "SourceLocation") [
Expand Down Expand Up @@ -1328,7 +1328,7 @@ module SimulationCode =
let properties = buildOutput ()
let methods =
match op.Location with
| Value location -> [ buildUnitTest targetName opName (fst location.Offset) op.SourceFile.Value ]
| Value location -> [ buildUnitTest targetName opName location.Offset.Line op.SourceFile.Value ]
// TODO: diagnostics
| Null -> failwith "missing location for unit test"

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

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\Simulators.Dev.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.2007.1709-alpha">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.2007.1709-alpha">

<PropertyGroup>
<OutputType>Library</OutputType>
Expand All @@ -22,4 +22,4 @@
</ItemGroup>
</Target>

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

<PropertyGroup>
<OutputType>Library</OutputType>
Expand All @@ -22,4 +22,4 @@
</ItemGroup>
</Target>

</Project>
</Project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.2007.1709-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.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.2007.1709-alpha">

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

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

<PropertyGroup>
<OutputType>Library</OutputType>
Expand All @@ -22,4 +22,4 @@
</ItemGroup>
</Target>

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

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.2007.1709-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.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.2007.1709-alpha">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.Quantum.Sdk/0.11.2006.3017-alpha">
<Project Sdk="Microsoft.Quantum.Sdk/0.12.2007.1709-alpha">

<Import Project="..\Common\AssemblyCommon.props" />
<Import Project="..\Common\DebugSymbols.props" />
Expand Down