1use super::{AbendId, CondId, ConstId, ExprId, FunctionId, Mode, Odo, PlaceId, TempId};
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}
16
17#[derive(Clone, Debug, PartialEq, Eq)]
18pub enum Const {
19 Bytes(Vec<u8>),
20 National(Vec<u8>),
21 Number(Fixed),
22 Figurative(Figurative),
23 All(Vec<u8>),
24}
25
26#[derive(Clone, Debug, PartialEq, Eq)]
29pub enum IntExpr {
30 Const(i64),
31 Item(PlaceId),
32 Fixed { expr: ExprId, dmax: u32, prepass: Vec<PlaceId> },
33}
34
35#[derive(Clone, Debug, PartialEq, Eq)]
36pub enum Expr {
37 Operand(Operand),
38 Neg(ExprId),
39 Bin(ExprId, BinOp, ExprId),
40 Pow(ExprId, IntExpr),
42}
43
44#[derive(Clone, Debug, PartialEq, Eq)]
45pub enum Cond {
46 Rel { a: Comparand, op: RelOp, b: Comparand, how: Compare },
47 Class { place: PlaceId, test: ByteClass },
48 Sign { value: Comparand, test: SignTest },
49 Name { subject: PlaceId, values: Vec<(ConstId, Option<ConstId>)>, how: Compare },
51 Not(CondId),
52 And(CondId, CondId),
53 Or(CondId, CondId),
54 Counter(TempId),
55 InTable { index: PlaceId, count: Count },
56 Sql(SqlTest),
57}
58
59#[derive(Clone, Debug, PartialEq, Eq)]
62pub enum Comparand {
63 Operand(Operand),
64 Expr { expr: ExprId, dmax: u32, mode: Mode, prepass: Vec<PlaceId> },
65}
66
67#[derive(Clone, Copy, Debug, PartialEq, Eq)]
68pub enum Compare {
69 PackedPfd,
70 Address,
71 Float,
72 Fixed,
73 National,
74 Alphanumeric,
75 Refused(AbendId),
76 References,
79}
80
81#[derive(Clone, Copy, Debug, PartialEq, Eq)]
82pub enum ByteClass {
83 Packed { signed: bool },
84 Zoned { signed: bool },
85 Digits,
86 Alphabetic,
87}
88
89#[derive(Clone, Copy, Debug, PartialEq, Eq)]
90pub enum SignTest {
91 Positive,
92 Negative,
93 Zero,
94}
95
96#[derive(Clone, Debug, PartialEq, Eq)]
97pub enum Count {
98 Fixed(u32),
99 Odo(Odo),
100}
101
102#[derive(Clone, Copy, Debug, PartialEq, Eq)]
104pub enum SqlTest {
105 Error,
106 NotFound,
107 Warning,
108}
109
110codec_enum!(Operand { Load(place) = 0, Const(id) = 1, LengthOf(place) = 2, AddressOf(place) = 3, Function(id) = 4 });
111codec_enum!(Const { Bytes(b) = 0, National(n) = 1, Number(f) = 2, Figurative(f) = 3, All(b) = 4 });
112codec_enum!(IntExpr { Const(n) = 0, Item(place) = 1, Fixed { expr, dmax, prepass } = 2 });
113codec_enum!(Expr { Operand(o) = 0, Neg(e) = 1, Bin(a, op, b) = 2, Pow(base, exponent) = 3 });
114codec_enum!(Cond {
115 Rel { a, op, b, how } = 0,
116 Class { place, test } = 1,
117 Sign { value, test } = 2,
118 Name { subject, values, how } = 3,
119 Not(c) = 4,
120 And(a, b) = 5,
121 Or(a, b) = 6,
122 Counter(t) = 7,
123 InTable { index, count } = 8,
124 Sql(test) = 9,
125});
126codec_enum!(Comparand { Operand(o) = 0, Expr { expr, dmax, mode, prepass } = 1 });
127codec_enum!(Compare {
128 PackedPfd = 0,
129 Address = 1,
130 Float = 2,
131 Fixed = 3,
132 National = 4,
133 Alphanumeric = 5,
134 Refused(abend) = 6,
135 References = 7,
136});
137codec_enum!(ByteClass { Packed { signed } = 0, Zoned { signed } = 1, Digits = 2, Alphabetic = 3 });
138codec_enum!(SignTest { Positive = 0, Negative = 1, Zero = 2 });
139codec_enum!(Count { Fixed(n) = 0, Odo(odo) = 1 });
140codec_enum!(SqlTest { Error = 0, NotFound = 1, Warning = 2 });