|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Half-open byte range inside a source file. More...
#include <ah-source.H>
Public Member Functions | |
| bool | is_valid () const noexcept |
| Returns whether the span belongs to a registered file. | |
| bool | empty () const noexcept |
| Returns whether the span contains no bytes. | |
| size_t | size () const noexcept |
| Returns the span length in bytes. | |
| bool | contains (const Source_Offset offset) const noexcept |
Returns whether offset lies inside the half-open range. | |
| std::string | to_string () const |
Formats the span as #file:[begin,end). | |
Public Attributes | |
| Source_File_Id | file_id = 0 |
Stable file identifier; 0 means invalid. | |
| Source_Offset | begin = 0 |
| Inclusive begin byte offset. | |
| Source_Offset | end = 0 |
| Exclusive end byte offset. | |
Half-open byte range inside a source file.
Spans are stable, cheap value objects used by tokens, AST nodes, symbols, and diagnostics. The range is [begin, end), so empty spans are allowed.
Definition at line 99 of file ah-source.H.
|
inlinenoexcept |
Returns whether offset lies inside the half-open range.
Definition at line 124 of file ah-source.H.
References Aleph::and, begin, end, and offset.
|
inlinenoexcept |
Returns whether the span contains no bytes.
Definition at line 112 of file ah-source.H.
|
inlinenoexcept |
Returns whether the span belongs to a registered file.
Definition at line 106 of file ah-source.H.
References Aleph::and, begin, end, and file_id.
Referenced by Aleph::Diagnostic_Engine::append_diagnostic(), Aleph::Source_Manager::begin_position(), Aleph::Source_Manager::end_position(), Aleph::Compiler_CFG_Lowering::merge_span(), Aleph::Compiler_IR_Lowering::Module_Builder::merge_span(), Aleph::Diagnostic_Engine::render_label_snippet(), Aleph::Source_Manager::slice(), Aleph::Source_Manager::snippet(), to_string(), and Aleph::Compiler_Token::to_string().
|
inlinenoexcept |
Returns the span length in bytes.
Definition at line 118 of file ah-source.H.
Referenced by Aleph::Source_Manager::slice().
|
inline |
Formats the span as #file:[begin,end).
Definition at line 130 of file ah-source.H.
References begin, Aleph::blossom_maximum_cardinality_matching(), end, file_id, is_valid(), and out.
Referenced by Aleph::Compiler_Token::to_string().
| Source_Offset Aleph::Source_Span::begin = 0 |
Inclusive begin byte offset.
Definition at line 102 of file ah-source.H.
Referenced by Aleph::Source_Manager::begin_position(), contains(), empty(), is_valid(), size(), Aleph::Source_Manager::slice(), Aleph::Source_Manager::snippet(), and to_string().
| Source_Offset Aleph::Source_Span::end = 0 |
Exclusive end byte offset.
Definition at line 103 of file ah-source.H.
Referenced by contains(), empty(), Aleph::Source_Manager::end_position(), is_valid(), size(), Aleph::Source_Manager::slice(), Aleph::Source_Manager::snippet(), and to_string().
| Source_File_Id Aleph::Source_Span::file_id = 0 |
Stable file identifier; 0 means invalid.
Definition at line 101 of file ah-source.H.
Referenced by Aleph::Source_Manager::begin_position(), Aleph::compiler_hir_merge_spans(), Aleph::compiler_merge_spans(), Aleph::Source_Manager::end_position(), is_valid(), Aleph::Compiler_Line_Frontend::parse_source_file(), Aleph::Source_Manager::slice(), Aleph::Source_Manager::snippet(), and to_string().