Example #1
0
void CheckerPropagate::SetTest(Bit *safe_bit)
{
  Assert(!m_where);

  Vector<Exp*> safe_terms;

  Solver *solver = m_frame->State()->GetSolver();
  solver->GetBitTerms(m_frame->Id(), safe_bit, &safe_terms);
  SortVector< Exp*, SortObjectsCompare<Exp> >(&safe_terms);

  // setup the initial where info in a pass over the whole bit. the bit might
  // be outright ignored or we might be forced to go to the caller because
  // of an ExpFrame subexpression.
  PropagateScanVisitor visitor;
  safe_bit->DoVisit(&visitor);

  if (visitor.ignore)
    m_where = new WhereNone(RK_None);
  else if (visitor.has_frame)
    m_where = WherePrecondition::Make(m_frame->Memory(), safe_bit);

  // try to find a direction which accomodates all terms in the bit.
  for (size_t ind = 0; ind < safe_terms.Size(); ind++) {
    Where *new_where = TryPropagate(safe_bit, safe_terms[ind]);

    if (new_where) {
      if (m_where) {
        // replace with the new direction only if it has higher priority.
        int priority = Where::PriorityCompare(new_where, m_where);
        if (priority < 0) {
          delete m_where;
          m_where = new_where;
        }
        else {
          delete new_where;
        }
      }
      else {
        m_where = new_where;
      }
    }
  }

  if (!m_where) {
    if (!safe_terms.Empty()) {
      // couldn't find a way to propagate from this point, generate Unexpected.
      m_where = new WhereNone(RK_Unexpected);
    }
    else {
      // nowhere to go from here.
      m_where = new WhereNone(RK_Finished);
    }
  }

  DecRefVector<Exp>(safe_terms, &safe_terms);
}
Example #2
0
void CheckerPropagate::SetBaseBit(Bit *base_bit, Bit *point_bit)
{
  Assert(!m_base_bit);
  Assert(!m_point_bit);

  base_bit->IncRef(this);
  m_base_bit = base_bit;

  point_bit->IncRef(this);
  m_point_bit = point_bit;

  Solver *solver = m_frame->State()->GetSolver();
  solver->GetBitTerms(m_frame->Id(), point_bit, &m_point_terms);
  SortVector< Exp*, SortObjectsCompare<Exp> >(&m_point_terms);
}