mirror of
https://github.com/erg-lang/erg.git
synced 2025-07-14 08:35:21 +00:00
31 lines
731 B
Rust
31 lines
731 B
Rust
use erg_common::shared::Shared;
|
|
use erg_common::traits::Stream;
|
|
|
|
use crate::error::{CompileError, CompileErrors};
|
|
|
|
#[derive(Debug, Clone, Default)]
|
|
pub struct SharedCompileErrors(Shared<CompileErrors>);
|
|
|
|
impl SharedCompileErrors {
|
|
pub fn new() -> Self {
|
|
Self(Shared::new(CompileErrors::empty()))
|
|
}
|
|
|
|
pub fn push(&self, error: CompileError) {
|
|
self.0.borrow_mut().push(error);
|
|
}
|
|
|
|
pub fn extend(&self, errors: CompileErrors) {
|
|
self.0.borrow_mut().extend(errors);
|
|
}
|
|
|
|
pub fn take(&self) -> CompileErrors {
|
|
self.0.borrow_mut().take_all().into()
|
|
}
|
|
|
|
pub fn clear(&self) {
|
|
self.0.borrow_mut().clear();
|
|
}
|
|
}
|
|
|
|
pub type SharedCompileWarnings = SharedCompileErrors;
|