+/** **/
+
+void ConstGen::computeYieldCond(EPRecord *record) {
+ ExecPoint *yieldep=record->getEP();
+ EPRecord *prevyield=NULL;
+ ExecPoint *prevyieldep=NULL;
+
+ for(int i=(int)(yieldlist->size()-1);i>=0;i--) {
+ EPRecord *tmpyield=(*yieldlist)[i];
+ ExecPoint *tmpep=tmpyield->getEP();
+ //Do we have a previous yield operation
+ if (yieldep->compare(tmpep)==CR_BEFORE) {
+ //Yes
+ prevyield=tmpyield;
+ prevyieldep=prevyield->getEP();
+ break;
+ }
+ }
+
+ yieldlist->push_back(record);
+
+ ModelVector<Constraint *> * novel_branches=new ModelVector<Constraint *>();
+ RecordIterator *sri=incompleteexploredbranch->iterator();
+ while(sri->hasNext()) {
+ EPRecord * unexploredbranch=sri->next();
+ ExecPoint * branchep=unexploredbranch->getEP();
+ if (yieldep->compare(branchep)!=CR_BEFORE) {
+ //Branch does not occur before yield, so skip
+ continue;
+ }
+
+ //See if the previous yield already accounts for this branch
+ if (prevyield != NULL &&
+ prevyieldep->compare(branchep)==CR_BEFORE) {
+ //Branch occurs before previous yield, so we can safely skip this branch
+ continue;
+ }
+
+ //This is a branch that could prevent this yield from being executed
+ BranchRecord *br=branchtable->get(unexploredbranch);
+ Constraint * novel_branch=br->getNewBranch();
+ novel_branches->push_back(novel_branch);
+ }
+
+ int num_constraints=((prevyield==NULL)?0:1)+novel_branches->size();
+ Constraint *carray[num_constraints];
+ int arr_index=0;
+
+ if (prevyield!=NULL) {
+ carray[arr_index++]=yieldtable->get(prevyield);//get constraint for old yield
+ }
+ for(uint i=0;i<novel_branches->size();i++) {
+ carray[arr_index++]=(*novel_branches)[i];
+ }
+
+ Constraint *cor=num_constraints!=0?new Constraint(OR, num_constraints, carray):&cfalse;
+
+ Constraint *var=getNewVar();
+ //If the variable is true, then we need to have taken some branch
+ //ahead of the yield
+ Constraint *implies=new Constraint(IMPLIES, var, cor);
+ ADDCONSTRAINT(implies, "possiblebranchnoyield");
+ yieldtable->put(record, var);
+
+ delete novel_branches;
+ delete sri;
+}
+
+