llvm_bitstream/
record.rs

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