plotnik_compiler/compile/
error.rs1use indexmap::IndexMap;
4
5use crate::analyze::type_check::DefId;
6use crate::bytecode::{InstructionIR, Label};
7
8#[derive(Clone, Debug)]
10pub enum CompileError {
11 DefinitionNotFound(String),
13 MissingBody(String),
15}
16
17impl std::fmt::Display for CompileError {
18 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19 match self {
20 Self::DefinitionNotFound(name) => write!(f, "definition not found: {name}"),
21 Self::MissingBody(name) => write!(f, "missing body for definition: {name}"),
22 }
23 }
24}
25
26impl std::error::Error for CompileError {}
27
28#[derive(Clone, Debug)]
30pub struct CompileResult {
31 pub instructions: Vec<InstructionIR>,
33 pub def_entries: IndexMap<DefId, Label>,
35 pub preamble_entry: Label,
38}