Commit 56df29b6 authored by sewardj's avatar sewardj
Browse files

[project @ 2000-01-11 14:21:43 by sewardj]

Add nameShow and namePutStr as hooks for said fns so that evaluator()
in hugs.c can refer to them in a style consistent with the way the rest
of Hugs refers to specific symbol names.
parent 1e53309d
......@@ -9,8 +9,8 @@
* included in the distribution.
*
* $RCSfile: hugs.c,v $
* $Revision: 1.34 $
* $Date: 2000/01/10 16:27:03 $
* $Revision: 1.35 $
* $Date: 2000/01/11 14:21:43 $
* ------------------------------------------------------------------------*/
#include <setjmp.h>
......@@ -320,6 +320,7 @@ String argv[]; {
}
addStackEntry("Prelude");
if (combined) addStackEntry("PrelHugs");
for (i=1; i < argc; ++i) { /* process command line arguments */
if (strcmp(argv[i], "--")==0) break;
......@@ -1385,6 +1386,7 @@ static Void local evaluator() { /* evaluate expr and print value */
checkExp();
defaultDefns = evalDefaults;
type = typeCheckExp(TRUE);
if (isPolyType(type)) {
ks = polySigOf(type);
bd = monotypeOf(type);
......@@ -1418,9 +1420,9 @@ static Void local evaluator() { /* evaluate expr and print value */
ERRTEXT "\n"
EEND;
}
inputExpr = ap2(findName(findText("show")),d,inputExpr);
inputExpr = ap(findName(findText("putStr")), inputExpr);
inputExpr = ap(nameRunIO_toplevel, inputExpr);
inputExpr = ap2(nameShow, d,inputExpr);
inputExpr = ap (namePutStr, inputExpr);
inputExpr = ap (nameRunIO_toplevel, inputExpr);
evalExp(); printf("\n");
if (addType) {
......
......@@ -9,8 +9,8 @@
* included in the distribution.
*
* $RCSfile: link.c,v $
* $Revision: 1.31 $
* $Date: 2000/01/10 17:19:33 $
* $Revision: 1.32 $
* $Date: 2000/01/11 14:21:43 $
* ------------------------------------------------------------------------*/
#include "prelude.h"
......@@ -89,6 +89,8 @@ Name nameBind; /* for translating monad comps */
Name nameZero; /* for monads with a zero */
Name nameId;
Name nameShow;
Name namePutStr;
Name nameRunIO_toplevel;
Name namePrint;
......@@ -331,7 +333,8 @@ Void linkPreludeTC(void) { /* Hook to tycons and classes in */
classFloating = linkClass("Floating");
classNum = linkClass("Num");
classMonad = linkClass("Monad");
assert(nonNull(typeDouble));
assert(nonNull(typeInteger));
stdDefaults = NIL;
stdDefaults = cons(typeDouble,stdDefaults);
# if DEFAULT_BIGNUM
......@@ -378,6 +381,7 @@ Void linkPreludeTC(void) { /* Hook to tycons and classes in */
*/
name(namePrimTakeMVar).type = primType(MONAD_Id, "rbc", "d");
if (combined) {
for (i=2; i<=NUM_DTUPLES; i++) {/* Add derived instances of tuples */
addTupInst(classEq,i);
addTupInst(classOrd,i);
......@@ -386,6 +390,7 @@ Void linkPreludeTC(void) { /* Hook to tycons and classes in */
addTupInst(classRead,i);
addTupInst(classBounded,i);
}
}
}
}
......@@ -424,9 +429,11 @@ Void linkPreludeCM(void) { /* Hook to cfuns and mfuns in */
nameInRange = linkName("inRange");
nameMinus = linkName("-");
/* These come before calls to implementPrim */
if (combined) {
for(i=0; i<NUM_TUPLES; ++i) {
implementTuple(i);
}
}
}
}
......@@ -440,26 +447,30 @@ Void linkPreludeNames(void) { /* Hook to names defined in Prelude */
/* primops */
nameMkIO = linkName("hugsprimMkIO");
for (i=0; asmPrimOps[i].name; ++i) {
Text t = findText(asmPrimOps[i].name);
Name n = findName(t);
if (isNull(n)) {
n = newName(t,NIL);
}
name(n).line = 0;
name(n).defn = NIL;
name(n).type = primType(asmPrimOps[i].monad,
asmPrimOps[i].args,
asmPrimOps[i].results);
name(n).arity = strlen(asmPrimOps[i].args);
name(n).primop = &(asmPrimOps[i]);
implementPrim(n);
}
if (!combined) {
for (i=0; asmPrimOps[i].name; ++i) {
Text t = findText(asmPrimOps[i].name);
Name n = findName(t);
if (isNull(n)) {
n = newName(t,NIL);
}
name(n).line = 0;
name(n).defn = NIL;
name(n).type = primType(asmPrimOps[i].monad,
asmPrimOps[i].args,
asmPrimOps[i].results);
name(n).arity = strlen(asmPrimOps[i].args);
name(n).primop = &(asmPrimOps[i]);
implementPrim(n);
}
}
/* static(tidyInfix) */
nameNegate = linkName("negate");
/* user interface */
nameRunIO_toplevel = linkName("hugsprimRunIO_toplevel");
nameShow = linkName("show");
namePutStr = linkName("putStr");
namePrint = linkName("print");
/* desugar */
nameOtherwise = linkName("otherwise");
......@@ -469,11 +480,11 @@ Void linkPreludeNames(void) { /* Hook to names defined in Prelude */
namePmSub = linkName("hugsprimPmSub");
# endif
/* translator */
nameEqChar = linkName("primEqChar");
nameEqChar = linkName("hugsprimEqChar");
nameCreateAdjThunk = linkName("hugsprimCreateAdjThunk");
namePmInt = linkName("hugsprimPmInt");
namePmInteger = linkName("hugsprimPmInteger");
namePmDouble = linkName("primPmDouble");
namePmDouble = linkName("hugsprimPmDouble");
namePmFromInteger = linkName("hugsprimPmFromInteger");
namePmSubtract = linkName("hugsprimPmSubtract");
......
extern Cell conCons;
extern Name nameShow;
extern Name namePutStr;
extern Name nameRunIO_toplevel;
/* The following data constructors are used to box unboxed
* arguments and are treated differently by the code generator.
* That is, they have primop `elem` {INT_REP,FLOAT_REP,...}.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment