8#ifndef TRITON_AST_CONTEXT_H
9#define TRITON_AST_CONTEXT_H
14#include <unordered_map>
35 class SymbolicExpression;
38 class SymbolicVariable;
53 class AstContext :
public std::enable_shared_from_this<AstContext> {
62 std::unordered_map<std::string, std::pair<triton::ast::WeakAbstractNode, triton::uint512>> valueMapping;
65 std::deque<SharedAbstractNode> nodes;
87 TRITON_EXPORT
void garbage(
void);
202 SharedAbstractNode node = std::make_shared<CompoundNode>(exprs, this->shared_from_this());
215 if (exprs.size() == 1) {
216 return exprs.front();
220 SharedAbstractNode node = std::make_shared<ConcatNode>(exprs, this->shared_from_this());
226 if (node->isSymbolized() ==
false) {
227 return this->
bv(node->evaluate(), node->getBitvectorSize());
233 auto n = this->simplify_concat(std::vector<SharedAbstractNode>(exprs.begin(), exprs.end()));
277 SharedAbstractNode node = std::make_shared<LandNode>(exprs, this->shared_from_this());
307 SharedAbstractNode node = std::make_shared<LxorNode>(exprs, this->shared_from_this());
AST Context - Used as AST builder.
TRITON_EXPORT void setRepresentationMode(triton::ast::representations::mode_e mode)
Sets the representation mode for this astContext.
TRITON_EXPORT triton::uint16 getArraySize(void) const
Returns the address space used for the ABV logic.
TRITON_EXPORT SharedAbstractNode bvsgt(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsgt node builder.
TRITON_EXPORT SharedAbstractNode bvmul(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvmul node builder.
TRITON_EXPORT SharedAbstractNode bvnand(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvnand node builder.
TRITON_EXPORT SharedAbstractNode bvsub(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsub node builder.
TRITON_EXPORT SharedAbstractNode distinct(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - distinct node builder.
TRITON_EXPORT SharedAbstractNode land(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - land node builder.
TRITON_EXPORT void garbage(void)
Garbage unused nodes.
SharedAbstractNode concat(const T &exprs)
AST C++ API - concat node builder.
TRITON_EXPORT SharedAbstractNode bvuge(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvuge node builder.
TRITON_EXPORT SharedAbstractNode bvshl(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvshl node builder.
SharedAbstractNode compound(const T &exprs)
AST C++ API - compound node builder.
TRITON_EXPORT SharedAbstractNode iff(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - iff node builder.
SharedAbstractNode land(const T &exprs)
AST C++ API - land node builder.
TRITON_EXPORT SharedAbstractNode bvfalse(void)
AST C++ API - bvfalse node builder.
TRITON_EXPORT SharedAbstractNode bvxnor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvxnor node builder.
TRITON_EXPORT SharedAbstractNode bvor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvor node builder.
TRITON_EXPORT SharedAbstractNode bvrol(const SharedAbstractNode &expr, triton::uint32 rot)
AST C++ API - bvrol node builder.
TRITON_EXPORT ~AstContext()
Destructor.
TRITON_EXPORT AstContext & operator=(const AstContext &other)
Operator.
SharedAbstractNode lor(const T &exprs)
AST C++ API - lor node builder.
TRITON_EXPORT AstContext(const triton::modes::SharedModes &modes)
Constructor.
TRITON_EXPORT SharedAbstractNode bvule(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvule node builder.
TRITON_EXPORT SharedAbstractNode store(const SharedAbstractNode &array, triton::usize index, const SharedAbstractNode &expr)
AST C++ API - store node builder.
TRITON_EXPORT SharedAbstractNode concat(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - concat node builder.
SharedAbstractNode forall(const T &vars, const SharedAbstractNode &body)
AST C++ API - forall node builder.
TRITON_EXPORT SharedAbstractNode bvand(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvand node builder.
TRITON_EXPORT SharedAbstractNode bvudiv(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvudiv node builder.
TRITON_EXPORT SharedAbstractNode string(std::string value)
AST C++ API - string node builder.
SharedAbstractNode lxor(const T &exprs)
AST C++ API - lxor node builder.
TRITON_EXPORT SharedAbstractNode bvxor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvxor node builder.
TRITON_EXPORT SharedAbstractNode reference(const triton::engines::symbolic::SharedSymbolicExpression &expr)
AST C++ API - reference node builder.
TRITON_EXPORT SharedAbstractNode zx(triton::uint32 sizeExt, const SharedAbstractNode &expr)
AST C++ API - zx node builder.
TRITON_EXPORT SharedAbstractNode bswap(const SharedAbstractNode &expr)
AST C++ API - bswap node builder.
TRITON_EXPORT SharedAbstractNode sx(triton::uint32 sizeExt, const SharedAbstractNode &expr)
AST C++ API - sx node builder.
TRITON_EXPORT SharedAbstractNode bvsge(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsge node builder.
TRITON_EXPORT SharedAbstractNode bvsrem(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsrem node builder.
TRITON_EXPORT SharedAbstractNode bvtrue(void)
AST C++ API - bvtrue node builder.
TRITON_EXPORT SharedAbstractNode bv(const triton::uint512 &value, triton::uint32 size)
AST C++ API - bv node builder.
TRITON_EXPORT SharedAbstractNode bvult(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvult node builder.
TRITON_EXPORT SharedAbstractNode bvashr(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvashr node builder.
TRITON_EXPORT SharedAbstractNode bvsdiv(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsdiv node builder.
TRITON_EXPORT triton::ast::representations::mode_e getRepresentationMode(void) const
Gets the representations mode of this astContext.
SharedAbstractNode getVariableNode(const std::string &name)
Gets a variable node from its name.
TRITON_EXPORT SharedAbstractNode lor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - lor node builder.
TRITON_EXPORT SharedAbstractNode bvnor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvnor node builder.
TRITON_EXPORT SharedAbstractNode bvsle(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsle node builder.
TRITON_EXPORT SharedAbstractNode lxor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - lxor node builder.
TRITON_EXPORT SharedAbstractNode variable(const triton::engines::symbolic::SharedSymbolicVariable &symVar)
AST C++ API - variable node builder.
TRITON_EXPORT SharedAbstractNode bvlshr(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvlshr node builder.
TRITON_EXPORT std::ostream & print(std::ostream &stream, AbstractNode *node)
Prints the node according to the current representation mode.
TRITON_EXPORT void updateVariable(const std::string &name, const triton::uint512 &value)
Updates a variable value in this context.
TRITON_EXPORT SharedAbstractNode ite(const SharedAbstractNode &ifExpr, const SharedAbstractNode &thenExpr, const SharedAbstractNode &elseExpr)
AST C++ API - ite node builder.
TRITON_EXPORT SharedAbstractNode assert_(const SharedAbstractNode &expr)
AST C++ API - assert node builder.
TRITON_EXPORT SharedAbstractNode lnot(const SharedAbstractNode &expr)
AST C++ API - lnot node builder.
TRITON_EXPORT SharedAbstractNode select(const SharedAbstractNode &array, triton::usize index)
AST C++ API - select node builder.
TRITON_EXPORT SharedAbstractNode bvneg(const SharedAbstractNode &expr)
AST C++ API - bvneg node builder.
TRITON_EXPORT SharedAbstractNode collect(const SharedAbstractNode &node)
Collect new nodes.
TRITON_EXPORT const triton::uint512 & getVariableValue(const std::string &name) const
Gets a variable value from its name.
TRITON_EXPORT SharedAbstractNode bvugt(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvugt node builder.
TRITON_EXPORT SharedAbstractNode bvslt(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvslt node builder.
TRITON_EXPORT SharedAbstractNode equal(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - equal node builder.
TRITON_EXPORT SharedAbstractNode integer(const triton::uint512 &value)
AST C++ API - integer node builder.
TRITON_EXPORT SharedAbstractNode bvror(const SharedAbstractNode &expr, triton::uint32 rot)
AST C++ API - bvror node builder.
TRITON_EXPORT SharedAbstractNode array(triton::uint32 addrSize)
AST C++ API - array node builder.
TRITON_EXPORT SharedAbstractNode bvadd(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvadd node builder.
TRITON_EXPORT SharedAbstractNode let(std::string alias, const SharedAbstractNode &expr2, const SharedAbstractNode &expr3)
AST C++ API - let node builder.
TRITON_EXPORT void initVariable(const std::string &name, const triton::uint512 &value, const SharedAbstractNode &node)
Initializes a variable in the context.
TRITON_EXPORT SharedAbstractNode extract(triton::uint32 high, triton::uint32 low, const SharedAbstractNode &expr)
AST C++ API - extract node builder.
TRITON_EXPORT SharedAbstractNode bvsmod(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsmod node builder.
TRITON_EXPORT SharedAbstractNode bvurem(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvurem node builder.
TRITON_EXPORT SharedAbstractNode bvnot(const SharedAbstractNode &expr)
AST C++ API - bvnot node builder.
TRITON_EXPORT SharedAbstractNode declare(const SharedAbstractNode &var)
AST C++ API - declare node builder.
The exception class used by all AST nodes.
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
std::shared_ptr< triton::ast::AstContext > SharedAstContext
Shared AST context.
std::shared_ptr< triton::modes::Modes > SharedModes
Shared Modes.
@ CONSTANT_FOLDING
[symbolic] Perform a constant folding optimization of sub ASTs which do not contain symbolic variable...
@ AST_OPTIMIZATIONS
[AST] Classical arithmetic optimisations to reduce the depth of the trees.
mode_e
All types of representation mode.
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
std::shared_ptr< triton::engines::symbolic::SymbolicVariable > SharedSymbolicVariable
Shared Symbolic variable.
std::uint16_t uint16
unisgned 16-bits
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
std::uint32_t uint32
unisgned 32-bits