LCOV - code coverage report
Current view: top level - src/dwarf/types - base.rs (source / functions) Coverage Total Hit
Test: lief.lcov Lines: 0.0 % 37 0
Test Date: 2026-04-12:00:00:00 Functions: 0.0 % 9 0

            Line data    Source code
       1              : use lief_ffi as ffi;
       2              : 
       3              : use crate::common::FromFFI;
       4              : use crate::dwarf::types::DwarfType;
       5              : use std::marker::PhantomData;
       6              : 
       7              : /// This class wraps the `DW_TAG_base_type` type which can be used -- for
       8              : /// instance -- to represent integers or primitive types.
       9              : pub struct Base<'a> {
      10              :     ptr: cxx::UniquePtr<ffi::DWARF_types_Base>,
      11              :     _owner: PhantomData<&'a ()>,
      12              : }
      13              : 
      14              : #[allow(non_camel_case_types)]
      15            0 : #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
      16              : pub enum Encoding {
      17              :     NONE,
      18              : 
      19              :     /// Mirror `DW_ATE_signed`
      20              :     SIGNED,
      21              : 
      22              :     /// Mirror `DW_ATE_signed_char`
      23              :     SIGNED_CHAR,
      24              : 
      25              :     /// Mirror `DW_ATE_unsigned`
      26              :     UNSIGNED,
      27              : 
      28              :     /// Mirror `DW_ATE_unsigned_char`
      29              :     UNSIGNED_CHAR,
      30              : 
      31              :     /// Mirror `DW_ATE_float`
      32              :     FLOAT,
      33              : 
      34              :     /// Mirror `DW_ATE_boolean`
      35              :     BOOLEAN,
      36              : 
      37              :     /// Mirror `DW_ATE_address`
      38              :     ADDRESS,
      39              : 
      40              :     UNKNOWN(u32),
      41              : }
      42              : 
      43              : impl From<u32> for Encoding {
      44            0 :     fn from(value: u32) -> Self {
      45            0 :         match value {
      46            0 :             0x00000000 => Encoding::NONE,
      47            0 :             0x00000001 => Encoding::SIGNED,
      48            0 :             0x00000002 => Encoding::SIGNED_CHAR,
      49            0 :             0x00000003 => Encoding::UNSIGNED,
      50            0 :             0x00000004 => Encoding::UNSIGNED_CHAR,
      51            0 :             0x00000005 => Encoding::FLOAT,
      52            0 :             0x00000006 => Encoding::BOOLEAN,
      53            0 :             0x00000007 => Encoding::ADDRESS,
      54            0 :             _ => Encoding::UNKNOWN(value),
      55              :         }
      56            0 :     }
      57              : }
      58              : impl From<Encoding> for u32 {
      59            0 :     fn from(value: Encoding) -> u32 {
      60            0 :         match value {
      61            0 :             Encoding::NONE => 0x00000000,
      62            0 :             Encoding::SIGNED => 0x00000001,
      63            0 :             Encoding::SIGNED_CHAR => 0x00000002,
      64            0 :             Encoding::UNSIGNED => 0x00000003,
      65            0 :             Encoding::UNSIGNED_CHAR => 0x00000004,
      66            0 :             Encoding::FLOAT => 0x00000005,
      67            0 :             Encoding::BOOLEAN => 0x00000006,
      68            0 :             Encoding::ADDRESS => 0x00000007,
      69            0 :             Encoding::UNKNOWN(_) => 0,
      70              :         }
      71            0 :     }
      72              : }
      73              : 
      74              : impl FromFFI<ffi::DWARF_types_Base> for Base<'_> {
      75            0 :     fn from_ffi(cmd: cxx::UniquePtr<ffi::DWARF_types_Base>) -> Self {
      76            0 :         Self {
      77            0 :             ptr: cmd,
      78            0 :             _owner: PhantomData,
      79            0 :         }
      80            0 :     }
      81              : }
      82              : 
      83              : impl Base<'_> {
      84              :     /// Describe how the base type is encoded and should be interpreted
      85            0 :     pub fn encoding(&self) -> Encoding {
      86            0 :         Encoding::from(self.ptr.encoding())
      87            0 :     }
      88              : }
      89              : 
      90              : impl DwarfType for Base<'_> {
      91            0 :     fn get_base(&self) -> &ffi::DWARF_Type {
      92            0 :         self.ptr.as_ref().unwrap().as_ref()
      93            0 :     }
      94              : }
        

Generated by: LCOV version 2.1-1