use std::sync::OnceLock;
use crate::diagnostic::Severity;
use crate::ir::CompiledSchema;
static META_SCHEMA: OnceLock<CompiledSchema> = OnceLock::new();
static PACK_SCHEMA: OnceLock<CompiledSchema> = OnceLock::new();
pub fn meta_schema() -> &'static CompiledSchema {
META_SCHEMA.get_or_init(|| {
let source = include_str!("../schemas/schema.vexil");
let result = super::compile_impl(source, true);
let has_errors = result
.diagnostics
.iter()
.any(|d| d.severity == Severity::Error);
assert!(
!has_errors,
"BUG: embedded vexil.schema failed to compile: {:?}",
result.diagnostics
);
result
.compiled
.expect("BUG: vexil.schema produced no compiled output")
})
}
pub fn pack_schema() -> &'static CompiledSchema {
PACK_SCHEMA.get_or_init(|| {
let source = include_str!("../schemas/pack.vexil");
let result = super::compile_impl(source, true);
let has_errors = result
.diagnostics
.iter()
.any(|d| d.severity == Severity::Error);
assert!(
!has_errors,
"BUG: embedded vexil.pack failed to compile: {:?}",
result.diagnostics
);
result
.compiled
.expect("BUG: vexil.pack produced no compiled output")
})
}