3 Predicate::Predicate(FuncInst * func_inst) :
5 entry_predicate(false),
10 unsigned int pred_expr_hash(struct pred_expr * expr)
12 return (unsigned int)((uintptr_t)expr);
15 bool pred_expr_equal(struct pred_expr * p1, struct pred_expr * p2)
17 if (p1->token != p2->token)
19 if (p1->token == EQUALITY && p1->location != p2->location)
21 if (p1->value != p2->value)
26 void Predicate::add_predicate(token_t token, void * location, bool value)
28 struct pred_expr *ptr = new pred_expr(token, location, value);
29 pred_expressions.add(ptr);
32 void Predicate::add_child(Predicate * child)
34 /* check duplication? */
35 children.push_back(child);
38 void Predicate::print_predicate()
40 model_print("\"%p\" [shape=box, label=\"\n", this);
42 PredExprSetIter * it = pred_expressions.iterator();
44 if (pred_expressions.getSize() == 0)
45 model_print("no predicate\n");
47 while (it->hasNext()) {
48 struct pred_expr * expr = it->next();
49 model_print("predicate: token: %d, location: %p, value: %d\n", expr->token, expr->location, expr->value);
51 model_print("\"];\n");
54 void Predicate::print_pred_subtree()
57 for (uint i = 0; i < children.size(); i++) {
58 Predicate * child = children[i];
59 child->print_pred_subtree();
60 model_print("\"%p\" -> \"%p\"\n", this, child);