Parses name mangled by borland mangling scheme into AST.
More...
#include <borland_ast_parser.h>
Parses name mangled by borland mangling scheme into AST.
◆ Status
Enumerator |
---|
success | |
init | |
in_progress | |
invalid_mangled_name | |
unknown_error | |
◆ BorlandASTParser()
retdec::demangler::borland::BorlandASTParser::BorlandASTParser |
( |
Context & |
context | ) |
|
|
explicit |
Constructor for AST parser. Immediately parses name mangled by borland mangling scheme into AST.
- Parameters
-
◆ ast()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::ast |
( |
| ) |
|
- Returns
- Shared pointer to AST.
◆ checkResult()
bool retdec::demangler::borland::BorlandASTParser::checkResult |
( |
std::shared_ptr< Node > |
node | ) |
|
|
private |
Checks result after parsing function. Sets status of parser.
- Parameters
-
node | Result of previous parsing. |
- Returns
- true if result was OK, false otherwise.
◆ consume() [1/2]
bool retdec::demangler::borland::BorlandASTParser::consume |
( |
char |
c | ) |
|
|
private |
If mangled name starts with c, consumes the front and returns true. Else sets invalid name status and returns false.
◆ consume() [2/2]
bool retdec::demangler::borland::BorlandASTParser::consume |
( |
const StringView & |
s | ) |
|
|
private |
If mangled name starts with s, consumes the front and returns true. Else sets invalid name status and returns false.
◆ consumeIfPossible() [1/2]
bool retdec::demangler::borland::BorlandASTParser::consumeIfPossible |
( |
char |
c | ) |
|
|
inlineprivate |
If mangled name starts with c, consumes the front and returns true. Else returns false.
◆ consumeIfPossible() [2/2]
bool retdec::demangler::borland::BorlandASTParser::consumeIfPossible |
( |
const StringView & |
s | ) |
|
|
inlineprivate |
If mangled name starts with s, consumes the front and returns true. Else returns false.
◆ couldBeOperator()
bool retdec::demangler::borland::BorlandASTParser::couldBeOperator |
( |
| ) |
|
|
private |
◆ parse()
void retdec::demangler::borland::BorlandASTParser::parse |
( |
const std::string & |
mangled | ) |
|
Main method of parser. Tries to create AST, sets status.
<mangled-name> ::= <mangled-function>
◆ parseArray()
std::shared_ptr< TypeNode > retdec::demangler::borland::BorlandASTParser::parseArray |
( |
const Qualifiers & |
quals | ) |
|
|
private |
Parses array type.
- Returns
- Array on success, nullptr otherwise.
◆ parseAsNameUntil()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseAsNameUntil |
( |
const char * |
end | ) |
|
|
private |
Parses mangled string as nested named type until end.
- Parameters
-
end | Pointer behind the last char to parse. |
- Returns
- Node representing named type on success, or nullptr of failure. On failure status is set to invalid_mangled_name.
◆ parseBackref()
bool retdec::demangler::borland::BorlandASTParser::parseBackref |
( |
std::shared_ptr< NodeArray > & |
paramArray | ) |
|
|
private |
Parses backreference in parameter list and adds it to parameter array.
- Returns
- true on success, false otherwise.
◆ parseBuildInType()
std::shared_ptr< TypeNode > retdec::demangler::borland::BorlandASTParser::parseBuildInType |
( |
const Qualifiers & |
quals | ) |
|
|
private |
Tries to parse built-in type. If no viable type is found, method has no effect.
- Returns
- Type on success, nullptr otherwise.
◆ parseCallConv()
CallConv retdec::demangler::borland::BorlandASTParser::parseCallConv |
( |
| ) |
|
|
private |
Tries to parse function call convention. If no call conv is recognized, status is set to invalid_mangled_name.
- Returns
- Call conv.
◆ parseFuncName()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseFuncName |
( |
| ) |
|
|
private |
- Returns
- Node representing name, could be nullptr on failure.
<func-name> ::= @ <classic-func-name>
<func-name> ::= <
llvm-func-name>
Definition: itanium_ast_ctypes_parser.h:12
◆ parseFuncNameClasic()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseFuncNameClasic |
( |
| ) |
|
|
private |
- Returns
- Node representing function name on success or nullptr on failure. On failure, status is set to incorrect_mangled_name
<classic-func-name> ::= <name> <template-name> $ <operator>
<name> ::= <name> @ <name>
<name> ::=
<template-name> ::= % <abs-name> %
<template-name ::=
◆ parseFuncNameLlvm()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseFuncNameLlvm |
( |
| ) |
|
|
private |
- Returns
- Node representing function name on success or nullptr on failure. On failure, status is set to incorrect_mangled_name
<
llvm-func-name> ::= <name> $ <
template-name> <
operator>
<name> ::= <name> @ <name>
<name> ::=
<template-name> ::= % <abs-name> %
<template-name ::=
◆ parseFuncParams()
std::shared_ptr< NodeArray > retdec::demangler::borland::BorlandASTParser::parseFuncParams |
( |
| ) |
|
|
private |
Parses funtion parameters.
- Returns
- ArrayNode with parameters if parameters are found, or nullptr if no.
◆ parseFunction()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseFunction |
( |
| ) |
|
|
private |
◆ parseFuncType()
Parse function details (call conv, parameter types, varargness, return type)
- Parameters
-
quals | Function qualifiers. |
- Returns
- Node representing function type on success, or nullptr on failure.
◆ parseIntExpresion()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseIntExpresion |
( |
StringView & |
s | ) |
|
|
private |
◆ parseNamedType()
std::shared_ptr< TypeNode > retdec::demangler::borland::BorlandASTParser::parseNamedType |
( |
unsigned |
nameLen, |
|
|
const Qualifiers & |
quals |
|
) |
| |
|
private |
Parses named types.
- Parameters
-
nameLen | Length of mangled name of the type. |
quals | |
- Returns
- Named type on success, nullptr otherwise.
◆ parseNumber() [1/2]
unsigned retdec::demangler::borland::BorlandASTParser::parseNumber |
( |
| ) |
|
|
private |
Parses number. If number starts with 0, status is set to invalid_mangled_name. If no number is found, method has no effect.
- Returns
- parsed number
◆ parseNumber() [2/2]
unsigned retdec::demangler::borland::BorlandASTParser::parseNumber |
( |
StringView & |
s | ) |
|
|
private |
◆ parseOperator()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseOperator |
( |
| ) |
|
|
private |
Tries to parse operator. If no operator could be substituted, method doesn't change mangled name.
- Returns
- Node representing operator on success, or nullptr on failure.
◆ parsePointer()
std::shared_ptr< TypeNode > retdec::demangler::borland::BorlandASTParser::parsePointer |
( |
const Qualifiers & |
quals | ) |
|
|
private |
Parses pointer type.
- Returns
- Pointer type on success, nullptr otherwise.
◆ parseQualifiers()
Qualifiers retdec::demangler::borland::BorlandASTParser::parseQualifiers |
( |
| ) |
|
|
private |
Tries to parse qualifiers. If no are found, mangled string is unchanged.
- Returns
- Qualifiers object.
◆ parseReference()
std::shared_ptr< TypeNode > retdec::demangler::borland::BorlandASTParser::parseReference |
( |
| ) |
|
|
private |
Parses reference type.
- Returns
- Reference type on success, nullptr otherwise.
◆ parseRReference()
std::shared_ptr< TypeNode > retdec::demangler::borland::BorlandASTParser::parseRReference |
( |
| ) |
|
|
private |
Parses R-reference type.
- Returns
- R-reference type on success, nullptr otherwise.
◆ parseTemplate()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseTemplate |
( |
std::shared_ptr< Node > |
templateNamespace | ) |
|
|
private |
Parses template.
- Parameters
-
templateNamespace | Namespace of template. |
- Returns
- Template on success, nullptr otherwise.
◆ parseTemplateBackref()
bool retdec::demangler::borland::BorlandASTParser::parseTemplateBackref |
( |
StringView & |
mangled, |
|
|
std::shared_ptr< NodeArray > & |
params |
|
) |
| |
|
private |
◆ parseTemplateName()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseTemplateName |
( |
std::shared_ptr< Node > |
templateNamespace | ) |
|
|
private |
Parses template name without namespace.
- Parameters
-
templateNamespace | namespace of template. |
- Returns
- Template Node with namespace on success, nullptr otherwise.
◆ parseTemplateParams()
std::shared_ptr< Node > retdec::demangler::borland::BorlandASTParser::parseTemplateParams |
( |
| ) |
|
|
private |
Parse template parameters.
- Returns
- ArrayNode with parameters on success, nullptr otherwise
◆ parseType()
std::shared_ptr< TypeNode > retdec::demangler::borland::BorlandASTParser::parseType |
( |
| ) |
|
|
private |
Parses mangled types. Can have no effect, if no viable type is found and mangled string didnt breake any rule for types.
- Returns
- Type on success, nullptr on failure.
◆ peek() [1/3]
char retdec::demangler::borland::BorlandASTParser::peek |
( |
| ) |
const |
|
inlineprivate |
- Returns
- First character from rest of the mangled name. If empty then EOF.
◆ peek() [2/3]
bool retdec::demangler::borland::BorlandASTParser::peek |
( |
char |
c | ) |
const |
|
inlineprivate |
- Returns
- True if _mangled starts with c. Else false.
◆ peek() [3/3]
bool retdec::demangler::borland::BorlandASTParser::peek |
( |
const StringView & |
s | ) |
const |
|
inlineprivate |
- Returns
- True if _mangled starts with string s. Else false.
◆ peekNumber()
unsigned retdec::demangler::borland::BorlandASTParser::peekNumber |
( |
| ) |
const |
|
private |
- Returns
- If present number on the front of rest of mangled string. Else 0.
◆ status()
◆ statusOk()
bool retdec::demangler::borland::BorlandASTParser::statusOk |
( |
| ) |
const |
|
inlineprivate |
◆ _ast
std::shared_ptr<Node> retdec::demangler::borland::BorlandASTParser::_ast |
|
private |
◆ _context
Context& retdec::demangler::borland::BorlandASTParser::_context |
|
private |
◆ _mangled
StringView retdec::demangler::borland::BorlandASTParser::_mangled |
|
private |
◆ _status
Status retdec::demangler::borland::BorlandASTParser::_status |
|
private |
The documentation for this class was generated from the following files: