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 AllNational(Vec<u8>),
27 Refused(AbendId),
30 Dbcs(Vec<u8>),
32}
33
34#[derive(Clone, Debug, PartialEq, Eq)]
37pub enum IntExpr {
38 Const(i64),
39 Item(PlaceId),
40 Fixed { expr: ExprId, dmax: u32, prepass: Vec<PlaceId> },
41 Walk(u8),
44}
45
46#[derive(Clone, Debug, PartialEq, Eq)]
47pub enum Expr {
48 Operand(Operand),
49 Neg(ExprId),
50 Bin(ExprId, BinOp, ExprId),
51 Pow(ExprId, IntExpr),
53}
54
55#[derive(Clone, Debug, PartialEq, Eq)]
56pub enum Cond {
57 Rel { a: Comparand, op: RelOp, b: Comparand, how: Compare },
58 Class { place: PlaceId, test: ByteClass },
59 Sign { value: Comparand, test: SignTest },
60 Name { subject: PlaceId, values: Vec<(ConstId, Option<ConstId>)>, how: Compare },
62 Not(CondId),
63 And(CondId, CondId),
64 Or(CondId, CondId),
65 Counter(TempId),
66 InTable { index: PlaceId, count: Count },
67 Sql(SqlTest),
68}
69
70#[derive(Clone, Debug, PartialEq, Eq)]
73pub enum Comparand {
74 Operand(Operand),
75 Expr { expr: ExprId, dmax: u32, mode: Mode, prepass: Vec<PlaceId> },
76}
77
78#[derive(Clone, Copy, Debug, PartialEq, Eq)]
79pub enum Compare {
80 PackedPfd,
81 Address,
82 Float,
83 Fixed,
84 National,
85 Alphanumeric,
86 Refused(AbendId),
87 References,
90 ZonedBytes { zoned_first: bool },
93 Dbcs,
96}
97
98#[derive(Clone, Copy, Debug, PartialEq, Eq)]
99pub enum ByteClass {
100 Packed { signed: bool },
101 Zoned { signed: bool },
102 Digits,
103 Alphabetic,
104 AlphabeticLower,
105 AlphabeticUpper,
106 Dbcs,
108 Kanji,
110}
111
112#[derive(Clone, Copy, Debug, PartialEq, Eq)]
113pub enum SignTest {
114 Positive,
115 Negative,
116 Zero,
117}
118
119#[derive(Clone, Debug, PartialEq, Eq)]
120pub enum Count {
121 Fixed(u32),
122 Odo(Odo),
123 Temp(TempId),
125}
126
127#[derive(Clone, Copy, Debug, PartialEq, Eq)]
129pub enum SqlTest {
130 Error,
131 NotFound,
132 Warning,
133}
134
135codec_enum!(Operand { Load(place) = 0, Const(id) = 1, LengthOf(place) = 2, AddressOf(place) = 3, Function(id) = 4, UserFunction(id) = 5 });
136codec_enum!(Const { Bytes(b) = 0, National(n) = 1, Number(f) = 2, Figurative(f) = 3, All(b) = 4, Refused(abend) = 5, AllNational(n) = 6, Dbcs(b) = 7 });
137codec_enum!(IntExpr { Const(n) = 0, Item(place) = 1, Fixed { expr, dmax, prepass } = 2, Walk(k) = 3 });
138codec_enum!(Expr { Operand(o) = 0, Neg(e) = 1, Bin(a, op, b) = 2, Pow(base, exponent) = 3 });
139codec_enum!(Cond {
140 Rel { a, op, b, how } = 0,
141 Class { place, test } = 1,
142 Sign { value, test } = 2,
143 Name { subject, values, how } = 3,
144 Not(c) = 4,
145 And(a, b) = 5,
146 Or(a, b) = 6,
147 Counter(t) = 7,
148 InTable { index, count } = 8,
149 Sql(test) = 9,
150});
151codec_enum!(Comparand { Operand(o) = 0, Expr { expr, dmax, mode, prepass } = 1 });
152codec_enum!(Compare {
153 PackedPfd = 0,
154 Address = 1,
155 Float = 2,
156 Fixed = 3,
157 National = 4,
158 Alphanumeric = 5,
159 Refused(abend) = 6,
160 References = 7,
161 ZonedBytes { zoned_first } = 8,
162 Dbcs = 9,
163});
164codec_enum!(ByteClass { Packed { signed } = 0, Zoned { signed } = 1, Digits = 2, Alphabetic = 3, AlphabeticLower = 4, AlphabeticUpper = 5, Dbcs = 6, Kanji = 7 });
165codec_enum!(SignTest { Positive = 0, Negative = 1, Zero = 2 });
166codec_enum!(Count { Fixed(n) = 0, Odo(odo) = 1, Temp(temp) = 2 });
167codec_enum!(SqlTest { Error = 0, NotFound = 1, Warning = 2 });