libTriton  version 0.9 build 1502
ast.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_AST_H
9 #define TRITON_AST_H
10 
11 #include <deque>
12 #include <memory>
13 #include <ostream>
14 #include <stdexcept>
15 #include <string>
16 #include <unordered_map>
17 #include <unordered_set>
18 #include <vector>
19 
20 #include <triton/astEnums.hpp>
21 #include <triton/cpuSize.hpp>
22 #include <triton/dllexport.hpp>
23 #include <triton/tritonTypes.hpp>
24 
25 
26 
28 namespace triton {
34  /* Forward declarations */
35  namespace engines {
36  namespace symbolic {
37  class SymbolicExpression;
38  using SharedSymbolicExpression = std::shared_ptr<triton::engines::symbolic::SymbolicExpression>;
39 
40  class SymbolicVariable;
41  using SharedSymbolicVariable = std::shared_ptr<triton::engines::symbolic::SymbolicVariable>;
42  };
43  };
44 
46  namespace ast {
53  class AstContext;
54  class AbstractNode;
55 
57  using SharedAbstractNode = std::shared_ptr<triton::ast::AbstractNode>;
58 
60  using WeakAbstractNode = std::weak_ptr<triton::ast::AbstractNode>;
61 
63  using SharedAstContext = std::shared_ptr<triton::ast::AstContext>;
64 
66  class AbstractNode : public std::enable_shared_from_this<AbstractNode> {
67  private:
69  virtual void initHash(void) = 0;
70 
71  protected:
74 
77 
79  std::vector<SharedAbstractNode> children;
80 
81  // This structure counter the number of use of a given parent as a node may have
82  // multiple time the same parent: eg. xor rax rax
83  std::unordered_map<AbstractNode*, std::pair<triton::uint32, WeakAbstractNode>> parents;
84 
87 
90 
93 
95  bool symbolized;
96 
98  bool logical;
99 
102 
103  public:
106 
108  TRITON_EXPORT virtual ~AbstractNode();
109 
111  TRITON_EXPORT SharedAstContext getContext(void) const;
112 
114  TRITON_EXPORT triton::ast::ast_e getType(void) const;
115 
117  TRITON_EXPORT triton::uint32 getBitvectorSize(void) const;
118 
120  TRITON_EXPORT triton::uint512 getBitvectorMask(void) const;
121 
123  TRITON_EXPORT bool isSigned(void) const;
124 
126  TRITON_EXPORT bool isSymbolized(void) const;
127 
129  TRITON_EXPORT bool isLogical(void) const;
130 
132  TRITON_EXPORT bool hasSameConcreteValueAndTypeAs(const SharedAbstractNode& other) const;
133 
135  TRITON_EXPORT bool canReplaceNodeWithoutUpdate(const SharedAbstractNode& other) const;
136 
138  TRITON_EXPORT bool equalTo(const SharedAbstractNode& other) const;
139 
141  TRITON_EXPORT triton::uint32 getLevel(void) const;
142 
144  TRITON_EXPORT triton::uint512 getHash(void) const;
145 
147  TRITON_EXPORT triton::uint512 evaluate(void) const;
148 
150  void initParents(void);
151 
153  TRITON_EXPORT std::vector<SharedAbstractNode>& getChildren(void);
154 
156  TRITON_EXPORT std::vector<SharedAbstractNode> getParents(void);
157 
159  TRITON_EXPORT void removeParent(AbstractNode* p);
160 
162  TRITON_EXPORT void setParent(AbstractNode* p);
163 
165  TRITON_EXPORT void setParent(std::unordered_set<AbstractNode*>& p);
166 
168  TRITON_EXPORT void setBitvectorSize(triton::uint32 size);
169 
171  TRITON_EXPORT void addChild(const SharedAbstractNode& child);
172 
174  TRITON_EXPORT void setChild(triton::uint32 index, const SharedAbstractNode& child);
175 
177  TRITON_EXPORT std::string str(void) const;
178 
180  TRITON_EXPORT virtual void init(bool withParents=false) = 0;
181  };
182 
183 
185  class AssertNode : public AbstractNode {
186  private:
187  TRITON_EXPORT void initHash(void);
188 
189  public:
190  TRITON_EXPORT AssertNode(const SharedAbstractNode& expr);
191  TRITON_EXPORT void init(bool withParents=false);
192  };
193 
194 
196  class BvaddNode : public AbstractNode {
197  private:
198  TRITON_EXPORT void initHash(void);
199 
200  public:
201  TRITON_EXPORT BvaddNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
202  TRITON_EXPORT void init(bool withParents=false);
203  };
204 
205 
207  class BvandNode : public AbstractNode {
208  private:
209  TRITON_EXPORT void initHash(void);
210 
211  public:
212  TRITON_EXPORT BvandNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
213  TRITON_EXPORT void init(bool withParents=false);
214  };
215 
216 
218  class BvashrNode : public AbstractNode {
219  private:
220  TRITON_EXPORT void initHash(void);
221 
222  public:
223  TRITON_EXPORT BvashrNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
224  TRITON_EXPORT void init(bool withParents=false);
225  };
226 
227 
229  class BvlshrNode : public AbstractNode {
230  private:
231  TRITON_EXPORT void initHash(void);
232 
233  public:
234  TRITON_EXPORT BvlshrNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
235  TRITON_EXPORT void init(bool withParents=false);
236  };
237 
238 
240  class BvmulNode : public AbstractNode {
241  private:
242  TRITON_EXPORT void initHash(void);
243 
244  public:
245  TRITON_EXPORT BvmulNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
246  TRITON_EXPORT void init(bool withParents=false);
247  };
248 
249 
251  class BvnandNode : public AbstractNode {
252  private:
253  TRITON_EXPORT void initHash(void);
254 
255  public:
256  TRITON_EXPORT BvnandNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
257  TRITON_EXPORT void init(bool withParents=false);
258  };
259 
260 
262  class BvnegNode : public AbstractNode {
263  private:
264  TRITON_EXPORT void initHash(void);
265 
266  public:
267  TRITON_EXPORT BvnegNode(const SharedAbstractNode& expr);
268  TRITON_EXPORT void init(bool withParents=false);
269  };
270 
271 
273  class BvnorNode : public AbstractNode {
274  private:
275  TRITON_EXPORT void initHash(void);
276 
277  public:
278  TRITON_EXPORT BvnorNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
279  TRITON_EXPORT void init(bool withParents=false);
280  };
281 
282 
284  class BvnotNode : public AbstractNode {
285  private:
286  TRITON_EXPORT void initHash(void);
287 
288  public:
289  TRITON_EXPORT BvnotNode(const SharedAbstractNode& expr1);
290  TRITON_EXPORT void init(bool withParents=false);
291  };
292 
293 
295  class BvorNode : public AbstractNode {
296  private:
297  TRITON_EXPORT void initHash(void);
298 
299  public:
300  TRITON_EXPORT BvorNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
301  TRITON_EXPORT void init(bool withParents=false);
302  };
303 
304 
306  class BvrolNode : public AbstractNode {
307  private:
308  TRITON_EXPORT void initHash(void);
309 
310  public:
311  TRITON_EXPORT BvrolNode(const SharedAbstractNode& expr, triton::uint32 rot);
312  TRITON_EXPORT BvrolNode(const SharedAbstractNode& expr, const SharedAbstractNode& rot);
313  TRITON_EXPORT void init(bool withParents=false);
314  };
315 
316 
318  class BvrorNode : public AbstractNode {
319  private:
320  TRITON_EXPORT void initHash(void);
321 
322  public:
323  TRITON_EXPORT BvrorNode(const SharedAbstractNode& expr, triton::uint32 rot);
324  TRITON_EXPORT BvrorNode(const SharedAbstractNode& expr, const SharedAbstractNode& rot);
325  TRITON_EXPORT void init(bool withParents=false);
326  };
327 
328 
330  class BvsdivNode : public AbstractNode {
331  private:
332  TRITON_EXPORT void initHash(void);
333 
334  public:
335  TRITON_EXPORT BvsdivNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
336  TRITON_EXPORT void init(bool withParents=false);
337  };
338 
339 
341  class BvsgeNode : public AbstractNode {
342  private:
343  TRITON_EXPORT void initHash(void);
344 
345  public:
346  TRITON_EXPORT BvsgeNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
347  TRITON_EXPORT void init(bool withParents=false);
348  };
349 
350 
352  class BvsgtNode : public AbstractNode {
353  private:
354  TRITON_EXPORT void initHash(void);
355 
356  public:
357  TRITON_EXPORT BvsgtNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
358  TRITON_EXPORT void init(bool withParents=false);
359  };
360 
361 
363  class BvshlNode : public AbstractNode {
364  private:
365  TRITON_EXPORT void initHash(void);
366 
367  public:
368  TRITON_EXPORT BvshlNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
369  TRITON_EXPORT void init(bool withParents=false);
370  };
371 
372 
374  class BvsleNode : public AbstractNode {
375  private:
376  TRITON_EXPORT void initHash(void);
377 
378  public:
379  TRITON_EXPORT BvsleNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
380  TRITON_EXPORT void init(bool withParents=false);
381  };
382 
383 
385  class BvsltNode : public AbstractNode {
386  private:
387  TRITON_EXPORT void initHash(void);
388 
389  public:
390  TRITON_EXPORT BvsltNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
391  TRITON_EXPORT void init(bool withParents=false);
392  };
393 
394 
396  class BvsmodNode : public AbstractNode {
397  private:
398  TRITON_EXPORT void initHash(void);
399 
400  public:
401  TRITON_EXPORT BvsmodNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
402  TRITON_EXPORT void init(bool withParents=false);
403  };
404 
405 
407  class BvsremNode : public AbstractNode {
408  private:
409  TRITON_EXPORT void initHash(void);
410 
411  public:
412  TRITON_EXPORT BvsremNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
413  TRITON_EXPORT void init(bool withParents=false);
414  };
415 
416 
418  class BvsubNode : public AbstractNode {
419  private:
420  TRITON_EXPORT void initHash(void);
421 
422  public:
423  TRITON_EXPORT BvsubNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
424  TRITON_EXPORT void init(bool withParents=false);
425  };
426 
427 
429  class BvudivNode : public AbstractNode {
430  private:
431  TRITON_EXPORT void initHash(void);
432 
433  public:
434  TRITON_EXPORT BvudivNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
435  TRITON_EXPORT void init(bool withParents=false);
436  };
437 
438 
440  class BvugeNode : public AbstractNode {
441  private:
442  TRITON_EXPORT void initHash(void);
443 
444  public:
445  TRITON_EXPORT BvugeNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
446  TRITON_EXPORT void init(bool withParents=false);
447  };
448 
449 
451  class BvugtNode : public AbstractNode {
452  private:
453  TRITON_EXPORT void initHash(void);
454 
455  public:
456  TRITON_EXPORT BvugtNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
457  TRITON_EXPORT void init(bool withParents=false);
458  };
459 
460 
462  class BvuleNode : public AbstractNode {
463  private:
464  TRITON_EXPORT void initHash(void);
465 
466  public:
467  TRITON_EXPORT BvuleNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
468  TRITON_EXPORT void init(bool withParents=false);
469  };
470 
471 
473  class BvultNode : public AbstractNode {
474  private:
475  TRITON_EXPORT void initHash(void);
476 
477  public:
478  TRITON_EXPORT BvultNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
479  TRITON_EXPORT void init(bool withParents=false);
480  };
481 
482 
484  class BvuremNode : public AbstractNode {
485  private:
486  TRITON_EXPORT void initHash(void);
487 
488  public:
489  TRITON_EXPORT BvuremNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
490  TRITON_EXPORT void init(bool withParents=false);
491  };
492 
493 
495  class BvxnorNode : public AbstractNode {
496  private:
497  TRITON_EXPORT void initHash(void);
498 
499  public:
500  TRITON_EXPORT BvxnorNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
501  TRITON_EXPORT void init(bool withParents=false);
502  };
503 
504 
506  class BvxorNode : public AbstractNode {
507  private:
508  TRITON_EXPORT void initHash(void);
509 
510  public:
511  TRITON_EXPORT BvxorNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
512  TRITON_EXPORT void init(bool withParents=false);
513  };
514 
515 
517  class BvNode : public AbstractNode {
518  private:
519  TRITON_EXPORT void initHash(void);
520 
521  public:
522  TRITON_EXPORT BvNode(const triton::uint512& value, triton::uint32 size, const SharedAstContext& ctxt);
523  TRITON_EXPORT void init(bool withParents=false);
524  };
525 
526 
528  class CompoundNode : public AbstractNode {
529  private:
530  TRITON_EXPORT void initHash(void);
531 
532  public:
533  template <typename T> CompoundNode(const T& exprs, const SharedAstContext& ctxt)
535  for (auto expr : exprs)
536  this->addChild(expr);
537  }
538 
539  TRITON_EXPORT void init(bool withParents=false);
540  };
541 
542 
544  class ConcatNode : public AbstractNode {
545  private:
546  TRITON_EXPORT void initHash(void);
547 
548  public:
549  template <typename T> ConcatNode(const T& exprs, const SharedAstContext& ctxt)
551  for (auto expr : exprs)
552  this->addChild(expr);
553  }
554 
555  TRITON_EXPORT ConcatNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
556  TRITON_EXPORT void init(bool withParents=false);
557  };
558 
559 
561  class DeclareNode : public AbstractNode {
562  private:
563  TRITON_EXPORT void initHash(void);
564 
565  public:
566  TRITON_EXPORT DeclareNode(const SharedAbstractNode& var);
567  TRITON_EXPORT void init(bool withParents=false);
568  };
569 
570 
572  class DistinctNode : public AbstractNode {
573  private:
574  TRITON_EXPORT void initHash(void);
575 
576  public:
577  TRITON_EXPORT DistinctNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
578  TRITON_EXPORT void init(bool withParents=false);
579  };
580 
581 
583  class EqualNode : public AbstractNode {
584  private:
585  TRITON_EXPORT void initHash(void);
586 
587  public:
588  TRITON_EXPORT EqualNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
589  TRITON_EXPORT void init(bool withParents=false);
590  };
591 
592 
594  class ExtractNode : public AbstractNode {
595  private:
596  TRITON_EXPORT void initHash(void);
597 
598  public:
599  TRITON_EXPORT ExtractNode(triton::uint32 high, triton::uint32 low, const SharedAbstractNode& expr);
600  TRITON_EXPORT void init(bool withParents=false);
601  };
602 
603 
605  class ForallNode : public AbstractNode {
606  private:
607  TRITON_EXPORT void initHash(void);
608 
609  public:
610  template <typename T> ForallNode(const T& vars, const SharedAbstractNode& body)
611  : AbstractNode(FORALL_NODE, body->getContext()) {
612  for (auto var : vars)
613  this->addChild(var);
614  this->addChild(body);
615  }
616 
617  TRITON_EXPORT void init(bool withParents=false);
618  };
619 
620 
622  class IffNode : public AbstractNode {
623  private:
624  TRITON_EXPORT void initHash(void);
625 
626  public:
627  TRITON_EXPORT IffNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
628  TRITON_EXPORT void init(bool withParents=false);
629  };
630 
631 
633  class IntegerNode : public AbstractNode {
634  private:
635  TRITON_EXPORT void initHash(void);
636 
637  protected:
638  triton::uint512 value;
639 
640  public:
641  TRITON_EXPORT IntegerNode(const triton::uint512& value, const SharedAstContext& ctxt);
642  TRITON_EXPORT void init(bool withParents=false);
643  TRITON_EXPORT triton::uint512 getInteger(void);
644  };
645 
646 
648  class IteNode : public AbstractNode {
649  private:
650  TRITON_EXPORT void initHash(void);
651 
652  public:
653  TRITON_EXPORT IteNode(const SharedAbstractNode& ifExpr, const SharedAbstractNode& thenExpr, const SharedAbstractNode& elseExpr);
654  TRITON_EXPORT void init(bool withParents=false);
655  };
656 
657 
659  class LandNode : public AbstractNode {
660  private:
661  TRITON_EXPORT void initHash(void);
662 
663  public:
664  template <typename T> LandNode(const T& exprs, const SharedAstContext& ctxt)
666  for (auto expr : exprs)
667  this->addChild(expr);
668  }
669 
670  TRITON_EXPORT LandNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
671  TRITON_EXPORT void init(bool withParents=false);
672  };
673 
674 
676  class LetNode : public AbstractNode {
677  private:
678  TRITON_EXPORT void initHash(void);
679 
680  public:
681  TRITON_EXPORT LetNode(std::string alias, const SharedAbstractNode& expr2, const SharedAbstractNode& expr3);
682  TRITON_EXPORT void init(bool withParents=false);
683  };
684 
685 
687  class LnotNode : public AbstractNode {
688  private:
689  TRITON_EXPORT void initHash(void);
690 
691  public:
692  TRITON_EXPORT LnotNode(const SharedAbstractNode& expr);
693  TRITON_EXPORT void init(bool withParents=false);
694  };
695 
696 
698  class LorNode : public AbstractNode {
699  private:
700  TRITON_EXPORT void initHash(void);
701 
702  public:
703  template <typename T> LorNode(const T& exprs, const SharedAstContext& ctxt)
705  for (auto expr : exprs)
706  this->addChild(expr);
707  }
708 
709  TRITON_EXPORT LorNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
710  TRITON_EXPORT void init(bool withParents=false);
711  };
712 
713 
715  class LxorNode : public AbstractNode {
716  private:
717  TRITON_EXPORT void initHash(void);
718 
719  public:
720  template <typename T> LxorNode(const T& exprs, const SharedAstContext& ctxt)
722  for (auto expr : exprs)
723  this->addChild(expr);
724  }
725 
726  TRITON_EXPORT LxorNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
727  TRITON_EXPORT void init(bool withParents=false);
728  };
729 
730 
732  class ReferenceNode : public AbstractNode {
733  private:
734  TRITON_EXPORT void initHash(void);
735 
736  protected:
738 
739  public:
741  TRITON_EXPORT void init(bool withParents=false);
742  TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression& getSymbolicExpression(void) const;
743  };
744 
745 
747  class StringNode : public AbstractNode {
748  private:
749  TRITON_EXPORT void initHash(void);
750 
751  protected:
752  std::string value;
753 
754  public:
755  TRITON_EXPORT StringNode(std::string value, const SharedAstContext& ctxt);
756  TRITON_EXPORT void init(bool withParents=false);
757  TRITON_EXPORT std::string getString(void);
758  };
759 
760 
762  class SxNode : public AbstractNode {
763  private:
764  TRITON_EXPORT void initHash(void);
765 
766  public:
767  TRITON_EXPORT SxNode(triton::uint32 sizeExt, const SharedAbstractNode& expr);
768  TRITON_EXPORT void init(bool withParents=false);
769  };
770 
771 
773  class VariableNode : public AbstractNode {
774  private:
775  TRITON_EXPORT void initHash(void);
776 
777  protected:
779 
780  public:
782  TRITON_EXPORT void init(bool withParents=false);
783  TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicVariable& getSymbolicVariable(void);
784  };
785 
786 
788  class ZxNode : public AbstractNode {
789  private:
790  TRITON_EXPORT void initHash(void);
791 
792  public:
794  TRITON_EXPORT ZxNode(triton::uint32 sizeExt, const SharedAbstractNode& expr);
795  TRITON_EXPORT void init(bool withParents=false);
796  };
797 
800 
802  triton::uint512 rotl(const triton::uint512& value, triton::uint32 shift);
803 
806 
808  TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, AbstractNode* node);
809 
811  TRITON_EXPORT SharedAbstractNode newInstance(AbstractNode* node, bool unroll=false);
812 
814  TRITON_EXPORT SharedAbstractNode unroll(const SharedAbstractNode& node);
815 
817  TRITON_EXPORT std::vector<SharedAbstractNode> childrenExtraction(const SharedAbstractNode& node, bool unroll, bool revert);
818 
820  TRITON_EXPORT std::vector<SharedAbstractNode> parentsExtraction(const SharedAbstractNode& node, bool revert);
821 
823  TRITON_EXPORT std::deque<SharedAbstractNode> search(const SharedAbstractNode& node, triton::ast::ast_e match=ANY_NODE);
824 
826  TRITON_EXPORT SharedAbstractNode dereference(const SharedAbstractNode& node);
827 
829  };
831 };
832 
833 #endif /* TRITON_AST_H */
Abstract node.
Definition: ast.hpp:66
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.
Definition: ast.cpp:122
TRITON_EXPORT triton::uint32 getLevel(void) const
Returns the deep level of the tree.
Definition: ast.cpp:146
bool symbolized
True if the tree contains a symbolic variable.
Definition: ast.hpp:95
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.
Definition: ast.cpp:115
TRITON_EXPORT SharedAstContext getContext(void) const
Access to its context.
Definition: ast.cpp:49
TRITON_EXPORT AbstractNode(triton::ast::ast_e type, const SharedAstContext &ctxt)
Constructor.
Definition: ast.cpp:31
triton::ast::ast_e type
The type of the node.
Definition: ast.hpp:76
TRITON_EXPORT void setParent(AbstractNode *p)
Sets a parent node.
Definition: ast.cpp:182
TRITON_EXPORT bool equalTo(const SharedAbstractNode &other) const
Returns true if the current tree is equal to the second one.
Definition: ast.cpp:128
TRITON_EXPORT void setChild(triton::uint32 index, const SharedAbstractNode &child)
Sets a child at an index.
Definition: ast.cpp:226
TRITON_EXPORT bool isSigned(void) const
According to the size of the expression, returns true if the MSB is 1.
Definition: ast.cpp:71
TRITON_EXPORT std::vector< SharedAbstractNode > getParents(void)
Returns the parents of node or an empty set if there is still no parent defined.
Definition: ast.cpp:164
TRITON_EXPORT triton::uint512 getHash(void) const
Returns the hash of the tree.
Definition: ast.cpp:141
SharedAstContext ctxt
Contect use to create this node.
Definition: ast.hpp:101
TRITON_EXPORT triton::uint512 getBitvectorMask(void) const
Returns the vector mask according the size of the node.
Definition: ast.cpp:64
virtual TRITON_EXPORT ~AbstractNode()
Destructor.
Definition: ast.cpp:43
triton::uint32 size
The size of the node.
Definition: ast.hpp:86
TRITON_EXPORT bool isSymbolized(void) const
Returns true if the tree contains a symbolic variable.
Definition: ast.cpp:78
std::vector< SharedAbstractNode > children
The children of the node.
Definition: ast.hpp:79
TRITON_EXPORT triton::uint32 getBitvectorSize(void) const
Returns the size of the node.
Definition: ast.cpp:59
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.
Definition: ast.cpp:83
TRITON_EXPORT std::vector< SharedAbstractNode > & getChildren(void)
Returns the children of the node.
Definition: ast.cpp:159
bool logical
True if it's a logical node.
Definition: ast.hpp:98
TRITON_EXPORT void setBitvectorSize(triton::uint32 size)
Sets the size of the node.
Definition: ast.cpp:249
triton::uint512 eval
The value of the tree from this root node.
Definition: ast.hpp:89
triton::uint512 hash
The hash of the tree.
Definition: ast.hpp:92
TRITON_EXPORT std::string str(void) const
Returns the string representation of the node.
Definition: ast.cpp:254
TRITON_EXPORT void addChild(const SharedAbstractNode &child)
Adds a child.
Definition: ast.cpp:221
TRITON_EXPORT void removeParent(AbstractNode *p)
Removes a parent node.
Definition: ast.cpp:203
void initParents(void)
Initializes parents.
Definition: ast.cpp:151
TRITON_EXPORT triton::uint512 evaluate(void) const
Evaluates the tree.
Definition: ast.cpp:136
TRITON_EXPORT triton::ast::ast_e getType(void) const
Returns the type of the node.
Definition: ast.cpp:54
triton::uint32 level
Deep level for computing hash.
Definition: ast.hpp:73
(assert <expr>) node
Definition: ast.hpp:185
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:271
(_ bv<value> <size>) node
Definition: ast.hpp:517
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1919
(bvadd <expr1> <expr2>) node
Definition: ast.hpp:196
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:322
(bvand <expr1> <expr2>) node
Definition: ast.hpp:207
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:373
(bvashr <expr1> <expr2>) node
Definition: ast.hpp:218
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:424
(bvlshr <expr1> <expr2>) node
Definition: ast.hpp:229
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:507
(bvmul <expr1> <expr2>) node
Definition: ast.hpp:240
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:558
(bvnand <expr1> <expr2>) node
Definition: ast.hpp:251
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:609
(bvneg <expr>) node
Definition: ast.hpp:262
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:659
(bvnor <expr1> <expr2>) node
Definition: ast.hpp:273
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:707
(bvnot <expr>) node
Definition: ast.hpp:284
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:757
(bvor <expr1> <expr2>) node
Definition: ast.hpp:295
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:805
((_ rotate_left rot) <expr>) node
Definition: ast.hpp:306
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:860
((_ rotate_right rot) <expr>) node
Definition: ast.hpp:318
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:922
(bvsdiv <expr1> <expr2>) node
Definition: ast.hpp:330
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:980
(bvsge <expr1> <expr2>) node
Definition: ast.hpp:341
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1044
(bvsgt <expr1> <expr2>) node
Definition: ast.hpp:352
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1102
(bvshl <expr1> <expr2>) node
Definition: ast.hpp:363
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1160
(bvsle <expr1> <expr2>) node
Definition: ast.hpp:374
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1211
(bvslt <expr1> <expr2>) node
Definition: ast.hpp:385
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1269
(bvsmod <expr1> <expr2>) node
Definition: ast.hpp:396
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1327
(bvsrem <expr1> <expr2>) node
Definition: ast.hpp:407
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1389
(bvsub <expr1> <expr2>) node
Definition: ast.hpp:418
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1451
(bvudiv <expr1> <expr2>) node
Definition: ast.hpp:429
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1502
(bvuge <expr1> <expr2>) node
Definition: ast.hpp:440
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1557
(bvugt <expr1> <expr2>) node
Definition: ast.hpp:451
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1608
(bvule <expr1> <expr2>) node
Definition: ast.hpp:462
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1659
(bvult <expr1> <expr2>) node
Definition: ast.hpp:473
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1710
(bvurem <expr1> <expr2>) node
Definition: ast.hpp:484
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1761
(bvxnor <expr1> <expr2>) node
Definition: ast.hpp:495
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1816
(bvxor <expr1> <expr2>) node
Definition: ast.hpp:506
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1867
[<expr1> <expr2> <expr3> ...] node
Definition: ast.hpp:528
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1976
(concat <expr1> <expr2> ...) node
Definition: ast.hpp:544
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2024
(declare-fun <var_name> () (_ BitVec <var_size>)) node
Definition: ast.hpp:561
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2080
(distinct <expr1> <expr2> ...) node
Definition: ast.hpp:572
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2131
(= <expr1> <expr2> ...) node
Definition: ast.hpp:583
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2182
((_ extract <high> <low>) <expr>) node
Definition: ast.hpp:594
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2234
(forall ((x (_ BitVec <size>)), ...) body)
Definition: ast.hpp:605
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2291
(iff <expr1> <expr2>)
Definition: ast.hpp:622
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2348
Integer node.
Definition: ast.hpp:633
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2404
(ite <ifExpr> <thenExpr> <elseExpr>)
Definition: ast.hpp:648
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2440
(and <expr1> <expr2>)
Definition: ast.hpp:659
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2498
(let ((<alias> <expr2>)) <expr3>)
Definition: ast.hpp:676
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2551
(lnot <expr>)
Definition: ast.hpp:687
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2601
(or <expr1> <expr2>)
Definition: ast.hpp:698
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2652
(xor <expr1> <expr2>)
Definition: ast.hpp:715
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2704
Reference node.
Definition: ast.hpp:732
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2756
String node.
Definition: ast.hpp:747
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2793
((_ sign_extend sizeExt) <expr>) node
Definition: ast.hpp:762
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2835
Variable node.
Definition: ast.hpp:773
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2894
((_ zero_extend sizeExt) <expr>) node
Definition: ast.hpp:788
TRITON_EXPORT ZxNode(triton::uint32 sizeExt, const SharedAbstractNode &expr)
Create a zero extend of expr to sizeExt bits.
Definition: ast.cpp:2930
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2936
SharedAbstractNode unroll(const triton::ast::SharedAbstractNode &node)
AST C++ API - Unrolls the SSA form of a given AST.
Definition: ast.cpp:3178
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition: ast.hpp:57
SharedAbstractNode dereference(const SharedAbstractNode &node)
Returns the first non referene node encountered.
Definition: ast.cpp:3295
std::weak_ptr< triton::ast::AbstractNode > WeakAbstractNode
Weak Abstract Node.
Definition: ast.hpp:60
triton::uint512 hash2n(triton::uint512 hash, triton::uint32 n)
Custom hash2n function for hash routine.
Definition: ast.cpp:3032
std::vector< SharedAbstractNode > parentsExtraction(const SharedAbstractNode &node, bool revert)
Returns node and all its parents of an AST sorted topologically. If revert is true,...
Definition: ast.cpp:3257
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,...
Definition: ast.cpp:3252
std::ostream & operator<<(std::ostream &stream, AbstractNode *node)
Displays the node in ast representation.
Definition: ast.cpp:3018
SharedAbstractNode newInstance(AbstractNode *node, bool unroll)
AST C++ API - Duplicates the AST.
Definition: ast.cpp:3156
triton::sint512 modularSignExtend(AbstractNode *node)
Custom modular sign extend for bitwise operation.
Definition: ast.cpp:3047
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.
Definition: ast.cpp:3262
triton::uint512 rotl(const triton::uint512 &value, triton::uint32 shift)
Custom rotate left function for hash routine.
Definition: ast.cpp:3040
std::shared_ptr< triton::ast::AstContext > SharedAstContext
Shared AST context.
Definition: ast.hpp:63
std::shared_ptr< triton::engines::symbolic::SymbolicVariable > SharedSymbolicVariable
Shared Symbolic variable.
Definition: ast.hpp:41
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
Definition: ast.hpp:38
boost::multiprecision::uint512_t uint512
unsigned 512-bits
Definition: tritonTypes.hpp:43
boost::multiprecision::int512_t sint512
signed 512-bits
Definition: tritonTypes.hpp:64
std::uint32_t uint32
unisgned 32-bits
Definition: tritonTypes.hpp:31
The Triton namespace.
Definition: api.cpp:227