libTriton  version 0.8 build 1436
ast.hpp
Go to the documentation of this file.
1 /*
3 ** Copyright (C) - Triton
4 **
5 ** This program is under the terms of the BSD License.
6 */
7 
8 #ifndef TRITON_AST_H
9 #define TRITON_AST_H
10 
11 #include <deque>
12 #include <map>
13 #include <memory>
14 #include <ostream>
15 #include <set>
16 #include <stdexcept>
17 #include <string>
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::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::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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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  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 IffNode : public AbstractNode {
606  private:
607  void initHash(void);
608 
609  public:
610  TRITON_EXPORT IffNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
611  TRITON_EXPORT void init(bool withParents=false);
612  };
613 
614 
616  class IntegerNode : public AbstractNode {
617  private:
618  void initHash(void);
619 
620  protected:
621  triton::uint512 value;
622 
623  public:
624  TRITON_EXPORT IntegerNode(const triton::uint512& value, const SharedAstContext& ctxt);
625  TRITON_EXPORT void init(bool withParents=false);
626  TRITON_EXPORT triton::uint512 getInteger(void);
627  };
628 
629 
631  class IteNode : public AbstractNode {
632  private:
633  void initHash(void);
634 
635  public:
636  TRITON_EXPORT IteNode(const SharedAbstractNode& ifExpr, const SharedAbstractNode& thenExpr, const SharedAbstractNode& elseExpr);
637  TRITON_EXPORT void init(bool withParents=false);
638  };
639 
640 
642  class LandNode : public AbstractNode {
643  private:
644  void initHash(void);
645 
646  public:
647  template <typename T> LandNode(const T& exprs, const SharedAstContext& ctxt)
649  for (auto expr : exprs)
650  this->addChild(expr);
651  }
652 
653  TRITON_EXPORT LandNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
654  TRITON_EXPORT void init(bool withParents=false);
655  };
656 
657 
659  class LetNode : public AbstractNode {
660  private:
661  void initHash(void);
662 
663  public:
664  TRITON_EXPORT LetNode(std::string alias, const SharedAbstractNode& expr2, const SharedAbstractNode& expr3);
665  TRITON_EXPORT void init(bool withParents=false);
666  };
667 
668 
670  class LnotNode : public AbstractNode {
671  private:
672  void initHash(void);
673 
674  public:
675  TRITON_EXPORT LnotNode(const SharedAbstractNode& expr);
676  TRITON_EXPORT void init(bool withParents=false);
677  };
678 
679 
681  class LorNode : public AbstractNode {
682  private:
683  void initHash(void);
684 
685  public:
686  template <typename T> LorNode(const T& exprs, const SharedAstContext& ctxt)
688  for (auto expr : exprs)
689  this->addChild(expr);
690  }
691 
692  TRITON_EXPORT LorNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
693  TRITON_EXPORT void init(bool withParents=false);
694  };
695 
696 
698  class LxorNode : public AbstractNode {
699  private:
700  void initHash(void);
701 
702  public:
703  template <typename T> LxorNode(const T& exprs, const SharedAstContext& ctxt)
705  for (auto expr : exprs)
706  this->addChild(expr);
707  }
708 
709  TRITON_EXPORT LxorNode(const SharedAbstractNode& expr1, const SharedAbstractNode& expr2);
710  TRITON_EXPORT void init(bool withParents=false);
711  };
712 
713 
715  class ReferenceNode : public AbstractNode {
716  private:
717  void initHash(void);
718 
719  protected:
721 
722  public:
724  TRITON_EXPORT void init(bool withParents=false);
725  TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicExpression& getSymbolicExpression(void) const;
726  };
727 
728 
730  class StringNode : public AbstractNode {
731  private:
732  void initHash(void);
733 
734  protected:
735  std::string value;
736 
737  public:
738  TRITON_EXPORT StringNode(std::string value, const SharedAstContext& ctxt);
739  TRITON_EXPORT void init(bool withParents=false);
740  TRITON_EXPORT std::string getString(void);
741  };
742 
743 
745  class SxNode : public AbstractNode {
746  private:
747  void initHash(void);
748 
749  public:
750  TRITON_EXPORT SxNode(triton::uint32 sizeExt, const SharedAbstractNode& expr);
751  TRITON_EXPORT void init(bool withParents=false);
752  };
753 
754 
756  class VariableNode : public AbstractNode {
757  private:
758  void initHash(void);
759 
760  protected:
762 
763  public:
765  TRITON_EXPORT void init(bool withParents=false);
766  TRITON_EXPORT const triton::engines::symbolic::SharedSymbolicVariable& getSymbolicVariable(void);
767  };
768 
769 
771  class ZxNode : public AbstractNode {
772  private:
773  void initHash(void);
774 
775  public:
777  TRITON_EXPORT ZxNode(triton::uint32 sizeExt, const SharedAbstractNode& expr);
778  TRITON_EXPORT void init(bool withParents=false);
779  };
780 
783 
785  triton::uint512 rotl(const triton::uint512& value, triton::uint32 shift);
786 
789 
791  TRITON_EXPORT std::ostream& operator<<(std::ostream& stream, AbstractNode* node);
792 
794  TRITON_EXPORT SharedAbstractNode newInstance(AbstractNode* node, bool unroll=false);
795 
797  TRITON_EXPORT SharedAbstractNode unroll(const SharedAbstractNode& node);
798 
800  TRITON_EXPORT std::vector<SharedAbstractNode> childrenExtraction(const SharedAbstractNode& node, bool unroll, bool revert);
801 
803  TRITON_EXPORT std::vector<SharedAbstractNode> parentsExtraction(const SharedAbstractNode& node, bool revert);
804 
806  TRITON_EXPORT std::deque<SharedAbstractNode> search(const SharedAbstractNode& node, triton::ast::ast_e match=ANY_NODE);
807 
809  };
811 };
812 
813 #endif /* TRITON_AST_H */
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:804
std::shared_ptr< triton::ast::AstContext > SharedAstContext
Shared AST context.
Definition: ast.hpp:63
(= <expr1> <expr2> ...) node
Definition: ast.hpp:583
(bvsge <expr1> <expr2>) node
Definition: ast.hpp:341
(ite <ifExpr> <thenExpr> <elseExpr>)
Definition: ast.hpp:631
triton::uint512 hash2n(triton::uint512 hash, triton::uint32 n)
Custom hash2n function for hash routine.
Definition: ast.cpp:2977
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:114
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:121
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2548
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2078
SharedAbstractNode unroll(const triton::ast::SharedAbstractNode &node)
AST C++ API - Unrolls the SSA form of a given AST.
Definition: ast.cpp:3122
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:557
bool logical
True if it's a logical node.
Definition: ast.hpp:98
triton::uint512 eval
The value of the tree from this root node.
Definition: ast.hpp:89
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2599
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1607
(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:1101
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1760
TRITON_EXPORT triton::uint512 getBitvectorMask(void) const
Returns the vector mask according the size of the node.
Definition: ast.cpp:64
TRITON_EXPORT triton::ast::ast_e getType(void) const
Returns the type of the node.
Definition: ast.cpp:54
(let ((<alias> <expr2>)) <expr3>)
Definition: ast.hpp:659
std::vector< SharedAbstractNode > children
The children of the node.
Definition: ast.hpp:79
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2387
Abstract node.
Definition: ast.hpp:66
bool symbolized
True if the tree contains a symbolic variable.
Definition: ast.hpp:95
TRITON_EXPORT AbstractNode(triton::ast::ast_e type, const SharedAstContext &ctxt)
Constructor.
Definition: ast.cpp:31
virtual TRITON_EXPORT void init(bool withParents=false)=0
Init properties of the node. If withParents is true, init also properties of parents.
std::ostream & operator<<(std::ostream &stream, AbstractNode *node)
Displays the node in ast representation.
Definition: ast.cpp:2963
TRITON_EXPORT triton::uint512 evaluate(void) const
Evaluates the tree.
Definition: ast.cpp:135
TRITON_EXPORT triton::uint32 getBitvectorSize(void) const
Returns the size of the node.
Definition: ast.cpp:59
(xor <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:2022
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1326
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1709
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:706
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1210
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1501
Integer node.
Definition: ast.hpp:616
The Triton namespace.
Definition: api.cpp:226
triton::sint512 modularSignExtend(AbstractNode *node)
Custom modular sign extend for bitwise operation.
Definition: ast.cpp:2992
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1815
String node.
Definition: ast.hpp:730
Reference node.
Definition: ast.hpp:715
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:163
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:3196
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 void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1388
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition: ast.hpp:57
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2841
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:270
((_ extract <high> <low>) <expr>) node
Definition: ast.hpp:594
TRITON_EXPORT std::vector< SharedAbstractNode > & getChildren(void)
Returns the children of the node.
Definition: ast.cpp:158
boost::multiprecision::int512_t sint512
signed 512-bits
Definition: tritonTypes.hpp:64
((_ 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:2295
(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:1268
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2351
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1658
(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:1556
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2703
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:658
(bvuge <expr1> <expr2>) node
Definition: ast.hpp:440
(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:1450
(bvurem <expr1> <expr2>) node
Definition: ast.hpp:484
(bvlshr <expr1> <expr2>) node
Definition: ast.hpp:229
((_ zero_extend sizeExt) <expr>) node
Definition: ast.hpp:771
(lnot <expr>)
Definition: ast.hpp:670
(and <expr1> <expr2>)
Definition: ast.hpp:642
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2782
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:608
TRITON_EXPORT SharedAstContext getContext(void) const
Access to its context.
Definition: ast.cpp:49
TRITON_EXPORT bool isSymbolized(void) const
Returns true if the tree contains a symbolic variable.
Definition: ast.cpp:78
TRITON_EXPORT std::string str(void) const
Returns the string representation of the node.
Definition: ast.cpp:253
(or <expr1> <expr2>)
Definition: ast.hpp:681
(bvneg <expr>) node
Definition: ast.hpp:262
(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:2232
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2129
TRITON_EXPORT void removeParent(AbstractNode *p)
Removes a parent node.
Definition: ast.cpp:202
(bvslt <expr1> <expr2>) node
Definition: ast.hpp:385
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:3201
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:321
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp: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:756
void initParents(void)
Initializes parents.
Definition: ast.cpp:150
(_ bv<value> <size>) node
Definition: ast.hpp:517
(iff <expr1> <expr2>)
Definition: ast.hpp:605
(bvashr <expr1> <expr2>) node
Definition: ast.hpp:218
TRITON_EXPORT void setChild(triton::uint32 index, const SharedAbstractNode &child)
Sets a child at an index.
Definition: ast.cpp:225
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2740
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2445
(bvor <expr1> <expr2>) node
Definition: ast.hpp:295
TRITON_EXPORT triton::uint32 getLevel(void) const
Returns the deep level of the tree.
Definition: ast.cpp:145
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1159
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
Definition: ast.hpp:38
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1917
(bvmul <expr1> <expr2>) node
Definition: ast.hpp:240
(bvxor <expr1> <expr2>) node
Definition: ast.hpp:506
(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:2651
std::uint32_t uint32
unisgned 32-bits
Definition: tritonTypes.hpp:31
triton::uint512 rotl(const triton::uint512 &value, triton::uint32 shift)
Custom rotate left function for hash routine.
Definition: ast.cpp:2985
(bvand <expr1> <expr2>) node
Definition: ast.hpp:207
SharedAbstractNode newInstance(AbstractNode *node, bool unroll)
AST C++ API - Duplicates the AST.
Definition: ast.cpp:3100
(bvnand <expr1> <expr2>) node
Definition: ast.hpp:251
((_ sign_extend sizeExt) <expr>) node
Definition: ast.hpp:745
virtual TRITON_EXPORT ~AbstractNode()
Destructor.
Definition: ast.cpp:43
TRITON_EXPORT ZxNode(triton::uint32 sizeExt, const SharedAbstractNode &expr)
Create a zero extend of expr to sizeExt bits.
Definition: ast.cpp:2877
(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:1866
TRITON_EXPORT void addChild(const SharedAbstractNode &child)
Adds a child.
Definition: ast.cpp:220
(bvxnor <expr1> <expr2>) node
Definition: ast.hpp:495
[<expr1> <expr2> <expr3> ...] node
Definition: ast.hpp:528
std::shared_ptr< triton::engines::symbolic::SymbolicVariable > SharedSymbolicVariable
Shared Symbolic variable.
Definition: ast.hpp:41
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2883
(bvnor <expr1> <expr2>) node
Definition: ast.hpp:273
TRITON_EXPORT void setParent(AbstractNode *p)
Sets a parent node.
Definition: ast.cpp:181
(bvult <expr1> <expr2>) node
Definition: ast.hpp:473
TRITON_EXPORT triton::uint512 getHash(void) const
Returns the hash of the tree.
Definition: ast.cpp:140
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:423
(concat <expr1> <expr2> ...) node
Definition: ast.hpp:544
triton::uint32 level
Deep level for computing hash.
Definition: ast.hpp:73
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:2180
TRITON_EXPORT void setBitvectorSize(triton::uint32 size)
Sets the size of the node.
Definition: ast.cpp:248
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:3206
(bvudiv <expr1> <expr2>) node
Definition: ast.hpp:429
triton::uint512 hash
The hash of the tree.
Definition: ast.hpp:92
(bvadd <expr1> <expr2>) node
Definition: ast.hpp:196
(bvshl <expr1> <expr2>) node
Definition: ast.hpp:363
boost::multiprecision::uint512_t uint512
unsigned 512-bits
Definition: tritonTypes.hpp:43
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:921
(distinct <expr1> <expr2> ...) node
Definition: ast.hpp:572
triton::uint32 size
The size of the node.
Definition: ast.hpp:86
triton::ast::ast_e type
The type of the node.
Definition: ast.hpp:76
((_ 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:372
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:979
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:859
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
Definition: ast.cpp:1974
(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:1043
std::weak_ptr< triton::ast::AbstractNode > WeakAbstractNode
Weak Abstract Node.
Definition: ast.hpp:60
(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:2498
(declare-fun <var_name> () (_ BitVec <var_size>)) node
Definition: ast.hpp:561
TRITON_EXPORT bool isLogical(void) const
Returns true if it's a logical node.
Definition: ast.cpp:83
TRITON_EXPORT bool equalTo(const SharedAbstractNode &other) const
Returns true if the current tree is equal to the second one.
Definition: ast.cpp:127
(bvnot <expr>) node
Definition: ast.hpp:284
SharedAstContext ctxt
Contect use to create this node.
Definition: ast.hpp:101
Variable node.
Definition: ast.hpp:756