+ if ( fileloc_lessthan (term1->loc, term2->loc) )
+ {
+ if (fileloc_lessthan (term2->loc, term3->loc) )
+ {
+ llassert (fileloc_lessthan (term1->loc, term3->loc) );
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+ }
+ }
+
+ if ( ! (fileloc_lessthan (term1->loc, term2->loc) ) )
+ {
+ if (!fileloc_lessthan (term2->loc, term3->loc) )
+ {
+ llassert (fileloc_lessthan (term3->loc, term1->loc) );
+ return TRUE;
+ }
+ else
+ {
+ return FALSE;
+
+ }
+ }
+
+ llassert(FALSE);
+ return FALSE;
+}
+
+constraint constraint_substituteTerm (constraint c, constraint subs)
+{
+ constraintTerm oldterm;
+ constraintExpr replacement;
+
+ llassert(subs->lexpr->expr == NULL);
+
+
+ oldterm = subs->lexpr->term;
+ replacement = subs->expr;
+
+ // Chessy hack assumes that subs always has the form g:1 = g:2 + expr
+
+ /*@i2*/
+
+ /*find out which value to substitute*/
+ TPRINTF((message ("doing substitute for %s and %s", constraint_print (c), constraint_print(subs) ) ) );
+ if ( constraintExpr_containsTerm (subs->expr, subs->lexpr->term) )
+ {
+ TPRINTF(("doing new stuff"));
+ if (fileloc_closer (c->lexpr->term, subs->expr->term, subs->lexpr->term) )
+ {
+ // use the other term
+ constraint new;
+ new = constraint_copy (subs);
+ new = solveforOther(new);
+ oldterm = new->expr->term;
+ replacement = new->lexpr;
+ }
+ }
+
+ c->lexpr = constraintExpr_substituteTerm (c->lexpr, oldterm, replacement);
+ c->expr = constraintExpr_substituteTerm (c->expr, oldterm, replacement);
+ return c;