Skip to main content

ironwork_rt/
refusal.rs

1//! The run-time half of ironwork's message catalogue: each construct a run reaches that ironwork
2//! does not run, refused by name. syntax::messages holds the compile-time half; docs/messages.md
3//! lists both, and a test there keeps their ids apart.
4
5use crate::abend::{Abend, AbendCode};
6use crate::vocab::Pos;
7use std::fmt::Display;
8
9#[derive(Clone, Copy, Debug, PartialEq, Eq)]
10pub struct Refusal {
11    pub id: &'static str,
12    pub text: &'static str,
13}
14
15impl Refusal {
16    /// The message as a run shows it: the id with severity S, then the site's words.
17    pub fn message(&self, text: impl Display) -> String {
18        format!("{}-S {text}", self.id)
19    }
20
21    /// The run's end with an IRONWORK abend at `pos`.
22    pub fn abend(&self, text: impl Display, pos: Pos) -> Abend {
23        self.ending(AbendCode::Ironwork, text, pos)
24    }
25
26    /// The run's end with `code`: EXEC for an EXEC statement, JAVA for a Java class or JNI service.
27    pub fn ending(&self, code: AbendCode, text: impl Display, pos: Pos) -> Abend {
28        Abend { code, message: self.message(text), pos, file: None }
29    }
30}
31
32macro_rules! catalogue {
33    ($($id:ident $text:literal;)*) => {
34        $(pub const $id: Refusal = Refusal { id: stringify!($id), text: $text };)*
35        /// Every run-time refusal, in id order.
36        pub const RUNTIME: &[Refusal] = &[$($id),*];
37    };
38}
39
40catalogue! {
41    IWR0058 "EXEC CICS {command} is not supported yet";
42    IWR0059 "EXEC CICS FORMATTIME {option} is not supported";
43    IWR0060 "EXEC {kind} {command} was reached: ironwork for COBOL checks EXEC statements but does not run them yet";
44    IWR0061 "EXEC SQL {verb} was reached: ironwork for COBOL does not run {statement}";
45    IWR0062 "{what} was reached: {class} is a Java class, and ironwork for COBOL checks Java classes but has no JVM to run them";
46    IWR0063 "CALL {name} was reached: {service} is a JNI service, and ironwork for COBOL has no JVM to run it";
47    IWR0064 "FUNCTION {name} is not supported yet";
48    IWR0065 "FUNCTION LENGTH of this argument is not supported yet";
49    IWR0066 "DISPLAY of a floating-point value is not supported yet";
50    IWR0067 "DISPLAY of a pointer, index or object reference is not supported";
51    IWR0068 "ADVANCING {name} on {file}, whose FD has LINAGE, is not supported yet";
52    IWR0070 "this BY VALUE argument is not supported";
53    IWR0071 "this INVOKE argument is not supported";
54    IWR0072 "{statement}: {name} is a Language Environment callable service that ironwork for COBOL does not provide yet";
55    IWR0073 "the VM does not run {construct} yet; run it with --interpret";
56    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";
57}