Skip to main content

quickjs_oxide/source/
mod.rs

1//! Exact source bytes and source coordinates, independent of parsing policy.
2pub mod coordinates;
3pub use coordinates::{DebugMetadataError, LineColumn, QuickJsSourceLocator, SourceOffset};
4pub mod text;
5pub use text::*;
6
7/// A byte and human-readable location in a UTF-8 source file.
8#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash)]
9pub struct SourceLocation {
10    pub byte_offset: usize,
11    pub line: u32,
12    pub column: u32,
13}
14
15impl SourceLocation {
16    #[must_use]
17    pub const fn new(byte_offset: usize, line: u32, column: u32) -> Self {
18        Self {
19            byte_offset,
20            line,
21            column,
22        }
23    }
24}
25
26/// Half-open source range `[start, end)`.
27#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Hash)]
28pub struct SourceSpan {
29    pub start: SourceLocation,
30    pub end: SourceLocation,
31}
32
33impl SourceSpan {
34    #[must_use]
35    pub const fn new(start: SourceLocation, end: SourceLocation) -> Self {
36        Self { start, end }
37    }
38}
39
40pub mod unicode;