mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 12:24:24 +00:00
Handle html+mirrors
BUG= R=sigmund@google.com Review URL: https://codereview.chromium.org/2296723003 .
This commit is contained in:
parent
f8f4228728
commit
726d8fdb23
4 changed files with 51 additions and 20 deletions
|
@ -2338,9 +2338,15 @@ class JavaScriptBackend extends Backend {
|
|||
|
||||
/// Called when [enqueuer] is empty, but before it is closed.
|
||||
bool onQueueEmpty(Enqueuer enqueuer, Iterable<ClassElement> recentClasses) {
|
||||
// Add elements referenced only via custom elements. Return early if any
|
||||
// elements are added to avoid counting the elements as due to mirrors.
|
||||
customElementsAnalysis.onQueueEmpty(enqueuer);
|
||||
if (!compiler.options.resolveOnly) {
|
||||
// TODO(johnniwinther): The custom element analysis eagerly enqueues
|
||||
// elements on the codegen queue. Change to compute the data needed
|
||||
// instead.
|
||||
|
||||
// Add elements referenced only via custom elements. Return early if any
|
||||
// elements are added to avoid counting the elements as due to mirrors.
|
||||
customElementsAnalysis.onQueueEmpty(enqueuer);
|
||||
}
|
||||
if (!enqueuer.queueIsEmpty) return false;
|
||||
|
||||
noSuchMethodRegistry.onQueueEmpty();
|
||||
|
|
|
@ -26,10 +26,13 @@ main(List<String> args) {
|
|||
await serializeDartCore(arguments: arguments);
|
||||
if (arguments.filename != null) {
|
||||
Uri entryPoint = Uri.base.resolve(nativeToUriPath(arguments.filename));
|
||||
SerializationResult result = await serialize(entryPoint,
|
||||
memorySourceFiles: serializedData.toMemorySourceFiles(),
|
||||
resolutionInputs: serializedData.toUris());
|
||||
await compile(
|
||||
entryPoint,
|
||||
resolutionInputs: serializedData.toUris(),
|
||||
sourceFiles: serializedData.toMemorySourceFiles());
|
||||
resolutionInputs: result.serializedData.toUris(),
|
||||
sourceFiles: result.serializedData.toMemorySourceFiles());
|
||||
} else {
|
||||
Uri entryPoint = Uri.parse('memory:main.dart');
|
||||
await arguments.forEachTest(serializedData, TESTS, compile);
|
||||
|
@ -51,7 +54,7 @@ Future compile(
|
|||
OutputCollector outputCollector = new OutputCollector();
|
||||
await measure(title, 'compile', () async {
|
||||
List<String> options = [];
|
||||
if (test.checkedMode) {
|
||||
if (test != null && test.checkedMode) {
|
||||
options.add(Flags.enableCheckedMode);
|
||||
}
|
||||
await runCompiler(
|
||||
|
|
|
@ -213,6 +213,7 @@ Future<List<SerializedData>> preserializeData(
|
|||
test.preserializedSourceFiles.isEmpty) {
|
||||
return <SerializedData>[serializedData];
|
||||
}
|
||||
|
||||
List<Uri> uriList = <Uri>[];
|
||||
for (String key in test.preserializedSourceFiles.keys) {
|
||||
uriList.add(Uri.parse('memory:$key'));
|
||||
|
@ -222,21 +223,33 @@ Future<List<SerializedData>> preserializeData(
|
|||
if (test.unserializedSourceFiles != null) {
|
||||
sourceFiles.addAll(test.unserializedSourceFiles);
|
||||
}
|
||||
OutputCollector outputCollector = new OutputCollector();
|
||||
Compiler compiler = compilerFor(
|
||||
memorySourceFiles: sourceFiles,
|
||||
resolutionInputs: serializedData.toUris(),
|
||||
options: [Flags.resolveOnly],
|
||||
outputProvider: outputCollector);
|
||||
compiler.librariesToAnalyzeWhenRun = uriList;
|
||||
await compiler.run(null);
|
||||
List<LibraryElement> libraries = <LibraryElement>[];
|
||||
for (Uri uri in uriList) {
|
||||
libraries.add(compiler.libraryLoader.lookupLibrary(uri));
|
||||
Uri additionalDataUri = Uri.parse('memory:additional.data');
|
||||
SerializedData additionalSerializedData;
|
||||
if (test.sourceFiles.isEmpty) {
|
||||
SerializationResult result = await serialize(
|
||||
uriList.first,
|
||||
memorySourceFiles: sourceFiles,
|
||||
resolutionInputs: serializedData.toUris(),
|
||||
dataUri: additionalDataUri);
|
||||
additionalSerializedData = result.serializedData;
|
||||
} else {
|
||||
OutputCollector outputCollector = new OutputCollector();
|
||||
Compiler compiler = compilerFor(
|
||||
entryPoint: test.sourceFiles.isEmpty ? uriList.first : null,
|
||||
memorySourceFiles: sourceFiles,
|
||||
resolutionInputs: serializedData.toUris(),
|
||||
options: [Flags.resolveOnly],
|
||||
outputProvider: outputCollector);
|
||||
compiler.librariesToAnalyzeWhenRun = uriList;
|
||||
await compiler.run(null);
|
||||
List<LibraryElement> libraries = <LibraryElement>[];
|
||||
for (Uri uri in uriList) {
|
||||
libraries.add(compiler.libraryLoader.lookupLibrary(uri));
|
||||
}
|
||||
additionalSerializedData = new SerializedData(
|
||||
additionalDataUri,
|
||||
outputCollector.getOutput('', 'data'));
|
||||
}
|
||||
SerializedData additionalSerializedData = new SerializedData(
|
||||
Uri.parse('memory:additional.data'),
|
||||
outputCollector.getOutput('', 'data'));
|
||||
return <SerializedData>[serializedData, additionalSerializedData];
|
||||
}
|
||||
|
||||
|
|
|
@ -762,6 +762,15 @@ var foo;
|
|||
'b.dart': '''
|
||||
var foo;
|
||||
''',}),
|
||||
|
||||
const Test('html and mirrors', const {},
|
||||
preserializedSourceFiles: const {
|
||||
'main.dart': '''
|
||||
import 'dart:html';
|
||||
import 'dart:mirrors';
|
||||
main() {}
|
||||
'''},
|
||||
expectedWarningCount: 1),
|
||||
];
|
||||
|
||||
class Test {
|
||||
|
|
Loading…
Reference in a new issue