X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=predicate.cc;h=77f362dafd9c4f8ea29e465a3c01f5f99ea9172c;hb=7ecb1872e35ceba59b6949aa3942521e01920bd6;hp=42c63100f07a75b74118265010d1f9ffbf6e13a1;hpb=493376d8483562a85a590b9dfa890a27669ca6b4;p=c11tester.git diff --git a/predicate.cc b/predicate.cc index 42c63100..77f362da 100644 --- a/predicate.cc +++ b/predicate.cc @@ -1,9 +1,12 @@ #include "predicate.h" -Predicate::Predicate(FuncInst * func_inst) : +Predicate::Predicate(FuncInst * func_inst, bool is_entry) : func_inst(func_inst), - predicates(), - children() + entry_predicate(is_entry), + pred_expressions(), + children(), + parents(), + backedge(NULL) {} unsigned int pred_expr_hash(struct pred_expr * expr) @@ -25,7 +28,7 @@ bool pred_expr_equal(struct pred_expr * p1, struct pred_expr * p2) void Predicate::add_predicate(token_t token, void * location, bool value) { struct pred_expr *ptr = new pred_expr(token, location, value); - predicates.add(ptr); + pred_expressions.add(ptr); } void Predicate::add_child(Predicate * child) @@ -34,13 +37,25 @@ void Predicate::add_child(Predicate * child) children.push_back(child); } +void Predicate::add_parent(Predicate * parent) +{ + /* check duplication? */ + parents.push_back(parent); +} + void Predicate::print_predicate() { - model_print("\"%p\" [shape=box, label=\"%p\n", this, this); + model_print("\"%p\" [shape=box, label=\"\n", this); + if (entry_predicate) { + model_print("entry node\"];\n"); + return; + } + func_inst->print(); - PredSetIter * it = predicates.iterator(); - if (predicates.getSize() == 0) + PredExprSetIter * it = pred_expressions.iterator(); + + if (pred_expressions.getSize() == 0) model_print("no predicate\n"); while (it->hasNext()) { @@ -58,4 +73,7 @@ void Predicate::print_pred_subtree() child->print_pred_subtree(); model_print("\"%p\" -> \"%p\"\n", this, child); } + + if (backedge != NULL) + model_print("\"%p\" -> \"%p\"[style=dashed, color=grey]\n", this, backedge); }