libTriton version 1.0 build 1590
Loading...
Searching...
No Matches
astRepresentation.cpp
Go to the documentation of this file.
1
2/*
3** Copyright (C) - Triton
4**
5** This program is under the terms of the Apache License 2.0.
6*/
7
8#include <new>
9#include <memory>
10
15#include <triton/exceptions.hpp>
16
17
18
19namespace triton {
20 namespace ast {
21 namespace representations {
22
24 /* Set the default representation */
26
27 /* Init representations interface */
28 this->representations[SMT_REPRESENTATION] = std::unique_ptr<AstSmtRepresentation>(new(std::nothrow) AstSmtRepresentation());
29 this->representations[PYTHON_REPRESENTATION] = std::unique_ptr<AstPythonRepresentation>(new(std::nothrow) AstPythonRepresentation());
30 this->representations[PCODE_REPRESENTATION] = std::unique_ptr<AstPcodeRepresentation>(new(std::nothrow) AstPcodeRepresentation());
31
32 if (this->representations[SMT_REPRESENTATION] == nullptr)
33 throw triton::exceptions::AstRepresentation("AstRepresentation::AstRepresentation(): Cannot allocate a new representation instance.");
34
35 if (this->representations[PYTHON_REPRESENTATION] == nullptr)
36 throw triton::exceptions::AstRepresentation("AstRepresentation::AstRepresentation(): Cannot allocate a new representation instance.");
37
38 if (this->representations[PCODE_REPRESENTATION] == nullptr)
39 throw triton::exceptions::AstRepresentation("AstRepresentation::AstRepresentation(): Cannot allocate a new representation instance.");
40 }
41
42
47
48
50 this->mode = other.mode;
51 return *this;
52 }
53
54
58
59
62 throw triton::exceptions::AstRepresentation("AstRepresentation::setMode(): Invalid representation mode.");
63 this->mode = mode;
64 }
65
66
67 std::ostream& AstRepresentation::print(std::ostream& stream, AbstractNode* node) {
68 return this->representations[this->mode]->print(stream, node);
69 }
70
71 };
72 };
73};
Abstract node.
Definition ast.hpp:68
TRITON_EXPORT std::ostream & print(std::ostream &stream, AbstractNode *node)
Prints the node according to the current representation mode.
triton::ast::representations::mode_e mode
The representation mode.
TRITON_EXPORT AstRepresentation & operator=(const AstRepresentation &other)
Operator.
std::unique_ptr< triton::ast::representations::AstRepresentationInterface > representations[triton::ast::representations::LAST_REPRESENTATION]
AstRepresentation interface.
TRITON_EXPORT void setMode(triton::ast::representations::mode_e mode)
Sets the representation mode.
TRITON_EXPORT triton::ast::representations::mode_e getMode(void) const
Returns the representation mode.
The exception class used by all AST node representations.
mode_e
All types of representation mode.
Definition astEnums.hpp:98
The Triton namespace.