steal from jai

This commit is contained in:
2026-06-01 22:40:24 -04:00
parent d864adfd05
commit 1d568f8ce3
17 changed files with 231 additions and 84 deletions
+15 -4
View File
@@ -1,3 +1,5 @@
use std::path::{Path, PathBuf};
#[derive(Debug, Clone, Copy)]
pub struct Span {
pub file: usize,
@@ -32,7 +34,7 @@ pub struct CompilerMsg {
#[derive(Default)]
pub struct CompilerOutput {
pub errors: Vec<CompilerMsg>,
pub files: Vec<String>,
pub files: Vec<PathBuf>,
}
impl CompilerOutput {
@@ -98,7 +100,7 @@ impl Span {
&text[self.start..=srange.end - 1],
)?;
if *eline != *sline + 1 {
writeln!(w, " ...")?;
writeln!(w, " ...")?;
}
writeln!(
w,
@@ -112,10 +114,19 @@ impl Span {
}
impl From<String> for CompilerMsg {
fn from(value: String) -> Self {
fn from(msg: String) -> Self {
Self {
spans: Vec::new(),
msg: value.to_string(),
msg,
}
}
}
impl<S: Into<String>> From<(S, Span)> for CompilerMsg {
fn from((msg, span): (S, Span)) -> Self {
Self {
spans: vec![span],
msg: msg.into(),
}
}
}