pub struct Parsed {
    pub consts: Consts,
    pub resources: Vec<Resource>,
    pub functions: Vec<Function>,
    pub structs: Vec<Struct>,
    pub flags: Vec<Flag>,
    /* private fields */
}
Expand description

Final output object after parsing all files.

Fields§

§consts: Consts§resources: Vec<Resource>§functions: Vec<Function>§structs: Vec<Struct>§flags: Vec<Flag>

Implementations§

source§

impl Parsed

source

pub fn new(consts: Consts, stmts: Vec<Statement>) -> Result<Self, Error>

Construct a new Parsed object

source

pub fn includes(&self) -> Iter<'_, Include>

source

pub fn aliases(&self) -> Iter<'_, TypeAlias>

source

pub fn templates(&self) -> Iter<'_, TypeRaw>

source

pub fn resources(&self) -> Iter<'_, Resource>

source

pub fn functions(&self) -> Iter<'_, Function>

source

pub fn structs(&self) -> Iter<'_, Struct>

source

pub fn unions(&self) -> Iter<'_, Union>

source

pub fn flags(&self) -> Iter<'_, Flag>

source

pub fn defines(&self) -> Iter<'_, Define>

source

pub fn consts(&self) -> &Consts

source

pub fn consts_mut(&mut self) -> &mut Consts

source

pub fn identifier_to_ident_type(&self, ident: &Identifier) -> Option<&IdentType>

Figure out which IdentType a certain identifier has.

source

pub fn name_to_ident_type(&self, name: &str) -> Option<&IdentType>

Figure out which IdentType a certain identifier has.

source

pub fn get_flag(&self, ident: &Identifier) -> Option<&Flag>

source

pub fn get_struct(&self, ident: &Identifier) -> Option<&Struct>

source

pub fn get_union(&self, ident: &Identifier) -> Option<&Union>

source

pub fn get_resource(&self, ident: &Identifier) -> Option<&Resource>

source

pub fn get_function(&self, ident: &Identifier) -> Option<&Function>

source

pub fn get_named_struct<I: Into<Identifier>>(&self, name: I) -> Option<&Struct>

source

pub fn get_named_union<I: Into<Identifier>>(&self, name: I) -> Option<&Union>

source

pub fn get_named_resource<I: Into<Identifier>>( &self, name: I ) -> Option<&Resource>

source

pub fn get_named_function<I: Into<Identifier>>( &self, name: I ) -> Option<&Function>

source

pub fn resource_to_basics(&self, ident: &Identifier) -> Vec<ArgType>

source

pub fn resource_to_basic_type(&self, ident: &Identifier) -> Option<ArgType>

Find out the underlying basic type of some resource.

source

pub fn remove_virtual_functions(&mut self)

Remove all functions defined as virtual

source

pub fn remove_func_no_sysno(&mut self, arch: &Arch)

source

pub fn remove_subfunctions(&mut self)

source

pub fn remove_aliases(&mut self)

source

pub fn remove_templates(&mut self)

source

pub fn remove_defines(&mut self)

source

pub fn remove_unions(&mut self)

source

pub fn remove_structs(&mut self)

source

pub fn insert_builtin(&mut self) -> Result<(), Error>

Insert builtin aliases and templates.

This is necessary, if one uses data from Syzkaller and want to call Self::postprocess.

source

pub fn simplify_and_fix(&mut self) -> Result<usize, Error>

Simplify / correct statements since there can be some ambiguity when parsing.

If for instance, we see some_id[...], we don’t really know what some_id refers to and therefore don’t know how to parse the contents in brackets.

source

pub fn process_aliases(&mut self) -> Result<usize, Error>

Parse and replace all aliases.

source

pub fn process_templates(&mut self) -> Result<usize, Error>

Unpack templates and create the necessary entities specific for the configured template.

This step may create new entities, so previous postproceccing may need to be redone based on this. Since this unpacks templates, the size of the data will increase. On Linux, it goes from about 8MB of JSON to 14MB of JSON.

source

pub fn postprocess(&mut self) -> Result<usize, Error>

Perform post-processing on all the defined statements.

This function does 3 different things in a loop until there is nothing more to do:

  1. Self::simplify_and_fix
  2. Self::process_aliases
  3. Self::process_templates

The function returns the number of items replaced

source

pub fn clear_unneeded(&mut self) -> Result<(), Error>

Is post-processing has been done, we can remove various aliases and temporary structures we don’t need.

source

pub fn unpack_template( tmpl: &TypeRaw, args: &Vec<Token> ) -> Result<Vec<Token>, Error>

Unpack a template with the given arguments and return a new token vector.

The returning vector can be passed to Statement::from_tokens to get one or more new statements.

Trait Implementations§

source§

impl Clone for Parsed

source§

fn clone(&self) -> Parsed

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Parsed

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Parsed

source§

fn default() -> Parsed

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Parsed

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Serialize for Parsed

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,