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
Show all changes
27 commits
Select commit Hold shift + click to select a range
e647958
Prevent result equality with QPRGen0
Jun 4, 2020
4bf68c5
Move more fields from SymbolTracker to ResolutionContext
Jun 4, 2020
7589685
Undo some changes to TypeChecking.cs
Jun 4, 2020
2064cd4
Move ResolutionContext up a bit
Jun 4, 2020
400a7f8
Better error message
Jun 4, 2020
38fb16a
Add basic tests
Jun 5, 2020
ded4328
Add more tests (but not working right now...)
Jun 5, 2020
a66da51
Fix tests
Jun 5, 2020
cbff168
Add tests for not equals
Jun 5, 2020
99433dc
Merge branch 'master' into samarsha/verify-gen0
bamarsha Jun 11, 2020
be43692
Use static member for Create
Jun 11, 2020
a470a0f
Move ResolutionContext to SymbolTracker.fs
Jun 11, 2020
daf37f9
Update doc comment to ArgumentException
bamarsha Jun 11, 2020
4e03498
Merge remote-tracking branch 'origin/samarsha/verify-gen0' into samar…
Jun 11, 2020
67785a2
Replace failwith with ArgumentException
Jun 11, 2020
e8cedce
Mention SymbolTracker versioning in ResolutionContext
Jun 11, 2020
43524a0
Restore supportsEqualityComparison and use VerifyIsOneOf
Jun 11, 2020
ecb5814
Undo changes to VerificationTools.fs
Jun 11, 2020
2c6f86a
Merge branch 'master' into samarsha/verify-gen0
bamarsha Jun 15, 2020
8103374
Rename ResolutionContext to ScopeContext
Jun 15, 2020
5b066ea
Include execution target in error message
Jun 16, 2020
907dda8
Make ScopeContext.ExecutionTarget non-nullable
Jun 16, 2020
b19f5fb
Merge branch 'master' into samarsha/verify-gen0
bamarsha Jun 16, 2020
b81bff9
Merge branch 'master' into samarsha/verify-gen0
bettinaheim Jun 19, 2020
576afe1
Update error message
Jun 19, 2020
4cf5e4f
Merge branch 'master' into samarsha/verify-gen0
bamarsha Jun 22, 2020
0709af7
Merge branch 'master' into samarsha/verify-gen0
bamarsha Jun 23, 2020
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
10 changes: 8 additions & 2 deletions src/QsCompiler/CompilationManager/CompilationUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ public class CompilationUnit : IReaderWriterLock, IDisposable

internal readonly RuntimeCapabilities RuntimeCapabilities;
internal readonly bool IsExecutable;
internal readonly NonNullable<string> ExecutionTarget;

public void Dispose()
{ this.SyncRoot.Dispose(); }
Expand All @@ -243,8 +244,12 @@ public void Dispose()
/// with the given sequence of locks registered as dependent locks if the sequence is not null.
/// Throws an ArgumentNullException if any of the given locks is.
/// </summary>
internal CompilationUnit(RuntimeCapabilities capabilities, bool isExecutable,
References externals = null, IEnumerable<ReaderWriterLockSlim> dependentLocks = null)
internal CompilationUnit(
RuntimeCapabilities capabilities,
bool isExecutable,
NonNullable<string> executionTarget,
References externals = null,
IEnumerable<ReaderWriterLockSlim> dependentLocks = null)
{
this.SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
this.DependentLocks = dependentLocks == null
Expand All @@ -254,6 +259,7 @@ internal CompilationUnit(RuntimeCapabilities capabilities, bool isExecutable,

this.RuntimeCapabilities = capabilities;
this.IsExecutable = isExecutable;
this.ExecutionTarget = executionTarget;

this.CompiledCallables = new Dictionary<QsQualifiedName, QsCallable>();
this.CompiledTypes = new Dictionary<QsQualifiedName, QsCustomType>();
Expand Down
17 changes: 13 additions & 4 deletions src/QsCompiler/CompilationManager/CompilationUnitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,15 @@ public class CompilationUnitManager : IDisposable
/// that action is called whenever diagnostics within a file have changed and are ready for publishing.
/// </summary>
public CompilationUnitManager(
Action<Exception> exceptionLogger = null, Action<PublishDiagnosticParams> publishDiagnostics = null, bool syntaxCheckOnly = false,
AssemblyConstants.RuntimeCapabilities capabilities = AssemblyConstants.RuntimeCapabilities.Unknown, bool isExecutable = false)
Action<Exception> exceptionLogger = null,
Action<PublishDiagnosticParams> publishDiagnostics = null,
bool syntaxCheckOnly = false,
AssemblyConstants.RuntimeCapabilities capabilities = AssemblyConstants.RuntimeCapabilities.Unknown,
bool isExecutable = false,
NonNullable<string> executionTarget = default)
{
this.EnableVerification = !syntaxCheckOnly;
this.CompilationUnit = new CompilationUnit(capabilities, isExecutable);
this.CompilationUnit = new CompilationUnit(capabilities, isExecutable, executionTarget);
this.FileContentManagers = new ConcurrentDictionary<NonNullable<string>, FileContentManager>();
this.ChangedFiles = new ManagedHashSet<NonNullable<string>>(new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion));
this.PublishDiagnostics = publishDiagnostics ?? (_ => { });
Expand Down Expand Up @@ -440,7 +444,12 @@ private Task SpawnGlobalTypeCheckingAsync(bool runSynchronously = false)
// work with a separate compilation unit instance such that processing of all further edits can go on in parallel
var sourceFiles = this.FileContentManagers.Values.OrderBy(m => m.FileName);
this.ChangedFiles.RemoveAll(f => sourceFiles.Any(m => m.FileName.Value == f.Value));
var compilation = new CompilationUnit(this.CompilationUnit.RuntimeCapabilities, this.CompilationUnit.IsExecutable, this.CompilationUnit.Externals, sourceFiles.Select(file => file.SyncRoot));
var compilation = new CompilationUnit(
this.CompilationUnit.RuntimeCapabilities,
this.CompilationUnit.IsExecutable,
this.CompilationUnit.ExecutionTarget,
this.CompilationUnit.Externals,
sourceFiles.Select(file => file.SyncRoot));
var content = compilation.UpdateGlobalSymbolsFor(sourceFiles);
foreach (var file in sourceFiles) this.PublishDiagnostics(file.Diagnostics());

Expand Down
54 changes: 42 additions & 12 deletions src/QsCompiler/CompilationManager/ProjectManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,22 @@ internal class ProjectProperties
public readonly string OutputPath;
public readonly AssemblyConstants.RuntimeCapabilities RuntimeCapabilities;
public readonly bool IsExecutable;
public readonly NonNullable<string> ExecutionTarget;
public readonly bool ExposeReferencesViaTestNames;

internal static ProjectProperties Default =>
new ProjectProperties("Latest", "", AssemblyConstants.RuntimeCapabilities.Unknown, false, false);

public ProjectProperties(string version, string outputPath, AssemblyConstants.RuntimeCapabilities runtimeCapabilities, bool isExecutable, bool loadTestNames)
public ProjectProperties(
string version,
string outputPath,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities,
bool isExecutable,
NonNullable<string> executionTarget,
bool loadTestNames)
{
this.Version = version ?? "";
this.OutputPath = outputPath ?? throw new ArgumentNullException(nameof(outputPath));
this.RuntimeCapabilities = runtimeCapabilities;
this.IsExecutable = isExecutable;
this.ExecutionTarget = executionTarget;
this.ExposeReferencesViaTestNames = loadTestNames;
}
}
Expand All @@ -47,13 +52,34 @@ public class ProjectInformation
public readonly ImmutableArray<string> ProjectReferences;
public readonly ImmutableArray<string> References;

