libTriton  version 0.7 build 1407
astContext.cpp
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 #include <triton/ast.hpp>
9 #include <triton/astContext.hpp>
10 #include <triton/exceptions.hpp>
13 
14 
15 
16 namespace triton {
17  namespace ast {
18 
20  : modes(modes) {
21  }
22 
23 
25  : modes(other.modes),
26  astRepresentation(other.astRepresentation),
27  valueMapping(other.valueMapping) {
28  }
29 
30 
32  this->valueMapping.clear();
33  }
34 
35 
37  this->astRepresentation = other.astRepresentation;
38  this->modes = other.modes;
39  this->valueMapping = other.valueMapping;
40  return *this;
41  }
42 
43 
45  SharedAbstractNode node = std::make_shared<AssertNode>(expr);
46  if (node == nullptr)
47  throw triton::exceptions::Ast("Node builders - Not enough memory");
48  node->init();
49  return node;
50  }
51 
52 
54  SharedAbstractNode node = std::make_shared<BvNode>(value, size, *this);
55  if (node == nullptr)
56  throw triton::exceptions::Ast("Node builders - Not enough memory");
57  node->init();
58  return node;
59  }
60 
61 
64  /* Optimization: 0 + A = A */
65  if (!expr1->isSymbolized() && expr1->evaluate() == 0)
66  return expr2;
67 
68  /* Optimization: A + 0 = A */
69  if (!expr2->isSymbolized() && expr2->evaluate() == 0)
70  return expr1;
71  }
72 
73  SharedAbstractNode node = std::make_shared<BvaddNode>(expr1, expr2);
74  if (node == nullptr)
75  throw triton::exceptions::Ast("Node builders - Not enough memory");
76  node->init();
77 
78  return node;
79  }
80 
81 
84  /* Optimization: 0 & A = 0 */
85  if (!expr1->isSymbolized() && expr1->evaluate() == 0)
86  return this->bv(0, expr1->getBitvectorSize());
87 
88  /* Optimization: A & 0 = 0 */
89  if (!expr2->isSymbolized() && expr2->evaluate() == 0)
90  return this->bv(0, expr1->getBitvectorSize());
91 
92  /* Optimization: A & -1 = A */
93  if (!expr2->isSymbolized() && expr2->evaluate() == expr2->getBitvectorMask())
94  return expr1;
95 
96  /* Optimization: -1 & A = A */
97  if (!expr1->isSymbolized() && expr1->evaluate() == expr1->getBitvectorMask())
98  return expr2;
99 
100  /* Optimization: A & A = A */
101  if (!expr1->isSymbolized() && !expr2->isSymbolized() && expr1->equalTo(expr2))
102  return expr1;
103  }
104 
105  SharedAbstractNode node = std::make_shared<BvandNode>(expr1, expr2);
106  if (node == nullptr)
107  throw triton::exceptions::Ast("Node builders - Not enough memory");
108  node->init();
109 
110  return node;
111  }
112 
113 
116  /* Optimization: 0 >> A = 0 */
117  if (!expr1->isSymbolized() && expr1->evaluate() == 0)
118  return this->bv(0, expr1->getBitvectorSize());
119 
120  /* Optimization: A >> 0 = A */
121  if (!expr2->isSymbolized() && expr2->evaluate() == 0)
122  return expr1;
123  }
124 
125  SharedAbstractNode node = std::make_shared<BvashrNode>(expr1, expr2);
126  if (node == nullptr)
127  throw triton::exceptions::Ast("Node builders - Not enough memory");
128  node->init();
129 
130  return node;
131  }
132 
133 
135  SharedAbstractNode node = std::make_shared<BvNode>(0, 1, *this);
136  if (node == nullptr)
137  throw triton::exceptions::Ast("Node builders - Not enough memory");
138  node->init();
139  return node;
140  }
141 
142 
145  /* Optimization: 0 >> A = 0 */
146  if (!expr1->isSymbolized() && expr1->evaluate() == 0)
147  return this->bv(0, expr1->getBitvectorSize());
148 
149  /* Optimization: A >> 0 = A */
150  if (!expr2->isSymbolized() && expr2->evaluate() == 0)
151  return expr1;
152 
153  /* Optimization: A >> B>=size(A) = 0 */
154  if (!expr2->isSymbolized() && expr2->evaluate() >= expr1->getBitvectorSize())
155  return this->bv(0, expr1->getBitvectorSize());
156  }
157 
158  SharedAbstractNode node = std::make_shared<BvlshrNode>(expr1, expr2);
159  if (node == nullptr)
160  throw triton::exceptions::Ast("Node builders - Not enough memory");
161  node->init();
162 
163  return node;
164  }
165 
166 
169  /* Optimization: 0 * A = 0 */
170  if (!expr1->isSymbolized() && expr1->evaluate() == 0)
171  return this->bv(0, expr1->getBitvectorSize());
172 
173  /* Optimization: A * 0 = 0 */
174  if (!expr2->isSymbolized() && expr2->evaluate() == 0)
175  return this->bv(0, expr1->getBitvectorSize());
176  }
177 
178  SharedAbstractNode node = std::make_shared<BvmulNode>(expr1, expr2);
179  if (node == nullptr)
180  throw triton::exceptions::Ast("Node builders - Not enough memory");
181  node->init();
182 
183  return node;
184  }
185 
186 
188  SharedAbstractNode node = std::make_shared<BvnandNode>(expr1, expr2);
189  if (node == nullptr)
190  throw triton::exceptions::Ast("Node builders - Not enough memory");
191  node->init();
192  return node;
193  }
194 
195 
197  SharedAbstractNode node = std::make_shared<BvnegNode>(expr);
198  if (node == nullptr)
199  throw triton::exceptions::Ast("Node builders - Not enough memory");
200  node->init();
201  return node;
202  }
203 
204 
206  SharedAbstractNode node = std::make_shared<BvnorNode>(expr1, expr2);
207  if (node == nullptr)
208  throw triton::exceptions::Ast("Node builders - Not enough memory");
209  node->init();
210  return node;
211  }
212 
213 
215  SharedAbstractNode node = std::make_shared<BvnotNode>(expr);
216  if (node == nullptr)
217  throw triton::exceptions::Ast("Node builders - Not enough memory");
218  node->init();
219  return node;
220  }
221 
222 
225  /* Optimization: 0 | A = A */
226  if (!expr1->isSymbolized() && expr1->evaluate() == 0)
227  return expr2;
228 
229  /* Optimization: A | 0 = A */
230  if (!expr2->isSymbolized() && expr2->evaluate() == 0)
231  return expr1;
232 
233  /* Optimization: -1 | A = -1 */
234  if (!expr1->isSymbolized() && expr1->evaluate() == expr1->getBitvectorMask())
235  return this->bv(expr1->getBitvectorMask(), expr1->getBitvectorSize());
236 
237  /* Optimization: A | -1 = -1 */
238  if (!expr2->isSymbolized() && expr2->evaluate() == expr2->getBitvectorMask())
239  return this->bv(expr2->getBitvectorMask(), expr2->getBitvectorSize());
240 
241  /* Optimization: A | A = A */
242  if (expr1->equalTo(expr2))
243  return expr1;
244  }
245 
246  SharedAbstractNode node = std::make_shared<BvorNode>(expr1, expr2);
247  if (node == nullptr)
248  throw triton::exceptions::Ast("Node builders - Not enough memory");
249  node->init();
250 
251  return node;
252  }
253 
254 
256  SharedAbstractNode node = std::make_shared<BvrolNode>(expr, rot);
257  if (node == nullptr)
258  throw triton::exceptions::Ast("Node builders - Not enough memory");
259  node->init();
260  return node;
261  }
262 
263 
265  /*
266  * If the mode SYMBOLIZE_INDEX_ROTATION we apply a AST transformation
267  * in order to make index rotation symbolic. Note that this mode increases the
268  * complexity of solving.
269  *
270  * bvrol(rot, expr) = ((expr << (rot % size)) | (expr >> (size - (rot % size))))
271  **/
273  auto size = expr->getBitvectorSize();
274  auto bvsize = this->bv(size, size);
275  auto node = this->bvor(
276  this->bvshl(expr, this->bvsmod(rot, bvsize)),
277  this->bvlshr(expr, this->bvsub(bvsize, this->bvsmod(rot, bvsize)))
278  );
279  return node;
280  }
281 
282  /* Otherwise, we concretize the index rotation */
283  SharedAbstractNode node = std::make_shared<BvrolNode>(expr, this->integer(rot->evaluate()));
284  if (node == nullptr)
285  throw triton::exceptions::Ast("Node builders - Not enough memory");
286  node->init();
287 
288  return node;
289  }
290 
291 
293  SharedAbstractNode node = std::make_shared<BvrorNode>(expr, rot);
294  if (node == nullptr)
295  throw triton::exceptions::Ast("Node builders - Not enough memory");
296  node->init();
297  return node;
298  }
299 
300 
302  /*
303  * If the mode SYMBOLIZE_INDEX_ROTATION we apply a AST transformation
304  * in order to make index rotation symbolic. Note that this mode increases the
305  * complexity of solving.
306  *
307  * bvror(rot, expr) = ((value >> (rot % size)) | (value << (size - (rot % size))))
308  **/
310  auto size = expr->getBitvectorSize();
311  auto bvsize = this->bv(size, size);
312  auto node = this->bvor(
313  this->bvlshr(expr, this->bvsmod(rot, bvsize)),
314  this->bvshl(expr, this->bvsub(bvsize, this->bvsmod(rot, bvsize)))
315  );
316  return node;
317  }
318 
319  /* Otherwise, we concretize the index rotation */
320  SharedAbstractNode node = std::make_shared<BvrorNode>(expr, this->integer(rot->evaluate()));
321  if (node == nullptr)
322  throw triton::exceptions::Ast("Node builders - Not enough memory");
323  node->init();
324 
325  return node;
326  }
327 
328 
331  /* Optimization: A / 1 = A */
332  if (!expr2->isSymbolized() && expr2->evaluate() == 1)
333  return expr1;
334  }
335 
336  SharedAbstractNode node = std::make_shared<BvsdivNode>(expr1, expr2);
337  if (node == nullptr)
338  throw triton::exceptions::Ast("Node builders - Not enough memory");
339  node->init();
340 
341  return node;
342  }
343 
344 
346  SharedAbstractNode node = std::make_shared<BvsgeNode>(expr1, expr2);
347  if (node == nullptr)
348  throw triton::exceptions::Ast("Node builders - Not enough memory");
349  node->init();
350  return node;
351  }
352 
353 
355  SharedAbstractNode node = std::make_shared<BvsgtNode>(expr1, expr2);
356  if (node == nullptr)
357  throw triton::exceptions::Ast("Node builders - Not enough memory");
358  node->init();
359  return node;
360  }
361 
362 
365  /* Optimization: 0 << A = 0 */
366  if (!expr1->isSymbolized() && expr1->evaluate() == 0)
367  return this->bv(0, expr1->getBitvectorSize());
368 
369  /* Optimization: A << 0 = A */
370  if (!expr2->isSymbolized() && expr2->evaluate() == 0)
371  return expr1;
372 
373  /* Optimization: A << B>=size(A) = 0 */
374  if (!expr2->isSymbolized() && expr2->evaluate() >= expr1->getBitvectorSize())
375  return this->bv(0, expr1->getBitvectorSize());
376  }
377 
378  SharedAbstractNode node = std::make_shared<BvshlNode>(expr1, expr2);
379  if (node == nullptr)
380  throw triton::exceptions::Ast("Node builders - Not enough memory");
381  node->init();
382 
383  return node;
384  }
385 
386 
388  SharedAbstractNode node = std::make_shared<BvsleNode>(expr1, expr2);
389  if (node == nullptr)
390  throw triton::exceptions::Ast("Node builders - Not enough memory");
391  node->init();
392  return node;
393  }
394 
395 
397  SharedAbstractNode node = std::make_shared<BvsltNode>(expr1, expr2);
398  if (node == nullptr)
399  throw triton::exceptions::Ast("Node builders - Not enough memory");
400  node->init();
401  return node;
402  }
403 
404 
406  SharedAbstractNode node = std::make_shared<BvsmodNode>(expr1, expr2);
407  if (node == nullptr)
408  throw triton::exceptions::Ast("Node builders - Not enough memory");
409  node->init();
410  return node;
411  }
412 
413 
415  SharedAbstractNode node = std::make_shared<BvsremNode>(expr1, expr2);
416  if (node == nullptr)
417  throw triton::exceptions::Ast("Node builders - Not enough memory");
418  node->init();
419  return node;
420  }
421 
422 
425  /* Optimization: A - 0 = A */
426  if (!expr2->isSymbolized() && expr2->evaluate() == 0)
427  return expr1;
428 
429  /* Optimization: 0 - A = -A */
430  if (!expr1->isSymbolized() && expr1->evaluate() == 0)
431  return this->bvneg(expr2);
432 
433  /* Optimization: A - A = 0 */
434  if (expr1->equalTo(expr2))
435  return this->bv(0, expr1->getBitvectorSize());
436  }
437 
438  SharedAbstractNode node = std::make_shared<BvsubNode>(expr1, expr2);
439  if (node == nullptr)
440  throw triton::exceptions::Ast("Node builders - Not enough memory");
441  node->init();
442 
443  return node;
444  }
445 
446 
448  SharedAbstractNode node = std::make_shared<BvNode>(1, 1, *this);
449  if (node == nullptr)
450  throw triton::exceptions::Ast("Node builders - Not enough memory");
451  node->init();
452  return node;
453  }
454 
455 
458  /* Optimization: A / 1 = A */
459  if (!expr2->isSymbolized() && expr2->evaluate() == 1)
460  return expr1;
461  }
462 
463  SharedAbstractNode node = std::make_shared<BvudivNode>(expr1, expr2);
464  if (node == nullptr)
465  throw triton::exceptions::Ast("Node builders - Not enough memory");
466  node->init();
467 
468  return node;
469  }
470 
471 
473  SharedAbstractNode node = std::make_shared<BvugeNode>(expr1, expr2);
474  if (node == nullptr)
475  throw triton::exceptions::Ast("Node builders - Not enough memory");
476  node->init();
477  return node;
478  }
479 
480 
482  SharedAbstractNode node = std::make_shared<BvugtNode>(expr1, expr2);
483  if (node == nullptr)
484  throw triton::exceptions::Ast("Node builders - Not enough memory");
485  node->init();
486  return node;
487  }
488 
489 
491  SharedAbstractNode node = std::make_shared<BvuleNode>(expr1, expr2);
492  if (node == nullptr)
493  throw triton::exceptions::Ast("Node builders - Not enough memory");
494  node->init();
495  return node;
496  }
497 
498 
500  SharedAbstractNode node = std::make_shared<BvultNode>(expr1, expr2);
501  if (node == nullptr)
502  throw triton::exceptions::Ast("Node builders - Not enough memory");
503  node->init();
504  return node;
505  }
506 
507 
509  SharedAbstractNode node = std::make_shared<BvuremNode>(expr1, expr2);
510  if (node == nullptr)
511  throw triton::exceptions::Ast("Node builders - Not enough memory");
512  node->init();
513  return node;
514  }
515 
516 
518  SharedAbstractNode node = std::make_shared<BvxnorNode>(expr1, expr2);
519  if (node == nullptr)
520  throw triton::exceptions::Ast("Node builders - Not enough memory");
521  node->init();
522  return node;
523  }
524 
525 
528  /* Optimization: A ^ 0 = A */
529  if (!expr2->isSymbolized() && expr2->evaluate() == 0)
530  return expr1;
531 
532  /* Optimization: 0 ^ A = A */
533  if (!expr1->isSymbolized() && expr1->evaluate() == 0)
534  return expr2;
535 
536  /* Optimization: A ^ A = 0 */
537  if (expr1->equalTo(expr2))
538  return this->bv(0, expr1->getBitvectorSize());
539  }
540 
541  SharedAbstractNode node = std::make_shared<BvxorNode>(expr1, expr2);
542  if (node == nullptr)
543  throw triton::exceptions::Ast("Node builders - Not enough memory");
544  node->init();
545 
546  return node;
547  }
548 
549 
550  template TRITON_EXPORT SharedAbstractNode AstContext::compound(const std::vector<SharedAbstractNode>& exprs);
551  template TRITON_EXPORT SharedAbstractNode AstContext::compound(const std::list<SharedAbstractNode>& exprs);
552 
553 
555  SharedAbstractNode node = std::make_shared<ConcatNode>(expr1, expr2);
556  if (node == nullptr)
557  throw triton::exceptions::Ast("Node builders - Not enough memory");
558  node->init();
559  return node;
560  }
561 
562 
563  template TRITON_EXPORT SharedAbstractNode AstContext::concat(const std::vector<SharedAbstractNode>& exprs);
564  template TRITON_EXPORT SharedAbstractNode AstContext::concat(const std::list<SharedAbstractNode>& exprs);
565 
566 
568  SharedAbstractNode node = std::make_shared<DeclareNode>(var);
569  if (node == nullptr)
570  throw triton::exceptions::Ast("Node builders - Not enough memory");
571  node->init();
572  return node;
573  }
574 
575 
577  SharedAbstractNode node = std::make_shared<DistinctNode>(expr1, expr2);
578  if (node == nullptr)
579  throw triton::exceptions::Ast("Node builders - Not enough memory");
580  node->init();
581  return node;
582  }
583 
584 
586  SharedAbstractNode node = std::make_shared<EqualNode>(expr1, expr2);
587  if (node == nullptr)
588  throw triton::exceptions::Ast("Node builders - Not enough memory");
589  node->init();
590  return node;
591  }
592 
593 
595  /* Optimization: If we extract the full size of expr, just return expr */
596  if (low == 0 && (high + 1) == expr->getBitvectorSize())
597  return expr;
598 
599  SharedAbstractNode node = std::make_shared<ExtractNode>(high, low, expr);
600 
601  if (node == nullptr)
602  throw triton::exceptions::Ast("Node builders - Not enough memory");
603 
604  node->init();
605  return node;
606  }
607 
608 
610  SharedAbstractNode node = std::make_shared<IffNode>(expr1, expr2);
611  if (node == nullptr)
612  throw triton::exceptions::Ast("Node builders - Not enough memory");
613  node->init();
614  return node;
615  }
616 
617 
619  SharedAbstractNode node = std::make_shared<IntegerNode>(value, *this);
620  if (node == nullptr)
621  throw triton::exceptions::Ast("Node builders - Not enough memory");
622  node->init();
623  return node;
624  }
625 
626 
628  SharedAbstractNode node = std::make_shared<IteNode>(ifExpr, thenExpr, elseExpr);
629  if (node == nullptr)
630  throw triton::exceptions::Ast("Node builders - Not enough memory");
631  node->init();
632  return node;
633  }
634 
635 
637  SharedAbstractNode node = std::make_shared<LandNode>(expr1, expr2);
638  if (node == nullptr)
639  throw triton::exceptions::Ast("Node builders - Not enough memory");
640  node->init();
641  return node;
642  }
643 
644 
645  template TRITON_EXPORT SharedAbstractNode AstContext::land(const std::vector<SharedAbstractNode>& exprs);
646  template TRITON_EXPORT SharedAbstractNode AstContext::land(const std::list<SharedAbstractNode>& exprs);
647 
648 
649  SharedAbstractNode AstContext::let(std::string alias, const SharedAbstractNode& expr2, const SharedAbstractNode& expr3) {
650  SharedAbstractNode node = std::make_shared<LetNode>(alias, expr2, expr3);
651  if (node == nullptr)
652  throw triton::exceptions::Ast("Node builders - Not enough memory");
653  node->init();
654  return node;
655  }
656 
657 
659  SharedAbstractNode node = std::make_shared<LnotNode>(expr);
660  if (node == nullptr)
661  throw triton::exceptions::Ast("Node builders - Not enough memory");
662  node->init();
663  return node;
664  }
665 
666 
668  SharedAbstractNode node = std::make_shared<LorNode>(expr1, expr2);
669  if (node == nullptr)
670  throw triton::exceptions::Ast("Node builders - Not enough memory");
671  node->init();
672  return node;
673  }
674 
675 
676  template TRITON_EXPORT SharedAbstractNode AstContext::lor(const std::vector<SharedAbstractNode>& exprs);
677  template TRITON_EXPORT SharedAbstractNode AstContext::lor(const std::list<SharedAbstractNode>& exprs);
678 
679 
681  SharedAbstractNode node = std::make_shared<ReferenceNode>(expr);
682  if (node == nullptr)
683  throw triton::exceptions::Ast("Node builders - Not enough memory");
684  node->init();
685  return node;
686  }
687 
688 
690  SharedAbstractNode node = std::make_shared<StringNode>(value, *this);
691  if (node == nullptr)
692  throw triton::exceptions::Ast("Node builders - Not enough memory");
693  node->init();
694  return node;
695  }
696 
697 
699  /* Optimization: Just return expr if the extend is zero */
700  if (sizeExt == 0)
701  return expr;
702 
703  SharedAbstractNode node = std::make_shared<SxNode>(sizeExt, expr);
704 
705  if (node == nullptr)
706  throw triton::exceptions::Ast("Node builders - Not enough memory");
707 
708  node->init();
709  return node;
710  }
711 
712 
714  // try to get node from variable pool
715  auto it = this->valueMapping.find(symVar->getName());
716  if (it != this->valueMapping.end()) {
717  auto& node = it->second.first;
718 
719  if (node->getBitvectorSize() != symVar->getSize())
720  throw triton::exceptions::Ast("Node builders - Missmatching variable size.");
721 
722  // This node already exist, just return it
723  node->init();
724  return node;
725  }
726  else {
727  // if not found, create a new variable node
728  SharedAbstractNode node = std::make_shared<VariableNode>(symVar, *this);
729  this->initVariable(symVar->getName(), 0, node);
730  if (node == nullptr)
731  throw triton::exceptions::Ast("Node builders - Not enough memory");
732  node->init();
733  return node;
734  }
735  }
736 
737 
739  /* Optimization: Just return expr if the extend is zero */
740  if (sizeExt == 0)
741  return expr;
742 
743  SharedAbstractNode node = std::make_shared<ZxNode>(sizeExt, expr);
744 
745  if (node == nullptr)
746  throw triton::exceptions::Ast("Node builders - Not enough memory");
747 
748  node->init();
749  return node;
750  }
751 
752 
753  void AstContext::initVariable(const std::string& name, const triton::uint512& value, const SharedAbstractNode& node) {
754  auto it = this->valueMapping.find(name);
755  if (it == this->valueMapping.end())
756  this->valueMapping.insert(std::make_pair(name, std::make_pair(node, value)));
757  else
758  throw triton::exceptions::Ast("Ast variable already initialized");
759  }
760 
761 
762  void AstContext::updateVariable(const std::string& name, const triton::uint512& value) {
763  auto& kv = this->valueMapping.at(name);
764  kv.second = value;
765  kv.first->init();
766  }
767 
768 
770  auto it = this->valueMapping.find(name);
771  if (it == this->valueMapping.end())
772  return nullptr;
773  else
774  return it->second.first;
775  }
776 
777 
778  const triton::uint512& AstContext::getVariableValue(const std::string& varName) const {
779  try {
780  return this->valueMapping.at(varName).second;
781  } catch (const std::out_of_range&) {
782  throw triton::exceptions::Ast("AstContext::getVariableValue(): Variable doesn't exists");
783  }
784  }
785 
786 
788  this->astRepresentation.setMode(mode);
789  }
790 
791 
793  return this->astRepresentation.getMode();
794  }
795 
796 
797  std::ostream& AstContext::print(std::ostream& stream, AbstractNode* node) {
798  return this->astRepresentation.print(stream, node);
799  }
800 
801  }; /* ast namespace */
802 }; /* triton namespace */
TRITON_EXPORT SharedAbstractNode assert_(const SharedAbstractNode &expr)
AST C++ API - assert node builder.
Definition: astContext.cpp:44
TRITON_EXPORT SharedAbstractNode iff(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - iff node builder.
Definition: astContext.cpp:609
TRITON_EXPORT SharedAbstractNode bvnor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvnor node builder.
Definition: astContext.cpp:205
TRITON_EXPORT void setRepresentationMode(triton::uint32 mode)
Sets the representation mode for this astContext.
Definition: astContext.cpp:787
TRITON_EXPORT SharedAbstractNode string(std::string value)
AST C++ API - string node builder.
Definition: astContext.cpp:689
TRITON_EXPORT SharedAbstractNode distinct(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - distinct node builder.
Definition: astContext.cpp:576
TRITON_EXPORT const triton::uint512 & getVariableValue(const std::string &varName) const
Gets a variable value from its name.
Definition: astContext.cpp:778
TRITON_EXPORT SharedAbstractNode land(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - land node builder.
Definition: astContext.cpp:636
Abstract node.
Definition: ast.hpp:64
TRITON_EXPORT SharedAbstractNode ite(const SharedAbstractNode &ifExpr, const SharedAbstractNode &thenExpr, const SharedAbstractNode &elseExpr)
AST C++ API - ite node builder.
Definition: astContext.cpp:627
TRITON_EXPORT SharedAbstractNode let(std::string alias, const SharedAbstractNode &expr2, const SharedAbstractNode &expr3)
AST C++ API - let node builder.
Definition: astContext.cpp:649
AST Context - Used as AST builder.
Definition: astContext.hpp:50
TRITON_EXPORT SharedAbstractNode bvrol(const SharedAbstractNode &expr, triton::uint32 rot)
AST C++ API - bvrol node builder.
Definition: astContext.cpp:255
TRITON_EXPORT SharedAbstractNode declare(const SharedAbstractNode &var)
AST C++ API - declare node builder.
Definition: astContext.cpp:567
TRITON_EXPORT SharedAbstractNode bvsdiv(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsdiv node builder.
Definition: astContext.cpp:329
SharedAbstractNode compound(const T &exprs)
AST C++ API - compound node builder.
Definition: astContext.hpp:180
The Triton namespace.
Definition: api.cpp:225
TRITON_EXPORT SharedAbstractNode lnot(const SharedAbstractNode &expr)
AST C++ API - lnot node builder.
Definition: astContext.cpp:658
TRITON_EXPORT SharedAbstractNode integer(triton::uint512 value)
AST C++ API - integer node builder.
Definition: astContext.cpp:618
The exception class used by all AST nodes.
Definition: exceptions.hpp:341
TRITON_EXPORT SharedAbstractNode bvslt(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvslt node builder.
Definition: astContext.cpp:396
TRITON_EXPORT SharedAbstractNode bvand(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvand node builder.
Definition: astContext.cpp:82
TRITON_EXPORT SharedAbstractNode bvsrem(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsrem node builder.
Definition: astContext.cpp:414
TRITON_EXPORT SharedAbstractNode reference(const triton::engines::symbolic::SharedSymbolicExpression &expr)
AST C++ API - reference node builder.
Definition: astContext.cpp:680
TRITON_EXPORT SharedAbstractNode bvurem(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvurem node builder.
Definition: astContext.cpp:508
TRITON_EXPORT AstContext(triton::modes::Modes &modes)
Constructor.
Definition: astContext.cpp:19
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
Definition: ast.hpp:58
TRITON_EXPORT SharedAbstractNode bvuge(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvuge node builder.
Definition: astContext.cpp:472
TRITON_EXPORT SharedAbstractNode bvnot(const SharedAbstractNode &expr)
AST C++ API - bvnot node builder.
Definition: astContext.cpp:214
The modes class.
Definition: modes.hpp:34
TRITON_EXPORT SharedAbstractNode extract(triton::uint32 high, triton::uint32 low, const SharedAbstractNode &expr)
AST C++ API - extract node builder.
Definition: astContext.cpp:594
TRITON_EXPORT SharedAbstractNode bvxnor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvxnor node builder.
Definition: astContext.cpp:517
TRITON_EXPORT SharedAbstractNode sx(triton::uint32 sizeExt, const SharedAbstractNode &expr)
AST C++ API - sx node builder.
Definition: astContext.cpp:698
TRITON_EXPORT ~AstContext()
Destructor.
Definition: astContext.cpp:31
TRITON_EXPORT SharedAbstractNode bvor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvor node builder.
Definition: astContext.cpp:223
TRITON_EXPORT bool isModeEnabled(triton::modes::mode_e mode) const
Returns true if the mode is enabled.
Definition: modes.cpp:30
TRITON_EXPORT SharedAbstractNode bvadd(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvadd node builder.
Definition: astContext.cpp:62
[AST] Classical arithmetic optimisations to reduce the depth of the trees.
Definition: modesEnums.hpp:31
TRITON_EXPORT SharedAbstractNode bvror(const SharedAbstractNode &expr, triton::uint32 rot)
AST C++ API - bvror node builder.
Definition: astContext.cpp:292
TRITON_EXPORT SharedAbstractNode bvashr(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvashr node builder.
Definition: astContext.cpp:114
TRITON_EXPORT void updateVariable(const std::string &name, const triton::uint512 &value)
Updates a variable value in this context.
Definition: astContext.cpp:762
TRITON_EXPORT SharedAbstractNode bv(triton::uint512 value, triton::uint32 size)
AST C++ API - bv node builder.
Definition: astContext.cpp:53
TRITON_EXPORT void initVariable(const std::string &name, const triton::uint512 &value, const SharedAbstractNode &node)
Initializes a variable in the context.
Definition: astContext.cpp:753
TRITON_EXPORT SharedAbstractNode bvmul(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvmul node builder.
Definition: astContext.cpp:167
TRITON_EXPORT SharedAbstractNode bvsmod(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsmod node builder.
Definition: astContext.cpp:405
TRITON_EXPORT SharedAbstractNode bvneg(const SharedAbstractNode &expr)
AST C++ API - bvneg node builder.
Definition: astContext.cpp:196
TRITON_EXPORT SharedAbstractNode concat(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - concat node builder.
Definition: astContext.cpp:554
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
Definition: ast.hpp:39
TRITON_EXPORT SharedAbstractNode zx(triton::uint32 sizeExt, const SharedAbstractNode &expr)
AST C++ API - zx node builder.
Definition: astContext.cpp:738
TRITON_EXPORT SharedAbstractNode bvxor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvxor node builder.
Definition: astContext.cpp:526
std::uint32_t uint32
unisgned 32-bits
Definition: tritonTypes.hpp:31
TRITON_EXPORT SharedAbstractNode bvlshr(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvlshr node builder.
Definition: astContext.cpp:143
TRITON_EXPORT SharedAbstractNode bvnand(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvnand node builder.
Definition: astContext.cpp:187
TRITON_EXPORT SharedAbstractNode equal(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - equal node builder.
Definition: astContext.cpp:585
TRITON_EXPORT void setMode(triton::uint32 mode)
Sets the representation mode.
[symbolic] Symbolize index rotation for bvrol and bvror (see #751). This mode increases the complexit...
Definition: modesEnums.hpp:36
TRITON_EXPORT SharedAbstractNode bvsge(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsge node builder.
Definition: astContext.cpp:345
TRITON_EXPORT std::ostream & print(std::ostream &stream, AbstractNode *node)
Displays the node according to the representation mode.
TRITON_EXPORT triton::uint32 getRepresentationMode(void) const
Gets the representations mode of this astContext.
Definition: astContext.cpp:792
TRITON_EXPORT SharedAbstractNode bvtrue(void)
AST C++ API - bvtrue node builder.
Definition: astContext.cpp:447
std::shared_ptr< triton::engines::symbolic::SymbolicVariable > SharedSymbolicVariable
Shared Symbolic variable.
Definition: ast.hpp:42
TRITON_EXPORT SharedAbstractNode bvudiv(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvudiv node builder.
Definition: astContext.cpp:456
TRITON_EXPORT SharedAbstractNode bvult(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvult node builder.
Definition: astContext.cpp:499
TRITON_EXPORT SharedAbstractNode bvshl(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvshl node builder.
Definition: astContext.cpp:363
TRITON_EXPORT SharedAbstractNode bvule(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvule node builder.
Definition: astContext.cpp:490
TRITON_EXPORT SharedAbstractNode variable(const triton::engines::symbolic::SharedSymbolicVariable &symVar)
AST C++ API - variable node builder.
Definition: astContext.cpp:713
TRITON_EXPORT SharedAbstractNode bvugt(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvugt node builder.
Definition: astContext.cpp:481
TRITON_EXPORT AstContext & operator=(const AstContext &other)
Operator.
Definition: astContext.cpp:36
TRITON_EXPORT SharedAbstractNode bvsgt(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsgt node builder.
Definition: astContext.cpp:354
boost::multiprecision::uint512_t uint512
unsigned 512-bits
Definition: tritonTypes.hpp:43
TRITON_EXPORT std::ostream & print(std::ostream &stream, AbstractNode *node)
Print the given node with this context representation.
Definition: astContext.cpp:797
TRITON_EXPORT SharedAbstractNode bvsub(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsub node builder.
Definition: astContext.cpp:423
TRITON_EXPORT SharedAbstractNode bvfalse(void)
AST C++ API - bvfalse node builder.
Definition: astContext.cpp:134
TRITON_EXPORT SharedAbstractNode bvsle(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - bvsle node builder.
Definition: astContext.cpp:387
SharedAbstractNode getVariableNode(const std::string &name)
Gets a variable node from its name.
Definition: astContext.cpp:769
TRITON_EXPORT triton::uint32 getMode(void) const
Returns the representation mode.
TRITON_EXPORT SharedAbstractNode lor(const SharedAbstractNode &expr1, const SharedAbstractNode &expr2)
AST C++ API - lor node builder.
Definition: astContext.cpp:667