Skip to content

Dev/remove libhandler #847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2025
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
1 change: 0 additions & 1 deletion Ext/libhandler
Submodule libhandler deleted from 0f1e36
91 changes: 90 additions & 1 deletion Src/PCompiler/CompilerCore/CompilerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,26 @@

namespace Plang.Compiler
{
/// <summary>
/// Represents the configuration settings for the P language compiler.
/// This class contains all parameters and options that control the compilation process,
/// including input/output paths, code generation options, and project settings.
/// </summary>
public class CompilerConfiguration : ICompilerConfiguration
{
/// <summary>
/// Initializes a new instance of the <see cref="CompilerConfiguration"/> class with default settings.
/// </summary>
/// <remarks>
/// Default settings include:
/// - No output directory
/// - Empty input file lists
/// - "generatedOutput" as project name
/// - Current directory as project root
/// - C# as the default output language
/// - Default location resolver and error handler
/// - Debug mode disabled
/// </remarks>
public CompilerConfiguration()
{
OutputDirectory = null;
Expand All @@ -25,6 +43,19 @@ public CompilerConfiguration()
ProjectDependencies = new List<string>();
Debug = false;
}
/// <summary>
/// Initializes a new instance of the <see cref="CompilerConfiguration"/> class with specific settings.
/// </summary>
/// <param name="output">The compiler output handler.</param>
/// <param name="outputDir">The directory where compiler output will be generated.</param>
/// <param name="outputLanguages">The list of target programming languages for code generation.</param>
/// <param name="inputFiles">The list of input files to compile (P files and foreign files).</param>
/// <param name="projectName">The name of the project being compiled. If null, derives from first input file.</param>
/// <param name="projectRoot">The root directory of the project. If null, uses the current directory.</param>
/// <param name="projectDependencies">The list of project dependencies. If null, initializes as empty list.</param>
/// <param name="pObservePackageName">The name of the PObserve package. If null, defaults to "{ProjectName}.pobserve".</param>
Copy link
Preview

Copilot AI Apr 23, 2025

Choose a reason for hiding this comment

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

The XML comment for pObservePackageName indicates a default behavior when null, but there is no implementation of a fallback assignment in the constructor. Consider implementing logic to set pObservePackageName to "{ProjectName}.pobserve" when it is not provided.

Copilot uses AI. Check for mistakes.

/// <param name="debug">Flag indicating whether to include debug information in output.</param>
/// <exception cref="ArgumentException">Thrown when no input files are provided.</exception>
public CompilerConfiguration(ICompilerOutput output, DirectoryInfo outputDir, IList<CompilerOutput> outputLanguages, IList<string> inputFiles,
string projectName, DirectoryInfo projectRoot = null, IList<string> projectDependencies = null, string pObservePackageName = null, bool debug = false)
{
Expand Down Expand Up @@ -59,21 +90,79 @@ public CompilerConfiguration(ICompilerOutput output, DirectoryInfo outputDir, IL
Debug = debug;
}

/// <summary>
/// Gets or sets the compiler output handler.
/// </summary>
public ICompilerOutput Output { get; set; }

/// <summary>
/// Gets or sets the directory where compiler output will be generated.
/// </summary>
public DirectoryInfo OutputDirectory { get; set; }

/// <summary>
/// Gets or sets the list of target programming languages for code generation.
/// </summary>
public IList<CompilerOutput> OutputLanguages { get; set; }

/// <summary>
/// Gets or sets the name of the project being compiled.
/// </summary>
public string ProjectName { get; set; }

/// <summary>
/// Gets or sets the name of the PObserve package.
/// </summary>
public string PObservePackageName { get; set; }

/// <summary>
/// Gets or sets the root directory of the project.
/// </summary>
public DirectoryInfo ProjectRootPath { get; set; }

/// <summary>
/// Gets or sets the backend code generator.
/// </summary>
public ICodeGenerator Backend { get; set; }

/// <summary>
/// Gets or sets the list of P language input files to compile.
/// </summary>
public IList<string> InputPFiles { get; set; }

/// <summary>
/// Gets or sets the list of foreign (non-P) input files to include.
/// </summary>
public IList<string> InputForeignFiles { get; set; }

/// <summary>
/// Gets or sets the location resolver for source code positions.
/// </summary>
public ILocationResolver LocationResolver { get; set; }

/// <summary>
/// Gets or sets the handler for translation errors.
/// </summary>
public ITranslationErrorHandler Handler { get; set; }

/// <summary>
/// Gets or sets the list of project dependencies.
/// </summary>
public IList<string> ProjectDependencies { get; set; }

/// <summary>
/// Gets or sets a value indicating whether debug information should be included in output.
/// </summary>
public bool Debug { get; set; }

/// <summary>
/// Copies all properties from another CompilerConfiguration instance to this instance.
/// </summary>
/// <param name="parsedConfig">The source configuration to copy from.</param>
/// <remarks>
/// This method performs a shallow copy of all properties from the specified configuration
/// to the current instance, effectively replacing the current configuration.
/// </remarks>
public void Copy(CompilerConfiguration parsedConfig)
{
Backend = parsedConfig.Backend;
Expand All @@ -91,4 +180,4 @@ public void Copy(CompilerConfiguration parsedConfig)
Debug = parsedConfig.Debug;
}
}
}
}
Loading