# include "exprChecks.h"
# include "exprNodeSList.h"
-/*@-czechfcns@*/
-/*@-nullderef@*/ /* !!! DRL needs to fix this code! */
-/*@-nullstate@*/ /* !!! DRL needs to fix this code! */
-/*@-nullpass@*/ /* !!! DRL needs to fix this code! */
-/*@-temptrans@*/ /* !!! DRL needs to fix this code! */
-
-/*@access exprNode@*/ /* !!! NO! Don't do this recklessly! */
-
bool constraintTerm_isDefined (constraintTerm t)
{
return t != NULL;
switch (term->kind)
{
- case EXPRNODE:
+ case CTT_EXPR:
/* we don't free an exprNode*/
break;
- case SREF:
+ case CTT_SREF:
/* sref */
sRef_free (term->value.sref);
break;
- case INTLITERAL:
+ case CTT_INTLITERAL:
/* don't free an int */
break;
- case ERRORBADCONSTRAINTTERMTYPE:
+ case CTT_ERRORBADCONSTRAINTTERMTYPE:
default:
/* type was set incorrectly */
llcontbug (message("constraintTerm_free type was set incorrectly"));
}
- term->kind = ERRORBADCONSTRAINTTERMTYPE;
+ term->kind = CTT_ERRORBADCONSTRAINTTERMTYPE;
free (term);
}
{
llassert(term != NULL);
- if (term->kind == INTLITERAL)
+ if (term->kind == CTT_INTLITERAL)
return TRUE;
return FALSE;
bool constraintTerm_isInitBlock (/*@observer@*/ /*@temp@*/ constraintTerm c) /*@*/
{
llassert (c != NULL);
- if (c->kind == EXPRNODE)
+
+ if (c->kind == CTT_EXPR)
{
-
- if (exprNode_isInitBlock(c->value.expr) )
+ if (exprNode_isInitBlock (c->value.expr))
{
return TRUE;
}
bool constraintTerm_isExprNode (/*@observer@*/ /*@temp@*/ constraintTerm c) /*@*/
{
llassert (c != NULL);
- if (c->kind == EXPRNODE)
+
+ if (c->kind == CTT_EXPR)
{
return TRUE;
}
return FALSE;
}
-
+/*@access exprNode@*/
int constraintTerm_getInitBlockLength (/*@observer@*/ /*@temp@*/ constraintTerm c) /*@*/
{
-
- exprNodeList list;
+ exprNodeList list;
int ret;
llassert (c != NULL);
llassert (constraintTerm_isInitBlock (c) );
- llassert (c->kind == EXPRNODE);
+ llassert (c->kind == CTT_EXPR);
llassert(exprNode_isDefined(c->value.expr) );
return ret;
}
-
+/*@noaccess exprNode@*/
bool constraintTerm_isStringLiteral (constraintTerm c) /*@*/
{
llassert (c != NULL);
- if (c->kind == EXPRNODE)
+ if (c->kind == CTT_EXPR)
{
if (exprNode_knownStringValue(c->value.expr) )
{
{
llassert (c != NULL);
llassert (constraintTerm_isStringLiteral (c) );
- llassert (c->kind == EXPRNODE);
+ llassert (c->kind == CTT_EXPR);
return (cstring_copy ( multiVal_forceString (exprNode_getValue (c->value.expr) ) ) );
}
constraintTerm constraintTerm_simplify (/*@returned@*/ constraintTerm term) /*@modifies term@*/
{
- if (term->kind == EXPRNODE)
+ if (term->kind == CTT_EXPR)
{
if ( exprNode_knownIntValue (term->value.expr ) )
{
temp = exprNode_getLongValue (term->value.expr);
term->value.intlit = (int)temp;
- term->kind = INTLITERAL;
+ term->kind = CTT_INTLITERAL;
}
}
return term;
/*@exposed@*/ sRef constraintTerm_getSRef (constraintTerm t)
{
llassert (constraintTerm_isDefined(t) );
- llassert (t->kind == SREF);
+ llassert (t->kind == CTT_SREF);
return (t->value.sref);
}
-/*@only@*/ constraintTerm constraintTerm_makeExprNode (/*@dependent@*/ exprNode e)
+/*@only@*/ constraintTerm constraintTerm_makeExprNode (/*@dependent@*/ exprNode e)
{
- constraintTerm ret = new_constraintTermExpr();
- ret->loc = fileloc_copy(exprNode_getfileloc(e));
+ constraintTerm ret = new_constraintTermExpr ();
+ ret->loc = fileloc_copy (exprNode_loc (e));
ret->value.expr = e;
- ret->kind = EXPRNODE;
- ret = constraintTerm_simplify(ret);
+ ret->kind = CTT_EXPR;
+ ret = constraintTerm_simplify (ret);
return ret;
}
-/*@only@*/ constraintTerm constraintTerm_makesRef (/*@temp@*/ /*@observer@*/ sRef s)
+/*@only@*/ constraintTerm constraintTerm_makesRef (/*@temp@*/ /*@observer@*/ sRef s)
{
constraintTerm ret = new_constraintTermExpr();
ret->loc = fileloc_undefined;
ret->value.sref = sRef_saveCopy(s);
- ret->kind = SREF;
+ ret->kind = CTT_SREF;
ret = constraintTerm_simplify(ret);
return ret;
}
switch (term->kind)
{
- case EXPRNODE:
+ case CTT_EXPR:
ret->value.expr = term->value.expr;
break;
- case INTLITERAL:
+ case CTT_INTLITERAL:
ret->value.intlit = term->value.intlit;
break;
- case SREF:
+ case CTT_SREF:
ret->value.sref = sRef_saveCopy(term->value.sref);
break;
default:
switch (term->kind)
{
- case EXPRNODE:
- /*@i334*/ /*wtf*/
+ case CTT_EXPR:
+
s = message ("%s", exprNode_unparse (term->value.expr) );
break;
- case INTLITERAL:
+ case CTT_INTLITERAL:
s = message (" %d ", (int) term->value.intlit);
break;
- case SREF:
+ case CTT_SREF:
s = message ("%q", sRef_unparse (term->value.sref) );
break;
switch (term->kind)
{
- case EXPRNODE:
- /*@i334*/ /*wtf*/
+ case CTT_EXPR:
+
break;
- case INTLITERAL:
+ case CTT_INTLITERAL:
break;
- case SREF:
+ case CTT_SREF:
term->value.sref = sRef_fixBaseParam (term->value.sref, arglist);
break;
default:
}
-cstring constraintTerm_print (constraintTerm term) /*@*/
+cstring constraintTerm_unparse (constraintTerm term) /*@*/
{
cstring s;
s = cstring_undefined;
switch (term->kind)
{
- case EXPRNODE:
- /*@i334*/ /*wtf*/
+ case CTT_EXPR:
+
s = message ("%s @ %q", exprNode_unparse (term->value.expr),
fileloc_unparse (term->loc) );
break;
- case INTLITERAL:
+ case CTT_INTLITERAL:
s = message ("%d", (int)term->value.intlit);
break;
- case SREF:
+ case CTT_SREF:
s = message ("%q", sRef_unparseDebug (term->value.sref) );
break;
{
constraintTerm ret = new_constraintTermExpr();
ret->value.intlit = i;
- ret->kind = INTLITERAL;
+ ret->kind = CTT_INTLITERAL;
ret->loc = fileloc_undefined;
return ret;
}
bool constraintTerm_canGetValue (constraintTerm term)
{
- if (term->kind == INTLITERAL)
+ if (term->kind == CTT_INTLITERAL)
{
return TRUE;
}
- else if (term->kind == SREF)
+ else if (term->kind == CTT_SREF)
{
if (sRef_hasValue (term->value.sref))
{
return FALSE;
}
}
- else if (term->kind == EXPRNODE)
+ else if (term->kind == CTT_EXPR)
{
return FALSE;
}
}
}
+void constraintTerm_setValue (constraintTerm term, long value)
+{
+ if (term->kind == CTT_INTLITERAL)
+ {
+ term->value.intlit = value;
+ }
+ else
+ {
+ BADBRANCH;
+ }
+}
+
long constraintTerm_getValue (constraintTerm term)
{
llassert (constraintTerm_canGetValue (term));
- if (term->kind == INTLITERAL)
+ if (term->kind == CTT_INTLITERAL)
{
return term->value.intlit;
}
- else if (term->kind == SREF)
+ else if (term->kind == CTT_SREF)
{
if (sRef_hasValue (term->value.sref))
{
BADBRANCH;
}
}
- else if (term->kind == EXPRNODE)
+ else if (term->kind == CTT_EXPR)
{
BADBRANCH;
}
{
llassert (t != NULL);
- llassert (t->kind == EXPRNODE);
+ llassert (t->kind == CTT_EXPR);
return t->value.expr;
/*@exposed@*/ sRef constraintTerm_getsRef (constraintTerm t)
{
llassert (t != NULL);
- if (t->kind == EXPRNODE)
+ if (t->kind == CTT_EXPR)
{
return exprNode_getSref(t->value.expr);
}
- if (t->kind == SREF)
+ if (t->kind == CTT_SREF)
{
return t->value.sref;
}
llassert (term1 !=NULL && term2 !=NULL);
DPRINTF ((message
- ("Comparing srefs for %s and %s ", constraintTerm_print(term1), constraintTerm_print(term2)
+ ("Comparing srefs for %s and %s ", constraintTerm_getName(term1), constraintTerm_getName(term2)
)
)
);
llassert (term1 !=NULL && term2 !=NULL);
if (constraintTerm_canGetValue (term1) && constraintTerm_canGetValue (term2))
- /* evans 2001-07-24: was (term1->kind == INTLITERAL) && (term2->kind == INTLITERAL) ) */
+
+ /*3/30/2003 comment updated to reflect name change form INTLITERAL to CTT_INTLITERAL*/
+ /* evans 2001-07-24: was (term1->kind == CTT_INTLITERAL) && (term2->kind == CTT_INTLITERAL) ) */
{
long t1, t2;
return (t1 == t2);
}
-
+
+ /*drl this if statement handles the case where constraintTerm_canGetValue only returns
+ true for term1 or term2 but no both
+ if constraintTerm_canGetValue returned tru for both we would have returned in the previous if statement
+ I suppose this could be done with xor but I've never used xor and don't feel like starting now
+ besides this way is more effecient.
+ */
if (constraintTerm_canGetValue (term1) || constraintTerm_canGetValue (term2))
{
- /* evans 2001-07-24: is this right? */ /*@i534@*/
+
return FALSE;
}
}
DPRINTF((message
- ("Comparing srefs for %s and %s ", constraintTerm_print(term1), constraintTerm_print(term2)
+ ("Comparing srefs for %s and %s ", constraintTerm_getName(term1), constraintTerm_getName(term2)
)
)
);
if (sRef_similarRelaxed(s1, s2) || sRef_sameName (s1, s2) )
{
- DPRINTF ((message (" %s and %s are same", constraintTerm_print(term1), constraintTerm_print(term2) ) ));
+ DPRINTF ((message (" %s and %s are same", constraintTerm_getName(term1), constraintTerm_getName(term2) ) ));
return TRUE;
}
else
{
- DPRINTF ((message (" %s and %s are not same", constraintTerm_print(term1), constraintTerm_print(term2) ) ));
+ DPRINTF ((message (" %s and %s are not same", constraintTerm_getName(term1), constraintTerm_getName(term2) ) ));
return FALSE;
}
}
switch (kind)
{
- case EXPRNODE:
+ case CTT_EXPR:
u = exprNode_getUentry(t->value.expr);
fprintf (f, "%s\n", cstring_toCharsSafe (uentry_rawName (u)));
break;
- case SREF:
+ case CTT_SREF:
{
sRef s;
}
break;
- case INTLITERAL:
+ case CTT_INTLITERAL:
fprintf (f, "%ld\n", t->value.intlit);
break;
switch (kind)
{
- case SREF:
+ case CTT_SREF:
{
sRef s;
char * term;
term = reader_getWord(&str);
-
+
+ if (term == NULL)
+ {
+ llfatalbug (message ("Library file appears to be corrupted.") );
+ }
if (strcmp (term, "Result") == 0 )
{
s = sRef_makeResult (ctype_unknown);
str2 = reader_getWord(&str);
param = reader_getInt(&str);
+ if (str2 == NULL)
+ {
+ llfatalbug (message ("Library file appears to be corrupted.") );
+ }
+
ostr2 = str2;
t = ctype_undump(&str2) ;
s = sRef_makeParam (param, t, stateInfo_makeLoc (g_currentloc, SA_CREATED));
}
break;
- case EXPRNODE:
+ case CTT_EXPR:
{
sRef s;
char * term;
cstring termStr;
term = reader_getWord(&str);
+
+ if (term == NULL)
+ {
+ llfatalbug (message ("Library file appears to be corrupted.") );
+ }
+
/* This must be an identifier that we can search for in usymTab */
termStr = cstring_makeLiteralTemp(term);
break;
- case INTLITERAL:
+ case CTT_INTLITERAL:
{
int i;
switch (term->kind)
{
- case EXPRNODE:
+ case CTT_EXPR:
ct = exprNode_getType (term->value.expr);
break;
- case INTLITERAL:
- /*@i888*/ /* hack */
+ case CTT_INTLITERAL:
ct = ctype_signedintegral;
break;
- case SREF:
+ case CTT_SREF:
ct = sRef_getType (term->value.sref) ;
break;
default:
{
switch (term->kind)
{
- case EXPRNODE:
+ case CTT_EXPR:
if (exprNode_isNumLiteral (term->value.expr) ||
exprNode_isStringLiteral (term->value.expr) ||
exprNode_isCharLiteral (term->value.expr) )
return FALSE;
}
- case INTLITERAL:
+ case CTT_INTLITERAL:
return TRUE;
- case SREF:
+ case CTT_SREF:
if ( sRef_isConst (term->value.sref) )
{
return TRUE;