dastworx, imports ana, fix AV when no moduleDeclaration

This commit is contained in:
Basile Burg 2016-10-18 04:31:00 +02:00
parent 465ea9d267
commit 4cb04ac073
No known key found for this signature in database
GPG Key ID: 1868039F415CB8CF
1 changed files with 16 additions and 17 deletions

View File

@ -12,7 +12,7 @@ import
/**
* Lists the modules imported by a module
*
* On the first line writes the module name between double quotes then
* On the first line writes the module name or # between double quotes then
* each import is written in a new line. Import detection is not accurate,
* the imports injected by a mixin template or by a string variable are not detected,
* the imports deactivated by a static condition neither.
@ -28,20 +28,20 @@ in
body
{
mixin(logCall);
auto rng = mod.moduleDeclaration.moduleName.identifiers
.map!(a => a.text).join(".");
if (!rng.empty)
{
writeln('"', rng, '"');
construct!(ImportLister).visit(mod);
}
if (mod.moduleDeclaration)
writeln('"', mod.moduleDeclaration.moduleName.identifiers
.map!(a => a.text).join("."), '"');
else
writeln("\"#\"");
construct!(ImportLister).visit(mod);
}
/**
* Lists the modules imported by several modules
*
* The output consists of several consecutive lists, as formated for
* listImports.
* listImports. When no moduleDeclaration is available, the first line of
* a list matches the filename.
*
* The results are used by to detect which are the static libraries used by a
* runnable module.
@ -58,14 +58,13 @@ void listFilesImports(string[] files)
ubyte[] source = cast(ubyte[]) std.file.read(fname);
Module mod = parseModule(getTokensForParser(source, config, &cache),
fname, &allocator, &ignoreErrors);
auto rng = mod.moduleDeclaration.moduleName.identifiers
.map!(a => a.text).join(".");
if (!rng.empty)
{
writeln('"', rng, '"');
il.visit(mod);
stdout.flush;
}
if (mod.moduleDeclaration)
writeln('"', mod.moduleDeclaration.moduleName.identifiers
.map!(a => a.text).join("."), '"');
else
writeln('"', fname, '"');
il.visit(mod);
stdout.flush;
}
}