pub mod error;
pub mod expression;
pub mod instruction;
pub mod register;
pub mod space;
pub mod statement;
pub use error::{PcodeError, PcodeErrorTy, PcodeResult};
pub use expression::{
BinaryOperator, Binop, Builtin, Expression, ExpressionTy, Ident, Load, LocalVarId,
LocalVarInterner, Range, RangeParam, SpaceRef as PcodeSpaceRef, UnaryOperator, Unop,
pretty_print_ident,
};
pub use instruction::{
BitRangeInfo, BodyWidths, InstructionPcode, LabelId, LocalSizes, Opcode, PcodeLowerError,
PcodeLoweringContext, PcodeOp, PcodePlan, PcodeSink, SymbolicWidth, Varnode, Width,
emit_instruction, infer_local_sizes, lower_instruction, lower_instruction_into,
plan_instruction, plan_instruction_with, resolve_body_widths,
};
pub use register::{Register, RegisterId, RegisterMutRef, RegisterRef};
pub use space::{SPACE_CONST, Space, SpaceId, SpaceRef, SpaceStore, SpaceType};
pub use statement::{Ast, AstNode, DelaySlotArg, LabelOrNode};
use jstd::Identifier;
#[derive(Identifier)]
pub struct PCodeOpId(usize);
#[derive(Identifier)]
pub struct FieldId(usize);
#[derive(Identifier)]
pub struct TableId(usize);
#[derive(Identifier)]
pub struct PMacroId(usize);
#[derive(Identifier)]
pub struct BitRangeFieldId(usize);
#[derive(Debug, Clone, PartialEq, Eq, Default, serde::Serialize, serde::Deserialize)]
pub struct PcodeAst {
pub statements: Vec<Ast>,
}
impl PcodeAst {
pub fn pretty_print(&self, resolver: &impl PcodeResolver) -> String {
self.statements
.iter()
.map(|statement| statement.pretty_print(resolver))
.collect::<Vec<_>>()
.join("\n")
}
}
pub trait PcodeResolver {
fn ident_name(&self, ident: &Ident) -> String;
fn field_name(&self, id: FieldId) -> String;
fn space_name(&self, id: SpaceId) -> String;
fn pcode_op_name(&self, id: PCodeOpId) -> String;
fn macro_name(&self, id: PMacroId) -> String;
}