* included in the distribution.
*
* $RCSfile: static.c,v $
- * $Revision: 1.30 $
- * $Date: 2000/03/13 11:37:16 $
+ * $Revision: 1.31 $
+ * $Date: 2000/03/22 18:14:23 $
* ------------------------------------------------------------------------*/
#include "prelude.h"
static Void local importName ( Module,Name );
static Void local importTycon ( Module,Tycon );
static Void local importClass ( Module,Class );
-static List local checkExports ( List );
+static List local checkExports ( List, Module );
static Void local checkTyconDefn ( Tycon );
static Void local depConstrs ( Tycon,List,Cell );
* Static analysis of modules:
* ------------------------------------------------------------------------*/
-#if HSCRIPT
-String reloadModule;
-#endif
-
-Void startModule(nm) /* switch to a new module */
-Cell nm; {
- Module m;
- if (!isCon(nm)) internal("startModule");
- if (isNull(m = findModule(textOf(nm))))
- m = newModule(textOf(nm));
- else if (!isPreludeScript()) {
- /* You're allowed to break the rules in the Prelude! */
-#if HSCRIPT
- reloadModule = textToStr(textOf(nm));
-#endif
- ERRMSG(0) "Module \"%s\" already loaded", textToStr(textOf(nm))
- EEND;
- }
+Void startModule ( Module m ) /* switch to a new module */
+{
+ if (isNull(m)) internal("startModule");
setCurrModule(m);
}
case NEWTYPE:
case DATATYPE:
if (DOTDOT == snd(entity)) {
- imports=dupOnto(tycon(f).defn,imports);
+ imports = dupOnto(tycon(f).defn,imports);
} else {
- imports=checkSubentities(imports,snd(entity),tycon(f).defn,
- "constructor of type",t);
+ imports = checkSubentities(
+ imports,snd(entity),tycon(f).defn,
+ "constructor of type",t);
}
break;
default:;
if (DOTDOT == snd(entity)) {
return dupOnto(cclass(f).members,imports);
} else {
- return checkSubentities(imports,snd(entity),cclass(f).members,
- "member of class",t);
+ return checkSubentities(
+ imports,snd(entity),cclass(f).members,
+ "member of class",t);
}
}
}
List imports = NIL; /* entities we want to import */
List hidden = NIL; /* entities we want to hide */
- if (moduleThisScript(m)) {
- ERRMSG(0) "Module \"%s\" recursively imports itself",
- textToStr(module(m).text)
- EEND;
- }
if (isPair(impList) && HIDDEN == fst(impList)) {
/* Somewhat inefficient - but obviously correct:
* imports = importsOf("module Foo") `setDifference` hidden;
Name n; {
Name clash = addName(n);
if (nonNull(clash) && clash!=n) {
- ERRMSG(0) "Entity \"%s\" imported from module \"%s\" already defined in module \"%s\"",
+ ERRMSG(0) "Entity \"%s\" imported from module \"%s\""
+ " already defined in module \"%s\"",
textToStr(name(n).text),
textToStr(module(source).text),
textToStr(module(name(clash).mod).text)
return exports; /* NOTUSED */
}
-static List local checkExports(exports)
-List exports; {
- Module m = lastModule();
+static List local checkExports ( List exports, Module thisModule )
+{
+ Module m = thisModule;
Text mt = module(m).text;
List es = NIL;
}
if (nonNull(tvs)) {
- if (length(tvs)>=NUM_OFFSETS) {
+ if (length(tvs) >= (OFF_MAX-OFF_MIN+1)) {
ERRMSG(line) "Too many type variables in %s\n", where
EEND;
} else {
return copyAdj(tyv->bound,tyv->offs,beta);
}
vn -= beta;
- if (vn<0 || vn>=NUM_OFFSETS) {
+ if (vn<0 || vn>=(OFF_MAX-OFF_MIN+1)) {
internal("copyAdj");
}
return mkOffset(vn);
EEND;
}
+#if 0
+ what is this for??
if (!moduleThisScript(name(n).mod)) {
return n;
}
+#endif
/* Later phases of the system cannot cope if we resolve references
* to unprocessed objects too early. This is the main reason that
* we cannot cope with recursive modules at the moment.
}
#endif
-Void checkDefns() { /* Top level static analysis */
- Module thisModule = lastModule();
+Void checkDefns ( Module thisModule ) { /* Top level static analysis */
+
staticAnalysis(RESET);
setCurrModule(thisModule);
/* Every module (including the Prelude) implicitly contains
* "import qualified Prelude"
*/
- module(thisModule).qualImports=cons(pair(mkCon(textPrelude),modulePrelude),
- module(thisModule).qualImports);
+ module(thisModule).qualImports
+ =cons(pair(mkCon(textPrelude),modulePrelude),
+ module(thisModule).qualImports);
}
mapProc(checkImportList, unqualImports);
/* export list. Note that this has to happen before dependency */
/* analysis so that references to Prelude.foo will be resolved */
/* when compiling the prelude. */
- module(thisModule).exports = checkExports(module(thisModule).exports);
+ module(thisModule).exports
+ = checkExports ( module(thisModule).exports, thisModule );
mapProc(checkTypeIn,typeInDefns); /* check restricted synonym defns */