use super::{
AbendId, ArithId, BlockId, CallId, CicsId, CondId, DebugId, DisplayId, ExprId, FileOpId, InitId, InspectId, IntExpr,
InvokeId, MovePlan, Operand, ParaId, PlaceId, RangeId, ReleaseId, ReportOp, ReturnId, SearchAllId, SortId, SqlId,
StepPlan, StringId, TempId, UnstringId,
};
use crate::abend::Ending;
use crate::vocab::AcceptFrom;
use crate::{codec_enum, codec_struct};
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Op {
Move { from: Operand, to: PlaceId, plan: MovePlan },
Initialize { target: PlaceId, plan: InitId },
Arith(ArithId),
SetAddress { record: u16, address: Operand },
SetUpDown { target: PlaceId, by: IntExpr, down: bool, plan: StepPlan },
Step { var: PlaceId, by: ExprId, plan: StepPlan, prepass: Vec<PlaceId> },
SetInt { target: PlaceId, value: IntExpr },
Inspect(InspectId),
String(StringId),
Unstring(UnstringId),
SearchAll(SearchAllId),
Nest,
Unnest(u8),
SetTemp(TempId, IntExpr),
DecTemp(TempId),
Display(DisplayId),
Accept { target: PlaceId, from: AcceptFrom, plan: MovePlan },
File(FileOpId),
Call(CallId),
Cancel(Operand),
Sort(SortId),
Release(ReleaseId),
Return(ReturnId),
Report(ReportOp),
Invoke(InvokeId),
Cics(CicsId),
Sql(SqlId),
Alter { para: ParaId, to: ParaId },
EnterSegment(u8),
SetSegment(u8),
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Step {
Next,
Arm(u8),
GoTo(ParaId),
End(Ending),
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Terminator {
Jump(BlockId),
Branch { cond: CondId, then: BlockId, otherwise: BlockId },
Select(Vec<BlockId>),
ParagraphEnd { next: ParaId },
GoTo(ParaId),
Switch { value: IntExpr, targets: Vec<ParaId>, otherwise: BlockId },
PerformEnter { range: RangeId, ret: BlockId },
ExitProgram { next: BlockId },
End(Ending),
Abend(AbendId),
AlteredGoTo { para: ParaId, otherwise: BlockId },
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Range {
pub first: ParaId,
pub last: ParaId,
pub kind: RangeKind,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum RangeKind {
Perform,
SortProcedure,
UseBeforeReporting,
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Frame {
pub first: ParaId,
pub last: ParaId,
pub kind: FrameKind,
pub ret: BlockId,
pub depth: u32,
pub temps: Vec<i64>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FrameKind {
Main,
Perform,
SortProcedure,
UseBeforeReporting { at: DebugId },
}
codec_enum!(Op {
Move { from, to, plan } = 0,
Initialize { target, plan } = 1,
Arith(id) = 2,
SetAddress { record, address } = 3,
SetUpDown { target, by, down, plan } = 4,
Step { var, by, plan, prepass } = 5,
SetInt { target, value } = 6,
Inspect(id) = 7,
String(id) = 8,
Unstring(id) = 9,
SearchAll(id) = 10,
Nest = 11,
Unnest(n) = 12,
SetTemp(temp, value) = 13,
DecTemp(temp) = 14,
Display(id) = 15,
Accept { target, from, plan } = 16,
File(id) = 17,
Call(id) = 18,
Cancel(name) = 19,
Sort(id) = 20,
Release(id) = 21,
Return(id) = 22,
Report(op) = 23,
Invoke(id) = 24,
Cics(id) = 25,
Sql(id) = 26,
Alter { para, to } = 27,
EnterSegment(priority) = 28,
SetSegment(priority) = 29,
});
codec_enum!(Step { Next = 0, Arm(arm) = 1, GoTo(para) = 2, End(ending) = 3 });
codec_enum!(Terminator {
Jump(block) = 0,
Branch { cond, then, otherwise } = 1,
Select(arms) = 2,
ParagraphEnd { next } = 3,
GoTo(para) = 4,
Switch { value, targets, otherwise } = 5,
PerformEnter { range, ret } = 6,
ExitProgram { next } = 7,
End(ending) = 8,
Abend(abend) = 9,
AlteredGoTo { para, otherwise } = 10,
});
codec_struct!(Range { first, last, kind });
codec_enum!(RangeKind { Perform = 0, SortProcedure = 1, UseBeforeReporting = 2 });
codec_struct!(Frame { first, last, kind, ret, depth, temps });
codec_enum!(FrameKind { Main = 0, Perform = 1, SortProcedure = 2, UseBeforeReporting { at } = 3 });