1use super::{AbendId, CondId, ConstId, ExprId, FunctionId, Mode, Odo, PlaceId, TempId, UserFunctionId};
4use crate::codec_enum;
5use crate::vocab::{BinOp, Figurative, RelOp};
6use numeric::precision::Fixed;
7
8#[derive(Clone, Copy, Debug, PartialEq, Eq)]
9pub enum Operand {
10 Load(PlaceId),
11 Const(ConstId),
12 LengthOf(PlaceId),
13 AddressOf(PlaceId),
14 Function(FunctionId),
15 UserFunction(UserFunctionId),
16}
17
18#[derive(Clone, Debug, PartialEq, Eq)]
19pub enum Const {
20 Bytes(Vec<u8>),
21 National(Vec<u8>),
22 Number(Fixed),
23 Figurative(Figurative),
24 All(Vec<u8>),
25 Refused(AbendId),
28}
29
30#[derive(Clone, Debug, PartialEq, Eq)]
33pub enum IntExpr {
34 Const(i64),
35 Item(PlaceId),
36 Fixed { expr: ExprId, dmax: u32, prepass: Vec<PlaceId> },
37 Walk(u8),
40}
41
42#[derive(Clone, Debug, PartialEq, Eq)]
43pub enum Expr {
44 Operand(Operand),
45 Neg(ExprId),
46 Bin(ExprId, BinOp, ExprId),
47 Pow(ExprId, IntExpr),
49}
50
51#[derive(Clone, Debug, PartialEq, Eq)]
52pub enum Cond {
53 Rel { a: Comparand, op: RelOp, b: Comparand, how: Compare },
54 Class { place: PlaceId, test: ByteClass },
55 Sign { value: Comparand, test: SignTest },
56 Name { subject: PlaceId, values: Vec<(ConstId, Option<ConstId>)>, how: Compare },
58 Not(CondId),
59 And(CondId, CondId),
60 Or(CondId, CondId),
61 Counter(TempId),
62 InTable { index: PlaceId, count: Count },
63 Sql(SqlTest),
64}
65
66#[derive(Clone, Debug, PartialEq, Eq)]
69pub enum Comparand {
70 Operand(Operand),
71 Expr { expr: ExprId, dmax: u32, mode: Mode, prepass: Vec<PlaceId> },
72}
73
74#[derive(Clone, Copy, Debug, PartialEq, Eq)]
75pub enum Compare {
76 PackedPfd,
77 Address,
78 Float,
79 Fixed,
80 National,
81 Alphanumeric,
82 Refused(AbendId),
83 References,
86 ZonedBytes { zoned_first: bool },
89}
90
91#[derive(Clone, Copy, Debug, PartialEq, Eq)]
92pub enum ByteClass {
93 Packed { signed: bool },
94 Zoned { signed: bool },
95 Digits,
96 Alphabetic,
97 AlphabeticLower,
98 AlphabeticUpper,
99}
100
101#[derive(Clone, Copy, Debug, PartialEq, Eq)]
102pub enum SignTest {
103 Positive,
104 Negative,
105 Zero,
106}
107
108#[derive(Clone, Debug, PartialEq, Eq)]
109pub enum Count {
110 Fixed(u32),
111 Odo(Odo),
112 Temp(TempId),
114}
115
116#[derive(Clone, Copy, Debug, PartialEq, Eq)]
118pub enum SqlTest {
119 Error,
120 NotFound,
121 Warning,
122}
123
124codec_enum!(Operand { Load(place) = 0, Const(id) = 1, LengthOf(place) = 2, AddressOf(place) = 3, Function(id) = 4, UserFunction(id) = 5 });
125codec_enum!(Const { Bytes(b) = 0, National(n) = 1, Number(f) = 2, Figurative(f) = 3, All(b) = 4, Refused(abend) = 5 });
126codec_enum!(IntExpr { Const(n) = 0, Item(place) = 1, Fixed { expr, dmax, prepass } = 2, Walk(k) = 3 });
127codec_enum!(Expr { Operand(o) = 0, Neg(e) = 1, Bin(a, op, b) = 2, Pow(base, exponent) = 3 });
128codec_enum!(Cond {
129 Rel { a, op, b, how } = 0,
130 Class { place, test } = 1,
131 Sign { value, test } = 2,
132 Name { subject, values, how } = 3,
133 Not(c) = 4,
134 And(a, b) = 5,
135 Or(a, b) = 6,
136 Counter(t) = 7,
137 InTable { index, count } = 8,
138 Sql(test) = 9,
139});
140codec_enum!(Comparand { Operand(o) = 0, Expr { expr, dmax, mode, prepass } = 1 });
141codec_enum!(Compare {
142 PackedPfd = 0,
143 Address = 1,
144 Float = 2,
145 Fixed = 3,
146 National = 4,
147 Alphanumeric = 5,
148 Refused(abend) = 6,
149 References = 7,
150 ZonedBytes { zoned_first } = 8,
151});
152codec_enum!(ByteClass { Packed { signed } = 0, Zoned { signed } = 1, Digits = 2, Alphabetic = 3, AlphabeticLower = 4, AlphabeticUpper = 5 });
153codec_enum!(SignTest { Positive = 0, Negative = 1, Zero = 2 });
154codec_enum!(Count { Fixed(n) = 0, Odo(odo) = 1, Temp(temp) = 2 });
155codec_enum!(SqlTest { Error = 0, NotFound = 1, Warning = 2 });