1pub mod error;
16pub mod expression;
17pub mod instruction;
18pub mod register;
19pub mod space;
20pub mod statement;
21
22pub use error::{PcodeError, PcodeErrorTy, PcodeResult};
23pub use expression::{
24 BinaryOperator, Binop, Builtin, Expression, ExpressionTy, Ident, Load, LocalVarId,
25 LocalVarInterner, Range, RangeParam, SpaceRef as PcodeSpaceRef, UnaryOperator, Unop,
26 pretty_print_ident,
27};
28pub use instruction::{
29 BitRangeInfo, BodyWidths, InstructionPcode, LabelId, LocalSizes, Opcode, PcodeLowerError,
30 PcodeLoweringContext, PcodeOp, PcodePlan, PcodeSink, SymbolicWidth, Varnode, Width,
31 emit_instruction, infer_local_sizes, lower_instruction, lower_instruction_into,
32 plan_instruction, plan_instruction_with, resolve_body_widths,
33};
34pub use register::{Register, RegisterId, RegisterMutRef, RegisterRef};
35pub use space::{SPACE_CONST, Space, SpaceId, SpaceRef, SpaceStore, SpaceType};
36pub use statement::{Ast, AstNode, DelaySlotArg, LabelOrNode};
37
38use jstd::Identifier;
39
40#[derive(Identifier)]
45pub struct PCodeOpId(usize);
46
47#[derive(Identifier)]
49pub struct FieldId(usize);
50#[derive(Identifier)]
52pub struct TableId(usize);
53#[derive(Identifier)]
55pub struct PMacroId(usize);
56#[derive(Identifier)]
58pub struct BitRangeFieldId(usize);
59
60#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
62pub struct PcodeAst {
63 pub statements: Vec<Ast>,
65}
66
67impl PcodeAst {
68 pub fn pretty_print(&self, resolver: &impl PcodeResolver) -> String {
70 self.statements
71 .iter()
72 .map(|statement| statement.pretty_print(resolver))
73 .collect::<Vec<_>>()
74 .join("\n")
75 }
76}
77
78pub trait PcodeResolver {
81 fn ident_name(&self, ident: &Ident) -> String;
83 fn field_name(&self, id: FieldId) -> String;
85 fn space_name(&self, id: SpaceId) -> String;
87 fn pcode_op_name(&self, id: PCodeOpId) -> String;
89 fn macro_name(&self, id: PMacroId) -> String;
91}