16#include <unordered_map>
17#include <unordered_set>
39 class SymbolicExpression;
68 class AbstractNode :
public std::enable_shared_from_this<AbstractNode> {
71 virtual void initHash(
void) = 0;
85 std::unordered_map<AbstractNode*, std::pair<triton::uint32, WeakAbstractNode>> parents;
128 TRITON_EXPORT
bool isArray(
void)
const;
131 TRITON_EXPORT
bool isSigned(
void)
const;
137 TRITON_EXPORT
bool isLogical(
void)
const;
161 TRITON_EXPORT std::vector<SharedAbstractNode>&
getChildren(
void);
164 TRITON_EXPORT std::vector<SharedAbstractNode>
getParents(
void);
173 TRITON_EXPORT
void setParent(std::unordered_set<AbstractNode*>& p);
185 TRITON_EXPORT std::string
str(
void)
const;
188 TRITON_EXPORT
virtual void init(
bool withParents=
false) = 0;
199 std::unordered_map<triton::uint64, triton::uint8> memory;
204 TRITON_EXPORT
void initHash(
void);
208 TRITON_EXPORT
void init(
bool withParents=
false);
223 TRITON_EXPORT std::unordered_map<triton::uint64, triton::uint8>&
getMemory(
void);
233 TRITON_EXPORT
void initHash(
void);
237 TRITON_EXPORT
void init(
bool withParents=
false);
244 TRITON_EXPORT
void initHash(
void);
248 TRITON_EXPORT
void init(
bool withParents=
false);
255 TRITON_EXPORT
void initHash(
void);
259 TRITON_EXPORT
void init(
bool withParents=
false);
266 TRITON_EXPORT
void initHash(
void);
270 TRITON_EXPORT
void init(
bool withParents=
false);
277 TRITON_EXPORT
void initHash(
void);
281 TRITON_EXPORT
void init(
bool withParents=
false);
288 TRITON_EXPORT
void initHash(
void);
292 TRITON_EXPORT
void init(
bool withParents=
false);
299 TRITON_EXPORT
void initHash(
void);
303 TRITON_EXPORT
void init(
bool withParents=
false);
310 TRITON_EXPORT
void initHash(
void);
314 TRITON_EXPORT
void init(
bool withParents=
false);
321 TRITON_EXPORT
void initHash(
void);
325 TRITON_EXPORT
void init(
bool withParents=
false);
332 TRITON_EXPORT
void initHash(
void);
336 TRITON_EXPORT
void init(
bool withParents=
false);
343 TRITON_EXPORT
void initHash(
void);
347 TRITON_EXPORT
void init(
bool withParents=
false);
354 TRITON_EXPORT
void initHash(
void);
358 TRITON_EXPORT
void init(
bool withParents=
false);
365 TRITON_EXPORT
void initHash(
void);
370 TRITON_EXPORT
void init(
bool withParents=
false);
377 TRITON_EXPORT
void initHash(
void);
382 TRITON_EXPORT
void init(
bool withParents=
false);
389 TRITON_EXPORT
void initHash(
void);
393 TRITON_EXPORT
void init(
bool withParents=
false);
400 TRITON_EXPORT
void initHash(
void);
404 TRITON_EXPORT
void init(
bool withParents=
false);
411 TRITON_EXPORT
void initHash(
void);
415 TRITON_EXPORT
void init(
bool withParents=
false);
422 TRITON_EXPORT
void initHash(
void);
426 TRITON_EXPORT
void init(
bool withParents=
false);
433 TRITON_EXPORT
void initHash(
void);
437 TRITON_EXPORT
void init(
bool withParents=
false);
444 TRITON_EXPORT
void initHash(
void);
448 TRITON_EXPORT
void init(
bool withParents=
false);
455 TRITON_EXPORT
void initHash(
void);
459 TRITON_EXPORT
void init(
bool withParents=
false);
466 TRITON_EXPORT
void initHash(
void);
470 TRITON_EXPORT
void init(
bool withParents=
false);
477 TRITON_EXPORT
void initHash(
void);
481 TRITON_EXPORT
void init(
bool withParents=
false);
488 TRITON_EXPORT
void initHash(
void);
492 TRITON_EXPORT
void init(
bool withParents=
false);
499 TRITON_EXPORT
void initHash(
void);
503 TRITON_EXPORT
void init(
bool withParents=
false);
510 TRITON_EXPORT
void initHash(
void);
514 TRITON_EXPORT
void init(
bool withParents=
false);
521 TRITON_EXPORT
void initHash(
void);
525 TRITON_EXPORT
void init(
bool withParents=
false);
532 TRITON_EXPORT
void initHash(
void);
536 TRITON_EXPORT
void init(
bool withParents=
false);
543 TRITON_EXPORT
void initHash(
void);
547 TRITON_EXPORT
void init(
bool withParents=
false);
554 TRITON_EXPORT
void initHash(
void);
558 TRITON_EXPORT
void init(
bool withParents=
false);
565 TRITON_EXPORT
void initHash(
void);
569 TRITON_EXPORT
void init(
bool withParents=
false);
576 TRITON_EXPORT
void initHash(
void);
580 TRITON_EXPORT
void init(
bool withParents=
false);
587 TRITON_EXPORT
void initHash(
void);
592 for (
auto expr : exprs)
596 TRITON_EXPORT
void init(
bool withParents=
false);
603 TRITON_EXPORT
void initHash(
void);
608 for (
auto expr : exprs)
613 TRITON_EXPORT
void init(
bool withParents=
false);
620 TRITON_EXPORT
void initHash(
void);
624 TRITON_EXPORT
void init(
bool withParents=
false);
631 TRITON_EXPORT
void initHash(
void);
635 TRITON_EXPORT
void init(
bool withParents=
false);
642 TRITON_EXPORT
void initHash(
void);
646 TRITON_EXPORT
void init(
bool withParents=
false);
653 TRITON_EXPORT
void initHash(
void);
657 TRITON_EXPORT
void init(
bool withParents=
false);
664 TRITON_EXPORT
void initHash(
void);
669 for (
auto var : vars)
674 TRITON_EXPORT
void init(
bool withParents=
false);
681 TRITON_EXPORT
void initHash(
void);
685 TRITON_EXPORT
void init(
bool withParents=
false);
692 TRITON_EXPORT
void initHash(
void);
699 TRITON_EXPORT
void init(
bool withParents=
false);
707 TRITON_EXPORT
void initHash(
void);
711 TRITON_EXPORT
void init(
bool withParents=
false);
718 TRITON_EXPORT
void initHash(
void);
723 for (
auto expr : exprs)
728 TRITON_EXPORT
void init(
bool withParents=
false);
735 TRITON_EXPORT
void initHash(
void);
739 TRITON_EXPORT
void init(
bool withParents=
false);
746 TRITON_EXPORT
void initHash(
void);
750 TRITON_EXPORT
void init(
bool withParents=
false);
757 TRITON_EXPORT
void initHash(
void);
762 for (
auto expr : exprs)
767 TRITON_EXPORT
void init(
bool withParents=
false);
774 TRITON_EXPORT
void initHash(
void);
779 for (
auto expr : exprs)
784 TRITON_EXPORT
void init(
bool withParents=
false);
791 TRITON_EXPORT
void initHash(
void);
798 TRITON_EXPORT
void init(
bool withParents=
false);
806 TRITON_EXPORT
void initHash(
void);
811 TRITON_EXPORT
void init(
bool withParents=
false);
822 std::unordered_map<triton::uint64, triton::uint8> memory;
827 TRITON_EXPORT
void initHash(
void);
832 TRITON_EXPORT
void init(
bool withParents=
false);
844 TRITON_EXPORT std::unordered_map<triton::uint64, triton::uint8>&
getMemory(
void);
854 TRITON_EXPORT
void initHash(
void);
861 TRITON_EXPORT
void init(
bool withParents=
false);
862 TRITON_EXPORT std::string getString(
void);
869 TRITON_EXPORT
void initHash(
void);
873 TRITON_EXPORT
void init(
bool withParents=
false);
880 TRITON_EXPORT
void initHash(
void);
887 TRITON_EXPORT
void init(
bool withParents=
false);
895 TRITON_EXPORT
void initHash(
void);
900 TRITON_EXPORT
void init(
bool withParents=
false);
TRITON_EXPORT bool canReplaceNodeWithoutUpdate(const SharedAbstractNode &other) const
Returns true if the node's value, value type and properties match those of the second one.
TRITON_EXPORT triton::uint32 getLevel(void) const
Returns the deep level of the tree.
bool symbolized
True if the tree contains a symbolic variable.
TRITON_EXPORT bool hasSameConcreteValueAndTypeAs(const SharedAbstractNode &other) const
Returns true if the node's concrete value and value type match those of the second one.
TRITON_EXPORT SharedAstContext getContext(void) const
Access to its context.
TRITON_EXPORT AbstractNode(triton::ast::ast_e type, const SharedAstContext &ctxt)
Constructor.
triton::ast::ast_e type
The type of the node.
TRITON_EXPORT void setParent(AbstractNode *p)
Sets a parent node.
TRITON_EXPORT bool equalTo(const SharedAbstractNode &other) const
Returns true if the current tree is equal to the second one.
TRITON_EXPORT void setChild(triton::uint32 index, const SharedAbstractNode &child)
Sets a child at an index.
TRITON_EXPORT bool isSigned(void) const
According to the size of the expression, returns true if the MSB is 1.
TRITON_EXPORT std::vector< SharedAbstractNode > getParents(void)
Returns the parents of node or an empty set if there is still no parent defined.
TRITON_EXPORT triton::uint512 getHash(void) const
Returns the hash of the tree.
bool array
True if it's an array node.
SharedAstContext ctxt
Contect use to create this node.
TRITON_EXPORT triton::uint512 getBitvectorMask(void) const
Returns the vector mask according the size of the node.
TRITON_EXPORT bool isArray(void) const
Returns true if it's an array node.
virtual TRITON_EXPORT ~AbstractNode()
Destructor.
triton::uint32 size
The size of the node.
TRITON_EXPORT bool isSymbolized(void) const
Returns true if the tree contains a symbolic variable.
std::vector< SharedAbstractNode > children
The children of the node.
TRITON_EXPORT triton::uint32 getBitvectorSize(void) const
Returns the size of the node.
virtual TRITON_EXPORT void init(bool withParents=false)=0
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT bool isLogical(void) const
Returns true if it's a logical node.
TRITON_EXPORT std::vector< SharedAbstractNode > & getChildren(void)
Returns the children of the node.
bool logical
True if it's a logical node.
TRITON_EXPORT void setBitvectorSize(triton::uint32 size)
Sets the size of the node.
triton::uint512 eval
The value of the tree from this root node.
triton::uint512 hash
The hash of the tree.
TRITON_EXPORT std::string str(void) const
Returns the string representation of the node.
TRITON_EXPORT void addChild(const SharedAbstractNode &child)
Adds a child.
TRITON_EXPORT void removeParent(AbstractNode *p)
Removes a parent node.
void initParents(void)
Initializes parents.
TRITON_EXPORT triton::uint512 evaluate(void) const
Evaluates the tree.
TRITON_EXPORT triton::ast::ast_e getType(void) const
Returns the type of the node.
triton::uint32 level
Deep level for computing hash.
(Array (_ BitVec indexSize) (_ BitVec 8)) node
TRITON_EXPORT void store(triton::uint64 addr, triton::uint8 value)
Stores a concrete value into the memory array.
TRITON_EXPORT triton::uint8 select(triton::uint64 addr) const
Select a concrete value into the memory array.
TRITON_EXPORT triton::uint32 getIndexSize(void) const
Gets the index size.
TRITON_EXPORT std::unordered_map< triton::uint64, triton::uint8 > & getMemory(void)
Gets the concrete memory array.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(_ bv<value> <size>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvadd <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvand <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvashr <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvlshr <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvmul <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvnand <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvnor <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvor <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
((_ rotate_left rot) <expr>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
((_ rotate_right rot) <expr>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvsdiv <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvsge <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvsgt <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvshl <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvsle <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvslt <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvsmod <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvsrem <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvsub <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvudiv <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvuge <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvugt <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvule <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvult <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvurem <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvxnor <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(bvxor <expr1> <expr2>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
[<expr1> <expr2> <expr3> ...] node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(concat <expr1> <expr2> ...) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(declare-fun <var_name> () (_ BitVec <var_size>)) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(distinct <expr1> <expr2> ...) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(= <expr1> <expr2> ...) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(forall ((x (_ BitVec <size>)), ...) body)
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(ite <ifExpr> <thenExpr> <elseExpr>)
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
(let ((<alias> <expr2>)) <expr3>)
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT triton::uint32 getIndexSize(void) const
Gets the index size.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT std::unordered_map< triton::uint64, triton::uint8 > & getMemory(void)
Gets the concrete memory array.
TRITON_EXPORT triton::uint8 select(triton::uint64 addr) const
Select a concrete value into the memory array.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
((_ sign_extend sizeExt) <expr>) node
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
((_ zero_extend sizeExt) <expr>) node
TRITON_EXPORT ZxNode(triton::uint32 sizeExt, const SharedAbstractNode &expr)
Create a zero extend of expr to sizeExt bits.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
The symbolic variable class.
The exception class used by all AST nodes.
triton::uint32 getIndexSize(const SharedAbstractNode &node)
Gets the index size of an array.
SharedAbstractNode unroll(const triton::ast::SharedAbstractNode &node)
AST C++ API - Unrolls the SSA form of a given AST.
SharedAbstractNode dereference(const SharedAbstractNode &node)
Returns the first non referene node encountered.
triton::uint512 hash2n(triton::uint512 hash, triton::uint32 n)
Custom hash2n function for hash routine.
std::vector< SharedAbstractNode > parentsExtraction(const SharedAbstractNode &node, bool revert)
Returns node and all its parents of an AST sorted topologically. If revert is true,...
std::vector< SharedAbstractNode > childrenExtraction(const SharedAbstractNode &node, bool unroll, bool revert)
Returns node and all its children of an AST sorted topologically. If unroll is true,...
T getInteger(const SharedAbstractNode &node)
Gets the value of an integer node.
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
std::ostream & operator<<(std::ostream &stream, AbstractNode *node)
Displays the node in ast representation.
std::weak_ptr< triton::ast::AbstractNode > WeakAbstractNode
Weak Abstract Node.
SharedAbstractNode newInstance(AbstractNode *node, bool unroll)
AST C++ API - Duplicates the AST.
std::shared_ptr< triton::ast::AstContext > SharedAstContext
Shared AST context.
triton::sint512 modularSignExtend(AbstractNode *node)
Custom modular sign extend for bitwise operation.
std::deque< SharedAbstractNode > search(const SharedAbstractNode &node, triton::ast::ast_e match)
Returns a deque of collected matched nodes via a depth-first pre order traversal.
triton::uint512 rotl(const triton::uint512 &value, triton::uint32 shift)
Custom rotate left function for hash routine.
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
std::shared_ptr< triton::engines::symbolic::SymbolicVariable > SharedSymbolicVariable
Shared Symbolic variable.
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
std::uint8_t uint8
unisgned 8-bits
std::string toString(const T &obj)
Converts an object to a string.