Exemple #1
0
cstring  constraint_unparseOr (constraint c) /*@*/
{
  cstring ret;
  constraint temp;

  ret = cstring_undefined;
     
  llassert (constraint_isDefined (c) );
 
  temp = c;

  ret = cstring_concatFree (ret, constraint_unparse (temp));

  temp = temp->or;
  
  while ( constraint_isDefined (temp)) 
    {
      ret = cstring_concatFree (ret, cstring_makeLiteral (" OR "));
      ret = cstring_concatFree (ret, constraint_unparse (temp));
      temp = temp->or;
    }

  return ret;

}
Exemple #2
0
static cstring constraint_unparseDeep (constraint c)
{
  cstring genExpr;
  cstring st;

  llassert (constraint_isDefined (c));
  st = constraint_unparse (c);
  
  if (c->orig != constraint_undefined)
    {
      st = cstring_appendChar (st, '\n');
      genExpr =  exprNode_unparse (c->orig->generatingExpr);

      if (!c->post)
	{
	  if (c->orig->fcnPre)
	    {
	      st = cstring_concatFree (st, message (" derived from %s precondition: %q", 
						    genExpr, constraint_unparseDeep (c->orig)));
	    }
	  else
	    {
	      st = cstring_concatFree (st, message (" needed to satisfy precondition:\n%q",
						    constraint_unparseDeep (c->orig)));
	    }
	}
      else
	{
	  st = cstring_concatFree (st, message ("derived from: %q",
						constraint_unparseDeep (c->orig)));
	}
    }

  return st;  
}
Exemple #3
0
constraint constraint_addGeneratingExpr (/*@returned@*/ constraint c, /*@exposed@*/ exprNode e)
{
  if (!constraint_isDefined (c)) 
    {
      return c;
    }
  
  if (c->generatingExpr == NULL)
    {
      c->generatingExpr = e;
      DPRINTF ((message ("setting generatingExpr for %s to %s", constraint_unparse (c), exprNode_unparse (e)) ));
    }
  else
    {
      DPRINTF ((message ("Not setting generatingExpr for %s to %s", constraint_unparse (c), exprNode_unparse (e)) ));
    }
  return c;
}
/*@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;
Exemple #5
0
static int constraint_getDepth (/*@observer@*/ /*@temp@*/ constraint c)
{
  int l , r;
  
  llassert (constraint_isDefined (c) );
 
  l = constraintExpr_getDepth (c->lexpr);
  r = constraintExpr_getDepth (c->expr);

  if (l > r)
    {
      DPRINTF (( message ("constraint depth returning %d for %s", l, constraint_unparse (c))));
      return l;
    }
  else
    {
      DPRINTF (( message ("constraint depth returning %d for %s", r, constraint_unparse (c))));
      return r;
    }
}
Exemple #6
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@*/
}
Exemple #7
0
 /*drl added 8-11-001*/
cstring constraint_printLocation (/*@observer@*/ /*@temp@*/ constraint c) /*@*/
{
  cstring string, ret;
  fileloc errorLoc;
  
  string = constraint_unparse (c);

  errorLoc = constraint_getFileloc (c);

  ret = message ("constraint: %q @ %q", string, fileloc_unparse (errorLoc));
  fileloc_free (errorLoc);
  return ret;

}
constraintList 
constraintList_add (/*@returned@*/ constraintList s, /*@only@*/ constraint el)
{
  llassert (constraintList_isDefined (s));

  /*drl7x */

  if (constraintList_resolve (el, s))
    {
      DPRINTF (("Resolved constraint: %s", constraint_unparse (el)));
      constraint_free (el);
      return s;
    }

  DPRINTF (("Adding constraint: %s", constraint_unparse (el)));
  
  if (s->nspace <= 0)
    constraintList_grow (s);

  s->nspace--;
  s->elements[s->nelements] = el;
  s->nelements++;
  return s;
}
Exemple #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;
}
Exemple #10
0
void constraint_printError (constraint c, fileloc loc)
{
  cstring string;
  fileloc errorLoc, temp;

  bool isLikely;
    
  llassert (constraint_isDefined (c) );
 
  /*drl 11/26/2001 avoid printing tautological constraints */
  if (constraint_isAlwaysTrue (c))
    {
      return;
    }


  string = constraint_unparseDetailed (c);

  errorLoc = loc;

  temp = constraint_getFileloc (c);

  if (fileloc_isDefined (temp))
    {
      errorLoc = temp;
    }
  else
    {
      llassert (FALSE);
      DPRINTF (("constraint %s had undefined fileloc %s", 
		constraint_unparse (c), fileloc_unparse (temp)));
      fileloc_free (temp);
      errorLoc = fileloc_copy (errorLoc);
    }

  
  if (context_getFlag (FLG_BOUNDSCOMPACTERRORMESSAGES))
    {
      string = cstring_replaceChar(string, '\n', ' ');
    }

  /*drl added 12/19/2002 print
    a different error fro "likely" bounds-errors*/
  
  isLikely = constraint_isConstantOnly (c);

  if (isLikely)
    {
      if (c->post)
	{
	  voptgenerror (FLG_FUNCTIONPOST, string, errorLoc);
	}
      else
	{
	  if (constraint_hasMaxSet (c))
	    {
	      voptgenerror (FLG_LIKELYBOUNDSWRITE, string, errorLoc);
	    }
	  else
	    {
	      voptgenerror (FLG_LIKELYBOUNDSREAD, string, errorLoc);
	    }
	}
    }
  else if (c->post)
    {
      voptgenerror (FLG_FUNCTIONPOST, string, errorLoc);
    }
  else
    {
      if (constraint_hasMaxSet (c))
	{
	  voptgenerror (FLG_BOUNDSWRITE, string, errorLoc);
	}
      else
	{
	  voptgenerror (FLG_BOUNDSREAD, string, errorLoc);
	}
    }

  fileloc_free(errorLoc);
}
Exemple #11
0
constraint constraint_origAddGeneratingExpr (/*@returned@*/ constraint c, exprNode e)
{
  llassert (constraint_isDefined (c) );
 
  if (c->orig != constraint_undefined)
    {
      c->orig = constraint_addGeneratingExpr (c->orig, e);
    }
  else
    {
      DPRINTF ((message ("constraint_origAddGeneratingExpr: Not setting generatingExpr for %s to %s", constraint_unparse (c), exprNode_unparse (e)) ));
    }
  return c;
}