* included in the distribution.
*
* $RCSfile: storage.c,v $
- * $Revision: 1.41 $
- * $Date: 2000/02/08 15:32:30 $
+ * $Revision: 1.46 $
+ * $Date: 2000/02/25 10:53:54 $
* ------------------------------------------------------------------------*/
#include "prelude.h"
Name n = NIL;
for (n = NAMEMIN; n < nameHw; n++)
if (name(n).text == t) break;
- if (n == nameHw) internal("getHugs_AsmObject_for(1)");
+ if (n == nameHw) {
+ fprintf ( stderr, "can't find `%s' in ...\n", s );
+ internal("getHugs_AsmObject_for(1)");
+ }
v = name(n).stgVar;
if (!isStgVar(v) || !isPtr(stgVarInfo(v)))
internal("getHugs_AsmObject_for(2)");
}
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 */
: 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;
{
x.i = snd(c);
return x.p;
}
+
Cell mkCPtr(p)
Ptr p;
{
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;
{
x.i.i2 = intOf(snd(snd(c)));
return x.p;
}
-#else
-#warning "type Addr not supported on this architecture - don't use it"
-Cell mkPtr(p)
+
+Cell mkCPtr(p)
Ptr p;
{
- ERRMSG(0) "mkPtr: type Addr not supported on this architecture"
- EEND;
+ IntOrPtr x;
+ x.p = p;
+ return pair(CPTRCELL,pair(mkInt(x.i.i1),mkInt(x.i.i2)));
}
-Ptr ptrOf(c)
+Ptr cptrOf(c)
Cell c;
{
- ERRMSG(0) "ptrOf: type Addr not supported on this architecture"
- EEND;
+ IntOrPtr x;
+ assert(fst(c) == CPTRCELL);
+ x.i.i1 = intOf(fst(snd(c)));
+ x.i.i2 = intOf(snd(snd(c)));
+ return x.p;
}
+
+#else
+
+#error "Can't implement mkPtr/ptrOf on this architecture."
+
#endif
+
String stringNegate( s )
String s;
{
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)";
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);
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 );
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 );
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" );
}