-/* -*- mode: hugs-c; -*- */
+
/* --------------------------------------------------------------------------
* Strongly connected components algorithm for static.c.
*
- * Copyright (c) The University of Nottingham and Yale University, 1994-1997.
- * All rights reserved. See NOTICE for details and conditions of use etc...
- * Hugs version 1.4, December 1997
+ * Hugs 98 is Copyright (c) Mark P Jones, Alastair Reid and the Yale
+ * Haskell Group 1994-99, and is distributed as Open Source software
+ * under the Artistic License; see the file "Artistic" that is included
+ * in the distribution for details.
*
* $RCSfile: scc.c,v $
- * $Revision: 1.2 $
- * $Date: 1998/12/02 13:22:34 $
+ * $Revision: 1.4 $
+ * $Date: 1999/04/27 10:07:01 $
* ------------------------------------------------------------------------*/
#ifndef SCC_C
#define SCC_C
-#define visited(d) (isInt(DEPENDS(d))) /* binding already visited ? */
+#define visited(d) (isInt(DEPENDS(d))) /* binding already visited?*/
static Cell daSccs = NIL;
static Int daCount;
static Int local sccMin Args((Int,Int));
-static Int local sccMin(x,y) /* calculate minimum of x,y (unless */
-Int x,y; { /* y is zero) */
+static Int local sccMin(x,y) /* calculate minimum of x,y */
+Int x, y; { /* (unless y is zero) */
return (x<=y || y==0) ? x : y;
}
#endif
#ifdef SCC
static List local SCC(bs) /* sort list with added dependency */
List bs; { /* info into SCCs */
+ List tmp = NIL;
clearStack();
daSccs = NIL; /* clear current list of SCCs */
for (daCount=1; nonNull(bs); bs=tl(bs)) /* visit each binding */
if (!visited(hd(bs)))
LOWLINK(hd(bs));
-
- return rev(daSccs); /* reverse to obtain correct order */
+ tmp = rev(daSccs);
+ daSccs = NIL;
+ return tmp; /* reverse to obtain correct order */
}
#endif
#ifdef SCC2 /* Two argument version */
static List local SCC2(bs,cs) /* sort lists with added dependency*/
List bs, cs; { /* info into SCCs */
+ List tmp = NIL;
clearStack();
daSccs = NIL; /* clear current list of SCCs */
for (; nonNull(cs); cs=tl(cs))
if (!visited(hd(cs)))
LOWLINK(hd(cs));
-
- return rev(daSccs); /* reverse to obtain correct order */
+ tmp = rev(daSccs);
+ daSccs = NIL;
+ return tmp; /* reverse to obtain correct order */
}
#endif