6
6
#include < nanobind/stl/unique_ptr.h>
7
7
#include < nanobind/stl/string.h>
8
8
9
+ namespace nanobind ::detail {
10
+ template <> struct type_hook <LIEF::dwarf::Parameter::Location> {
11
+ static const std::type_info* get (const LIEF::dwarf::Parameter::Location *src) {
12
+ using Parameter = LIEF::dwarf::Parameter;
13
+ if (src) {
14
+ if (Parameter::RegisterLoc::classof (src)) {
15
+ return &typeid (Parameter::RegisterLoc);
16
+ }
17
+ }
18
+ return &typeid (Parameter::Location);
19
+ }
20
+ };
21
+ }
22
+
9
23
namespace LIEF ::dwarf::py {
10
24
template <>
11
25
void create<dw::Parameter>(nb::module_& m) {
@@ -18,6 +32,28 @@ void create<dw::Parameter>(nb::module_& m) {
18
32
)doc" _doc
19
33
);
20
34
35
+ using Location = dw::Parameter::Location;
36
+ using RegisterLoc = dw::Parameter::RegisterLoc;
37
+
38
+ nb::class_<Location> loc (param, " Location" ,
39
+ R"doc(
40
+ This class exposes information about the location of a parameter
41
+ )doc" _doc);
42
+
43
+ nb::enum_<dw::Parameter::Location::Type>(loc, " Type" )
44
+ .value (" UNKNOWN" , Location::Type::UNKNOWN)
45
+ .value (" REGISTER" , Location::Type::REG);
46
+
47
+ loc
48
+ .def_ro (" type" , &Location::type);
49
+
50
+ nb::class_<RegisterLoc, Location>(param, " RegisterLoc" ,
51
+ R"doc(
52
+ This class represents a register location
53
+ )doc" _doc)
54
+
55
+ .def_ro (" id" , &RegisterLoc::id, " DWARF id of the register" _doc);
56
+
21
57
param
22
58
.def_prop_ro (" name" , &dw::Parameter::name,
23
59
R"doc(
@@ -30,6 +66,13 @@ void create<dw::Parameter>(nb::module_& m) {
30
66
Type of this parameter
31
67
)doc" _doc
32
68
)
69
+
70
+ .def_prop_ro (" location" , &dw::Parameter::location,
71
+ R"doc(
72
+ Location of this parameter. For instance it can be a specific register
73
+ that is not following the calling convention.
74
+ )doc" _doc
75
+ )
33
76
;
34
77
35
78
nb::module_ m_params = m.def_submodule (" parameters" );
0 commit comments