summaryrefslogtreecommitdiff
path: root/rust/src/function.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/function.rs')
-rw-r--r--rust/src/function.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/rust/src/function.rs b/rust/src/function.rs
index c1c29873..edde15a7 100644
--- a/rust/src/function.rs
+++ b/rust/src/function.rs
@@ -40,6 +40,7 @@ pub use binaryninjacore_sys::BNHighlightStandardColor as HighlightStandardColor;
use crate::architecture::RegisterId;
use crate::confidence::Conf;
use crate::high_level_il::HighLevelILFunction;
+use crate::language_representation::CoreLanguageRepresentationFunction;
use crate::low_level_il::{LiftedILFunction, RegularLowLevelILFunction};
use crate::medium_level_il::MediumLevelILFunction;
use crate::variable::{
@@ -476,6 +477,42 @@ impl Function {
}
}
+ /// Get the language representation of the function.
+ ///
+ /// * `language` - The language representation, ex. "Pseudo C".
+ pub fn language_representation<S: BnStrCompatible>(
+ &self,
+ language: S,
+ ) -> Option<Ref<CoreLanguageRepresentationFunction>> {
+ let lang_name = language.into_bytes_with_nul();
+ let repr = unsafe {
+ BNGetFunctionLanguageRepresentation(
+ self.handle,
+ lang_name.as_ref().as_ptr() as *const c_char,
+ )
+ };
+ NonNull::new(repr)
+ .map(|handle| unsafe { CoreLanguageRepresentationFunction::ref_from_raw(handle) })
+ }
+
+ /// Get the language representation of the function, if available.
+ ///
+ /// * `language` - The language representation, ex. "Pseudo C".
+ pub fn language_representation_if_available<S: BnStrCompatible>(
+ &self,
+ language: S,
+ ) -> Option<Ref<CoreLanguageRepresentationFunction>> {
+ let lang_name = language.into_bytes_with_nul();
+ let repr = unsafe {
+ BNGetFunctionLanguageRepresentationIfAvailable(
+ self.handle,
+ lang_name.as_ref().as_ptr() as *const c_char,
+ )
+ };
+ NonNull::new(repr)
+ .map(|handle| unsafe { CoreLanguageRepresentationFunction::ref_from_raw(handle) })
+ }
+
pub fn high_level_il(&self, full_ast: bool) -> Result<Ref<HighLevelILFunction>, ()> {
unsafe {
let hlil_ptr = BNGetFunctionHighLevelIL(self.handle);