From e4706792d290d4c5cb6a020d2973689efb7457ff Mon Sep 17 00:00:00 2001 From: sewardj Date: Mon, 17 Apr 2000 11:39:23 +0000 Subject: [PATCH] [project @ 2000-04-17 11:39:23 by sewardj] Make :r (reload) behave more like Hugs98: try and set the current module to what it was at the last non-failing reload. --- ghc/interpreter/hugs.c | 62 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 13 deletions(-) diff --git a/ghc/interpreter/hugs.c b/ghc/interpreter/hugs.c index 0d8df99..e2507bc 100644 --- a/ghc/interpreter/hugs.c +++ b/ghc/interpreter/hugs.c @@ -9,8 +9,8 @@ * included in the distribution. * * $RCSfile: hugs.c,v $ - * $Revision: 1.66 $ - * $Date: 2000/04/10 15:39:09 $ + * $Revision: 1.67 $ + * $Date: 2000/04/17 11:39:23 $ * ------------------------------------------------------------------------*/ #include @@ -122,6 +122,9 @@ static Bool disableOutput = FALSE; /* TRUE => quiet */ List ifaces_outstanding = NIL; +static ConId currentModule_failed = NIL; /* Remember failed module from :r */ + + /* -------------------------------------------------------------------------- * Hugs entry point: @@ -1528,26 +1531,56 @@ static Bool loadThePrelude ( void ) } +/* 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)) ); @@ -2758,10 +2791,13 @@ Int what; { /* system to respond as appropriate ... */ 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); + } } /*-------------------------------------------------------------------------*/ -- 1.7.10.4