X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Finterpreter%2Flink.c;h=98235f3b97e9f8803288dbe4c16404bdeae0bfda;hb=e3bb5d64a61847a306ef38f14b39768adb721cf6;hp=3444cd4c55792c96e9da8f5bf39e04ffa0dfd845;hpb=3e2280b12b060fe5e8a2430beff7a49e3137ffb3;p=ghc-hetmet.git diff --git a/ghc/interpreter/link.c b/ghc/interpreter/link.c index 3444cd4..98235f3 100644 --- a/ghc/interpreter/link.c +++ b/ghc/interpreter/link.c @@ -9,18 +9,17 @@ * included in the distribution. * * $RCSfile: link.c,v $ - * $Revision: 1.33 $ - * $Date: 2000/01/11 15:40:57 $ + * $Revision: 1.54 $ + * $Date: 2000/03/23 14:54:21 $ * ------------------------------------------------------------------------*/ -#include "prelude.h" +#include "hugsbasictypes.h" #include "storage.h" -#include "backend.h" #include "connect.h" #include "errors.h" -#include "Assembler.h" /* for asmPrimOps and AsmReps */ - -#include "link.h" +#include "Assembler.h" /* for asmPrimOps and AsmReps */ +#include "Rts.h" /* to make Prelude.h palatable */ +#include "Prelude.h" /* for fixupRTStoPreludeRefs */ Type typeArrow; /* Function spaces */ @@ -96,9 +95,7 @@ Name namePrint; Name nameOtherwise; Name nameUndefined; /* generic undefined value */ -#if NPLUSK Name namePmSub; -#endif Name namePMFail; Name nameEqChar; Name namePmInt; @@ -136,6 +133,17 @@ Name nameFrom; Name nameFromThenTo; Name nameNegate; +Name nameAssert; +Name nameAssertError; +Name nameTangleMessage; +Name nameIrrefutPatError; +Name nameNoMethodBindingError; +Name nameNonExhaustiveGuardsError; +Name namePatError; +Name nameRecSelError; +Name nameRecConError; +Name nameRecUpdError; + /* these names are required before we've had a chance to do the right thing */ Name nameSel; Name nameUnsafeUnpackCString; @@ -273,7 +281,7 @@ static Name predefinePrim ( String s ) * * ------------------------------------------------------------------------*/ -/* In standalone mode, linkPreludeTC, linkPreludeCM and linkPreludeNames +/* In standalone mode, linkPreludeTC, linkPreludeCM and linkPrimNames are called, in that order, during static analysis of Prelude.hs. In combined mode such an analysis does not happen. Instead these calls will be made as a result of a call link(POSTPREL). @@ -333,15 +341,10 @@ 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 stdDefaults = cons(typeInteger,stdDefaults); -# else - stdDefaults = cons(typeInt,stdDefaults); -# endif predNum = ap(classNum,aVar); predFractional = ap(classFractional,aVar); @@ -372,24 +375,26 @@ assert(nonNull(typeInteger)); nameMkPrimMVar = addPrimCfunREP(findText("MVar#"),1,0,0); nameMkInteger = addPrimCfunREP(findText("Integer#"),1,0,0); - name(namePrimSeq).type = primType(MONAD_Id, "ab", "b"); - name(namePrimCatch).type = primType(MONAD_Id, "aH", "a"); - name(namePrimRaise).type = primType(MONAD_Id, "E", "a"); - - /* This is a lie. For a more accurate type of primTakeMVar - see ghc/interpreter/lib/Prelude.hs. - */ - 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); - addTupInst(classIx,i); - addTupInst(classShow,i); - addTupInst(classRead,i); - addTupInst(classBounded,i); + if (!combined) { + name(namePrimSeq).type = primType(MONAD_Id, "ab", "b"); + name(namePrimCatch).type = primType(MONAD_Id, "aH", "a"); + name(namePrimRaise).type = primType(MONAD_Id, "E", "a"); + + /* This is a lie. For a more accurate type of primTakeMVar + see ghc/interpreter/lib/Prelude.hs. + */ + 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); + addTupInst(classIx,i); + addTupInst(classShow,i); + addTupInst(classRead,i); + addTupInst(classBounded,i); + } } } } @@ -410,9 +415,9 @@ Void linkPreludeCM(void) { /* Hook to cfuns and mfuns in */ nameEq = linkName("=="); nameFromInt = linkName("fromInt"); nameFromInteger = linkName("fromInteger"); - nameFromDouble = linkName("fromDouble"); nameReturn = linkName("return"); nameBind = linkName(">>="); + nameMFail = linkName("fail"); nameLe = linkName("<="); nameGt = linkName(">"); nameShowsPrec = linkName("showsPrec"); @@ -429,18 +434,18 @@ 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)"), pair(STAR,pair(STAR,STAR)), 2,DATATYPE,NIL); + + /* desugaring */ + pFun(nameInd, "_indirect"); + name(nameInd).number = DFUNNAME; + + /* newtype and USE_NEWTYPE_FOR_DICTS */ + /* make a name entry for PrelBase.id _before_ loading Prelude + since ifSetClassDefaultsAndDCon() may need to refer to + nameId. + */ + modulePrelBase = findModule(findText("PrelBase")); + module(modulePrelBase).objectExtraNames + = singleton(findText("libHS_cbits")); + + setCurrModule(modulePrelBase); + pFun(nameId, "id"); + setCurrModule(modulePrelude); + } else { + fixupRTStoPreludeRefs(NULL); - modulePrelude = newModule(textPrelude); + modulePrelude = //newModule(textPrelude); + findFakeModule(textPrelude); setCurrModule(modulePrelude); for (i=0; i