[project @ 2000-04-25 17:40:44 by andy]
[ghc-hetmet.git] / ghc / interpreter / stgSubst.c
index ccf0512..98b92f1 100644 (file)
@@ -1,23 +1,22 @@
-/* -*- mode: hugs-c; -*- */
+
 /* --------------------------------------------------------------------------
  * Substitute variables in an expression
  *
- * 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
+ * The Hugs 98 system is Copyright (c) Mark P Jones, Alastair Reid, the
+ * Yale Haskell Group, and the Oregon Graduate Institute of Science and
+ * Technology, 1994-1999, All rights reserved.  It is distributed as
+ * free software under the license in the file "License", which is
+ * included in the distribution.
  *
  * $RCSfile: stgSubst.c,v $
- * $Revision: 1.2 $
- * $Date: 1998/12/02 13:22:40 $
+ * $Revision: 1.8 $
+ * $Date: 2000/03/23 14:54:21 $
  * ------------------------------------------------------------------------*/
 
-#include "prelude.h"
+#include "hugsbasictypes.h"
 #include "storage.h"
 #include "connect.h"
 #include "errors.h"
-#include "stg.h"
-
-#include "stgSubst.h"
 
 /* --------------------------------------------------------------------------
  * Local function prototypes:
@@ -68,7 +67,9 @@ static Void substBind( List sub, StgVar bind )
 
 static Void substAlt( List sub, StgCaseAlt alt )
 {
-    stgCaseAltBody(alt) = substExpr(sub,stgCaseAltBody(alt));
+    if (isDefaultAlt(alt))
+       stgDefaultBody(alt) = substExpr(sub,stgDefaultBody(alt)); else
+       stgCaseAltBody(alt) = substExpr(sub,stgCaseAltBody(alt));
 }
 
 static Void substPrimAlt( List sub, StgPrimAlt alt )
@@ -101,6 +102,9 @@ StgExpr substExpr( List sub, StgExpr e )
             stgAppFun(e) = substVar(sub,stgAppFun(e));
             map1Over(substAtom,sub,stgAppArgs(e));
             break;
+    case STGCON:
+            map1Over(substAtom,sub,stgConArgs(e));
+            break;
     case STGVAR:
     case NAME:
             return substVar(sub,e);
@@ -110,4 +114,5 @@ StgExpr substExpr( List sub, StgExpr e )
     return e;
 }
 
+
 /*-------------------------------------------------------------------------*/