* included in the distribution.
*
* $RCSfile: compiler.c,v $
- * $Revision: 1.16 $
- * $Date: 1999/12/10 15:59:42 $
+ * $Revision: 1.20 $
+ * $Date: 2000/03/10 14:53:00 $
* ------------------------------------------------------------------------*/
#include "prelude.h"
static Cell local translate(e) /* Translate expression: */
Cell e; {
+#if 0
+ printf ( "translate: " );print(e,100);printf("\n");
+#endif
switch (whatIs(e)) {
case LETREC : snd(snd(e)) = translate(snd(snd(e)));
return expandLetrec(e);
nv));
}
- default : fprintf(stderr, "stuff=%d\n",whatIs(e));internal("translate");
+ default : fprintf(stderr, "stuff=%d\n",whatIs(e));
+ internal("translate");
}
return e;
}
static Void local transAlt(e) /* Translate alt: */
Cell e; { /* ([Pat], Rhs) ==> ([Pat], Rhs') */
+#if 0
+ printf ( "transAlt: " );print(snd(e),100);printf("\n");
+#endif
snd(e) = transRhs(snd(e));
}
case STRCELL :
case CHARCELL :
-#if NPLUSK
case ADDPAT :
-#endif
case TUPLE :
case NAME : return pat;
Cell h = getHead(p);
if (h==nameFromInt || h==nameFromInteger || h==nameFromDouble)
return p;
-#if NPLUSK
else if (whatIs(h)==ADDPAT)
return ap(fun(p),refutePat(arg(p)));
-#endif
#if TREX
else if (isExt(h)) {
Cell pf = refutePat(extField(p));
if (h==nameFromInt ||
h==nameFromInteger || h==nameFromDouble)
return WILDCARD;
-#if NPLUSK
else if (whatIs(h)==ADDPAT)
return pat;
-#endif
#if TREX
else if (isExt(h)) {
Cell pf = matchPat(extField(pat));
return remPat(snd(pat),nv,lds);
}
-#if NPLUSK
case ADDPAT : return remPat1(arg(pat), /* n + k = expr */
ap(ap(ap(namePmSub,
arg(fun(pat))),
mkInt(snd(fun(fun(pat))))),
expr),
lds);
-#endif
case FINLIST : return remPat1(mkConsList(snd(pat)),expr,lds);
case AP : return pmcPair(co,sc,e);
-#if NPLUSK
case ADDPAT :
-#endif
#if TREX
case EXT :
#endif
Cell h = getHead(p);
switch (whatIs(h)) {
case CONFLDS : return fst(snd(p));
-#if NPLUSK
case ADDPAT : arg(fun(p)) = translate(arg(fun(p)));
return fun(p);
-#endif
#if TREX
case EXT : h = fun(fun(p));
arg(h) = translate(arg(h));
case CHARCELL : return 0;
#if TREX
case AP : switch (whatIs(fun(d))) {
-#if NPLUSK
case ADDPAT : return 1;
-#endif
case EXT : return 2;
default : return 0;
}
#else
-#if NPLUSK
case AP : return (whatIs(fun(d))==ADDPAT) ? 1 : 0;
-#else
- case AP : return 0; /* must be an Int or Float lit */
-#endif
#endif
}
internal("discrArity");
static Bool local eqNumDiscr(d1,d2) /* Determine whether two numeric */
Cell d1, d2; { /* descriptors have same value */
-#if NPLUSK
if (whatIs(fun(d1))==ADDPAT)
return whatIs(fun(d2))==ADDPAT && snd(fun(d1))==snd(fun(d2));
-#endif
if (isInt(arg(d1)))
return isInt(arg(d2)) && intOf(arg(d1))==intOf(arg(d2));
if (isFloat(arg(d1)))
fflush (stdout);
switch (status) {
case Deadlock:
- case AllBlocked: /* I don't understand the distinction - ADR */
printf("{Deadlock or Blackhole}");
if (doRevertCAFs) RevertCAFs();
break;
Name n; { /* generated function */
List defs = name(n).defn;
Int arity = length(fst(hd(defs)));
+#if 0
+ printf ( "compGenFn: " );print(defs,100);printf("\n");
+#endif
compiler(RESET);
currentName = n;
mapProc(transAlt,defs);