use std::alloc::Layout;
use crate::{ast::Identifier, token};
#[derive(Debug)]
pub enum CompileError {
NotFinishedInMain,
IdentifierNotFound(Identifier),
CreationFailed(InstructionsError),
InstructionWriteError(InstructionsError),
ScopeCreateFaild(InstructionsError),
WrongPrefixOperator(token::Kind),
WrongInfixOperator(token::Kind),
}
#[derive(Debug)]
pub enum InstructionsError {
AllocationFailed(Layout),
TooLargeToAllocate,
CannotRead { offset: usize },
}
#[derive(Debug)]
pub enum FrameError {
InnerError(InstructionsError),
}
impl From<InstructionsError> for FrameError {
fn from(err: InstructionsError) -> Self {
FrameError::InnerError(err)
}
}
#[derive(Debug)]
pub enum BytecodeError {
InnerError(InstructionsError),
}
impl From<InstructionsError> for BytecodeError {
fn from(err: InstructionsError) -> Self {
Self::InnerError(err)
}
}