1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
//! Record parsing and handling functionality for `llvm-bitstream`.
/// A convenience alias for the fields of a record.
pub type Fields = Vec<u64>;
/// Represents a single bitstream record.
#[derive(Clone, Debug)]
pub struct Record {
/// The abbreviation ID that was used to parse this record, or `None` if
/// this record was parsed from an `UNABBREV_RECORD` encoding.
pub abbrev_id: Option<u64>,
/// The code that identifies the record's kind.
pub code: u64,
/// The fields of this record.
pub fields: Fields,
}
impl Record {
/// Creates a new `Record` from the given code and fields.
pub fn from_unabbrev(code: u64, fields: Fields) -> Self {
Self {
abbrev_id: None,
code: code,
fields: fields,
}
}
/// Creates a new `Record` from the given abbreviation ID, code, and fields.
pub fn from_abbrev(abbrev_id: u64, code: u64, fields: Fields) -> Self {
Self {
abbrev_id: Some(abbrev_id),
code: code,
fields: fields,
}
}
}
/// Represents a single block scope in the bitstream.
#[derive(Debug)]
pub struct Block {
/// The ID of the block.
pub block_id: u64,
/// The length of the block, in bytes. Blocks are always 32-bit-word-aligned.
pub len: u64,
}