13#include <unordered_map>
14#include <unordered_set>
67 mask = mask >> (512 - this->
size);
73 if ((this->
eval >> (this->
size-1)) & 1)
117 switch (this->
type) {
139 return (this->
evaluate() == other->evaluate()) &&
141 (this->
isLogical() == other->isLogical());
152 return (this->
evaluate() == other->evaluate()) &&
154 (this->
getHash() == other->getHash()) &&
155 (this->
getLevel() == other->getLevel());
176 for (
auto& sp : ancestors) {
188 std::vector<SharedAbstractNode> res;
189 std::vector<AbstractNode*> toRemove;
191 for (
auto& kv: parents) {
192 if (
auto sp = kv.second.second.lock())
195 toRemove.push_back(kv.first);
198 for(
auto* an: toRemove)
206 auto it = parents.find(p);
208 if (it == parents.end()) {
210 this->parents.insert(std::make_pair(p, std::make_pair(1,
WeakAbstractNode(A))));
213 if (it->second.second.expired()) {
216 this->parents.insert(std::make_pair(p, std::make_pair(1,
WeakAbstractNode(A))));
220 it->second.first += 1;
227 auto it = this->parents.find(p);
229 if (it == parents.end())
233 if (it->second.first == 0)
234 this->parents.erase(it);
254 if (child ==
nullptr)
257 if (this->
children[index] != child) {
259 this->
children[index]->removeParent(
this);
262 child->setParent(
this);
268 child->initParents();
281 if (!s.str().empty())
291 this->indexSize = indexSize;
292 this->
addChild(this->ctxt->integer(indexSize));
305 this->
children[index]->setParent(
this);
319 void ArrayNode::initHash(
void) {
333 this->memory[addr] = value;
338 if (this->memory.find(addr) != this->memory.end()) {
339 return this->memory.at(addr);
361 return this->indexSize;
388 this->
children[index]->setParent(
this);
402 void AssertNode::initHash(
void) {
442 this->
eval |= ((this->
children[0]->evaluate() >> index) & 0xff);
447 this->
children[index]->setParent(
this);
461 void BswapNode::initHash(
void) {
501 this->
children[index]->setParent(
this);
515 void BvaddNode::initHash(
void) {
555 this->
children[index]->setParent(
this);
569 void BvandNode::initHash(
void) {
605 value = this->
children[0]->evaluate();
628 else if (shift == 0) {
641 this->
children[index]->setParent(
this);
655 void BvashrNode::initHash(
void) {
695 this->
children[index]->setParent(
this);
709 void BvlshrNode::initHash(
void) {
749 this->
children[index]->setParent(
this);
763 void BvmulNode::initHash(
void) {
803 this->
children[index]->setParent(
this);
817 void BvnandNode::initHash(
void) {
853 this->
children[index]->setParent(
this);
867 void BvnegNode::initHash(
void) {
907 this->
children[index]->setParent(
this);
921 void BvnorNode::initHash(
void) {
957 this->
children[index]->setParent(
this);
971 void BvnotNode::initHash(
void) {
1011 this->
children[index]->setParent(
this);
1025 void BvorNode::initHash(
void) {
1029 if (s) this->
hash = this->
hash * s;
1061 rot = triton::ast::getInteger<triton::uint32>(this->
children[1]);
1062 value = this->
children[0]->evaluate();
1073 this->
children[index]->setParent(
this);
1087 void BvrolNode::initHash(
void) {
1091 if (s) this->
hash = this->
hash * s;
1123 rot = triton::ast::getInteger<triton::uint32>(this->
children[1]);
1124 value = this->
children[0]->evaluate();
1135 this->
children[index]->setParent(
this);
1149 void BvrorNode::initHash(
void) {
1153 if (s) this->
hash = this->
hash * s;
1193 if (op2Signed == 0) {
1194 this->
eval = (op1Signed < 0 ? 1 : -1);
1202 this->
children[index]->setParent(
this);
1216 void BvsdivNode::initHash(
void) {
1220 if (s) this->
hash = this->
hash * s;
1257 this->
eval = (op1Signed >= op2Signed);
1263 this->
children[index]->setParent(
this);
1277 void BvsgeNode::initHash(
void) {
1281 if (s) this->
hash = this->
hash * s;
1318 this->
eval = (op1Signed > op2Signed);
1324 this->
children[index]->setParent(
this);
1338 void BvsgtNode::initHash(
void) {
1342 if (s) this->
hash = this->
hash * s;
1378 this->
children[index]->setParent(
this);
1392 void BvshlNode::initHash(
void) {
1396 if (s) this->
hash = this->
hash * s;
1433 this->
eval = (op1Signed <= op2Signed);
1439 this->
children[index]->setParent(
this);
1453 void BvsleNode::initHash(
void) {
1457 if (s) this->
hash = this->
hash * s;
1494 this->
eval = (op1Signed < op2Signed);
1500 this->
children[index]->setParent(
this);
1514 void BvsltNode::initHash(
void) {
1518 if (s) this->
hash = this->
hash * s;
1565 this->
children[index]->setParent(
this);
1579 void BvsmodNode::initHash(
void) {
1583 if (s) this->
hash = this->
hash * s;
1630 this->
children[index]->setParent(
this);
1644 void BvsremNode::initHash(
void) {
1648 if (s) this->
hash = this->
hash * s;
1684 this->
children[index]->setParent(
this);
1698 void BvsubNode::initHash(
void) {
1702 if (s) this->
hash = this->
hash * s;
1742 this->
children[index]->setParent(
this);
1756 void BvudivNode::initHash(
void) {
1760 if (s) this->
hash = this->
hash * s;
1796 this->
children[index]->setParent(
this);
1810 void BvugeNode::initHash(
void) {
1814 if (s) this->
hash = this->
hash * s;
1850 this->
children[index]->setParent(
this);
1864 void BvugtNode::initHash(
void) {
1868 if (s) this->
hash = this->
hash * s;
1904 this->
children[index]->setParent(
this);
1918 void BvuleNode::initHash(
void) {
1922 if (s) this->
hash = this->
hash * s;
1958 this->
children[index]->setParent(
this);
1972 void BvultNode::initHash(
void) {
1976 if (s) this->
hash = this->
hash * s;
2016 this->
children[index]->setParent(
this);
2030 void BvuremNode::initHash(
void) {
2034 if (s) this->
hash = this->
hash * s;
2070 this->
children[index]->setParent(
this);
2084 void BvxnorNode::initHash(
void) {
2088 if (s) this->
hash = this->
hash * s;
2124 this->
children[index]->setParent(
this);
2138 void BvxorNode::initHash(
void) {
2142 if (s) this->
hash = this->
hash * s;
2156 this->
addChild(this->ctxt->integer(value & this->getBitvectorMask()));
2168 value = triton::ast::getInteger<triton::uint512>(this->
children[0]);
2169 size = triton::ast::getInteger<triton::uint32>(this->
children[1]);
2185 this->
children[index]->setParent(
this);
2199 void BvNode::initHash(
void) {
2203 if (s) this->
hash = this->
hash * s;
2227 this->
children[index]->setParent(
this);
2241 void CompoundNode::initHash(
void) {
2245 if (s) this->
hash = this->
hash * s;
2272 this->
size += this->
children[index]->getBitvectorSize();
2276 throw triton::exceptions::Ast(
"ConcatNode::init(): Size cannot be greater than triton::bitsize::max_supported.");
2287 this->
children[index]->setParent(
this);
2301 void ConcatNode::initHash(
void) {
2305 if (s) this->
hash = this->
hash * s;
2327 throw triton::exceptions::Ast(
"DeclareNode::init(): The child node must be a VARIABLE_NODE or an ARRAY_NODE.");
2337 this->
children[index]->setParent(
this);
2351 void DeclareNode::initHash(
void) {
2355 if (s) this->
hash = this->
hash * s;
2391 this->
children[index]->setParent(
this);
2405 void DistinctNode::initHash(
void) {
2409 if (s) this->
hash = this->
hash * s;
2445 this->
children[index]->setParent(
this);
2459 void EqualNode::initHash(
void) {
2463 if (s) this->
hash = this->
hash * s;
2492 high = triton::ast::getInteger<triton::uint32>(this->
children[0]);
2493 low = triton::ast::getInteger<triton::uint32>(this->
children[1]);
2499 this->
size = ((high - low) + 1);
2505 throw triton::exceptions::Ast(
"ExtractNode::init(): The size of the extraction is higher than the child expression.");
2509 this->
children[index]->setParent(
this);
2523 void ExtractNode::initHash(
void) {
2527 if (s) this->
hash = this->
hash * s;
2560 this->
children[index]->setParent(
this);
2574 void ForallNode::initHash(
void) {
2578 if (s) this->
hash = this->
hash * s;
2611 this->
eval = (P && Q) || (!P && !Q);
2617 this->
children[index]->setParent(
this);
2631 void IffNode::initHash(
void) {
2635 if (s) this->
hash = this->
hash * s;
2648 this->value = value;
2673 void IntegerNode::initHash(
void) {
2696 throw triton::exceptions::Ast(
"IteNode::init(): Must take two nodes of same size as 'then' and 'else' branches.");
2702 throw triton::exceptions::Ast(
"IteNode::init(): Must take either two logical nodes or two bv nodes as 'then' and 'else' branches.");
2713 this->
children[index]->setParent(
this);
2727 void IteNode::initHash(
void) {
2731 if (s) this->
hash = this->
hash * s;
2764 this->
children[index]->setParent(
this);
2779 void LandNode::initHash(
void) {
2783 if (s) this->
hash = this->
hash * s;
2817 this->
children[index]->setParent(
this);
2831 void LetNode::initHash(
void) {
2835 if (s) this->
hash = this->
hash * s;
2867 this->
children[index]->setParent(
this);
2881 void LnotNode::initHash(
void) {
2885 if (s) this->
hash = this->
hash * s;
2918 this->
children[index]->setParent(
this);
2933 void LorNode::initHash(
void) {
2937 if (s) this->
hash = this->
hash * s;
2970 this->
children[index]->setParent(
this);
2985 void LxorNode::initHash(
void) {
2989 if (s) this->
hash = this->
hash * s;
3009 this->
array = this->expr->getAst()->isArray();
3010 this->
eval = this->expr->getAst()->evaluate();
3011 this->
logical = this->expr->getAst()->isLogical();
3012 this->
size = this->expr->getAst()->getBitvectorSize();
3013 this->
symbolized = this->expr->getAst()->isSymbolized();
3014 this->
level = 1 + this->expr->getAst()->getLevel();
3016 this->expr->getAst()->setParent(
this);
3027 void ReferenceNode::initHash(
void) {
3028 this->
hash = this->expr->getAst()->getHash();
3079 this->
children[index]->setParent(
this);
3093 void SelectNode::initHash(
void) {
3097 if (s) this->
hash = this->
hash * s;
3131 throw triton::exceptions::Ast(
"StoreNode::init(): Size of indexing must be equal to the array indexing size.");
3161 this->
children[index]->setParent(
this);
3175 void StoreNode::initHash(
void) {
3179 if (s) this->
hash = this->
hash * s;
3189 if (this->memory.find(addr) != this->memory.end()) {
3190 return this->memory.at(addr);
3207 return this->memory;
3212 return this->indexSize;
3220 this->value = value;
3240 std::string StringNode::getString(
void) {
3245 void StringNode::initHash(
void) {
3249 for (std::string::const_iterator it=this->value.cbegin(); it != this->value.cend(); it++) {
3275 sizeExt = triton::ast::getInteger<triton::uint32>(this->
children[0]);
3278 this->
size = sizeExt + this->
children[1]->getBitvectorSize();
3280 throw triton::exceptions::Ast(
"SxNode::SxNode(): Size cannot be greater than triton::bitsize::max_supported.");
3284 this->
eval = ((((this->
children[1]->evaluate() >> (this->
children[1]->getBitvectorSize()-1)) == 0) ?
3289 this->
children[index]->setParent(
this);
3303 void SxNode::initHash(
void) {
3307 if (s) this->
hash = this->
hash * s;
3326 this->
size = this->symVar->getSize();
3341 return this->symVar;
3345 void VariableNode::initHash(
void) {
3350 for (
char c : this->symVar->getName()) {
3376 sizeExt = triton::ast::getInteger<triton::uint32>(this->
children[0]);
3379 this->
size = sizeExt + this->
children[1]->getBitvectorSize();
3389 this->
children[index]->setParent(
this);
3403 void ZxNode::initHash(
void) {
3407 if (s) this->
hash = this->
hash * s;
3425 template TRITON_EXPORT CompoundNode::CompoundNode(
const std::list<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3426 template TRITON_EXPORT CompoundNode::CompoundNode(
const std::vector<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3427 template TRITON_EXPORT ConcatNode::ConcatNode(
const std::list<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3428 template TRITON_EXPORT ConcatNode::ConcatNode(
const std::vector<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3429 template TRITON_EXPORT ForallNode::ForallNode(
const std::list<SharedAbstractNode>& vars,
const SharedAbstractNode& body);
3430 template TRITON_EXPORT ForallNode::ForallNode(
const std::vector<SharedAbstractNode>& vars,
const SharedAbstractNode& body);
3431 template TRITON_EXPORT LandNode::LandNode(
const std::list<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3432 template TRITON_EXPORT LandNode::LandNode(
const std::vector<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3433 template TRITON_EXPORT LorNode::LorNode(
const std::list<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3434 template TRITON_EXPORT LorNode::LorNode(
const std::vector<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3435 template TRITON_EXPORT LxorNode::LxorNode(
const std::list<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3436 template TRITON_EXPORT LxorNode::LxorNode(
const std::vector<SharedAbstractNode>& exprs,
const SharedAstContext& ctxt);
3450 return node->
getContext()->print(stream, node);
3466 hash = ((hash * hash) & mask);
3472 if ((shift &= 511) == 0)
3474 return ((value << shift) | (value >> (512 - shift)));
3506 if (node ==
nullptr)
3509 switch (node->getType()) {
3510 case ARRAY_NODE: newNode = std::make_shared<ArrayNode>(*
reinterpret_cast<ArrayNode*
>(node));
break;
3511 case ASSERT_NODE: newNode = std::make_shared<AssertNode>(*
reinterpret_cast<AssertNode*
>(node));
break;
3512 case BSWAP_NODE: newNode = std::make_shared<BswapNode>(*
reinterpret_cast<BswapNode*
>(node));
break;
3513 case BVADD_NODE: newNode = std::make_shared<BvaddNode>(*
reinterpret_cast<BvaddNode*
>(node));
break;
3514 case BVAND_NODE: newNode = std::make_shared<BvandNode>(*
reinterpret_cast<BvandNode*
>(node));
break;
3515 case BVASHR_NODE: newNode = std::make_shared<BvashrNode>(*
reinterpret_cast<BvashrNode*
>(node));
break;
3516 case BVLSHR_NODE: newNode = std::make_shared<BvlshrNode>(*
reinterpret_cast<BvlshrNode*
>(node));
break;
3517 case BVMUL_NODE: newNode = std::make_shared<BvmulNode>(*
reinterpret_cast<BvmulNode*
>(node));
break;
3518 case BVNAND_NODE: newNode = std::make_shared<BvnandNode>(*
reinterpret_cast<BvnandNode*
>(node));
break;
3519 case BVNEG_NODE: newNode = std::make_shared<BvnegNode>(*
reinterpret_cast<BvnegNode*
>(node));
break;
3520 case BVNOR_NODE: newNode = std::make_shared<BvnorNode>(*
reinterpret_cast<BvnorNode*
>(node));
break;
3521 case BVNOT_NODE: newNode = std::make_shared<BvnotNode>(*
reinterpret_cast<BvnotNode*
>(node));
break;
3522 case BVOR_NODE: newNode = std::make_shared<BvorNode>(*
reinterpret_cast<BvorNode*
>(node));
break;
3523 case BVROL_NODE: newNode = std::make_shared<BvrolNode>(*
reinterpret_cast<BvrolNode*
>(node));
break;
3524 case BVROR_NODE: newNode = std::make_shared<BvrorNode>(*
reinterpret_cast<BvrorNode*
>(node));
break;
3525 case BVSDIV_NODE: newNode = std::make_shared<BvsdivNode>(*
reinterpret_cast<BvsdivNode*
>(node));
break;
3526 case BVSGE_NODE: newNode = std::make_shared<BvsgeNode>(*
reinterpret_cast<BvsgeNode*
>(node));
break;
3527 case BVSGT_NODE: newNode = std::make_shared<BvsgtNode>(*
reinterpret_cast<BvsgtNode*
>(node));
break;
3528 case BVSHL_NODE: newNode = std::make_shared<BvshlNode>(*
reinterpret_cast<BvshlNode*
>(node));
break;
3529 case BVSLE_NODE: newNode = std::make_shared<BvsleNode>(*
reinterpret_cast<BvsleNode*
>(node));
break;
3530 case BVSLT_NODE: newNode = std::make_shared<BvsltNode>(*
reinterpret_cast<BvsltNode*
>(node));
break;
3531 case BVSMOD_NODE: newNode = std::make_shared<BvsmodNode>(*
reinterpret_cast<BvsmodNode*
>(node));
break;
3532 case BVSREM_NODE: newNode = std::make_shared<BvsremNode>(*
reinterpret_cast<BvsremNode*
>(node));
break;
3533 case BVSUB_NODE: newNode = std::make_shared<BvsubNode>(*
reinterpret_cast<BvsubNode*
>(node));
break;
3534 case BVUDIV_NODE: newNode = std::make_shared<BvudivNode>(*
reinterpret_cast<BvudivNode*
>(node));
break;
3535 case BVUGE_NODE: newNode = std::make_shared<BvugeNode>(*
reinterpret_cast<BvugeNode*
>(node));
break;
3536 case BVUGT_NODE: newNode = std::make_shared<BvugtNode>(*
reinterpret_cast<BvugtNode*
>(node));
break;
3537 case BVULE_NODE: newNode = std::make_shared<BvuleNode>(*
reinterpret_cast<BvuleNode*
>(node));
break;
3538 case BVULT_NODE: newNode = std::make_shared<BvultNode>(*
reinterpret_cast<BvultNode*
>(node));
break;
3539 case BVUREM_NODE: newNode = std::make_shared<BvuremNode>(*
reinterpret_cast<BvuremNode*
>(node));
break;
3540 case BVXNOR_NODE: newNode = std::make_shared<BvxnorNode>(*
reinterpret_cast<BvxnorNode*
>(node));
break;
3541 case BVXOR_NODE: newNode = std::make_shared<BvxorNode>(*
reinterpret_cast<BvxorNode*
>(node));
break;
3542 case BV_NODE: newNode = std::make_shared<BvNode>(*
reinterpret_cast<BvNode*
>(node));
break;
3543 case COMPOUND_NODE: newNode = std::make_shared<CompoundNode>(*
reinterpret_cast<CompoundNode*
>(node));
break;
3544 case CONCAT_NODE: newNode = std::make_shared<ConcatNode>(*
reinterpret_cast<ConcatNode*
>(node));
break;
3545 case DECLARE_NODE: newNode = std::make_shared<DeclareNode>(*
reinterpret_cast<DeclareNode*
>(node));
break;
3546 case DISTINCT_NODE: newNode = std::make_shared<DistinctNode>(*
reinterpret_cast<DistinctNode*
>(node));
break;
3547 case EQUAL_NODE: newNode = std::make_shared<EqualNode>(*
reinterpret_cast<EqualNode*
>(node));
break;
3548 case EXTRACT_NODE: newNode = std::make_shared<ExtractNode>(*
reinterpret_cast<ExtractNode*
>(node));
break;
3549 case FORALL_NODE: newNode = std::make_shared<ForallNode>(*
reinterpret_cast<ForallNode*
>(node));
break;
3550 case IFF_NODE: newNode = std::make_shared<IffNode>(*
reinterpret_cast<IffNode*
>(node));
break;
3551 case INTEGER_NODE: newNode = std::make_shared<IntegerNode>(*
reinterpret_cast<IntegerNode*
>(node));
break;
3552 case ITE_NODE: newNode = std::make_shared<IteNode>(*
reinterpret_cast<IteNode*
>(node));
break;
3553 case LAND_NODE: newNode = std::make_shared<LandNode>(*
reinterpret_cast<LandNode*
>(node));
break;
3554 case LET_NODE: newNode = std::make_shared<LetNode>(*
reinterpret_cast<LetNode*
>(node));
break;
3555 case LNOT_NODE: newNode = std::make_shared<LnotNode>(*
reinterpret_cast<LnotNode*
>(node));
break;
3556 case LOR_NODE: newNode = std::make_shared<LorNode>(*
reinterpret_cast<LorNode*
>(node));
break;
3557 case LXOR_NODE: newNode = std::make_shared<LxorNode>(*
reinterpret_cast<LxorNode*
>(node));
break;
3560 return triton::ast::shallowCopy(
reinterpret_cast<ReferenceNode*
>(node)->getSymbolicExpression()->getAst().get(),
unroll);
3562 newNode = std::make_shared<ReferenceNode>(*
reinterpret_cast<ReferenceNode*
>(node));
3565 case SELECT_NODE: newNode = std::make_shared<SelectNode>(*
reinterpret_cast<SelectNode*
>(node));
break;
3566 case STORE_NODE: newNode = std::make_shared<StoreNode>(*
reinterpret_cast<StoreNode*
>(node));
break;
3567 case STRING_NODE: newNode = std::make_shared<StringNode>(*
reinterpret_cast<StringNode*
>(node));
break;
3568 case SX_NODE: newNode = std::make_shared<SxNode>(*
reinterpret_cast<SxNode*
>(node));
break;
3569 case VARIABLE_NODE: newNode = node->shared_from_this();
break;
3570 case ZX_NODE: newNode = std::make_shared<ZxNode>(*
reinterpret_cast<ZxNode*
>(node));
break;
3575 if (newNode ==
nullptr)
3581 auto parents = newNode->getParents();
3582 for (
auto& p : parents) {
3583 newNode->removeParent(p.get());
3587 return node->getContext()->collect(newNode);
3592 std::unordered_map<AbstractNode*, SharedAbstractNode> exprs;
3595 for (
auto&& n : nodes) {
3597 const auto& newNode = shallowCopy(n.get(),
unroll);
3598 exprs[n.get()] = newNode;
3601 auto& children = newNode->getChildren();
3602 for (
auto& child : children) {
3603 child = exprs[child.get()];
3604 child->setParent(newNode.get());
3609 return exprs.at(node);
3628 static std::vector<SharedAbstractNode> nodesExtraction(
const SharedAbstractNode& node,
bool unroll,
bool revert,
bool descend) {
3629 std::vector<SharedAbstractNode> result;
3630 std::unordered_set<AbstractNode*> visited;
3631 std::stack<std::pair<SharedAbstractNode, bool>> worklist;
3633 if (node ==
nullptr)
3640 worklist.push({node,
false});
3642 while (!worklist.empty()) {
3645 std::tie(ast, postOrder) = worklist.top();
3650 result.push_back(ast);
3654 if (!visited.insert(ast.get()).second) {
3658 worklist.push({ast,
true});
3660 const auto& relatives = descend ? ast->getChildren() : ast->getParents();
3663 for (
const auto& r : relatives) {
3664 if (visited.find(r.get()) == visited.end()) {
3665 worklist.push({r,
false});
3671 const SharedAbstractNode& ref =
reinterpret_cast<ReferenceNode*
>(ast.get())->getSymbolicExpression()->getAst();
3672 if (visited.find(ref.get()) == visited.end()) {
3673 worklist.push({ref,
false});
3680 std::reverse(result.begin(), result.end());
3688 return nodesExtraction(node,
unroll, revert,
true);
3693 return nodesExtraction(node,
false, revert,
false);
3698 std::stack<AbstractNode*> worklist;
3699 std::deque<SharedAbstractNode> result;
3700 std::unordered_set<const AbstractNode*> visited;
3702 worklist.push(node.get());
3703 while (!worklist.empty()) {
3708 if (visited.find(current) != visited.end()) {
3712 visited.insert(current);
3714 result.push_front(current->shared_from_this());
3721 worklist.push(child.get());
3735 ptr = ref->getSymbolicExpression()->getAst().get();
3738 return ptr->shared_from_this();
3743 switch(node->getType()) {
TRITON_EXPORT bool canReplaceNodeWithoutUpdate(const SharedAbstractNode &other) const
Returns true if the node's value, value type and properties match those of the second one.
TRITON_EXPORT triton::uint32 getLevel(void) const
Returns the deep level of the tree.
bool symbolized
True if the tree contains a symbolic variable.
TRITON_EXPORT bool hasSameConcreteValueAndTypeAs(const SharedAbstractNode &other) const
Returns true if the node's concrete value and value type match those of the second one.
TRITON_EXPORT SharedAstContext getContext(void) const
Access to its context.
TRITON_EXPORT AbstractNode(triton::ast::ast_e type, const SharedAstContext &ctxt)
Constructor.
triton::ast::ast_e type
The type of the node.
TRITON_EXPORT void setParent(AbstractNode *p)
Sets a parent node.
TRITON_EXPORT bool equalTo(const SharedAbstractNode &other) const
Returns true if the current tree is equal to the second one.
TRITON_EXPORT void setChild(triton::uint32 index, const SharedAbstractNode &child)
Sets a child at an index.
TRITON_EXPORT bool isSigned(void) const
According to the size of the expression, returns true if the MSB is 1.
TRITON_EXPORT std::vector< SharedAbstractNode > getParents(void)
Returns the parents of node or an empty set if there is still no parent defined.
TRITON_EXPORT triton::uint512 getHash(void) const
Returns the hash of the tree.
bool array
True if it's an array node.
SharedAstContext ctxt
Contect use to create this node.
TRITON_EXPORT triton::uint512 getBitvectorMask(void) const
Returns the vector mask according the size of the node.
TRITON_EXPORT bool isArray(void) const
Returns true if it's an array node.
virtual TRITON_EXPORT ~AbstractNode()
Destructor.
triton::uint32 size
The size of the node.
TRITON_EXPORT bool isSymbolized(void) const
Returns true if the tree contains a symbolic variable.
std::vector< SharedAbstractNode > children
The children of the node.
TRITON_EXPORT triton::uint32 getBitvectorSize(void) const
Returns the size of the node.
TRITON_EXPORT bool isLogical(void) const
Returns true if it's a logical node.
TRITON_EXPORT std::vector< SharedAbstractNode > & getChildren(void)
Returns the children of the node.
bool logical
True if it's a logical node.
TRITON_EXPORT void setBitvectorSize(triton::uint32 size)
Sets the size of the node.
triton::uint512 eval
The value of the tree from this root node.
triton::uint512 hash
The hash of the tree.
TRITON_EXPORT std::string str(void) const
Returns the string representation of the node.
TRITON_EXPORT void addChild(const SharedAbstractNode &child)
Adds a child.
TRITON_EXPORT void removeParent(AbstractNode *p)
Removes a parent node.
void initParents(void)
Initializes parents.
TRITON_EXPORT triton::uint512 evaluate(void) const
Evaluates the tree.
TRITON_EXPORT triton::ast::ast_e getType(void) const
Returns the type of the node.
triton::uint32 level
Deep level for computing hash.
(Array (_ BitVec indexSize) (_ BitVec 8)) node
TRITON_EXPORT void store(triton::uint64 addr, triton::uint8 value)
Stores a concrete value into the memory array.
TRITON_EXPORT triton::uint8 select(triton::uint64 addr) const
Select a concrete value into the memory array.
TRITON_EXPORT triton::uint32 getIndexSize(void) const
Gets the index size.
TRITON_EXPORT std::unordered_map< triton::uint64, triton::uint8 > & getMemory(void)
Gets the concrete memory array.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT triton::uint32 getIndexSize(void) const
Gets the index size.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT std::unordered_map< triton::uint64, triton::uint8 > & getMemory(void)
Gets the concrete memory array.
TRITON_EXPORT triton::uint8 select(triton::uint64 addr) const
Select a concrete value into the memory array.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
TRITON_EXPORT ZxNode(triton::uint32 sizeExt, const SharedAbstractNode &expr)
Create a zero extend of expr to sizeExt bits.
TRITON_EXPORT void init(bool withParents=false)
Init properties of the node. If withParents is true, init also properties of parents.
The exception class used by all AST nodes.
triton::uint32 getIndexSize(const SharedAbstractNode &node)
Gets the index size of an array.
SharedAbstractNode unroll(const triton::ast::SharedAbstractNode &node)
AST C++ API - Unrolls the SSA form of a given AST.
std::shared_ptr< triton::ast::AbstractNode > SharedAbstractNode
Shared Abstract Node.
SharedAbstractNode dereference(const SharedAbstractNode &node)
Returns the first non referene node encountered.
std::weak_ptr< triton::ast::AbstractNode > WeakAbstractNode
Weak Abstract Node.
triton::uint512 hash2n(triton::uint512 hash, triton::uint32 n)
Custom hash2n function for hash routine.
std::vector< SharedAbstractNode > parentsExtraction(const SharedAbstractNode &node, bool revert)
Returns node and all its parents of an AST sorted topologically. If revert is true,...
std::vector< SharedAbstractNode > childrenExtraction(const SharedAbstractNode &node, bool unroll, bool revert)
Returns node and all its children of an AST sorted topologically. If unroll is true,...
std::ostream & operator<<(std::ostream &stream, AbstractNode *node)
Displays the node in ast representation.
SharedAbstractNode newInstance(AbstractNode *node, bool unroll)
AST C++ API - Duplicates the AST.
triton::sint512 modularSignExtend(AbstractNode *node)
Custom modular sign extend for bitwise operation.
std::deque< SharedAbstractNode > search(const SharedAbstractNode &node, triton::ast::ast_e match)
Returns a deque of collected matched nodes via a depth-first pre order traversal.
triton::uint512 rotl(const triton::uint512 &value, triton::uint32 shift)
Custom rotate left function for hash routine.
std::shared_ptr< triton::ast::AstContext > SharedAstContext
Shared AST context.
constexpr triton::uint32 byte
byte size in bit
constexpr triton::uint32 max_supported
max size supported in bit
std::shared_ptr< triton::engines::symbolic::SymbolicVariable > SharedSymbolicVariable
Shared Symbolic variable.
std::shared_ptr< triton::engines::symbolic::SymbolicExpression > SharedSymbolicExpression
Shared Symbolic Expression.
std::size_t usize
unsigned MAX_INT 32 or 64 bits according to the CPU.
std::uint64_t uint64
unisgned 64-bits
std::uint32_t uint32
unisgned 32-bits
std::uint8_t uint8
unisgned 8-bits