[project @ 1999-11-29 18:59:23 by sewardj]
[ghc-hetmet.git] / ghc / interpreter / hugs.c
index 80c4921..7102d18 100644 (file)
@@ -9,8 +9,8 @@
  * included in the distribution.
  *
  * $RCSfile: hugs.c,v $
- * $Revision: 1.22 $
- * $Date: 1999/11/23 09:59:38 $
+ * $Revision: 1.25 $
+ * $Date: 1999/11/29 18:59:26 $
  * ------------------------------------------------------------------------*/
 
 #include <setjmp.h>
@@ -29,7 +29,7 @@
 #include "Rts.h"
 #include "RtsAPI.h"
 #include "Schedule.h"
-
+#include "Assembler.h"                                /* DEBUG_LoadSymbols */
 
 Bool haskell98 = TRUE;                  /* TRUE => Haskell 98 compatibility*/
 
@@ -108,12 +108,13 @@ static Void   local browse              Args((Void));
 
 static Bool   printing     = FALSE;     /* TRUE => currently printing value*/
 static Bool   showStats    = FALSE;     /* TRUE => print stats after eval  */
-static Bool   listScripts  = TRUE;      /* TRUE => list scripts after loading*/
+static Bool   listScripts  = TRUE;    /* TRUE => list scripts after loading*/
 static Bool   addType      = FALSE;     /* TRUE => print type with value   */
 static Bool   useDots      = RISCOS;    /* TRUE => use dots in progress    */
 static Bool   quiet        = FALSE;     /* TRUE => don't show progress     */
 static Bool   lastWasObject = FALSE;
        Bool   preludeLoaded = FALSE;
+       Bool   debugSC       = FALSE;
 
 typedef 
    struct { 
@@ -224,17 +225,13 @@ char *argv[]; {
 
     CStackBase = &argc;                 /* Save stack base for use in gc   */
 
-    /* Try and figure out an absolute path to the executable, so
-       we can make a reasonable guess about where the default
-       libraries (Prelude etc) are.
-    */
-    setDefaultLibDir ( argv[0] );
-
     /* If first arg is +Q or -Q, be entirely silent, and automatically run
        main after loading scripts.  Useful for running the nofib suite.    */
     if (argc > 1 && (strcmp(argv[1],"+Q") == 0 || strcmp(argv[1],"-Q")==0)) {
        autoMain = TRUE;
-       hugsEnableOutput(0);
+       if (strcmp(argv[1],"-Q") == 0) {
+        hugsEnableOutput(0);
+       }
     }
 
     Printf("__   __ __  __  ____   ___      _________________________________________\n");
@@ -244,6 +241,13 @@ char *argv[]; {
     Printf("||   ||                         Report bugs to: hugs-bugs@haskell.org\n");
     Printf("||   || Version: %s _________________________________________\n\n",HUGS_VERSION);
 
+    /* Get the absolute path to the directory containing the hugs 
+       executable, so that we know where the Prelude and nHandle.so/.dll are.
+       We do this by reading env var STGHUGSDIR.  This needs to succeed, so
+       setInstallDir won't return unless it succeeds.
+    */
+    setInstallDir ( argv[0] );
+
 #if SYMANTEC_C
     Printf("   Ported to Macintosh by Hans Aberg, compiled " __DATE__ ".\n\n");
 #endif
@@ -317,7 +321,12 @@ String argv[]; {
     }
 
 #if DEBUG
-    DEBUG_LoadSymbols(argv_0_orig);
+    { 
+       char exe_name[N_INSTALLDIR + 6];
+       strcpy(exe_name, installDir);
+       strcat(exe_name, "hugs");
+       DEBUG_LoadSymbols(exe_name);
+    }
 #endif
 
 
@@ -760,9 +769,7 @@ struct options toggle[] = {             /* List of command line toggles    */
 #if DEBUG_CODE
     {'D', 1, "Debug: show generated G code",          &debugCode},
 #endif
-#if DEBUG_SHOWSC
     {'S', 1, "Debug: show generated SC code",         &debugSC},
-#endif
 #if 0
     {'f', 1, "Terminate evaluation on first error",   &failOnError},
     {'u', 1, "Use \"show\" to display results",       &useShow},
@@ -852,8 +859,8 @@ static Void local makeStackEntry ( ScriptInfo* ent, String iname )
         );
    if (!ok) {
       ERRMSG(0) 
-       /* "Can't file source or object+interface for module \"%s\"", */
-         "Can't file source for module \"%s\"",
+         "Can't find source or object+interface for module \"%s\"",
+         /* "Can't find source for module \"%s\"", */
          iname
       EEND;
    }
@@ -863,11 +870,10 @@ static Void local makeStackEntry ( ScriptInfo* ent, String iname )
    /* Load objects in preference to sources if both are available */
    /* 11 Oct 99: disable object loading in the interim.
       Will probably only reinstate when HEP becomes available.
+   */
    fromObj = sAvail
                 ? (oAvail && iAvail && timeEarlier(sTime,oTime))
                 : TRUE;
-   */
-   fromObj = FALSE;
 
    /* ToDo: namesUpto overflow */
    ent->modName     = strCopy(iname);
@@ -1342,7 +1348,7 @@ static Void local evaluator() {        /* evaluate expr and print value    */
 #endif
 
 #if 1
-    if (typeMatches(type,ap(typeIO,typeUnit))) {
+    if (isProgType(ks,bd)) {
         inputExpr = ap(nameRunIO,inputExpr);
         evalExp();
         Putchar('\n');