use crate::abend::{Abend, AbendCode};
use crate::vocab::Pos;
use std::fmt::Display;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Refusal {
pub id: &'static str,
pub text: &'static str,
}
impl Refusal {
pub fn message(&self, text: impl Display) -> String {
format!("{}-S {text}", self.id)
}
pub fn abend(&self, text: impl Display, pos: Pos) -> Abend {
self.ending(AbendCode::Ironwork, text, pos)
}
pub fn ending(&self, code: AbendCode, text: impl Display, pos: Pos) -> Abend {
Abend { code, message: self.message(text), pos, file: None }
}
}
macro_rules! catalogue {
($($id:ident $text:literal;)*) => {
$(pub const $id: Refusal = Refusal { id: stringify!($id), text: $text };)*
pub const RUNTIME: &[Refusal] = &[$($id),*];
};
}
catalogue! {
IWR0058 "EXEC CICS {command} is not supported yet";
IWR0059 "EXEC CICS FORMATTIME {option} is not supported";
IWR0060 "EXEC {kind} {command} was reached: ironwork for COBOL checks EXEC statements but does not run them yet";
IWR0061 "EXEC SQL {verb} was reached: ironwork for COBOL does not run {statement}";
IWR0062 "{what} was reached: {class} is a Java class, and ironwork for COBOL checks Java classes but has no JVM to run them";
IWR0063 "CALL {name} was reached: {service} is a JNI service, and ironwork for COBOL has no JVM to run it";
IWR0064 "FUNCTION {name} is not supported yet";
IWR0065 "FUNCTION LENGTH of this argument is not supported yet";
IWR0066 "DISPLAY of a floating-point value is not supported yet";
IWR0067 "DISPLAY of a pointer, index or object reference is not supported";
IWR0068 "ADVANCING {name} on {file}, whose FD has LINAGE, is not supported yet";
IWR0070 "this BY VALUE argument is not supported";
IWR0071 "this INVOKE argument is not supported";
IWR0072 "{statement}: {name} is a Language Environment callable service that ironwork for COBOL does not provide yet";
IWR0073 "the VM does not run {construct} yet; run it with --interpret";
IWR0074 "{file}, a GLOBAL file of {declarer}, is written as a print file in one of {declarer} and {program} and not the other, which is not supported yet";
}