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
8 changes: 6 additions & 2 deletions src/QsCompiler/CommandLineTool/Commands/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public static int Run(BuildOptions options, ConsoleLogger logger)
{
ProjectName = options.ProjectName,
AssemblyConstants = assemblyConstants,
TargetPackageAssemblies = options.TargetSpecificDecompositions,
TargetPackageAssemblies = options.TargetSpecificDecompositions ?? Enumerable.Empty<string>(),
RuntimeCapabilities = options.RuntimeCapabilites,
SkipMonomorphization = options.RuntimeCapabilites == RuntimeCapabilities.Unknown,
GenerateFunctorSupport = true,
Expand All @@ -226,7 +226,11 @@ public static int Run(BuildOptions options, ConsoleLogger logger)
CompilationLoader.CompilationTaskEvent += CompilationTracker.OnCompilationTaskEvent;
}

var loaded = new CompilationLoader(options.LoadSourcesOrSnippet(logger), options.References, loadOptions, logger);
var loaded = new CompilationLoader(
options.LoadSourcesOrSnippet(logger),
options.References ?? Enumerable.Empty<string>(),
loadOptions,
logger);
if (options.PerfFolder != null)
{
try
Expand Down
8 changes: 6 additions & 2 deletions src/QsCompiler/CommandLineTool/Commands/Diagnose.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public static int Run(DiagnoseOptions options, ConsoleLogger logger)
var loadOptions = new CompilationLoader.Configuration
{
AssemblyConstants = assemblyConstants,
TargetPackageAssemblies = options.TargetSpecificDecompositions,
TargetPackageAssemblies = options.TargetSpecificDecompositions ?? Enumerable.Empty<string>(),
RuntimeCapabilities = options.RuntimeCapabilites,
SkipMonomorphization = options.RuntimeCapabilites == RuntimeCapabilities.Unknown,
GenerateFunctorSupport = true,
Expand All @@ -285,7 +285,11 @@ public static int Run(DiagnoseOptions options, ConsoleLogger logger)
EnableAdditionalChecks = true,
ExposeReferencesViaTestNames = options.ExposeReferencesViaTestNames
};
var loaded = new CompilationLoader(options.LoadSourcesOrSnippet(logger), options.References, loadOptions, logger);
var loaded = new CompilationLoader(
options.LoadSourcesOrSnippet(logger),
options.References ?? Enumerable.Empty<string>(),
loadOptions,
logger);
if (loaded.VerifiedCompilation == null)
{
return ReturnCode.Status(loaded);
Expand Down
9 changes: 8 additions & 1 deletion src/QsCompiler/CommandLineTool/Commands/Format.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,18 @@ ImmutableDictionary<Uri, string> LoadSources(SourceFileLoader loadFromDisk) =>
options.LoadSourcesOrSnippet(logger)(loadFromDisk)
.ToImmutableDictionary(entry => entry.Key, entry => UpdateArrayLiterals(entry.Value)); // manually replace array literals

var loaded = new CompilationLoader(LoadSources, options.References, logger: logger); // no rewrite steps, no generation
// no rewrite steps, no generation
var loaded =
new CompilationLoader(LoadSources, options.References ?? Enumerable.Empty<string>(), logger: logger);
if (ReturnCode.Status(loaded) == ReturnCode.UNRESOLVED_FILES)
{
return ReturnCode.UNRESOLVED_FILES; // ignore compilation errors
}
else if (loaded.VerifiedCompilation is null)
{
logger.Log(ErrorCode.QsGenerationFailed, Enumerable.Empty<string>());
return ReturnCode.CODE_GENERATION_ERRORS;
}

// TODO: a lot of the formatting logic defined here and also in the routines above
// is supposed to move into the compilation manager in order to be available for the language server to provide formatting
Expand Down
6 changes: 3 additions & 3 deletions src/QsCompiler/CommandLineTool/CompilationTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private class CompilationTask
/// <summary>
/// Represents the name of the parent compilation task.
/// </summary>
public readonly string ParentName;
public readonly string? ParentName;

/// <summary>
/// Represents the name of the compilation task.
Expand Down Expand Up @@ -56,15 +56,15 @@ private class CompilationTask
/// <summary>
/// Generates a key that uniquely identifies a task in the compilation process based on the task's name and its parent's name.
/// </summary>
internal static string GenerateKey(string parentName, string name)
internal static string GenerateKey(string? parentName, string name)
{
return string.Format("{0}.{1}", parentName ?? "ROOT", name);
}

/// <summary>
/// Creates a compilation task object and starts its stopwatch.
/// </summary>
public CompilationTask(string parentName, string name)
public CompilationTask(string? parentName, string name)
{
this.ParentName = parentName;
this.Name = name;
Expand Down
10 changes: 5 additions & 5 deletions src/QsCompiler/CommandLineTool/Options.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,17 +298,17 @@ public static bool IsCodeSnippet(NonNullable<string> fileId) =>
/// </summary>
internal CompilationLoader.SourceLoader LoadSourcesOrSnippet(ILogger logger) => loadFromDisk =>
{
bool inputIsEmptyOrNull = this.Input == null || !this.Input.Any();
if (this.CodeSnippet == null && !inputIsEmptyOrNull)
var input = this.Input ?? Enumerable.Empty<string>();
if (this.CodeSnippet == null && input.Any())
{
return loadFromDisk(this.Input);
return loadFromDisk(input);
}
else if (this.CodeSnippet != null && inputIsEmptyOrNull)
else if (this.CodeSnippet != null && !input.Any())
{
return new Dictionary<Uri, string> { { SNIPPET_FILE_URI, AsSnippet(this.CodeSnippet, this.WithinFunction) } }.ToImmutableDictionary();
}

if (inputIsEmptyOrNull)
if (!input.Any())
{
logger?.Log(ErrorCode.MissingInputFileOrSnippet, Enumerable.Empty<string>());
}
Expand Down
4 changes: 2 additions & 2 deletions src/QsCompiler/CompilationManager/Diagnostics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ internal static string Warning(int code) =>

// warnings 70**

public static Diagnostic LoadWarning(WarningCode code, IEnumerable<string> args, string source) =>
public static Diagnostic LoadWarning(WarningCode code, IEnumerable<string> args, string? source) =>
new Diagnostic
{
Severity = DiagnosticSeverity.Warning,
Expand Down Expand Up @@ -164,7 +164,7 @@ internal static string Error(int code) =>

// errors 70**

public static Diagnostic LoadError(ErrorCode code, IEnumerable<string> args, string source) =>
public static Diagnostic LoadError(ErrorCode code, IEnumerable<string> args, string? source) =>
new Diagnostic
{
Severity = DiagnosticSeverity.Error,
Expand Down
Loading