compiler/stage2_l0/src/driver.l0

Module driver

Overview Symbols grouped by source file: compiler/stage2_l0/src/driver.l0

Module: driver

Source: compiler/stage2_l0/src/driver.l0 Language: Dea/L0

Imports / Includes

  • parser
  • source_paths
  • lexer
  • util.log
  • ast
  • util.strings
  • tokens
  • util.diag
  • std.vector
  • std.string
  • std.text
  • std.fs
  • sys.rt

Symbols

Function dr_unit_free

func dr_unit_free(self: DriverUnit*)

Free a loaded driver unit and its parse result.

Parameters:

  • self: Driver unit to free.

Function dr_units_free

func dr_units_free(units: VectorBase*?)

Free an optional vector of driver units.

Parameters:

  • units: Optional driver-unit vector to free.

Function driver_state_free

func driver_state_free(self: DriverState*)

Free driver state and all owned parse/cache data.

Parameters:

  • self: Driver state to free.

Function driver_has_errors

func driver_has_errors(self: DriverState*) -> bool

Report whether driver analysis produced any errors.

Parameters:

  • self: Driver state to inspect.

Returns: true if the driver's diagnostics contain an error.

Function driver_diag_count

func driver_diag_count(self: DriverState*) -> int

Return the number of diagnostics collected by the driver.

Parameters:

  • self: Driver state to inspect.

Returns: Total diagnostic count.

Function driver_diag_get

func driver_diag_get(self: DriverState*, index: int) -> Diagnostic*

Return a driver diagnostic by index.

Parameters:

  • self: Driver state to inspect.
  • index: Zero-based diagnostic index.

Returns: Diagnostic at index.

Function driver_unit_count

func driver_unit_count(self: DriverState*) -> int

Return the number of loaded driver units.

Parameters:

  • self: Driver state to inspect.

Returns: Loaded module count.

Function driver_unit_get

func driver_unit_get(self: DriverState*, index: int) -> DriverUnit*

Return a loaded driver unit by index.

Parameters:

  • self: Driver state to inspect.
  • index: Zero-based unit index.

Returns: Driver unit at index.

Function driver_find_unit

func driver_find_unit(self: DriverState*, module_name: string) -> DriverUnit*?

Find a loaded driver unit by module name.

Parameters:

  • self: Driver state to inspect.
  • module_name: Module name to search for.

Returns: Matching driver unit, or null if not loaded.

Function driver_module_names_sorted

func driver_module_names_sorted(self: DriverState*) -> StringVector*

Return loaded module names in sorted order.

Parameters:

  • self: Driver state to inspect.

Returns: New vector containing sorted module names.

Function dr_copy_parse_diags

func dr_copy_parse_diags(dst: DiagCollector*, pr: ParseResult*)

Copy parse diagnostics into the driver collector.

Parameters:

  • dst: Destination diagnostic collector.
  • pr: Parse result providing diagnostics.

Function dr_emit_error

func dr_emit_error(diags: DiagCollector*, code: string, message: string, filename: string)

Emit a driver diagnostic without a precise source span.

Parameters:

Function dr_sv_has

func dr_sv_has(items: StringVector*, module_name: string) -> bool

Check whether a string vector contains a module name.

Parameters:

  • items: Vector to search.
  • module_name: Module name to look for.

Returns: true if module_name is present in items.

Function dr_mark_loaded

func dr_mark_loaded(loaded: StringVector*, module_name: string)

Mark a module as loaded if it is not already recorded.

Parameters:

  • loaded: Vector of loaded module names.
  • module_name: Module name to record.

Function dr_parse_source

func dr_parse_source(path: string, source: string, cfg: LogConfig*) -> ParseResult*

Lex and parse one module source file while emitting Stage 1-style debug logs.

Parameters:

  • path: Source path being processed.
  • source: Source text to lex and parse.
  • cfg: Logging configuration.

Returns: Parse result for the module.

Function dr_visit_closure

func dr_visit_closure(state: DriverState*, search_paths: SourceSearchPaths*, module_name: string, visited: StringVector*, cfg: LogConfig*)

Revisit the loaded module closure to mirror Stage 1 cache-hit logging.

Parameters:

  • state: Driver state containing loaded modules.
  • search_paths: Source search paths used for lookups.
  • module_name: Current module name.
  • visited: Module names already traversed by this closure walk.
  • cfg: Logging configuration.

Function dr_load_module

func dr_load_module(state: DriverState*, search_paths: SourceSearchPaths*, loading_chain: string, module_name: string, cfg: LogConfig*) -> bool

Load one module and its import closure into the driver state.

Parameters:

  • state: Driver state that caches loaded modules and diagnostics.
  • search_paths: Source search paths used to resolve module names.
  • loading_chain: Import chain encoded with |name| sentinels for cycle detection.
  • module_name: Module name to load.
  • cfg: Logging configuration.

Returns: true if the module was loaded successfully or was already cached.

Function driver_analyze_entry

func driver_analyze_entry(search_paths: SourceSearchPaths*, entry_module: string, cfg: LogConfig*) -> DriverState*

Load and parse an entry module and its imports.

Parameters:

  • search_paths: Source search paths used for module resolution.
  • entry_module: Entry module name.
  • cfg: Logging configuration.

Returns: Driver state containing parsed modules, caches, and diagnostics.

Struct DriverUnit

Represents the DriverUnit structure.

DriverUnit Field module_name

module_name: string

DriverUnit Field path

path: string

DriverUnit Field parse_result

parse_result: ParseResult*

Struct DriverState

Represents the DriverState structure.

DriverState Field entry_module

entry_module: string

DriverState Field units

units: VectorBase*

DriverState Field loaded

loaded: StringVector*

DriverState Field diags

diags: DiagCollector*

DriverState Field source_names

source_names: StringVector*

DriverState Field source_texts

source_texts: StringVector*