LIEF: Library to Instrument Executable Formats Version 0.16.0
Loading...
Searching...
No Matches
Parameter.hpp
Go to the documentation of this file.
1/* Copyright 2022 - 2024 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
23namespace LIEF {
24namespace dwarf {
25
26class Type;
27
28namespace details {
29class Parameter;
30}
31class LIEF_API Parameter {
37 public:
38 enum class KIND {
39 UNKNOWN = 0,
40 TEMPLATE_TYPE,
41 TEMPLATE_VALUE,
42 FORMAL,
43 };
44 Parameter() = delete;
45 Parameter(Parameter&& other);
46 Parameter& operator=(Parameter&& other);
47 Parameter& operator=(const Parameter&) = delete;
48 Parameter(const Parameter&) = delete;
49
50 KIND kind() const;
51 std::string name() const;
54 std::unique_ptr<Type> type() const;
57
58 template<class T>
59 const T* as() const {
60 if (T::classof(this)) {
61 return static_cast<const T*>(this);
62 }
63 return nullptr;
64 }
65
66 virtual ~Parameter();
67
68 LIEF_LOCAL static
69 std::unique_ptr<Parameter> create(std::unique_ptr<details::Parameter> impl);
70
71 protected:
72 Parameter(std::unique_ptr<details::Parameter> impl);
73 std::unique_ptr<details::Parameter> impl_;
74};
75
76namespace parameters {
77class LIEF_API Formal : public Parameter {
92 public:
93 using Parameter::Parameter;
94 static bool classof(const Parameter* P) {
95 return P->kind() == Parameter::KIND::FORMAL;
96 }
97
98 ~Formal() override = default;
99};
100
101class LIEF_API TemplateValue : public Parameter {
113 public:
114 using Parameter::Parameter;
115 static bool classof(const Parameter* P) {
116 return P->kind() == Parameter::KIND::TEMPLATE_VALUE;
117 }
118
119 ~TemplateValue() override = default;
120};
121class LIEF_API TemplateType : public Parameter {
133public:
134 using Parameter::Parameter;
135 static bool classof(const Parameter* P) {
136 return P->kind() == Parameter::KIND::TEMPLATE_TYPE;
137 }
138
139 ~TemplateType() override = default;
140};
141
142}
143
144}
145}
146#endif
LIEF::dwarf::Parameter
This class represents a DWARF parameter which can be either:
Definition Parameter.hpp:36
LIEF::dwarf::Parameter::name
std::string name() const
Name of the parameter.
LIEF::dwarf::Parameter::Parameter
Parameter()=delete
LIEF::dwarf::Parameter::Parameter
Parameter(Parameter &&other)
LIEF::dwarf::Parameter::operator=
Parameter & operator=(Parameter &&other)
LIEF::dwarf::Parameter::create
static std::unique_ptr< Parameter > create(std::unique_ptr< details::Parameter > impl)
LIEF::dwarf::Parameter::~Parameter
virtual ~Parameter()
LIEF::dwarf::Parameter::type
std::unique_ptr< Type > type() const
Type of this parameter.
LIEF::dwarf::Parameter::Parameter
Parameter(const Parameter &)=delete
LIEF::dwarf::Parameter::kind
KIND kind() const
LIEF::dwarf::Parameter::as
const T * as() const
Definition Parameter.hpp:59
LIEF::dwarf::Parameter::operator=
Parameter & operator=(const Parameter &)=delete
LIEF::dwarf::Type
This class represents a DWARF Type which includes:
Definition DWARF/Type.hpp:64
LIEF::dwarf::parameters::Formal
This class represents a regular function parameter.
Definition Parameter.hpp:91
LIEF::dwarf::parameters::Formal::classof
static bool classof(const Parameter *P)
Definition Parameter.hpp:94
LIEF::dwarf::parameters::Formal::~Formal
~Formal() override=default
LIEF::dwarf::parameters::TemplateType
This class represents a template type parameter.
Definition Parameter.hpp:132
LIEF::dwarf::parameters::TemplateType::~TemplateType
~TemplateType() override=default
LIEF::dwarf::parameters::TemplateType::classof
static bool classof(const Parameter *P)
Definition Parameter.hpp:135
LIEF::dwarf::parameters::TemplateValue
This class represents a template value parameter.
Definition Parameter.hpp:112
LIEF::dwarf::parameters::TemplateValue::~TemplateValue
~TemplateValue() override=default
LIEF::dwarf::parameters::TemplateValue::classof
static bool classof(const Parameter *P)
Definition Parameter.hpp:115
LIEF::dwarf::details
Definition DWARF/CompilationUnit.hpp:30
LIEF::dwarf::parameters
Definition Parameter.hpp:76
LIEF::dwarf
Namespace for the DWARF debug format.
Definition DWARF/CompilationUnit.hpp:28
LIEF
LIEF namespace.
Definition Abstract/Binary.hpp:36
visibility.h
LIEF_API
#define LIEF_API
Definition visibility.h:41
LIEF_LOCAL
#define LIEF_LOCAL
Definition visibility.h:42