1use super::{AbendId, Comparand, Compare, Count, DebugId, ExprId, Operand, PlaceId, RefMod, StorePlan, SymId};
7use crate::vocab::Figurative;
8use crate::{codec_enum, codec_struct};
9use zarch::hfp::Precision;
10
11#[derive(Clone, Copy, Debug, PartialEq, Eq)]
12pub enum MovePlan {
13 Alnum { image: Image, justified: bool },
14 AlnumEdited { image: Image, edit: u32, positions: u32 },
15 National(NationalFrom),
16 Numeric { from: NumericFrom, store: StorePlan },
17 Float { from: FloatFrom, precision: Precision },
18 Address,
19 Index,
20 Refused(AbendId),
21}
22
23#[derive(Clone, Copy, Debug, PartialEq, Eq)]
24pub enum Image {
25 Bytes,
26 All,
27 Figurative,
28 Digits { digits: u32 },
29}
30
31#[derive(Clone, Copy, Debug, PartialEq, Eq)]
32pub enum NationalFrom {
33 Units,
34 Decoded,
35 Figurative,
36}
37
38#[derive(Clone, Copy, Debug, PartialEq, Eq)]
39pub enum NumericFrom {
40 Value,
41 PackedCopy,
43 Float,
44 Zero,
45 Fill,
47 Zoned,
49 DeEdit { edit: u32, digits: u32, scale: u32 },
50}
51
52#[derive(Clone, Copy, Debug, PartialEq, Eq)]
53pub enum FloatFrom {
54 Float,
55 Fixed,
56 Zero,
57}
58
59#[derive(Clone, Debug, PartialEq, Eq)]
61pub struct InitPlan {
62 pub fields: Vec<InitField>,
63}
64
65#[derive(Clone, Copy, Debug, PartialEq, Eq)]
68pub struct InitField {
69 pub offset: u32,
70 pub len: u32,
71 pub value: Figurative,
72 pub store: MovePlan,
73}
74
75#[derive(Clone, Debug, PartialEq, Eq)]
77pub struct DisplayPlan<P = PlaceId, O = Operand> {
78 pub items: Vec<DisplayItem<P, O>>,
79 pub no_advancing: bool,
80}
81
82#[derive(Clone, Copy, Debug, PartialEq, Eq)]
83pub enum DisplayItem<P = PlaceId, O = Operand> {
84 Bytes(P),
86 National(P),
87 Digits { place: P, digits: u32, signed: bool },
90 Refused { place: P, abend: AbendId },
92 Text(SymId),
94 Value(O),
96}
97
98#[derive(Clone, Debug, PartialEq, Eq)]
101pub struct SearchAllPlan<P = PlaceId, V = Comparand, N = Count> {
102 pub index: P,
104 pub store: StorePlan,
105 pub count: N,
106 pub keys: Vec<SearchKey<V>>,
108}
109
110#[derive(Clone, Copy, Debug, PartialEq, Eq)]
112pub struct SearchKey<V = Comparand> {
113 pub ascending: bool,
114 pub key: V,
115 pub value: V,
116 pub how: Compare,
117}
118
119#[derive(Clone, Debug, PartialEq, Eq)]
120pub struct FunctionPlan {
121 pub func: Func,
122 pub args: Vec<ExprId>,
123 pub side: Option<TrimSide>,
124 pub refmod: Option<RefMod>,
125 pub at: DebugId,
126}
127
128#[derive(Clone, Copy, Debug, PartialEq, Eq)]
129pub enum Func {
130 Char,
131 Ord,
132 NationalOf,
133 Length,
134 UpperCase,
135 LowerCase,
136 Reverse,
137 CurrentDate,
138 Numval,
139 NumvalC,
140 Trim,
141 Mod,
142 Rem,
143 Integer,
144 IntegerPart,
145 Abs,
146 Min,
147 Max,
148 IntegerOfDate,
149 DateOfInteger,
150}
151
152#[derive(Clone, Copy, Debug, PartialEq, Eq)]
153pub enum TrimSide {
154 Leading,
155 Trailing,
156}
157
158#[derive(Clone, Debug, PartialEq, Eq)]
163pub struct InvokePlan {
164 pub receiver: Receiver,
165 pub method: MethodName,
166 pub args: Vec<(Operand, SymId)>,
167 pub returning: Option<(PlaceId, SymId)>,
168 pub on_exception: bool,
169 pub not_on_exception: bool,
170}
171
172#[derive(Clone, Copy, Debug, PartialEq, Eq)]
175pub enum Receiver {
176 SelfRef,
177 Super,
178 Class { name: SymId, external: SymId },
179 Object(PlaceId),
180}
181
182#[derive(Clone, Copy, Debug, PartialEq, Eq)]
183pub enum MethodName {
184 New,
185 Named(SymId),
186 Dynamic(PlaceId),
187}
188
189codec_enum!(MovePlan {
190 Alnum { image, justified } = 0,
191 AlnumEdited { image, edit, positions } = 1,
192 National(from) = 2,
193 Numeric { from, store } = 3,
194 Float { from, precision } = 4,
195 Address = 5,
196 Index = 6,
197 Refused(abend) = 7,
198});
199codec_enum!(Image { Bytes = 0, All = 1, Figurative = 2, Digits { digits } = 3 });
200codec_enum!(NationalFrom { Units = 0, Decoded = 1, Figurative = 2 });
201codec_enum!(NumericFrom {
202 Value = 0,
203 PackedCopy = 1,
204 Float = 2,
205 Zero = 3,
206 Fill = 4,
207 Zoned = 5,
208 DeEdit { edit, digits, scale } = 6,
209});
210codec_enum!(FloatFrom { Float = 0, Fixed = 1, Zero = 2 });
211codec_struct!(InitPlan { fields });
212codec_struct!(InitField { offset, len, value, store });
213codec_struct!(DisplayPlan { items, no_advancing });
214codec_enum!(DisplayItem {
215 Bytes(place) = 0,
216 National(place) = 1,
217 Digits { place, digits, signed } = 2,
218 Refused { place, abend } = 3,
219 Text(text) = 4,
220 Value(value) = 5,
221});
222codec_struct!(SearchAllPlan { index, store, count, keys });
223codec_struct!(SearchKey { ascending, key, value, how });
224codec_struct!(FunctionPlan { func, args, side, refmod, at });
225codec_enum!(Func {
226 Char = 0,
227 Ord = 1,
228 NationalOf = 2,
229 Length = 3,
230 UpperCase = 4,
231 LowerCase = 5,
232 Reverse = 6,
233 CurrentDate = 7,
234 Numval = 8,
235 NumvalC = 9,
236 Trim = 10,
237 Mod = 11,
238 Rem = 12,
239 Integer = 13,
240 IntegerPart = 14,
241 Abs = 15,
242 Min = 16,
243 Max = 17,
244 IntegerOfDate = 18,
245 DateOfInteger = 19,
246});
247codec_enum!(TrimSide { Leading = 0, Trailing = 1 });
248codec_struct!(InvokePlan { receiver, method, args, returning, on_exception, not_on_exception });
249codec_enum!(Receiver { SelfRef = 0, Super = 1, Class { name, external } = 2, Object(place) = 3 });
250codec_enum!(MethodName { New = 0, Named(name) = 1, Dynamic(place) = 2 });
251
252macro_rules! placeholder {
253 ($($ty:ident: $doc:literal,)*) => {$(
254 #[doc = $doc]
255 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
256 pub enum $ty {
257 #[default]
258 Placeholder,
259 }
260
261 codec_enum!($ty { Placeholder = 0 });
262 )*};
263}
264
265placeholder! {
266 FileOp: "A file verb with its phrases, §9.4; waits for `OpenMode`, `StartRel` and `FileDesc`.",
267 FileDesc: "A file's declaration, §9.4; not defined yet.",
268 SortPlan: "SORT or MERGE, §9.6; waits for `SortKey` and `Fastsrt`.",
269 ReleasePlan: "RELEASE, §9.6; not defined yet.",
270 ReturnPlan: "RETURN, §9.6; not defined yet.",
271 ReportOp: "INITIATE, GENERATE, TERMINATE or SUPPRESS, §9.6; not defined yet.",
272 CicsCommand: "An EXEC CICS command, §9.5; waits for the CICS code to move into rt.",
273}