Skip to content

Commit

Permalink
Merging from master: resolving conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
aman-goel committed Oct 5, 2023
2 parents f83a2cf + 05c9862 commit 46138f5
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
10 changes: 5 additions & 5 deletions Src/PCompiler/CompilerCore/Compiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public int Compile(ICompilerConfiguration job)
}

DirectoryInfo parentDirectory = job.OutputDirectory;
foreach (var entry in job.OutputLanguages)
foreach (var entry in job.OutputLanguages.Distinct())
{
job.OutputDirectory = Directory.CreateDirectory(Path.Combine(parentDirectory.FullName, entry.Key));
job.OutputDirectory = Directory.CreateDirectory(Path.Combine(parentDirectory.FullName, entry.ToString()));
job.Output = new DefaultCompilerOutput(job.OutputDirectory);
job.Backend = TargetLanguage.GetCodeGenerator(entry.Value);
job.Backend = TargetLanguage.GetCodeGenerator(entry);

job.Output.WriteInfo($"----------------------------------------");
job.Output.WriteInfo($"Code generation for {entry.Key}...");
job.Output.WriteInfo($"Code generation for {entry}...");

// Run the selected backend on the project and write the files.
var compiledFiles = job.Backend.GenerateCode(job, scope);
Expand All @@ -82,7 +82,7 @@ public int Compile(ICompilerConfiguration job)
}
catch (TranslationException e)
{
job.Output.WriteError($"[{entry.Key} Compiling Generated Code:]\n" + e.Message);
job.Output.WriteError($"[{entry} Compiling Generated Code:]\n" + e.Message);
job.Output.WriteError("[THIS SHOULD NOT HAVE HAPPENED, please report it to the P team or create a GitHub issue]\n" + e.Message);
Environment.ExitCode = 2;
return Environment.ExitCode;
Expand Down
6 changes: 3 additions & 3 deletions Src/PCompiler/CompilerCore/CompilerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public CompilerConfiguration()
ProjectRootPath = new DirectoryInfo(Directory.GetCurrentDirectory());
LocationResolver = new DefaultLocationResolver();
Handler = new DefaultTranslationErrorHandler(LocationResolver);
OutputLanguages = new Dictionary<string, CompilerOutput>{{"CSharp", CompilerOutput.CSharp}};
OutputLanguages = new List<CompilerOutput>{CompilerOutput.CSharp};
Backend = null;
ProjectDependencies = new List<string>();
}
public CompilerConfiguration(ICompilerOutput output, DirectoryInfo outputDir, IDictionary<string, CompilerOutput> outputLanguages, IList<string> inputFiles,
public CompilerConfiguration(ICompilerOutput output, DirectoryInfo outputDir, IList<CompilerOutput> outputLanguages, IList<string> inputFiles,
string projectName, DirectoryInfo projectRoot = null, IList<string> projectDependencies = null, string pObservePackageName = null)
{
if (!inputFiles.Any())
Expand Down Expand Up @@ -59,7 +59,7 @@ public CompilerConfiguration(ICompilerOutput output, DirectoryInfo outputDir, ID

public ICompilerOutput Output { get; set; }
public DirectoryInfo OutputDirectory { get; set; }
public IDictionary<string, CompilerOutput> OutputLanguages { get; set; }
public IList<CompilerOutput> OutputLanguages { get; set; }
public string ProjectName { get; set; }
public string PObservePackageName { get; set; }
public DirectoryInfo ProjectRootPath { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion Src/PCompiler/CompilerCore/ICompilerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface ICompilerConfiguration
string ProjectName { get; }
string PObservePackageName { get; }
DirectoryInfo ProjectRootPath { get; }
public IDictionary<string, CompilerOutput> OutputLanguages { get; }
IList<CompilerOutput> OutputLanguages { get; }
ICompilerOutput Output { get; set; }
DirectoryInfo OutputDirectory { get; set; }
ICodeGenerator Backend { get; set; }
Expand Down
10 changes: 5 additions & 5 deletions Src/PCompiler/PCommandLine/Options/PCompilerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,26 @@ private static void UpdateConfigurationWithParsedArgument(CompilerConfiguration
compilerConfiguration.ProjectName = (string)option.Value;
break;
case "mode":
compilerConfiguration.OutputLanguages = new Dictionary<string, CompilerOutput>();
compilerConfiguration.OutputLanguages = new List<CompilerOutput>();
switch (((string)option.Value).ToLowerInvariant())
{
case "bugfinding":
case "csharp":
compilerConfiguration.OutputLanguages["CSharp"] = CompilerOutput.CSharp;
compilerConfiguration.OutputLanguages.Add(CompilerOutput.CSharp);
break;
case "verification":
case "coverage":
case "symbolic":
case "psym":
case "pcover":
compilerConfiguration.OutputLanguages["Symbolic"] = CompilerOutput.Symbolic;
compilerConfiguration.OutputLanguages.Add(CompilerOutput.Symbolic);
break;
case "pobserve":
case "java":
compilerConfiguration.OutputLanguages["Java"] = CompilerOutput.Java;
compilerConfiguration.OutputLanguages.Add(CompilerOutput.Java);
break;
case "stately":
compilerConfiguration.OutputLanguages["Stately"] = CompilerOutput.Stately;
compilerConfiguration.OutputLanguages.Add(CompilerOutput.Stately);
break;
default:
throw new Exception($"Unexpected mode: '{option.Value}'");
Expand Down
14 changes: 7 additions & 7 deletions Src/PCompiler/PCommandLine/Parser/ParsePProjectFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ private string GetOutputDirectoryName(FileInfo fullPathName)
return Directory.GetCurrentDirectory();
}

private IDictionary<string, CompilerOutput> GetTargetLanguages(FileInfo fullPathName)
private IList<CompilerOutput> GetTargetLanguages(FileInfo fullPathName)
{
var outputLanguages = new Dictionary<string, CompilerOutput>();
var outputLanguages = new List<CompilerOutput>();
var projectXml = XElement.Load(fullPathName.FullName);
if (!projectXml.Elements("Target").Any())
{
outputLanguages["CSharp"] = CompilerOutput.CSharp;
outputLanguages.Add(CompilerOutput.CSharp);
}
else
{
Expand All @@ -226,21 +226,21 @@ private IDictionary<string, CompilerOutput> GetTargetLanguages(FileInfo fullPath
{
case "bugfinding":
case "csharp":
outputLanguages["CSharp"] = CompilerOutput.CSharp;
outputLanguages.Add(CompilerOutput.CSharp);
break;
case "verification":
case "coverage":
case "symbolic":
case "psym":
case "pcover":
outputLanguages["Symbolic"] = CompilerOutput.Symbolic;
outputLanguages.Add(CompilerOutput.Symbolic);
break;
case "pobserve":
case "java":
outputLanguages["Java"] = CompilerOutput.Java;
outputLanguages.Add(CompilerOutput.Java);
break;
case "stately":
outputLanguages["Stately"] = CompilerOutput.Stately;
outputLanguages.Add(CompilerOutput.Stately);
break;
default:
throw new CommandlineParsingError(
Expand Down
2 changes: 1 addition & 1 deletion Tst/UnitTests/Core/TestCaseFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public CompilerTestCase CreateTestCase(DirectoryInfo testDir)
ICompilerTestRunner runner;
ITestResultsValidator validator;

var output = new Dictionary<string, CompilerOutput>{{"C", CompilerOutput.C}};
var output = new List<CompilerOutput>{CompilerOutput.C};
runner = new CompileOnlyRunner(output, inputFiles.Select(x => x.FullName).ToList());

// TODO: validate information about the particular kind of compiler error
Expand Down
4 changes: 2 additions & 2 deletions Tst/UnitTests/Runners/CompileOnlyRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ namespace UnitTests.Runners
/// </summary>
public class CompileOnlyRunner : ICompilerTestRunner
{
private readonly IDictionary<string, CompilerOutput> compilerOutputs;
private readonly IList<CompilerOutput> compilerOutputs;
private readonly IList<string> inputFiles;

/// <summary>
/// Box a new compile runner
/// </summary>
/// <param name="compilerOutputs"></param>
/// <param name="inputFiles">The P source files to compile</param>
public CompileOnlyRunner(IDictionary<string, CompilerOutput> compilerOutputs, IList<string> inputFiles)
public CompileOnlyRunner(IList<CompilerOutput> compilerOutputs, IList<string> inputFiles)
{
this.inputFiles = inputFiles;
this.compilerOutputs = compilerOutputs;
Expand Down
2 changes: 1 addition & 1 deletion Tst/UnitTests/Runners/PCheckerRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ private int DoCompile(DirectoryInfo scratchDirectory)
{
var compiler = new Compiler();
var outputStream = new TestExecutionStream(scratchDirectory);
var compilerConfiguration = new CompilerConfiguration(outputStream, scratchDirectory, new Dictionary<string, CompilerOutput>{{"CSharp", CompilerOutput.CSharp}}, sources.Select(x => x.FullName).ToList(), "Main", scratchDirectory);
var compilerConfiguration = new CompilerConfiguration(outputStream, scratchDirectory, new List<CompilerOutput>{CompilerOutput.CSharp}, sources.Select(x => x.FullName).ToList(), "Main", scratchDirectory);
try
{
return compiler.Compile(compilerConfiguration);
Expand Down
2 changes: 1 addition & 1 deletion Tst/UnitTests/Runners/PrtRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void DoCompile(DirectoryInfo scratchDirectory)
var compiler = new Compiler();
var outputStream = new TestExecutionStream(scratchDirectory);
var compilerConfiguration = new CompilerConfiguration(outputStream, scratchDirectory,
new Dictionary<string, CompilerOutput>{{"C", CompilerOutput.C}}, sources.Select(x => x.FullName).ToList(), "main");
new List<CompilerOutput>{CompilerOutput.C}, sources.Select(x => x.FullName).ToList(), "main");
compiler.Compile(compilerConfiguration);
}

Expand Down

0 comments on commit 46138f5

Please sign in to comment.