[project @ 2000-03-10 14:53:00 by sewardj]
[ghc-hetmet.git] / ghc / interpreter / stg.c
index 0b4dadc..20220c3 100644 (file)
@@ -9,8 +9,8 @@
  * included in the distribution.
  *
  * $RCSfile: stg.c,v $
- * $Revision: 1.7 $
- * $Date: 1999/10/15 21:40:57 $
+ * $Revision: 1.12 $
+ * $Date: 2000/03/10 14:53:00 $
  * ------------------------------------------------------------------------*/
 
 #include "prelude.h"
  * Utility functions
  * ------------------------------------------------------------------------*/
 
-void* stgConInfo( StgDiscr d )
+/* Make an info table for a constructor or tuple. */
+void* stgConInfo ( StgDiscr d )
 {
+    int tag;
     switch (whatIs(d)) {
-    case NAME:
-            return asmMkInfo(cfunOf(d),name(d).arity);
-    case TUPLE: 
-            return asmMkInfo(0,tupleOf(d));
-    default: 
-            internal("stgConInfo");
+       case NAME: {
+          tag = cfunOf(d);
+          if (tag > 0) tag--;
+          if (!name(d).itbl)
+             name(d).itbl = asmMkInfo(tag,name(d).arity);
+          return name(d).itbl;
+       }
+       case TUPLE: {
+          tag = 0;
+          if (!tycon(d).itbl)
+             tycon(d).itbl = asmMkInfo(tag,tupleOf(d));
+          return tycon(d).itbl;
+       }
+       default: 
+          internal("stgConInfo");
     }
 }
 
-int stgDiscrTag( StgDiscr d )
+/* Return the tag for a constructor or tuple, starting at zero. */
+int stgDiscrTag ( StgDiscr d )
 {
+    int tag;
     switch (whatIs(d)) {
-    case NAME:
-            return cfunOf(d);
-    case TUPLE: 
-            return 0;
-    default: 
-            internal("stgDiscrTag");
+       case NAME:  tag = cfunOf(d); break;
+       case TUPLE: tag = 0;
+       default:    internal("stgDiscrTag");   
     }
+    if (tag > 0) tag--;
+    return tag;
 }
 
 /* --------------------------------------------------------------------------
@@ -183,7 +195,6 @@ static Void putStgAlts    ( Int left, List alts );
 static Void local putStgVar(StgVar v) 
 {
     if (isName(v)) {
-        if (name(v).inlineMe) putStr("IL__");
         unlexVar(name(v).text);
     } else {
         putStr("id");
@@ -450,7 +461,7 @@ Void putStgExpr( StgExpr e )                        /* pretty print expr */
     case STGPRIM: 
         {
             Cell op = stgPrimOp(e);
-            unlexVar(name(op).text);
+            unlexVarStr(asmGetPrimopName(name(op).primop));
             putStgAtoms(stgPrimArgs(e));
             break;
         }
@@ -535,7 +546,6 @@ StgVar b;
     beginStgPP(fp);
     n = nameFromStgVar(b);
     if (nonNull(n)) {
-       if (name(n).inlineMe) { putStr("INLINE\n"); pIndent(0); };
        putStr(textToStr(name(n).text));
     } else {
        putStgVar(b);
@@ -546,7 +556,6 @@ StgVar b;
     endStgPP(fp);
 }
 
-#if 1 /*DEBUG_PRINTER*/
 Void ppStg( StgVar v )
 {
    printStg(stdout,v);
@@ -588,6 +597,5 @@ extern Void ppStgVars( List vs )
    printf("\n");
    endStgPP(stdout);
 }
-#endif
 
 /*-------------------------------------------------------------------------*/