retdec
itanium_ast_ctypes_parser.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_ITANIUM_AST_CTYPES_PARSER_H
8 #define RETDEC_ITANIUM_AST_CTYPES_PARSER_H
9 
11 
12 namespace llvm {
13 namespace itanium_demangle {
14 class FunctionEncoding;
15 class FunctionType;
16 class NameType;
17 class NodeArray;
18 class Node;
19 class PointerType;
20 class ReferenceType;
21 class ArrayType;
22 class NodeOrString;
23 }
24 }
25 
26 namespace retdec {
27 namespace demangler {
28 
29 /*
30  * @brief Parser for AST created in Itanium demangler to ctypes parsers.
31  */
33 {
34 public:
36 
37  std::shared_ptr<ctypes::Function> parseAsFunction(
38  const std::string &name,
39  const llvm::itanium_demangle::Node *ast,
40  std::unique_ptr<ctypes::Module> &module,
41  const TypeWidths &typeWidths = {},
42  const TypeSignedness &typeSignedness = {},
43  unsigned defaultBitWidth = 0);
44 
45 private:
46  std::shared_ptr<ctypes::Function> parseFunction(
47  const std::string &mangledName, const llvm::itanium_demangle::FunctionEncoding *functionEncodingNode);
48 
50  llvm::itanium_demangle::NodeArray node, bool &isVarArg);
51 
52  std::shared_ptr<ctypes::Type> parseType(
53  const llvm::itanium_demangle::Node *typeNode);
54 
55  std::shared_ptr<ctypes::IntegralType> parseIntegralType(
56  const std::string &name);
57 
58  std::shared_ptr<ctypes::FloatingPointType> parseFloatingPointType(
59  const std::string &name);
60 
61  std::shared_ptr<ctypes::PointerType> parsePointer(
62  const llvm::itanium_demangle::PointerType *typeNode);
63 
64  std::shared_ptr<ctypes::Type> parseReference(
65  const llvm::itanium_demangle::ReferenceType *typeNode);
66 
67  std::shared_ptr<ctypes::Type> parseNameTypeNode(
68  const llvm::itanium_demangle::NameType *typeNode);
69 
70  std::shared_ptr<ctypes::ArrayType> parseArrayType(
71  const llvm::itanium_demangle::ArrayType *typeNode);
72 
73  unsigned parseDimension(
74  const llvm::itanium_demangle::NodeOrString *dimensions);
75 
76  std::shared_ptr<ctypes::FunctionType> parseFuntionType(
77  const llvm::itanium_demangle::FunctionType *typeNode);
78 
80  llvm::itanium_demangle::NodeArray parameters,
81  bool &isVarArg);
82 };
83 
84 } // demangler
85 } // retdec
86 
87 #endif //RETDEC_ITANIUM_AST_CTYPES_PARSER_H
Base class for all AST to ctypes parsers.
std::vector< std::shared_ptr< Type > > Parameters
Definition: function_type.h:28
std::vector< Parameter > Parameters
Definition: function.h:32
std::map< std::string, ctypes::IntegralType::Signess > TypeSignedness
Set container for C-types' signedness.
Definition: ctypes_parser.h:30
unsigned defaultBitWidth
Bitwidth used for types not in typeWidths.
Definition: ctypes_parser.h:47
std::map< std::string, unsigned > TypeWidths
Set container for C-types' bit width.
Definition: ctypes_parser.h:28
TypeSignedness typeSignedness
C-types' signedness.
Definition: ctypes_parser.h:45
TypeWidths typeWidths
C-types' bit widths.
Definition: ctypes_parser.h:43
Definition: ast_ctypes_parser.h:18
Definition: itanium_ast_ctypes_parser.h:33
ctypes::FunctionType::Parameters parseFuncTypeParameters(llvm::itanium_demangle::NodeArray parameters, bool &isVarArg)
Definition: itanium_ast_ctypes_parser.cpp:329
unsigned parseDimension(const llvm::itanium_demangle::NodeOrString *dimensions)
Definition: itanium_ast_ctypes_parser.cpp:291
std::shared_ptr< ctypes::Type > parseReference(const llvm::itanium_demangle::ReferenceType *typeNode)
Definition: itanium_ast_ctypes_parser.cpp:197
std::shared_ptr< ctypes::ArrayType > parseArrayType(const llvm::itanium_demangle::ArrayType *typeNode)
Definition: itanium_ast_ctypes_parser.cpp:270
std::shared_ptr< ctypes::Function > parseFunction(const std::string &mangledName, const llvm::itanium_demangle::FunctionEncoding *functionEncodingNode)
Definition: itanium_ast_ctypes_parser.cpp:85
std::shared_ptr< ctypes::PointerType > parsePointer(const llvm::itanium_demangle::PointerType *typeNode)
Definition: itanium_ast_ctypes_parser.cpp:186
std::shared_ptr< ctypes::FunctionType > parseFuntionType(const llvm::itanium_demangle::FunctionType *typeNode)
Definition: itanium_ast_ctypes_parser.cpp:316
std::shared_ptr< ctypes::IntegralType > parseIntegralType(const std::string &name)
Definition: itanium_ast_ctypes_parser.cpp:166
std::shared_ptr< ctypes::Type > parseType(const llvm::itanium_demangle::Node *typeNode)
Definition: itanium_ast_ctypes_parser.cpp:128
std::shared_ptr< ctypes::FloatingPointType > parseFloatingPointType(const std::string &name)
Definition: itanium_ast_ctypes_parser.cpp:176
ctypes::Function::Parameters parseFunctionParameters(llvm::itanium_demangle::NodeArray node, bool &isVarArg)
Definition: itanium_ast_ctypes_parser.cpp:106
std::shared_ptr< ctypes::Function > parseAsFunction(const std::string &name, const llvm::itanium_demangle::Node *ast, std::unique_ptr< ctypes::Module > &module, const TypeWidths &typeWidths={}, const TypeSignedness &typeSignedness={}, unsigned defaultBitWidth=0)
Definition: itanium_ast_ctypes_parser.cpp:59
std::shared_ptr< ctypes::Type > parseNameTypeNode(const llvm::itanium_demangle::NameType *typeNode)
Definition: itanium_ast_ctypes_parser.cpp:215
ShPtr< Module > module
The current module.
Definition: hll_writer.cpp:100
Definition: itanium_ast_ctypes_parser.h:12
Definition: archive_wrapper.h:19