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 * 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, * 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 injected by a mixin template or by a string variable are not detected,
* the imports deactivated by a static condition neither. * the imports deactivated by a static condition neither.
@ -28,20 +28,20 @@ in
body body
{ {
mixin(logCall); mixin(logCall);
auto rng = mod.moduleDeclaration.moduleName.identifiers if (mod.moduleDeclaration)
.map!(a => a.text).join("."); writeln('"', mod.moduleDeclaration.moduleName.identifiers
if (!rng.empty) .map!(a => a.text).join("."), '"');
{ else
writeln('"', rng, '"'); writeln("\"#\"");
construct!(ImportLister).visit(mod); construct!(ImportLister).visit(mod);
}
} }
/** /**
* Lists the modules imported by several modules * Lists the modules imported by several modules
* *
* The output consists of several consecutive lists, as formated for * 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 * The results are used by to detect which are the static libraries used by a
* runnable module. * runnable module.
@ -58,14 +58,13 @@ void listFilesImports(string[] files)
ubyte[] source = cast(ubyte[]) std.file.read(fname); ubyte[] source = cast(ubyte[]) std.file.read(fname);
Module mod = parseModule(getTokensForParser(source, config, &cache), Module mod = parseModule(getTokensForParser(source, config, &cache),
fname, &allocator, &ignoreErrors); fname, &allocator, &ignoreErrors);
auto rng = mod.moduleDeclaration.moduleName.identifiers if (mod.moduleDeclaration)
.map!(a => a.text).join("."); writeln('"', mod.moduleDeclaration.moduleName.identifiers
if (!rng.empty) .map!(a => a.text).join("."), '"');
{ else
writeln('"', rng, '"'); writeln('"', fname, '"');
il.visit(mod); il.visit(mod);
stdout.flush; stdout.flush;
}
} }
} }