OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library deferred_load; | 5 library deferred_load; |
6 | 6 |
7 import 'constants/expressions.dart'; | 7 import 'constants/expressions.dart'; |
8 import 'constants/values.dart' show | 8 import 'constants/values.dart' show |
9 Constant, | 9 ConstantValue, |
10 ConstructedConstant, | 10 ConstructedConstantValue, |
11 DeferredConstant, | 11 DeferredConstantValue, |
12 StringConstant; | 12 StringConstantValue; |
13 | 13 |
14 import 'dart2jslib.dart' show | 14 import 'dart2jslib.dart' show |
15 Backend, | 15 Backend, |
16 Compiler, | 16 Compiler, |
17 CompilerTask, | 17 CompilerTask, |
18 invariant, | 18 invariant, |
19 MessageKind; | 19 MessageKind; |
20 | 20 |
21 import 'dart_backend/dart_backend.dart' show | 21 import 'dart_backend/dart_backend.dart' show |
22 DartBackend; | 22 DartBackend; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
130 new Map<String, List<OutputUnit>>(); | 130 new Map<String, List<OutputUnit>>(); |
131 final Map<Import, String> importDeferName = new Map<Import, String>(); | 131 final Map<Import, String> importDeferName = new Map<Import, String>(); |
132 | 132 |
133 /// A mapping from elements and constants to their output unit. Query this via | 133 /// A mapping from elements and constants to their output unit. Query this via |
134 /// [outputUnitForElement] | 134 /// [outputUnitForElement] |
135 final Map<Element, OutputUnit> _elementToOutputUnit = | 135 final Map<Element, OutputUnit> _elementToOutputUnit = |
136 new Map<Element, OutputUnit>(); | 136 new Map<Element, OutputUnit>(); |
137 | 137 |
138 /// A mapping from constants to their output unit. Query this via | 138 /// A mapping from constants to their output unit. Query this via |
139 /// [outputUnitForConstant] | 139 /// [outputUnitForConstant] |
140 final Map<Constant, OutputUnit> _constantToOutputUnit = | 140 final Map<ConstantValue, OutputUnit> _constantToOutputUnit = |
141 new Map<Constant, OutputUnit>(); | 141 new Map<ConstantValue, OutputUnit>(); |
142 | 142 |
143 /// All the imports with a [DeferredLibrary] annotation, mapped to the | 143 /// All the imports with a [DeferredLibrary] annotation, mapped to the |
144 /// [LibraryElement] they import. | 144 /// [LibraryElement] they import. |
145 /// The main library is included in this set for convenience. | 145 /// The main library is included in this set for convenience. |
146 final Map<Import, LibraryElement> _allDeferredImports = | 146 final Map<Import, LibraryElement> _allDeferredImports = |
147 new Map<Import, LibraryElement>(); | 147 new Map<Import, LibraryElement>(); |
148 | 148 |
149 // For each deferred import we want to know exactly what elements have to | 149 // For each deferred import we want to know exactly what elements have to |
150 // be loaded. | 150 // be loaded. |
151 Map<Import, Set<Element>> _importedDeferredBy = null; | 151 Map<Import, Set<Element>> _importedDeferredBy = null; |
152 Map<Import, Set<Constant>> _constantsDeferredBy = null; | 152 Map<Import, Set<ConstantValue>> _constantsDeferredBy = null; |
153 | 153 |
154 Set<Element> _mainElements = new Set<Element>(); | 154 Set<Element> _mainElements = new Set<Element>(); |
155 | 155 |
156 DeferredLoadTask(Compiler compiler) : super(compiler) { | 156 DeferredLoadTask(Compiler compiler) : super(compiler) { |
157 mainOutputUnit.imports.add(_fakeMainImport); | 157 mainOutputUnit.imports.add(_fakeMainImport); |
158 } | 158 } |
159 | 159 |
160 Backend get backend => compiler.backend; | 160 Backend get backend => compiler.backend; |
161 | 161 |
162 /// Returns the [OutputUnit] where [element] belongs. | 162 /// Returns the [OutputUnit] where [element] belongs. |
(...skipping 10 matching lines...) Expand all Loading... |
173 if (element.enclosingElement == null) { | 173 if (element.enclosingElement == null) { |
174 _elementToOutputUnit[element] = mainOutputUnit; | 174 _elementToOutputUnit[element] = mainOutputUnit; |
175 break; | 175 break; |
176 } | 176 } |
177 element = element.enclosingElement.implementation; | 177 element = element.enclosingElement.implementation; |
178 } | 178 } |
179 return _elementToOutputUnit[element]; | 179 return _elementToOutputUnit[element]; |
180 } | 180 } |
181 | 181 |
182 /// Returns the [OutputUnit] where [constant] belongs. | 182 /// Returns the [OutputUnit] where [constant] belongs. |
183 OutputUnit outputUnitForConstant(Constant constant) { | 183 OutputUnit outputUnitForConstant(ConstantValue constant) { |
184 if (!isProgramSplit) return mainOutputUnit; | 184 if (!isProgramSplit) return mainOutputUnit; |
185 | 185 |
186 return _constantToOutputUnit[constant]; | 186 return _constantToOutputUnit[constant]; |
187 } | 187 } |
188 | 188 |
189 bool isDeferred(Element element) { | 189 bool isDeferred(Element element) { |
190 return outputUnitForElement(element) != mainOutputUnit; | 190 return outputUnitForElement(element) != mainOutputUnit; |
191 } | 191 } |
192 | 192 |
193 /// Returns true if e1 and e2 are in the same output unit. | 193 /// Returns true if e1 and e2 are in the same output unit. |
194 bool inSameOutputUnit(Element e1, Element e2) { | 194 bool inSameOutputUnit(Element e1, Element e2) { |
195 return outputUnitForElement(e1) == outputUnitForElement(e2); | 195 return outputUnitForElement(e1) == outputUnitForElement(e2); |
196 } | 196 } |
197 | 197 |
198 void registerConstantDeferredUse(DeferredConstant constant, | 198 void registerConstantDeferredUse(DeferredConstantValue constant, |
199 PrefixElement prefix) { | 199 PrefixElement prefix) { |
200 OutputUnit outputUnit = new OutputUnit(); | 200 OutputUnit outputUnit = new OutputUnit(); |
201 outputUnit.imports.add(prefix.deferredImport); | 201 outputUnit.imports.add(prefix.deferredImport); |
202 _constantToOutputUnit[constant] = outputUnit; | 202 _constantToOutputUnit[constant] = outputUnit; |
203 } | 203 } |
204 | 204 |
205 /// Answers whether [element] is explicitly deferred when referred to from | 205 /// Answers whether [element] is explicitly deferred when referred to from |
206 /// [library]. | 206 /// [library]. |
207 bool _isExplicitlyDeferred(Element element, LibraryElement library) { | 207 bool _isExplicitlyDeferred(Element element, LibraryElement library) { |
208 Link<Import> imports = _getImports(element, library); | 208 Link<Import> imports = _getImports(element, library); |
(...skipping 18 matching lines...) Expand all Loading... |
227 return library.getImportsFor(element); | 227 return library.getImportsFor(element); |
228 } | 228 } |
229 | 229 |
230 /// Finds all elements and constants that [element] depends directly on. | 230 /// Finds all elements and constants that [element] depends directly on. |
231 /// (not the transitive closure.) | 231 /// (not the transitive closure.) |
232 /// | 232 /// |
233 /// Adds the results to [elements] and [constants]. | 233 /// Adds the results to [elements] and [constants]. |
234 void _collectAllElementsAndConstantsResolvedFrom( | 234 void _collectAllElementsAndConstantsResolvedFrom( |
235 Element element, | 235 Element element, |
236 Set<Element> elements, | 236 Set<Element> elements, |
237 Set<Constant> constants, | 237 Set<ConstantValue> constants, |
238 isMirrorUsage) { | 238 isMirrorUsage) { |
239 | 239 |
240 /// Recursively add the constant and its dependencies to [constants]. | 240 /// Recursively add the constant and its dependencies to [constants]. |
241 void addConstants(Constant constant) { | 241 void addConstants(ConstantValue constant) { |
242 if (constants.contains(constant)) return; | 242 if (constants.contains(constant)) return; |
243 constants.add(constant); | 243 constants.add(constant); |
244 if (constant is ConstructedConstant) { | 244 if (constant is ConstructedConstantValue) { |
245 elements.add(constant.type.element); | 245 elements.add(constant.type.element); |
246 } | 246 } |
247 constant.getDependencies().forEach(addConstants); | 247 constant.getDependencies().forEach(addConstants); |
248 } | 248 } |
249 | 249 |
250 /// Collects all direct dependencies of [element]. | 250 /// Collects all direct dependencies of [element]. |
251 /// | 251 /// |
252 /// The collected dependent elements and constants are are added to | 252 /// The collected dependent elements and constants are are added to |
253 /// [elements] and [constants] respectively. | 253 /// [elements] and [constants] respectively. |
254 void collectDependencies(Element element) { | 254 void collectDependencies(Element element) { |
(...skipping 23 matching lines...) Expand all Loading... |
278 treeElements.forEachConstantNode((Node node, _) { | 278 treeElements.forEachConstantNode((Node node, _) { |
279 // Explicitly depend on the backend constants. | 279 // Explicitly depend on the backend constants. |
280 addConstants( | 280 addConstants( |
281 backend.constants.getConstantForNode(node, treeElements).value); | 281 backend.constants.getConstantForNode(node, treeElements).value); |
282 }); | 282 }); |
283 elements.addAll(treeElements.otherDependencies); | 283 elements.addAll(treeElements.otherDependencies); |
284 } | 284 } |
285 | 285 |
286 // TODO(sigurdm): How is metadata on a patch-class handled? | 286 // TODO(sigurdm): How is metadata on a patch-class handled? |
287 for (MetadataAnnotation metadata in element.metadata) { | 287 for (MetadataAnnotation metadata in element.metadata) { |
288 ConstExp constant = backend.constants.getConstantForMetadata(metadata); | 288 ConstantExpression constant = |
| 289 backend.constants.getConstantForMetadata(metadata); |
289 if (constant != null) { | 290 if (constant != null) { |
290 addConstants(constant.value); | 291 addConstants(constant.value); |
291 } | 292 } |
292 } | 293 } |
293 if (element.isClass) { | 294 if (element.isClass) { |
294 // If we see a class, add everything its live instance members refer | 295 // If we see a class, add everything its live instance members refer |
295 // to. Static members are not relevant, unless we are processing | 296 // to. Static members are not relevant, unless we are processing |
296 // extra dependencies due to mirrors. | 297 // extra dependencies due to mirrors. |
297 void addLiveInstanceMember(Element element) { | 298 void addLiveInstanceMember(Element element) { |
298 if (!compiler.enqueuer.resolution.isLive(element)) return; | 299 if (!compiler.enqueuer.resolution.isLive(element)) return; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return result; | 360 return result; |
360 } | 361 } |
361 | 362 |
362 /// Recursively traverses the graph of dependencies from [element], mapping | 363 /// Recursively traverses the graph of dependencies from [element], mapping |
363 /// deferred imports to each dependency it needs in the sets | 364 /// deferred imports to each dependency it needs in the sets |
364 /// [_importedDeferredBy] and [_constantsDeferredBy]. | 365 /// [_importedDeferredBy] and [_constantsDeferredBy]. |
365 void _mapDependencies(Element element, Import import, | 366 void _mapDependencies(Element element, Import import, |
366 {isMirrorUsage: false}) { | 367 {isMirrorUsage: false}) { |
367 Set<Element> elements = _importedDeferredBy.putIfAbsent(import, | 368 Set<Element> elements = _importedDeferredBy.putIfAbsent(import, |
368 () => new Set<Element>()); | 369 () => new Set<Element>()); |
369 Set<Constant> constants = _constantsDeferredBy.putIfAbsent(import, | 370 Set<ConstantValue> constants = _constantsDeferredBy.putIfAbsent(import, |
370 () => new Set<Constant>()); | 371 () => new Set<ConstantValue>()); |
371 | 372 |
372 // Only process elements once, unless we are doing dependencies due to | 373 // Only process elements once, unless we are doing dependencies due to |
373 // mirrors, which are added in additional traversals. | 374 // mirrors, which are added in additional traversals. |
374 if (!isMirrorUsage && elements.contains(element)) return; | 375 if (!isMirrorUsage && elements.contains(element)) return; |
375 // Anything used directly by main will be loaded from the start | 376 // Anything used directly by main will be loaded from the start |
376 // We do not need to traverse it again. | 377 // We do not need to traverse it again. |
377 if (import != _fakeMainImport && _mainElements.contains(element)) return; | 378 if (import != _fakeMainImport && _mainElements.contains(element)) return; |
378 | 379 |
379 // Here we modify [_importedDeferredBy]. | 380 // Here we modify [_importedDeferredBy]. |
380 elements.add(element); | 381 elements.add(element); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 } | 415 } |
415 | 416 |
416 // For each deferred import we analyze all elements reachable from the | 417 // For each deferred import we analyze all elements reachable from the |
417 // imported library through non-deferred imports. | 418 // imported library through non-deferred imports. |
418 handleLibrary(LibraryElement library, Import deferredImport) { | 419 handleLibrary(LibraryElement library, Import deferredImport) { |
419 library.implementation.forEachLocalMember((Element element) { | 420 library.implementation.forEachLocalMember((Element element) { |
420 mapDependenciesIfResolved(element, deferredImport); | 421 mapDependenciesIfResolved(element, deferredImport); |
421 }); | 422 }); |
422 | 423 |
423 for (MetadataAnnotation metadata in library.metadata) { | 424 for (MetadataAnnotation metadata in library.metadata) { |
424 ConstExp constant = | 425 ConstantExpression constant = |
425 backend.constants.getConstantForMetadata(metadata); | 426 backend.constants.getConstantForMetadata(metadata); |
426 if (constant != null) { | 427 if (constant != null) { |
427 _mapDependencies(constant.value.computeType(compiler).element, | 428 _mapDependencies(constant.value.computeType(compiler).element, |
428 deferredImport); | 429 deferredImport); |
429 } | 430 } |
430 } | 431 } |
431 for (LibraryTag tag in library.tags) { | 432 for (LibraryTag tag in library.tags) { |
432 for (MetadataAnnotation metadata in tag.metadata) { | 433 for (MetadataAnnotation metadata in tag.metadata) { |
433 ConstExp constant = | 434 ConstantExpression constant = |
434 backend.constants.getConstantForMetadata(metadata); | 435 backend.constants.getConstantForMetadata(metadata); |
435 if (constant != null) { | 436 if (constant != null) { |
436 _mapDependencies(constant.value.computeType(compiler).element, | 437 _mapDependencies(constant.value.computeType(compiler).element, |
437 deferredImport); | 438 deferredImport); |
438 } | 439 } |
439 } | 440 } |
440 } | 441 } |
441 } | 442 } |
442 | 443 |
443 for (Import deferredImport in _allDeferredImports.keys) { | 444 for (Import deferredImport in _allDeferredImports.keys) { |
(...skipping 16 matching lines...) Expand all Loading... |
460 String result; | 461 String result; |
461 if (import == _fakeMainImport) { | 462 if (import == _fakeMainImport) { |
462 result = "main"; | 463 result = "main"; |
463 } else if (import.isDeferred) { | 464 } else if (import.isDeferred) { |
464 result = import.prefix.toString(); | 465 result = import.prefix.toString(); |
465 } else { | 466 } else { |
466 Link<MetadataAnnotation> metadatas = import.metadata; | 467 Link<MetadataAnnotation> metadatas = import.metadata; |
467 assert(metadatas != null); | 468 assert(metadatas != null); |
468 for (MetadataAnnotation metadata in metadatas) { | 469 for (MetadataAnnotation metadata in metadatas) { |
469 metadata.ensureResolved(compiler); | 470 metadata.ensureResolved(compiler); |
470 Element element = metadata.constant.value.computeType(compiler).elemen
t; | 471 Element element = |
| 472 metadata.constant.value.computeType(compiler).element; |
471 if (element == deferredLibraryClass) { | 473 if (element == deferredLibraryClass) { |
472 ConstructedConstant constant = metadata.constant.value; | 474 ConstructedConstantValue constant = metadata.constant.value; |
473 StringConstant s = constant.fields[0]; | 475 StringConstantValue s = constant.fields[0]; |
474 result = s.value.slowToString(); | 476 result = s.primitiveValue.slowToString(); |
475 break; | 477 break; |
476 } | 478 } |
477 } | 479 } |
478 } | 480 } |
479 assert(result != null); | 481 assert(result != null); |
480 importDeferName[import] = makeUnique(result, usedImportNames);; | 482 importDeferName[import] = makeUnique(result, usedImportNames);; |
481 } | 483 } |
482 | 484 |
483 int counter = 1; | 485 int counter = 1; |
484 | 486 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
524 } | 526 } |
525 | 527 |
526 void onResolutionComplete(FunctionElement main) { | 528 void onResolutionComplete(FunctionElement main) { |
527 if (!isProgramSplit) { | 529 if (!isProgramSplit) { |
528 allOutputUnits.add(mainOutputUnit); | 530 allOutputUnits.add(mainOutputUnit); |
529 return; | 531 return; |
530 } | 532 } |
531 if (main == null) return; | 533 if (main == null) return; |
532 LibraryElement mainLibrary = main.library; | 534 LibraryElement mainLibrary = main.library; |
533 _importedDeferredBy = new Map<Import, Set<Element>>(); | 535 _importedDeferredBy = new Map<Import, Set<Element>>(); |
534 _constantsDeferredBy = new Map<Import, Set<Constant>>(); | 536 _constantsDeferredBy = new Map<Import, Set<ConstantValue>>(); |
535 _importedDeferredBy[_fakeMainImport] = _mainElements; | 537 _importedDeferredBy[_fakeMainImport] = _mainElements; |
536 | 538 |
537 measureElement(mainLibrary, () { | 539 measureElement(mainLibrary, () { |
538 | 540 |
539 // Starting from main, traverse the program and find all dependencies. | 541 // Starting from main, traverse the program and find all dependencies. |
540 _mapDependencies(compiler.mainFunction, _fakeMainImport); | 542 _mapDependencies(compiler.mainFunction, _fakeMainImport); |
541 | 543 |
542 // Also add "global" dependencies to the main OutputUnit. These are | 544 // Also add "global" dependencies to the main OutputUnit. These are |
543 // things that the backend need but cannot associate with a particular | 545 // things that the backend need but cannot associate with a particular |
544 // element, for example, startRootIsolate. This set also contains | 546 // element, for example, startRootIsolate. This set also contains |
545 // elements for which we lack precise information. | 547 // elements for which we lack precise information. |
546 for (Element element in compiler.globalDependencies.otherDependencies) { | 548 for (Element element in compiler.globalDependencies.otherDependencies) { |
547 _mapDependencies(element, _fakeMainImport); | 549 _mapDependencies(element, _fakeMainImport); |
548 } | 550 } |
549 | 551 |
550 // Now check to see if we have to add more elements due to mirrors. | 552 // Now check to see if we have to add more elements due to mirrors. |
551 if (compiler.mirrorsLibrary != null) { | 553 if (compiler.mirrorsLibrary != null) { |
552 _addMirrorElements(); | 554 _addMirrorElements(); |
553 } | 555 } |
554 | 556 |
555 // Build the OutputUnits using these two maps. | 557 // Build the OutputUnits using these two maps. |
556 Map<Element, OutputUnit> elementToOutputUnitBuilder = | 558 Map<Element, OutputUnit> elementToOutputUnitBuilder = |
557 new Map<Element, OutputUnit>(); | 559 new Map<Element, OutputUnit>(); |
558 Map<Constant, OutputUnit> constantToOutputUnitBuilder = | 560 Map<ConstantValue, OutputUnit> constantToOutputUnitBuilder = |
559 new Map<Constant, OutputUnit>(); | 561 new Map<ConstantValue, OutputUnit>(); |
560 | 562 |
561 // Reverse the mappings. For each element record an OutputUnit collecting | 563 // Reverse the mappings. For each element record an OutputUnit collecting |
562 // all deferred imports mapped to this element. Same for constants. | 564 // all deferred imports mapped to this element. Same for constants. |
563 for (Import import in _importedDeferredBy.keys) { | 565 for (Import import in _importedDeferredBy.keys) { |
564 for (Element element in _importedDeferredBy[import]) { | 566 for (Element element in _importedDeferredBy[import]) { |
565 // Only one file should be loaded when the program starts, so make | 567 // Only one file should be loaded when the program starts, so make |
566 // sure that only one OutputUnit is created for [fakeMainImport]. | 568 // sure that only one OutputUnit is created for [fakeMainImport]. |
567 if (import == _fakeMainImport) { | 569 if (import == _fakeMainImport) { |
568 elementToOutputUnitBuilder[element] = mainOutputUnit; | 570 elementToOutputUnitBuilder[element] = mainOutputUnit; |
569 } else { | 571 } else { |
570 elementToOutputUnitBuilder | 572 elementToOutputUnitBuilder |
571 .putIfAbsent(element, () => new OutputUnit()) | 573 .putIfAbsent(element, () => new OutputUnit()) |
572 .imports.add(import); | 574 .imports.add(import); |
573 } | 575 } |
574 } | 576 } |
575 for (Constant constant in _constantsDeferredBy[import]) { | 577 for (ConstantValue constant in _constantsDeferredBy[import]) { |
576 // Only one file should be loaded when the program starts, so make | 578 // Only one file should be loaded when the program starts, so make |
577 // sure that only one OutputUnit is created for [fakeMainImport]. | 579 // sure that only one OutputUnit is created for [fakeMainImport]. |
578 if (import == _fakeMainImport) { | 580 if (import == _fakeMainImport) { |
579 constantToOutputUnitBuilder[constant] = mainOutputUnit; | 581 constantToOutputUnitBuilder[constant] = mainOutputUnit; |
580 } else { | 582 } else { |
581 constantToOutputUnitBuilder | 583 constantToOutputUnitBuilder |
582 .putIfAbsent(constant, () => new OutputUnit()) | 584 .putIfAbsent(constant, () => new OutputUnit()) |
583 .imports.add(import); | 585 .imports.add(import); |
584 } | 586 } |
585 } | 587 } |
586 } | 588 } |
587 | 589 |
588 // Release maps; | 590 // Release maps; |
589 _importedDeferredBy = null; | 591 _importedDeferredBy = null; |
590 _constantsDeferredBy = null; | 592 _constantsDeferredBy = null; |
591 | 593 |
592 // Find all the output units elements/constants have been mapped to, and | 594 // Find all the output units elements/constants have been mapped to, and |
593 // canonicalize them. | 595 // canonicalize them. |
594 elementToOutputUnitBuilder.forEach( | 596 elementToOutputUnitBuilder.forEach( |
595 (Element element, OutputUnit outputUnit) { | 597 (Element element, OutputUnit outputUnit) { |
596 OutputUnit representative = allOutputUnits.lookup(outputUnit); | 598 OutputUnit representative = allOutputUnits.lookup(outputUnit); |
597 if (representative == null) { | 599 if (representative == null) { |
598 representative = outputUnit; | 600 representative = outputUnit; |
599 allOutputUnits.add(representative); | 601 allOutputUnits.add(representative); |
600 } | 602 } |
601 _elementToOutputUnit[element] = representative; | 603 _elementToOutputUnit[element] = representative; |
602 }); | 604 }); |
603 constantToOutputUnitBuilder.forEach( | 605 constantToOutputUnitBuilder.forEach( |
604 (Constant constant, OutputUnit outputUnit) { | 606 (ConstantValue constant, OutputUnit outputUnit) { |
605 OutputUnit representative = allOutputUnits.lookup(outputUnit); | 607 OutputUnit representative = allOutputUnits.lookup(outputUnit); |
606 if (representative == null) { | 608 if (representative == null) { |
607 representative = outputUnit; | 609 representative = outputUnit; |
608 allOutputUnits.add(representative); | 610 allOutputUnits.add(representative); |
609 } | 611 } |
610 _constantToOutputUnit[constant] = representative; | 612 _constantToOutputUnit[constant] = representative; |
611 }); | 613 }); |
612 | 614 |
613 // Generate a unique name for each OutputUnit. | 615 // Generate a unique name for each OutputUnit. |
614 _assignNamesToOutputUnits(allOutputUnits); | 616 _assignNamesToOutputUnits(allOutputUnits); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 Import import = tag; | 652 Import import = tag; |
651 | 653 |
652 /// Give an error if the old annotation-based syntax has been used. | 654 /// Give an error if the old annotation-based syntax has been used. |
653 Link<MetadataAnnotation> metadataList = import.metadata; | 655 Link<MetadataAnnotation> metadataList = import.metadata; |
654 if (metadataList != null) { | 656 if (metadataList != null) { |
655 for (MetadataAnnotation metadata in metadataList) { | 657 for (MetadataAnnotation metadata in metadataList) { |
656 metadata.ensureResolved(compiler); | 658 metadata.ensureResolved(compiler); |
657 Element element = | 659 Element element = |
658 metadata.constant.value.computeType(compiler).element; | 660 metadata.constant.value.computeType(compiler).element; |
659 if (element == deferredLibraryClass) { | 661 if (element == deferredLibraryClass) { |
660 compiler.reportFatalError(import, MessageKind.DEFERRED_OLD_SYNT
AX); | 662 compiler.reportFatalError( |
| 663 import, MessageKind.DEFERRED_OLD_SYNTAX); |
661 } | 664 } |
662 } | 665 } |
663 } | 666 } |
664 | 667 |
665 String prefix = (import.prefix != null) | 668 String prefix = (import.prefix != null) |
666 ? import.prefix.toString() | 669 ? import.prefix.toString() |
667 : null; | 670 : null; |
668 // The last import we saw with the same prefix. | 671 // The last import we saw with the same prefix. |
669 Import previousDeferredImport = prefixDeferredImport[prefix]; | 672 Import previousDeferredImport = prefixDeferredImport[prefix]; |
670 if (import.isDeferred) { | 673 if (import.isDeferred) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 Element maybePrefix = elements[identifier]; | 758 Element maybePrefix = elements[identifier]; |
756 if (maybePrefix != null && maybePrefix.isPrefix) { | 759 if (maybePrefix != null && maybePrefix.isPrefix) { |
757 PrefixElement prefixElement = maybePrefix; | 760 PrefixElement prefixElement = maybePrefix; |
758 if (prefixElement.isDeferred) { | 761 if (prefixElement.isDeferred) { |
759 return prefixElement; | 762 return prefixElement; |
760 } | 763 } |
761 } | 764 } |
762 return null; | 765 return null; |
763 } | 766 } |
764 } | 767 } |
OLD | NEW |