retdec
borland_ast_ctypes_parser.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_BORLAND_AST_CTYPES_PARSER_H
8 #define RETDEC_BORLAND_AST_CTYPES_PARSER_H
9 
12 
13 namespace retdec {
14 namespace demangler {
15 
16 /*
17  * @brief Parser for AST created in Borland demangler to ctypes parsers.
18  */
20 {
21 public:
22  BorlandToCtypesParser() = default;
23 
24  std::shared_ptr<ctypes::Function> parseAsFunction(
25  const std::string &name,
26  std::shared_ptr<demangler::borland::Node> ast,
27  std::unique_ptr<ctypes::Module> &module,
28  const TypeWidths &typeWidths = {},
29  const TypeSignedness &typeSignedness = {},
30  unsigned defaultBitWidth = 0);
31 
32 private:
33  std::shared_ptr<retdec::ctypes::Function> parseFunction(
34  const std::string &mangledName, std::shared_ptr<demangler::borland::FunctionNode> function);
35 
36  std::shared_ptr<ctypes::Type> parseType(
37  std::shared_ptr<demangler::borland::TypeNode> typeNode);
38 
39  std::shared_ptr<ctypes::IntegralType> parseIntegralType(
40  std::shared_ptr<demangler::borland::IntegralTypeNode> integralNode);
41 
42  std::shared_ptr<ctypes::FloatingPointType> parseFloatingPointType(
43  std::shared_ptr<demangler::borland::FloatTypeNode> floatNode);
44 
45  std::shared_ptr<ctypes::IntegralType> parseCharType(
46  std::shared_ptr<demangler::borland::CharTypeNode> charNode);
47 
48  std::shared_ptr<ctypes::Type> parseBuiltInType(
49  std::shared_ptr<demangler::borland::BuiltInTypeNode> typeNode);
50 
51  std::shared_ptr<ctypes::PointerType> parsePointerType(
52  std::shared_ptr<demangler::borland::PointerTypeNode> pointerNode);
53 
54  std::shared_ptr<ctypes::Type> parseReferenceType(
55  std::shared_ptr<demangler::borland::ReferenceTypeNode> referenceNode);
56 
57  std::shared_ptr<ctypes::Type> parseRReferenceType(
58  std::shared_ptr<demangler::borland::RReferenceTypeNode> referenceNode);
59 
60  std::shared_ptr<ctypes::NamedType> parseNamedType(
61  std::shared_ptr<demangler::borland::NamedTypeNode> namedTypeNode);
62 
64  std::shared_ptr<demangler::borland::NodeArray> paramsNode);
65 
68 
69  std::shared_ptr<ctypes::FunctionType> parsefuncType(
70  std::shared_ptr<demangler::borland::FunctionTypeNode> funcTypeNode);
71 
73  std::shared_ptr<demangler::borland::NodeArray> paramsNode);
74 
75  std::shared_ptr<ctypes::ArrayType> parseArrayType(
76  std::shared_ptr<demangler::borland::ArrayNode> ArrayTypeNode);
77 };
78 
79 } // demangler
80 } // retdec
81 
82 #endif //RETDEC_BORLAND_AST_CTYPES_PARSER_H
Base class for all AST to ctypes parsers.
File to include, when all borland_ast node files are needed.
A representation of a C call convention.
Definition: call_convention.h:19
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: borland_ast_ctypes_parser.h:20
std::shared_ptr< ctypes::ArrayType > parseArrayType(std::shared_ptr< demangler::borland::ArrayNode > ArrayTypeNode)
Definition: borland_ast_ctypes_parser.cpp:322
std::shared_ptr< ctypes::IntegralType > parseCharType(std::shared_ptr< demangler::borland::CharTypeNode > charNode)
Definition: borland_ast_ctypes_parser.cpp:158
std::shared_ptr< ctypes::Type > parseType(std::shared_ptr< demangler::borland::TypeNode > typeNode)
Definition: borland_ast_ctypes_parser.cpp:79
std::shared_ptr< ctypes::PointerType > parsePointerType(std::shared_ptr< demangler::borland::PointerTypeNode > pointerNode)
Definition: borland_ast_ctypes_parser.cpp:199
std::shared_ptr< ctypes::NamedType > parseNamedType(std::shared_ptr< demangler::borland::NamedTypeNode > namedTypeNode)
Definition: borland_ast_ctypes_parser.cpp:248
std::shared_ptr< ctypes::Function > parseAsFunction(const std::string &name, std::shared_ptr< demangler::borland::Node > ast, std::unique_ptr< ctypes::Module > &module, const TypeWidths &typeWidths={}, const TypeSignedness &typeSignedness={}, unsigned defaultBitWidth=0)
Definition: borland_ast_ctypes_parser.cpp:22
ctypes::CallConvention parseCallConvention(demangler::borland::CallConv callConv)
Definition: borland_ast_ctypes_parser.cpp:292
ctypes::Function::Parameters parseFuncParameters(std::shared_ptr< demangler::borland::NodeArray > paramsNode)
Definition: borland_ast_ctypes_parser.cpp:257
std::shared_ptr< ctypes::FloatingPointType > parseFloatingPointType(std::shared_ptr< demangler::borland::FloatTypeNode > floatNode)
Definition: borland_ast_ctypes_parser.cpp:147
std::shared_ptr< ctypes::Type > parseRReferenceType(std::shared_ptr< demangler::borland::RReferenceTypeNode > referenceNode)
Definition: borland_ast_ctypes_parser.cpp:233
std::shared_ptr< retdec::ctypes::Function > parseFunction(const std::string &mangledName, std::shared_ptr< demangler::borland::FunctionNode > function)
Definition: borland_ast_ctypes_parser.cpp:54
std::shared_ptr< ctypes::Type > parseReferenceType(std::shared_ptr< demangler::borland::ReferenceTypeNode > referenceNode)
Definition: borland_ast_ctypes_parser.cpp:216
std::shared_ptr< ctypes::Type > parseBuiltInType(std::shared_ptr< demangler::borland::BuiltInTypeNode > typeNode)
Definition: borland_ast_ctypes_parser.cpp:174
std::shared_ptr< ctypes::IntegralType > parseIntegralType(std::shared_ptr< demangler::borland::IntegralTypeNode > integralNode)
Definition: borland_ast_ctypes_parser.cpp:135
ctypes::FunctionType::Parameters parseFuncTypeParameters(std::shared_ptr< demangler::borland::NodeArray > paramsNode)
Definition: borland_ast_ctypes_parser.cpp:275
std::shared_ptr< ctypes::FunctionType > parsefuncType(std::shared_ptr< demangler::borland::FunctionTypeNode > funcTypeNode)
Definition: borland_ast_ctypes_parser.cpp:308
ShPtr< Module > module
The current module.
Definition: hll_writer.cpp:100
CallConv
Definition: function_type.h:19
Definition: archive_wrapper.h:19