* included in the distribution.
*
* $RCSfile: hugs.c,v $
- * $Revision: 1.65 $
- * $Date: 2000/04/10 14:28:14 $
+ * $Revision: 1.67 $
+ * $Date: 2000/04/17 11:39:23 $
* ------------------------------------------------------------------------*/
#include <setjmp.h>
static String local strCopy ( String );
static Void local browseit ( Module,String,Bool );
static Void local browse ( Void );
+static void local clearCurrentFile ( void );
+
/* --------------------------------------------------------------------------
* Machine dependent code for Hugs interpreter:
List ifaces_outstanding = NIL;
+static ConId currentModule_failed = NIL; /* Remember failed module from :r */
+
+
/* --------------------------------------------------------------------------
* Hugs entry point:
*toggle[i].flag = state;
return;
}
+ clearCurrentFile();
ERRMSG(0) "Unknown toggle `%c'", c
- EEND;
+ EEND_NO_LONGJMP;
}
static Void local togglesIn(state) /* Print current list of toggles in*/
String s = readFilename();
if (s && chdir(s)) {
ERRMSG(0) "Unable to change to directory \"%s\"", s
- EEND;
+ EEND_NO_LONGJMP;
}
}
}
+/* Refresh the current target modules, and attempt to set the
+ current module to what it was before (ie currentModule):
+ if currentModule_failed is different from currentModule,
+ use that instead
+ if nextCurrMod is non null, try to set it to that instead
+ if the one we're after insn't available, select a target
+ from the end of the module group list.
+*/
static void refreshActions ( ConId nextCurrMod, Bool cleanAfter )
{
List t;
- ConId tryFor = mkCon(module(currentModule).text);
+ ConId tryFor;
+
+ /* Remember what the old current module was. */
+ tryFor = mkCon(module(currentModule).text);
+
+ /* Do the Real Work. */
achieveTargetModules(FALSE);
+
+ /* Remember if the current module was invalidated by this
+ refresh, so later refreshes can attempt to reload it. */
+ if (!elemMG(tryFor))
+ currentModule_failed = tryFor;
+
+ /* If a previous refresh failed to get an old current module,
+ try for that instead. */
+ if (nonNull(currentModule_failed)
+ && textOf(currentModule_failed) != textOf(tryFor)
+ && elemMG(currentModule_failed))
+ tryFor = currentModule_failed;
+ /* If our caller specified a new current module, that overrides
+ all historical settings. */
if (nonNull(nextCurrMod))
tryFor = nextCurrMod;
+ /* Finally, if we can't actually get hold of whatever it was we
+ were after, select something which is possible. */
if (!elemMG(tryFor))
tryFor = selectLatestMG();
+
/* combined mode kludge, to get Prelude rather than PrelHugs */
if (combined && textOf(tryFor)==findText("PrelHugs"))
tryFor = mkCon(findText("Prelude"));
if (cleanAfter) {
- /* delete any targetModules which didn't actually get loaded */
- t = targetModules;
- targetModules = NIL;
- for (; nonNull(t); t=tl(t))
- if (elemMG(hd(t)))
- targetModules = cons(hd(t),targetModules);
+ /* delete any targetModules which didn't actually get loaded */
+ t = targetModules;
+ targetModules = NIL;
+ for (; nonNull(t); t=tl(t))
+ if (elemMG(hd(t)))
+ targetModules = cons(hd(t),targetModules);
}
setCurrModule ( findModule(textOf(tryFor)) );
bd = type;
if (whatIs(bd)==QUAL) {
+ clearCurrentFile();
ERRMSG(0) "Unresolved overloading" ETHEN
ERRTEXT "\n*** Type : " ETHEN ERRTYPE(type);
ERRTEXT "\n*** Expression : " ETHEN ERREXPR(inputExpr);
} else {
Cell d = provePred(ks,NIL,ap(classShow,bd));
if (isNull(d)) {
+ clearCurrentFile();
ERRMSG(0) "Cannot find \"show\" function for:" ETHEN
ERRTEXT "\n*** expression : " ETHEN ERREXPR(inputExpr);
ERRTEXT "\n*** of type : " ETHEN ERRTYPE(type);
names = addNamesMatching((String)0,names);
}
if (isNull(names)) { /* Then print them out */
+ clearCurrentFile();
ERRMSG(0) "No names selected"
EEND_NO_LONGJMP;
return;
modConIds = initialize(argc,argv); /* the initial modules to load */
setBreakAction ( HugsIgnoreBreak );
prelOK = loadThePrelude();
- if (combined) everybody(POSTPREL);
if (!prelOK) {
if (autoMain)
exit(1);
}
+ if (combined) everybody(POSTPREL);
loadActions(modConIds);
if (autoMain) {
compiler(what);
codegen(what);
- mark(moduleGraph);
- mark(prelModules);
- mark(targetModules);
- mark(daSccs);
+ if (what == MARK) {
+ mark(moduleGraph);
+ mark(prelModules);
+ mark(targetModules);
+ mark(daSccs);
+ mark(currentModule_failed);
+ }
}
/*-------------------------------------------------------------------------*/