libTriton  version 0.9 build 1504
symbolicExpression.hpp
Go to the documentation of this file.
1 /*
3 ** Copyright (C) - Triton
4 **
5 ** This program is under the terms of the Apache License 2.0.
6 */
7 
8 #ifndef TRITON_SYMBOLICEXPRESSION_H
9 #define TRITON_SYMBOLICEXPRESSION_H
10 
11 #include <string>
12 #include <memory>
13 
14 #include <triton/ast.hpp>
15 #include <triton/dllexport.hpp>
16 #include <triton/memoryAccess.hpp>
17 #include <triton/register.hpp>
18 #include <triton/symbolicEnums.hpp>
19 #include <triton/tritonTypes.hpp>
20 
21 
22 
24 namespace triton {
31  namespace engines {
39  namespace symbolic {
47 
49 
50  protected:
53 
56 
58  std::string comment;
59 
62 
65 
68 
69  public:
71  bool isTainted;
72 
74  TRITON_EXPORT SymbolicExpression(const triton::ast::SharedAbstractNode& node,
75  triton::usize id,
77  const std::string& comment="");
78 
80  TRITON_EXPORT SymbolicExpression(const SymbolicExpression& other);
81 
83  TRITON_EXPORT SymbolicExpression& operator=(const SymbolicExpression& other);
84 
86  TRITON_EXPORT triton::usize getId(void) const;
87 
89  TRITON_EXPORT bool isMemory(void) const;
90 
92  TRITON_EXPORT bool isRegister(void) const;
93 
95  TRITON_EXPORT bool isSymbolized(void) const;
96 
98  TRITON_EXPORT triton::engines::symbolic::expression_e getType(void) const;
99 
101  TRITON_EXPORT const triton::ast::SharedAbstractNode& getAst(void) const;
102 
104  TRITON_EXPORT triton::ast::SharedAbstractNode getNewAst(void) const;
105 
107  TRITON_EXPORT const std::string& getComment(void) const;
108 
110  TRITON_EXPORT std::string getFormattedId(void) const;
111 
113  TRITON_EXPORT std::string getFormattedComment(void) const;
114 
116  TRITON_EXPORT std::string getFormattedExpression(void) const;
117 
119  TRITON_EXPORT const triton::arch::MemoryAccess& getOriginMemory(void) const;
120 
122  TRITON_EXPORT const triton::arch::Register& getOriginRegister(void) const;
123 
125  TRITON_EXPORT void setAst(const triton::ast::SharedAbstractNode& node);
126 
128  TRITON_EXPORT void setComment(const std::string& comment);
129 
132 
134  TRITON_EXPORT void setOriginMemory(const triton::arch::MemoryAccess& mem);
135 
137  TRITON_EXPORT void setOriginRegister(const triton::arch::Register& reg);
138  };
139 
141  using SharedSymbolicExpression = std::shared_ptr<triton::engines::symbolic::SymbolicExpression>;
142 
144  using WeakSymbolicExpression = std::weak_ptr<triton::engines::symbolic::SymbolicExpression>;
145 
147  TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, const SymbolicExpression& symExpr);
148 
150  TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, const SymbolicExpression* symExpr);
151 
153  };
155  };
157 };
158 
159 #endif /* TRITON_SYMBOLICEXPRESSION_H */
This class is used to represent a memory access.
This class is used when an instruction has a register operand.
Definition: register.hpp:44
TRITON_EXPORT bool isMemory(void) const
Returns true if the symbolic expression is assigned to a memory.
TRITON_EXPORT triton::usize getId(void) const
Returns the symbolic expression id.
triton::usize id
The symbolic expression id. This id is unique.
TRITON_EXPORT SymbolicExpression(const triton::ast::SharedAbstractNode &node, triton::usize id, triton::engines::symbolic::expression_e type, const std::string &comment="")
Constructor.
TRITON_EXPORT std::string getFormattedId(void) const
Returns the id as string of the symbolic expression according the mode of the AST representation.
TRITON_EXPORT std::string getFormattedComment(void) const
Returns the comment as string of the symbolic expression according the mode of the AST representation...
TRITON_EXPORT void setAst(const triton::ast::SharedAbstractNode &node)
Sets a root node.
TRITON_EXPORT void setType(triton::engines::symbolic::expression_e type)
Sets the kind of the symbolic expression.
TRITON_EXPORT const triton::ast::SharedAbstractNode & getAst(void) const
Returns the SMT AST root node of the symbolic expression. This is the semantics.
TRITON_EXPORT std::string getFormattedExpression(void) const
Returns the symbolic expression representation as string according the mode of the AST representation...
TRITON_EXPORT const triton::arch::Register & getOriginRegister(void) const
Returns the origin register if kind is equal to triton::engines::symbolic::REG, REG_INVALID otherwise...
TRITON_EXPORT const std::string & getComment(void) const
Returns the comment of the symbolic expression.
bool isTainted
True if the symbolic expression is tainted.
TRITON_EXPORT const triton::arch::MemoryAccess & getOriginMemory(void) const
Returns the origin memory access if kind is equal to triton::engines::symbolic::MEM,...
TRITON_EXPORT void setComment(const std::string &comment)
Sets a comment to the symbolic expression.
TRITON_EXPORT bool isSymbolized(void) const
Returns true if the expression contains a symbolic variable.
triton::arch::Register originRegister
The origin register if kind is equal to triton::engines::symbolic::REG, REG_INVALID otherwise.
TRITON_EXPORT void setOriginRegister(const triton::arch::Register &reg)
Sets the origin register.
TRITON_EXPORT triton::engines::symbolic::expression_e getType(void) const
Returns the type of the symbolic expression assignment.
triton::ast::SharedAbstractNode ast
The root node (AST) of the symbolic expression.
triton::arch::MemoryAccess originMemory
The origin memory address if kind is equal to triton::engines::symbolic::MEM, invalid memory otherwis...
TRITON_EXPORT triton::ast::SharedAbstractNode getNewAst(void) const
Returns a new SMT AST root node of the symbolic expression. This new instance is a duplicate of the o...
TRITON_EXPORT bool isRegister(void) const
Returns true if the symbolic expression is assigned to a register.
TRITON_EXPORT void setOriginMemory(const triton::arch::MemoryAccess &mem)
Sets the origin memory acccess.
triton::engines::symbolic::expression_e type
The type of the symbolic expression assignment.
std::string comment
The comment of the symbolic expression.
TRITON_EXPORT SymbolicExpression & operator=(const SymbolicExpression &other)
Operator.
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition: ast.hpp:57
std::weak_ptr< triton::engines::symbolic::SymbolicExpression > WeakSymbolicExpression
Weak Symbolic Expression.
expression_e
Type of symbolic expressions.
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
Definition: ast.hpp:38
std::ostream & operator<<(std::ostream &stream, const SymbolicExpression &symExpr)
Displays a symbolic expression.
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
Definition: tritonTypes.hpp:67
The Triton namespace.
Definition: api.cpp:227