[project @ 2000-02-24 14:09:14 by sewardj]
[ghc-hetmet.git] / ghc / interpreter / storage.c
index 193613e..39d969f 100644 (file)
@@ -9,8 +9,8 @@
  * included in the distribution.
  *
  * $RCSfile: storage.c,v $
- * $Revision: 1.41 $
- * $Date: 2000/02/08 15:32:30 $
+ * $Revision: 1.44 $
+ * $Date: 2000/02/24 14:05:55 $
  * ------------------------------------------------------------------------*/
 
 #include "prelude.h"
@@ -1643,12 +1643,13 @@ String f; {                             /* of status for later restoration  */
 }
 
 Bool isPreludeScript() {                /* Test whether this is the Prelude*/
-    return (scriptHw==0);
+    return (scriptHw < N_PRELUDE_SCRIPTS /*==0*/ );
 }
 
 Bool moduleThisScript(m)                /* Test if given module is defined */
 Module m; {                             /* in current script file          */
-    return scriptHw<1 || m>=scripts[scriptHw-1].moduleHw;
+    return scriptHw < 1
+           || m>=scripts[scriptHw-1].moduleHw;
 }
 
 Module lastModule() {              /* Return module in current script file */
@@ -2440,7 +2441,7 @@ Int n; {
            : pair(INTCELL,n);
 }
 
-#if SIZEOF_INTP == SIZEOF_INT
+#if SIZEOF_VOID_P == SIZEOF_INT
 typedef union {Int i; Ptr p;} IntOrPtr;
 Cell mkPtr(p)
 Ptr p;
@@ -2474,7 +2475,7 @@ Cell c;
     x.i = snd(c);
     return x.p;
 }
-#elif SIZEOF_INTP == 2*SIZEOF_INT
+#elif SIZEOF_VOID_P == 2*SIZEOF_INT
 typedef union {struct {Int i1; Int i2;} i; Ptr p;} IntOrPtr;
 Cell mkPtr(p)
 Ptr p;
@@ -2942,6 +2943,11 @@ static String maybeTyconStr ( Tycon t )
    if (isTycon(t)) return textToStr(tycon(t).text); else return "??";
 }
 
+static String maybeClassStr ( Class c )
+{
+   if (isClass(c)) return textToStr(cclass(c).text); else return "??";
+}
+
 static String maybeText ( Text t )
 {
    if (isNull(t)) return "(nil)";
@@ -2963,8 +2969,7 @@ void dumpTycon ( Int t )
    printf ( "{\n" );
    printf ( "    text: %s\n",     textToStr(tycon(t).text) );
    printf ( "    line: %d\n",     tycon(t).line );
-   printf ( "     mod: %d %s\n",  tycon(t).mod, 
-                                  maybeModuleStr(tycon(t).mod));
+   printf ( "     mod: %s\n",     maybeModuleStr(tycon(t).mod));
    printf ( "   tuple: %d\n",     tycon(t).tuple);
    printf ( "   arity: %d\n",     tycon(t).arity);
    printf ( "    kind: ");        print100(tycon(t).kind);
@@ -2990,8 +2995,7 @@ void dumpName ( Int n )
    printf ( "{\n" );
    printf ( "    text: %s\n",     textToStr(name(n).text) );
    printf ( "    line: %d\n",     name(n).line );
-   printf ( "     mod: %d %s\n",  name(n).mod, 
-                                  maybeModuleStr(name(n).mod));
+   printf ( "     mod: %s\n",     maybeModuleStr(name(n).mod));
    printf ( "  syntax: %d\n",     name(n).syntax );
    printf ( "  parent: %d\n",     name(n).parent );
    printf ( "   arity: %d\n",     name(n).arity );
@@ -3017,8 +3021,7 @@ void dumpClass ( Int c )
    printf ( "{\n" );
    printf ( "    text: %s\n",     textToStr(cclass(c).text) );
    printf ( "    line: %d\n",     cclass(c).line );
-   printf ( "     mod: %d %s\n",  cclass(c).mod, 
-                                  maybeModuleStr(cclass(c).mod));
+   printf ( "     mod: %s\n",     maybeModuleStr(cclass(c).mod));
    printf ( "   arity: %d\n",     cclass(c).arity );
    printf ( "   level: %d\n",     cclass(c).level );
    printf ( "   kinds: ");        print100( cclass(c).kinds );
@@ -3045,7 +3048,15 @@ void dumpInst ( Int i )
       return;
    }
    printf ( "{\n" );
-//   printf ( "    text: %s\n",     textToStr(cclass(c)).text) );
+   printf ( "   class: %s\n",     maybeClassStr(inst(i).c) );
+   printf ( "    line: %d\n",     inst(i).line );
+   printf ( "     mod: %s\n",     maybeModuleStr(inst(i).mod));
+   printf ( "   kinds: ");        print100( inst(i).kinds );
+   printf ( "    head: ");        print100( inst(i).head );
+   printf ( "   specs: ");        print100( inst(i).specifics );
+   printf ( "  #specs: %d\n",     inst(i).numSpecifics );
+   printf ( "   impls: ");        print100( inst(i).implements );
+   printf ( " builder: %s\n",     maybeNameStr( inst(i).builder ) );
    printf ( "}\n" );
 }