Skip to content

Commit 7e97b22

Browse files
committed
aaaaa
1 parent 8e970c8 commit 7e97b22

File tree

8 files changed

+577
-591
lines changed

8 files changed

+577
-591
lines changed

rust/src/function.rs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub use binaryninjacore_sys::BNHighlightStandardColor as HighlightStandardColor;
4040
use crate::architecture::RegisterId;
4141
use crate::confidence::Conf;
4242
use crate::high_level_il::HighLevelILFunction;
43+
use crate::language_representation::CoreLanguageRepresentationFunction;
4344
use crate::low_level_il::{LiftedILFunction, RegularLowLevelILFunction};
4445
use crate::medium_level_il::MediumLevelILFunction;
4546
use crate::variable::{
@@ -467,6 +468,42 @@ impl Function {
467468
}
468469
}
469470

471+
/// Get the language representation of the function.
472+
///
473+
/// * `language` - The language representation, ex. "Pseudo C".
474+
pub fn language_representation<S: BnStrCompatible>(
475+
&self,
476+
language: S,
477+
) -> Option<Ref<CoreLanguageRepresentationFunction>> {
478+
let lang_name = language.into_bytes_with_nul();
479+
let repr = unsafe {
480+
BNGetFunctionLanguageRepresentation(
481+
self.handle,
482+
lang_name.as_ref().as_ptr() as *const c_char,
483+
)
484+
};
485+
NonNull::new(repr)
486+
.map(|handle| unsafe { CoreLanguageRepresentationFunction::ref_from_raw(handle) })
487+
}
488+
489+
/// Get the language representation of the function, if available.
490+
///
491+
/// * `language` - The language representation, ex. "Pseudo C".
492+
pub fn language_representation_if_available<S: BnStrCompatible>(
493+
&self,
494+
language: S,
495+
) -> Option<Ref<CoreLanguageRepresentationFunction>> {
496+
let lang_name = language.into_bytes_with_nul();
497+
let repr = unsafe {
498+
BNGetFunctionLanguageRepresentationIfAvailable(
499+
self.handle,
500+
lang_name.as_ref().as_ptr() as *const c_char,
501+
)
502+
};
503+
NonNull::new(repr)
504+
.map(|handle| unsafe { CoreLanguageRepresentationFunction::ref_from_raw(handle) })
505+
}
506+
470507
pub fn high_level_il(&self, full_ast: bool) -> Result<Ref<HighLevelILFunction>, ()> {
471508
unsafe {
472509
let hlil_ptr = BNGetFunctionHighLevelIL(self.handle);

0 commit comments

Comments
 (0)