modules (moduleClosure): use imap instead of map to produce uniq keys for
the genericClosure. svn path=/nixpkgs/trunk/; revision=27014
This commit is contained in:
parent
85d3fd3e3c
commit
02677481ae
|
@ -80,19 +80,29 @@ rec {
|
||||||
|
|
||||||
moduleClosure = initModules: args:
|
moduleClosure = initModules: args:
|
||||||
let
|
let
|
||||||
moduleImport = m:
|
moduleImport = origin: index: m:
|
||||||
let m' = applyIfFunction (importIfPath m) args;
|
let m' = applyIfFunction (importIfPath m) args;
|
||||||
in (unifyModuleSyntax m') // {
|
in (unifyModuleSyntax m') // {
|
||||||
# used by generic closure to avoid duplicated imports.
|
# used by generic closure to avoid duplicated imports.
|
||||||
key = if isPath m then m else if m' ? key then m'.key else "<unknown location>";
|
key =
|
||||||
|
if isPath m then m
|
||||||
|
else if m' ? key then m'.key
|
||||||
|
else newModuleName origin index;
|
||||||
};
|
};
|
||||||
|
|
||||||
getImports = m: attrByPath ["imports"] [] m;
|
getImports = m: attrByPath ["imports"] [] m;
|
||||||
|
|
||||||
|
newModuleName = origin: index:
|
||||||
|
"${origin.key}:<import-${toString index}>";
|
||||||
|
|
||||||
|
topLevel = {
|
||||||
|
key = "<top-level>";
|
||||||
|
};
|
||||||
|
|
||||||
in
|
in
|
||||||
(lazyGenericClosure {
|
(lazyGenericClosure {
|
||||||
startSet = map moduleImport initModules;
|
startSet = imap (moduleImport topLevel) initModules;
|
||||||
operator = m: map moduleImport (getImports m);
|
operator = m: imap (moduleImport m) (getImports m);
|
||||||
});
|
});
|
||||||
|
|
||||||
selectDeclsAndDefs = modules:
|
selectDeclsAndDefs = modules:
|
||||||
|
|
Loading…
Reference in New Issue