internal static ProjectInformation Empty(string version, string outputPath, AssemblyConstants.RuntimeCapabilities runtimeCapabilities) =>
new ProjectInformation(version, outputPath, runtimeCapabilities, false, false, Enumerable.Empty<string>(), Enumerable.Empty<string>(), Enumerable.Empty<string>());

public ProjectInformation(string version, string outputPath, AssemblyConstants.RuntimeCapabilities runtimeCapabilities, bool isExecutable, bool loadTestNames,
IEnumerable<string> sourceFiles, IEnumerable<string> projectReferences, IEnumerable<string> references)
internal static ProjectInformation Empty(
string version,
string outputPath,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities) =>
new ProjectInformation(
version,
outputPath,
runtimeCapabilities,
false,
NonNullable<string>.New("Unspecified"),
false,
Enumerable.Empty<string>(),
Enumerable.Empty<string>(),
Enumerable.Empty<string>());

public ProjectInformation(
string version,
string outputPath,
AssemblyConstants.RuntimeCapabilities runtimeCapabilities,
bool isExecutable,
NonNullable<string> executionTarget,
bool loadTestNames,
IEnumerable<string> sourceFiles,
IEnumerable<string> projectReferences,
IEnumerable<string> references)
{
this.Properties = new ProjectProperties(version, outputPath, runtimeCapabilities, isExecutable, loadTestNames);
this.Properties = new ProjectProperties(
version, outputPath, runtimeCapabilities, isExecutable, executionTarget, loadTestNames);
this.SourceFiles = sourceFiles?.ToImmutableArray() ?? throw new ArgumentNullException(nameof(sourceFiles));
this.ProjectReferences = projectReferences?.ToImmutableArray() ?? throw new ArgumentNullException(nameof(projectReferences));
this.References = references?.ToImmutableArray() ?? throw new ArgumentNullException(nameof(references));
Expand Down Expand Up @@ -146,8 +172,12 @@ internal Project(Uri projectFile, ProjectInformation projectInfo,
// but we don't do any semantic verification, and we don't publish diagnostics for them.
this.Processing = new ProcessingQueue(onException);
this.Manager = new CompilationUnitManager(
onException, ignore ? null : publishDiagnostics, syntaxCheckOnly: ignore,
this.Properties.RuntimeCapabilities, this.Properties.IsExecutable);
onException,
ignore ? null : publishDiagnostics,
syntaxCheckOnly: ignore,
this.Properties.RuntimeCapabilities,
this.Properties.IsExecutable,
this.Properties.ExecutionTarget);
this.Log = log ?? ((msg, severity) => Console.WriteLine($"{severity}: {msg}"));

this.LoadedSourceFiles = ImmutableHashSet<Uri>.Empty;
Expand Down
Loading