assembler: great leap forwards (more like the Cultural Revolution)
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
//! This module contains code for various types of errors that may occur when assembling a
|
||||
//! set of source DSA files.
|
||||
|
||||
use std::fmt::{Debug, Display};
|
||||
|
||||
use crate::source::source_info::SourceInfo;
|
||||
|
||||
/// An error that may occur during the assembly of a set of source files.
|
||||
#[derive(Debug)]
|
||||
pub struct AssembleError {
|
||||
/// Display implementation can handle when the source code information is shown or
|
||||
/// not.
|
||||
source_info: Option<SourceInfo>,
|
||||
/// The type of assembly error that occurred.
|
||||
kind: AssembleErrorKind,
|
||||
/// The formatter to handle printing the error.
|
||||
formatter: Box<dyn ErrorFormatter>,
|
||||
}
|
||||
|
||||
impl AssembleError {
|
||||
pub fn new_source_error(source_info: SourceInfo, kind: AssembleErrorKind) -> Self {
|
||||
Self {
|
||||
source_info: Some(source_info),
|
||||
kind,
|
||||
formatter,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_other_error(kind: AssembleErrorKind) {}
|
||||
}
|
||||
|
||||
impl Display for AssembleError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
self.formatter
|
||||
.write(f, self.source_info.as_ref(), &self.kind)
|
||||
}
|
||||
}
|
||||
|
||||
/// Marker trait.
|
||||
impl std::error::Error for AssembleError {}
|
||||
|
||||
/// Different types of errors that may occur when assembling a set of input source files.
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug)]
|
||||
pub enum AssembleErrorKind {}
|
||||
|
||||
pub mod conversions;
|
||||
pub mod formatters;
|
||||
Reference in New Issue
Block a user