X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Finterpreter%2Fstatic.c;h=16fad260e804d2936688594c99ae4311bfaab722;hb=e6c29f8b1abd4892bcb4a8626fc817e16ab960cd;hp=582e079c4e536b7934a87974b8cc6f63bc9468cf;hpb=ad9bc691f47d26c56fbea4d83d49468708438905;p=ghc-hetmet.git diff --git a/ghc/interpreter/static.c b/ghc/interpreter/static.c index 582e079..16fad26 100644 --- a/ghc/interpreter/static.c +++ b/ghc/interpreter/static.c @@ -9,8 +9,8 @@ * included in the distribution. * * $RCSfile: static.c,v $ - * $Revision: 1.36 $ - * $Date: 2000/04/05 10:25:08 $ + * $Revision: 1.40 $ + * $Date: 2000/04/07 10:00:28 $ * ------------------------------------------------------------------------*/ #include "hugsbasictypes.h" @@ -31,8 +31,8 @@ static List local checkSubentities ( List,List,List,String,Text ); static List local checkExportTycon ( List,Text,Cell,Tycon ); static List local checkExportClass ( List,Text,Cell,Class ); static List local checkExport ( List,Text,Cell ); -static List local checkImportEntity ( List,Module,Bool,Cell ); -static List local resolveImportList ( Module,Cell,Bool ); +static List local checkImportEntity ( List,Module,Cell ); +static List local resolveImportList ( Module,Cell ); static Void local checkImportList ( Pair ); static Void local importEntity ( Module,Cell ); @@ -334,21 +334,14 @@ Text textParent; { return imports; } -static List local checkImportEntity(imports,exporter,priv,entity) +static List local checkImportEntity(imports,exporter,entity) List imports; /* Accumulated list of things to import */ Module exporter; -Bool priv; Cell entity; { /* Entry from import list */ List oldImports = imports; Text t = isIdent(entity) ? textOf(entity) : textOf(fst(entity)); List es = NIL; - if (priv) { - es = module(exporter).names; - es = dupOnto(module(exporter).tycons,es); - es = dupOnto(module(exporter).classes,es); - } else { - es = module(exporter).exports; - } + es = module(exporter).exports; for(; nonNull(es); es=tl(es)) { Cell e = hd(es); /* :: Entity @@ -398,18 +391,6 @@ Cell entity; { /* Entry from import list */ if (isIdent(entity) && name(e).text == t) { imports = cons(e,imports); } - } else if (isTycon(e) && priv) { - if (tycon(e).text == t) { - imports = cons(e,imports); - return dupOnto(tycon(e).defn,imports); - } - } else if (isClass(e) && priv) { - if (cclass(e).text == t) { - imports = cons(e,imports); - return dupOnto(cclass(e).members,imports); - } - } else if (whatIs(e) == TUPLE && priv) { - // do nothing } else { internal("checkImportEntity3"); } @@ -423,10 +404,9 @@ Cell entity; { /* Entry from import list */ return imports; } -static List local resolveImportList(m,impList,priv) +static List local resolveImportList(m,impList) Module m; /* exporting module */ -Cell impList; -Bool priv; { +Cell impList; { List imports = NIL; if (DOTDOT == impList) { List es = module(m).exports; @@ -450,7 +430,7 @@ Bool priv; { } } } else { - map2Accum(checkImportEntity,imports,m,priv,impList); + map1Accum(checkImportEntity,imports,m,impList); } return imports; } @@ -467,17 +447,10 @@ Pair importSpec; { /* Somewhat inefficient - but obviously correct: * imports = importsOf("module Foo") `setDifference` hidden; */ - hidden = resolveImportList(m, snd(impList),FALSE); - imports = resolveImportList(m, DOTDOT,FALSE); - } else if (isPair(impList) && STAR == fst(impList)) { - // Previously, I was forcing an import Prelude, - // but this precluded doing things like - // import Prelude hiding ( catch) - // so, for now, you need to put an explicit - // import Prelude if you use import privileged. - imports = resolveImportList(m, snd(impList),TRUE); + hidden = resolveImportList(m, snd(impList)); + imports = resolveImportList(m, DOTDOT); } else { - imports = resolveImportList(m, impList,FALSE); + imports = resolveImportList(m, impList); } for(; nonNull(imports); imports=tl(imports)) { @@ -3290,15 +3263,14 @@ Cell intName; Cell type; { Text t = textOf(intName); Name n = findName(t); - Int l = intOf(line); if (isNull(n)) { n = newName(t,NIL); } else if (name(n).defn!=PREDEFINED) { - ERRMSG(l) "Redeclaration of foreign \"%s\"", textToStr(t) + ERRMSG(line) "Redeclaration of foreign \"%s\"", textToStr(t) EEND; } - name(n).line = l; + name(n).line = line; name(n).defn = extName; name(n).type = type; name(n).callconv = callconv; @@ -3328,15 +3300,14 @@ Cell intName; Cell type; { Text t = textOf(intName); Name n = findName(t); - Int l = intOf(line); if (isNull(n)) { n = newName(t,NIL); } else if (name(n).defn!=PREDEFINED) { - ERRMSG(l) "Redeclaration of foreign \"%s\"", textToStr(t) + ERRMSG(line) "Redeclaration of foreign \"%s\"", textToStr(t) EEND; } - name(n).line = l; + name(n).line = line; name(n).defn = NIL; /* nothing to say */ name(n).type = type; name(n).callconv = callconv; @@ -4720,12 +4691,6 @@ Cell e; { 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. @@ -5037,7 +5002,7 @@ Void checkDefns ( Module thisModule ) { /* Top level static analysis */ mapProc(checkQualImport, module(thisModule).qualImports); mapProc(checkUnqualImport,unqualImports); /* Add "import Prelude" if there`s no explicit import */ - if (modName == textPrimPrel || modName == textPrelude) { + if (modName == textPrelPrim || modName == textPrelude) { /* Nothing. */ } else if (isNull(cellAssoc(modulePrelude,unqualImports)) && isNull(cellRevAssoc(modulePrelude,module(thisModule).qualImports))) {