Skip to main content

ironwork_rt/lir/
place.rs

1//! Places (lir.md ยง5): data references resolved at lowering, which an executor evaluates to a `Loc`.
2
3use super::{DebugId, IntExpr, SymId, XmlRegister};
4use crate::storage::Kind;
5use crate::{codec_enum, codec_struct};
6
7#[derive(Clone, Debug, PartialEq, Eq)]
8pub struct Place {
9    pub base: Base,
10    pub offset: u32,
11    /// One occurrence, before OCCURS DEPENDING ON and reference modification.
12    pub len: u32,
13    pub kind: Kind,
14    /// PICTURE P positions right of the item's digits: its value is its digits times ten to this.
15    pub scaling: u32,
16    /// One per OCCURS level, outermost first.
17    pub subscripts: Vec<Subscript>,
18    pub odo: Option<Odo>,
19    pub refmod: Option<RefMod>,
20    pub name: SymId,
21    pub at: DebugId,
22}
23
24#[derive(Clone, Copy, Debug, PartialEq, Eq)]
25pub enum Base {
26    Program,
27    Local,
28    Linkage(u16),
29    /// RETURN-CODE at run-unit offset 0, when the program declares none.
30    ReturnCode,
31    Eib,
32    SelfRef,
33    JniEnv,
34    /// An XML PARSE fragment register, the current event's text: `offset` and `len` are 0 and the
35    /// fragment gives both. Its reference modification is checked whatever `check` says, abending
36    /// IRONWORK "reference modification (s:l) of NAME is outside its N bytes".
37    Xml(XmlRegister),
38}
39
40/// `check` is the occurrence count, present only under SSRANGE.
41#[derive(Clone, Debug, PartialEq, Eq)]
42pub struct Subscript {
43    pub stride: u32,
44    pub value: IntExpr,
45    pub check: Option<u32>,
46}
47
48#[derive(Clone, Debug, PartialEq, Eq)]
49pub struct Odo {
50    pub object: IntExpr,
51    pub max: u32,
52    pub element: u32,
53    pub check: bool,
54}
55
56/// Start and length count character positions: two bytes each when the place's kind is national.
57#[derive(Clone, Debug, PartialEq, Eq)]
58pub struct RefMod {
59    pub start: IntExpr,
60    pub length: Option<IntExpr>,
61    pub check: bool,
62}
63
64codec_struct!(Place { base, offset, len, kind, scaling, subscripts, odo, refmod, name, at });
65codec_enum!(Base {
66    Program = 0,
67    Local = 1,
68    Linkage(record) = 2,
69    ReturnCode = 3,
70    Eib = 4,
71    SelfRef = 5,
72    JniEnv = 6,
73    Xml(register) = 7,
74});
75codec_struct!(Subscript { stride, value, check });
76codec_struct!(Odo { object, max, element, check });
77codec_struct!(RefMod { start, length, check });