diag.l0

diag.l0

Module: util.diag

Source: compiler/stage2_l0/src/util/diag.l0 Language: Dea/L0

Imports / Includes

  • std.vector

Symbols

Enum DiagnosticSeverity

1
DiagnosticSeverity

Defines the DiagnosticSeverity enumeration.

Variants:

  • Error
  • Warning
  • Note

Type Alias DiagnosticVector

1
type DiagnosticVector = VectorBase

Function dgv_create

1
func dgv_create() -> DiagnosticVector*

Create an empty vector of diagnostics.

Returns: Diagnostic vector with an initial small capacity.

Function dgv_push

1
func dgv_push(self: DiagnosticVector*, diag: Diagnostic)

Append a diagnostic to the vector.

Parameters:

Function dgv_get

1
func dgv_get(self: DiagnosticVector*, index: int) -> Diagnostic*

Return a diagnostic from the vector.

Parameters:

  • self: Diagnostic vector to inspect.
  • index: Zero-based diagnostic index.

Returns: Diagnostic at index.

Function dgv_length

1
func dgv_length(self: DiagnosticVector*) -> int

Return the number of diagnostics stored in the vector.

Parameters:

Returns: Total diagnostic count.

Function dgv_free

1
func dgv_free(self: DiagnosticVector*)

Free a diagnostic vector and release ARC-owned fields in each entry.

Parameters:

Function diag_create

1
func diag_create() -> DiagCollector*

Create an empty diagnostic collector.

Returns: New collector with no diagnostics.

Function diag_error

1
func diag_error(dc: DiagCollector*, phase: string, code: string, message: string, filename: string, line: int, column: int, line_end: int, column_end: int)

Record an error diagnostic.

Parameters:

  • dc: Collector receiving the diagnostic.
  • phase: Compiler phase name.
  • code: Diagnostic code.
  • message: Diagnostic message.
  • filename: Source filename, or empty when unavailable.
  • line: Starting line number.
  • column: Starting column number.
  • line_end: Ending line number.
  • column_end: Ending column number.

Function diag_warn

1
func diag_warn(dc: DiagCollector*, phase: string, code: string, message: string, filename: string, line: int, column: int, line_end: int, column_end: int)

Record a warning diagnostic.

Parameters:

  • dc: Collector receiving the diagnostic.
  • phase: Compiler phase name.
  • code: Diagnostic code.
  • message: Diagnostic message.
  • filename: Source filename, or empty when unavailable.
  • line: Starting line number.
  • column: Starting column number.
  • line_end: Ending line number.
  • column_end: Ending column number.

Function diag_note

1
func diag_note(dc: DiagCollector*, phase: string, code: string, message: string, filename: string, line: int, column: int, line_end: int, column_end: int)

Record an informational note diagnostic.

Parameters:

  • dc: Collector receiving the diagnostic.
  • phase: Compiler phase name.
  • code: Diagnostic code.
  • message: Diagnostic message.
  • filename: Source filename, or empty when unavailable.
  • line: Starting line number.
  • column: Starting column number.
  • line_end: Ending line number.
  • column_end: Ending column number.

Function diag_has_errors

1
func diag_has_errors(dc: DiagCollector*) -> bool

Report whether the collector contains any errors.

Parameters:

Returns: true if at least one error diagnostic has been recorded.

Function diag_count

1
func diag_count(dc: DiagCollector*) -> int

Return the number of collected diagnostics.

Parameters:

Returns: Total diagnostic count.

Function diag_get

1
func diag_get(dc: DiagCollector*, index: int) -> Diagnostic*

Return a diagnostic from the collector.

Parameters:

  • dc: Diagnostic collector to inspect.
  • index: Zero-based diagnostic index.

Returns: Diagnostic at index.

Function diag_copy

1
func diag_copy(dst: DiagCollector*, src: Diagnostic*)

Copy a diagnostic into another collector.

Parameters:

  • dst: Destination collector.
  • src: Diagnostic to copy.

Function diag_free

1
func diag_free(dc: DiagCollector*)

Free a diagnostic collector and its backing storage.

Parameters:

Struct Diagnostic

Diagnostic represents an error, warning, or note message produced during compilation.

It includes information about the phase of compilation, a code for the specific issue, the severity level, a human-readable message, and the location in the source code.

Diagnostic Field phase

1
phase: string

Diagnostic Field code

1
code: string

Diagnostic Field severity

1
severity: DiagnosticSeverity

Diagnostic Field message

1
message: string

Diagnostic Field filename

1
filename: string

Diagnostic Field line

1
line: int

Diagnostic Field column

1
column: int

Diagnostic Field line_end

1
line_end: int

Diagnostic Field column_end

1
column_end: int

Struct DiagCollector

Represents the DiagCollector structure.

DiagCollector Field items

1
items: DiagnosticVector*

DiagCollector Field error_count

1
error_count: int