Driver

public struct Driver : ParsableCommand, Sendable

Undocumented

  • A validation error that includes the command’s full help message.

    See more

    Declaration

    Swift

    private struct ValidationErrorWithHelp : Error, CustomStringConvertible, Sendable
  • The type of the output files to generate.

    See more

    Declaration

    Swift

    private enum OutputType : String, ExpressibleByArgument, Sendable
  • The result of a compiler invocation.

    See more

    Declaration

    Swift

    public struct CompilationResult : Sendable
  • Declaration

    Swift

    public static let configuration: CommandConfiguration
  • Undocumented

    Declaration

    Swift

    @Flag
    private var compileInputAsModules: Bool { get set }
  • Undocumented

    Declaration

    Swift

    @Flag
    private var importBuiltinModule: Bool { get set }
  • Undocumented

    Declaration

    Swift

    @Flag
    private var freestanding: Bool { get set }
  • Undocumented

    Declaration

    Swift

    @Flag
    private var experimentalParallelTypeChecking: Bool { get set }
  • Undocumented

    Declaration

    Swift

    @Flag
    private var typeCheckOnly: Bool { get set }
  • Undocumented

    Declaration

    Swift

    @Option
    private var inferenceTracingSite: SourceLine? { get set }
  • Undocumented

    Declaration

    Swift

    @Option
    private var showRequirementsSite: SourceLine? { get set }
  • Undocumented

    Declaration

    Swift

    @Option
    private var outputType: OutputType { get set }
  • Undocumented

    Declaration

    Swift

    @Option
    private var transforms: ModulePassList? { get set }
  • Undocumented

    Declaration

    Swift

    @Option
    private var librarySearchPaths: [String] { get set }
  • Undocumented

    Declaration

    Swift

    @Option
    private var libraries: [String] { get set }
  • Undocumented

    Declaration

    Swift

    @Option
    private var outputURL: URL? { get set }
  • Undocumented

    Declaration

    Swift

    @Flag
    private var verbose: Bool { get set }
  • Undocumented

    Declaration

    Swift

    @Flag
    private var version: Bool { get set }
  • Undocumented

    Declaration

    Swift

    @Flag
    private var optimize: Bool { get set }
  • Undocumented

    Declaration

    Swift

    @Argument
    private var inputs: [URL] { get set }
  • Creates a new instance with default options.

    Declaration

    Swift

    public init()
  • The URL of the current working directory.

    Declaration

    Swift

    private var currentDirectory: URL { get }
  • Compiles input with the given command line arguments and returns the compiler’s exit status, the URL of the output file, and any diagnostics.

    Declaration

    Swift

    public static func compileToTemporary(
      _ input: URL, withOptions options: [String], extending baseProgram: TypedProgram? = nil
    ) throws -> CompilationResult

    Parameters

    input

    The URL of a single Hylo source file or the root directory of a Hylo module.

    options

    The compiler’s options sans input and output arguments.

    baseProgram

    A program with some or all of the dependencies of the compiler’s input, which have been compiled with options compatible with options. All dependencies are loaded from disk if this argument is nil

  • Executes the command.

    Declaration

    Swift

    public func run() throws
  • Executes the command, loading modules into baseProgram and reporting diagnostics to log.

    Declaration

    Swift

    public func executeCommand(
      extending baseProgram: TypedProgram? = nil,
      reportingDiagnosticsTo log: inout DiagnosticSet
    ) throws

    Parameters

    baseProgram

    A program with some or all of the dependencies of the compiler’s input, which have been compiled with options compatible with the driver’s current configuration. All dependencies are loaded from disk if this argument is nil

    log

    A set of diagnostics that doesn’t contain any error.

  • Logs m to the standard error iff verbose is true.

    Declaration

    Swift

    private func logVerbose(_ m: @autoclosure () -> String)
  • Returns true if type inference related to n, which is in p, would be traced.

    Declaration

    Swift

    private func shouldTraceInference(_ n: AnyNodeID, _ p: TypedProgram) -> Bool
  • Returns true if the requirement system of n, which is in p, should be logged.

    Declaration

    Swift

    private func shouldLogRequirements(_ n: AnyDeclID, _ p: TypedProgram) -> Bool
  • Returns program lowered to Hylo IR, accumulating diagnostics in log and throwing if an error occurred.

    Mandatory IR passes are applied unless self.outputType is .rawIR.

    Declaration

    Swift

    private func lower(
      program: TypedProgram, reportingDiagnosticsTo log: inout DiagnosticSet
    ) throws -> IR.Program
  • Returns m, which is program, lowered to Hylo IR, accumulating diagnostics in log and throwing if an error occurred.

    Mandatory IR passes are applied unless self.outputType is .rawIR.

    Declaration

    Swift

    private func lower(
      _ m: ModuleDecl.ID, in program: TypedProgram, reportingDiagnosticsTo log: inout DiagnosticSet
    ) throws -> IR.Module
  • Combines the object files located at objects into an executable file at binaryPath, logging diagnostics to log.

    Declaration

    Swift

    private func makeMacOSExecutable(
      at binaryPath: String, linking objects: [URL], diagnostics: inout DiagnosticSet
    ) throws
  • Combines the object files located at objects into an executable file at binaryPath, logging diagnostics to log.

    Declaration

    Swift

    private func makeLinuxExecutable(
      at binaryPath: String,
      linking objects: [URL],
      diagnostics: inout DiagnosticSet
    ) throws
  • Combines the object files located at objects into an executable file at binaryPath, logging diagnostics to log.

    Declaration

    Swift

    private func makeWindowsExecutable(
      at binaryPath: String,
      linking objects: [URL],
      diagnostics: inout DiagnosticSet
    ) throws
  • Returns self.outputURL transformed as a suitable executable file path, using productName as a default name if outputURL is nil.

    Declaration

    Swift

    private func executableOutputPath(default productName: String) -> String
  • If inputs contains a single URL u whose path is non-empty, returns the last component of u without any path extension and stripping all leading dots; returns “Main” otherwise.

    Declaration

    Swift

    private func makeProductName(_ inputs: [URL]) -> String
  • Writes source to url, possibly with verbose logging.

    Declaration

    Swift

    private func write(_ source: String, toURL url: URL) throws
  • Creates a module from the contents at url and adds it to the AST.

    Requires

    url must denote a directly.

    Declaration

    Swift

    private func addModule(url: URL)
  • Returns the path of the binary executable that is invoked at the command-line with the name given by invocationName.

    Declaration

    Swift

    private func findExecutable(invokedAs invocationName: String) throws -> URL
  • Runs the executable at path, passing arguments on the command line, and returns its standard output sans any leading or trailing whitespace.

    Declaration

    Swift

    @discardableResult
    private func runCommandLine(
      _ programPath: String,
      _ arguments: [String] = [],
      diagnostics: inout DiagnosticSet
    ) throws -> String?
  • A map from the name by which an executable is invoked to path of the named binary.

    Declaration

    Swift

    private static let executableLocationCache: SharedMutable<[String : URL]>
  • Writes a textual description of input to the given output file.

    Declaration

    Swift

    func write(_ input: AST, to output: URL) throws
  • Given the desired name of the compiler’s product, returns the file to write when “raw-ast” is selected as the output type.

    Declaration

    Swift

    private func astFile(_ productName: String) -> URL
  • Given the desired name of the compiler’s product, returns the file to write when “ir” or “raw-ir” is selected as the output type.

    Declaration

    Swift

    private func irFile(_ productName: String) -> URL
  • Given the desired name of the compiler’s product, returns the file to write when “llvm” is selected as the output type.

    Declaration

    Swift

    private func llvmFile(_ productName: String) -> URL
  • Given the desired name of the compiler’s product, returns the file to write when “intel-asm” is selected as the output type.

    Declaration

    Swift

    private func intelASMFile(_ productName: String) -> URL
  • Given the desired name of the compiler’s product, returns the file to write when “binary” is selected as the output type.

    Declaration

    Swift

    private func binaryFile(_ productName: String) -> URL