Exemplo n.º 1
0
constraint constraint_copy (/*@temp@*/ /*@observer@*/ constraint c)
{
  if (!constraint_isDefined (c))
    {
      return constraint_undefined;
    }
  else
    {
      constraint ret = constraint_makeNew ();
      ret->lexpr = constraintExpr_copy (c->lexpr);
      ret->ar = c->ar;
      ret->expr =  constraintExpr_copy (c->expr);
      ret->post = c->post;
      /*@-assignexpose@*/
      ret->generatingExpr = c->generatingExpr;
      /*@=assignexpose@*/
      
      if (c->orig != NULL)
	ret->orig = constraint_copy (c->orig);
      else
	ret->orig = NULL;
      
      if (c->or != NULL)
	ret->or = constraint_copy (c->or);
      else
	ret->or = NULL;
      
      ret->fcnPre = c->fcnPre;
      
      return ret;
    }
}
Exemplo n.º 2
0
constraint constraint_preserveOrig (/*@returned@*/ constraint c) /*@modifies c @*/
{
  if (constraint_isDefined (c))
    {
      DPRINTF (("Doing constraint_preserverOrig for %q", constraint_printLocation (c)));
      
      if (c->orig == constraint_undefined)
	{
	  c->orig = constraint_copy (c);
	}
      else if (c->orig->fcnPre)
	{
	  constraint temp = c->orig;
	  
	  /* avoid infinite loop */
	  c->orig = NULL;
	  c->orig = constraint_copy (c);
	  /*drl 03/2/2003 if c != NULL then the copy of c will != null*/
	  llassert (constraint_isDefined (c->orig) );
	  
	  if (c->orig->orig == NULL)
	    {
	      c->orig->orig = temp;
	      temp = NULL;
	    }
	  else
	    {
	      llcontbug ((message ("Expected c->orig->orig to be null")));
	      constraint_free (c->orig->orig);
	      c->orig->orig = temp;
	      temp = NULL;
	    }
	}
      else
	{
	  DPRINTF (("Not changing constraint"));
	}
    }

  DPRINTF ((message ("After Doing constraint_preserverOrig for %q ", constraint_unparseDetailed (c))));
  return c;
}
Exemplo n.º 3
0
/*@only@*/ constraintList constraintList_addList (/*@only@*/ /*@returned@*/ constraintList s, /*@observer@*/ /*@temp@*/ constraintList newList)
{
  llassert(constraintList_isDefined (s));
  llassert(constraintList_isDefined (newList));

  if (newList == constraintList_undefined)
    return s;
  
  constraintList_elements (newList, elem)
    {
      s = constraintList_add (s, constraint_copy(elem));
    }
Exemplo n.º 4
0
constraint constraint_doFixResult (constraint postcondition, /*@dependent@*/ exprNode fcnCall)
{
  postcondition = constraint_copy (postcondition);

  llassert (constraint_isDefined (postcondition) );
 
  
  postcondition->lexpr = constraintExpr_doFixResult (postcondition->lexpr, fcnCall);
  postcondition->expr = constraintExpr_doFixResult (postcondition->expr, fcnCall);

  return postcondition;
}
Exemplo n.º 5
0
void constraint_overWrite (constraint c1, constraint c2) 
{
  llassert (constraint_isDefined (c1) && constraint_isDefined (c2));

  llassert (c1 != c2);

  DPRINTF ((message ("OverWriteing constraint %q with %q", constraint_unparse (c1),
		   constraint_unparse (c2))));
  
  constraintExpr_free (c1->lexpr);
  constraintExpr_free (c1->expr);
  
  c1->lexpr = constraintExpr_copy (c2->lexpr);
  c1->ar = c2->ar;
  c1->expr =  constraintExpr_copy (c2->expr);
  c1->post = c2->post;

  if (c1->orig != NULL)
    constraint_free (c1->orig);

  if (c2->orig != NULL)
    c1->orig = constraint_copy (c2->orig);
  else
    c1->orig = NULL;

  if (c1->or != NULL)
    constraint_free (c1->or);

  if (c2->or != NULL)
    c1->or = constraint_copy (c2->or);
  else
    c1->or = NULL;

  c1->fcnPre = c2->fcnPre;

  /*@-assignexpose@*/
  c1->generatingExpr = c2->generatingExpr;
  /*@=assignexpose@*/
}
Exemplo n.º 6
0
/*@only@*/ constraint constraint_doSRefFixConstraintParam (constraint precondition,
						   exprNodeList arglist)
{

  precondition = constraint_copy (precondition);

  llassert (constraint_isDefined (precondition) );
 
  precondition->lexpr = constraintExpr_doSRefFixConstraintParam (precondition->lexpr, arglist);
  precondition->expr = constraintExpr_doSRefFixConstraintParam (precondition->expr, arglist);

  precondition->fcnPre = FALSE;
  return constraint_simplify(precondition);
}
Exemplo n.º 7
0
static /*@only@*/ constraintList getLessThanConstraints (/*@observer@*/ constraintList c)
{
  constraintList ret;

  ret = constraintList_makeNew ();
  constraintList_elements (c, el)
    {
      llassert (constraint_isDefined (el));
      if ( constraint_isUndefined (el)  )
      	continue;
      
      if (el->ar == LT || el->ar == LTE)
	{
	  constraint temp;
	  temp = constraint_copy (el);

	  ret = constraintList_add (ret, temp);
	}
    }
/*@only@*/ constraintList constraintList_subsumeEnsures (constraintList list1, constraintList list2)
{
  constraintList ret;
  ret = constraintList_makeNew();
  constraintList_elements (list1, el)
    {
      
      DPRINTF ((message ("Examining %s", constraint_unparse (el) ) ) );
      if (!constraintList_resolve (el, list2) )
	{
	  constraint temp;
	  temp = constraint_copy(el);
	  ret = constraintList_add (ret, temp);
	}
      else
	{
	  DPRINTF ((message ("Subsuming %s", constraint_unparse (el) ) ) );
	}
    } end_constraintList_elements;
Exemplo n.º 9
0
constraint makeConstraintParse3 (constraintExpr l, lltok relOp, constraintExpr r)     
{
  constraint ret;
  ret = constraint_makeNew ();
  llassert (constraintExpr_isDefined (l));
    
  ret->lexpr = constraintExpr_copy (l);

  if (lltok_getTok (relOp) == GE_OP)
    {
      ret->ar = GTE;
    }
  else if (lltok_getTok (relOp) == LE_OP)
    {
      ret->ar = LTE;
    }
  else if (lltok_getTok (relOp) == EQ_OP)
    {
      ret->ar = EQ;
    }
  else
    llfatalbug ( message ("Unsupported relational operator"));

  ret->expr = constraintExpr_copy (r);

  ret->post = TRUE;

  ret->orig = constraint_copy (ret);

  ret = constraint_simplify (ret);
  /* ret->orig = ret; */

  DPRINTF (("GENERATED CONSTRAINT:"));
  DPRINTF ((message ("%s", constraint_unparse (ret))));
  return ret;
}