Struct syzlang_parser::parser::Parsed
source · 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
impl Parsed
sourcepub fn new(consts: Consts, stmts: Vec<Statement>) -> Result<Self, Error>
pub fn new(consts: Consts, stmts: Vec<Statement>) -> Result<Self, Error>
Construct a new Parsed object
pub fn includes(&self) -> Iter<'_, Include>
pub fn aliases(&self) -> Iter<'_, TypeAlias>
pub fn templates(&self) -> Iter<'_, TypeRaw>
pub fn resources(&self) -> Iter<'_, Resource>
pub fn functions(&self) -> Iter<'_, Function>
pub fn structs(&self) -> Iter<'_, Struct>
pub fn unions(&self) -> Iter<'_, Union>
pub fn flags(&self) -> Iter<'_, Flag>
pub fn defines(&self) -> Iter<'_, Define>
pub fn consts(&self) -> &Consts
pub fn consts_mut(&mut self) -> &mut Consts
sourcepub fn identifier_to_ident_type(&self, ident: &Identifier) -> Option<&IdentType>
pub fn identifier_to_ident_type(&self, ident: &Identifier) -> Option<&IdentType>
Figure out which IdentType a certain identifier has.
sourcepub fn name_to_ident_type(&self, name: &str) -> Option<&IdentType>
pub fn name_to_ident_type(&self, name: &str) -> Option<&IdentType>
Figure out which IdentType a certain identifier has.
pub fn get_flag(&self, ident: &Identifier) -> Option<&Flag>
pub fn get_struct(&self, ident: &Identifier) -> Option<&Struct>
pub fn get_union(&self, ident: &Identifier) -> Option<&Union>
pub fn get_resource(&self, ident: &Identifier) -> Option<&Resource>
pub fn get_function(&self, ident: &Identifier) -> Option<&Function>
pub fn get_named_struct<I: Into<Identifier>>(&self, name: I) -> Option<&Struct>
pub fn get_named_union<I: Into<Identifier>>(&self, name: I) -> Option<&Union>
pub fn get_named_resource<I: Into<Identifier>>( &self, name: I ) -> Option<&Resource>
pub fn get_named_function<I: Into<Identifier>>( &self, name: I ) -> Option<&Function>
pub fn resource_to_basics(&self, ident: &Identifier) -> Vec<ArgType>
sourcepub fn resource_to_basic_type(&self, ident: &Identifier) -> Option<ArgType>
pub fn resource_to_basic_type(&self, ident: &Identifier) -> Option<ArgType>
Find out the underlying basic type of some resource.
sourcepub fn remove_virtual_functions(&mut self)
pub fn remove_virtual_functions(&mut self)
Remove all functions defined as virtual
pub fn remove_func_no_sysno(&mut self, arch: &Arch)
pub fn remove_subfunctions(&mut self)
pub fn remove_aliases(&mut self)
pub fn remove_templates(&mut self)
pub fn remove_defines(&mut self)
pub fn remove_unions(&mut self)
pub fn remove_structs(&mut self)
sourcepub fn insert_builtin(&mut self) -> Result<(), Error>
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.
sourcepub fn simplify_and_fix(&mut self) -> Result<usize, Error>
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.
sourcepub fn process_aliases(&mut self) -> Result<usize, Error>
pub fn process_aliases(&mut self) -> Result<usize, Error>
Parse and replace all aliases.
sourcepub fn process_templates(&mut self) -> Result<usize, Error>
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.
sourcepub fn postprocess(&mut self) -> Result<usize, Error>
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:
The function returns the number of items replaced
sourcepub fn clear_unneeded(&mut self) -> Result<(), Error>
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.
sourcepub fn unpack_template(
tmpl: &TypeRaw,
args: &Vec<Token>
) -> Result<Vec<Token>, Error>
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.