Line data Source code
1 : use lief_ffi as ffi;
2 :
3 : use crate::common::FromFFI;
4 :
5 : use super::Operand;
6 :
7 : /// This structure represents an immediate operand.
8 : ///
9 : /// For instance:
10 : ///
11 : /// ```text
12 : /// mov x0, #8;
13 : /// |
14 : /// +---> Immediate(8)
15 : /// ```
16 : pub struct Immediate {
17 : ptr: cxx::UniquePtr<ffi::asm_aarch64_operands_Immediate>,
18 : }
19 :
20 : impl FromFFI<ffi::asm_aarch64_operands_Immediate> for Immediate {
21 0 : fn from_ffi(ptr: cxx::UniquePtr<ffi::asm_aarch64_operands_Immediate>) -> Self {
22 0 : Self { ptr }
23 0 : }
24 : }
25 :
26 : impl Operand for Immediate {
27 : #[doc(hidden)]
28 0 : fn as_generic(&self) -> &ffi::asm_aarch64_Operand {
29 0 : self.ptr.as_ref().unwrap().as_ref()
30 0 : }
31 : }
32 :
33 : impl Immediate {
34 : /// The constant value wrapped by this operand
35 0 : pub fn value(&self) -> i64 {
36 0 : self.ptr.value()
37 0 : }
38 : }
|