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