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};
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}
33
34/// `check` is the occurrence count, present only under SSRANGE.
35#[derive(Clone, Debug, PartialEq, Eq)]
36pub struct Subscript {
37    pub stride: u32,
38    pub value: IntExpr,
39    pub check: Option<u32>,
40}
41
42#[derive(Clone, Debug, PartialEq, Eq)]
43pub struct Odo {
44    pub object: IntExpr,
45    pub max: u32,
46    pub element: u32,
47    pub check: bool,
48}
49
50#[derive(Clone, Debug, PartialEq, Eq)]
51pub struct RefMod {
52    pub start: IntExpr,
53    pub length: Option<IntExpr>,
54    pub check: bool,
55}
56
57codec_struct!(Place { base, offset, len, kind, subscripts, odo, refmod, name, at });
58codec_enum!(Base {
59    Program = 0,
60    Local = 1,
61    Linkage(record) = 2,
62    ReturnCode = 3,
63    Eib = 4,
64    SelfRef = 5,
65    JniEnv = 6,
66});
67codec_struct!(Subscript { stride, value, check });
68codec_struct!(Odo { object, max, element, check });
69codec_struct!(RefMod { start, length, check });