LIEF: Library to Instrument Executable Formats Version 1.0.0
Loading...
Searching...
No Matches
Parameter.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2026 R. Thomas
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15#ifndef LIEF_DWARF_PARAMETER_H
16#define LIEF_DWARF_PARAMETER_H
17
18#include "LIEF/visibility.h"
19
20#include <memory>
21#include <string>
22#include <cstdint>
23
24namespace LIEF {
25namespace dwarf {
26
27class Type;
28
29namespace details {
30class Parameter;
31}
32
38 public:
39 enum class KIND {
40 UNKNOWN = 0,
41 TEMPLATE_TYPE,
42 TEMPLATE_VALUE,
43 FORMAL,
44 };
45
48 public:
49 enum class Type : uint8_t {
50 UNKNOWN = 0,
51 REG,
52 };
54 type(ty) {}
55
56 template<class T>
57 const T* as() const {
58 if (T::classof(this)) {
59 return static_cast<const T*>(this);
60 }
61 return nullptr;
62 }
63
65 };
66
68 class LIEF_API RegisterLoc : public Location {
69 public:
70 RegisterLoc(uint64_t reg_id) :
71 Location(Type::REG),
72 id(reg_id) {}
73
74 static bool classof(const Location* loc) {
75 return loc->type == Type::REG;
76 }
77
79 uint64_t id = 0;
80 };
81
82 Parameter() = delete;
85 Parameter& operator=(const Parameter&) = delete;
86 Parameter(const Parameter&) = delete;
87
88
89 KIND kind() const;
90
92 std::string name() const;
93
95 std::unique_ptr<Type> type() const;
96
99 std::unique_ptr<Location> location() const;
100
101 template<class T>
102 const T* as() const {
103 if (T::classof(this)) {
104 return static_cast<const T*>(this);
105 }
106 return nullptr;
107 }
108
109 virtual ~Parameter();
110
111 LIEF_LOCAL static std::unique_ptr<Parameter>
112 create(std::unique_ptr<details::Parameter> impl);
113
114 protected:
115 Parameter(std::unique_ptr<details::Parameter> impl);
116 std::unique_ptr<details::Parameter> impl_;
117};
118
119namespace parameters {
120
134class LIEF_API Formal : public Parameter {
135 public:
137 static bool classof(const Parameter* P) {
138 return P->kind() == Parameter::KIND::FORMAL;
139 }
140
141 ~Formal() override = default;
142};
143
144
156 public:
158 static bool classof(const Parameter* P) {
159 return P->kind() == Parameter::KIND::TEMPLATE_VALUE;
160 }
161
162 ~TemplateValue() override = default;
163};
164
176 public:
178 static bool classof(const Parameter* P) {
179 return P->kind() == Parameter::KIND::TEMPLATE_TYPE;
180 }
181
182 ~TemplateType() override = default;
183};
184
185}
186
187}
188}
189#endif
Type
Definition Parameter.hpp:49
@ UNKNOWN
Definition Parameter.hpp:50
@ REG
Definition Parameter.hpp:51
const T * as() const
Definition Parameter.hpp:57
Type type
Definition Parameter.hpp:64
Location(Type ty)
Definition Parameter.hpp:53
static bool classof(const Location *loc)
Definition Parameter.hpp:74
uint64_t id
DWARF id of the register.
Definition Parameter.hpp:79
RegisterLoc(uint64_t reg_id)
Definition Parameter.hpp:70
std::string name() const
Name of the parameter.
Parameter(Parameter &&other)
Parameter & operator=(Parameter &&other)
KIND
Definition Parameter.hpp:39
@ TEMPLATE_VALUE
DW_TAG_template_value_parameter.
Definition Parameter.hpp:42
@ TEMPLATE_TYPE
DW_TAG_template_type_parameter.
Definition Parameter.hpp:41
@ FORMAL
DW_TAG_formal_parameter.
Definition Parameter.hpp:43
static std::unique_ptr< Parameter > create(std::unique_ptr< details::Parameter > impl)
std::unique_ptr< Type > type() const
Type of this parameter.
Parameter(const Parameter &)=delete
std::unique_ptr< Location > location() const
Location of this parameter. For instance it can be a specific register that is not following the call...
const T * as() const
Definition Parameter.hpp:102
Parameter & operator=(const Parameter &)=delete
This class represents a DWARF Type which includes:
Definition DWARF/Type.hpp:65
This class represents a regular function parameter.
Definition Parameter.hpp:134
static bool classof(const Parameter *P)
Definition Parameter.hpp:137
This class represents a template type parameter.
Definition Parameter.hpp:175
static bool classof(const Parameter *P)
Definition Parameter.hpp:178
This class represents a template value parameter.
Definition Parameter.hpp:155
static bool classof(const Parameter *P)
Definition Parameter.hpp:158
Definition DWARF/CompilationUnit.hpp:30
Definition Parameter.hpp:119
Namespace for the DWARF debug format.
Definition DWARF/CompilationUnit.hpp:28
LIEF namespace.
Definition Abstract/Binary.hpp:40
#define LIEF_API
Definition visibility.h:43
#define LIEF_LOCAL
Definition visibility.h:44