Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(346)

Side by Side Diff: pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart

Issue 2908153003: It's alive! (Closed)
Patch Set: Updated cf. comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 dart2js.js_emitter.full_emitter; 5 library dart2js.js_emitter.full_emitter;
6 6
7 import 'dart:collection' show HashMap; 7 import 'dart:collection' show HashMap;
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames; 10 import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames;
11 import 'package:js_runtime/shared/embedded_names.dart' 11 import 'package:js_runtime/shared/embedded_names.dart'
12 show JsBuiltin, JsGetName; 12 show JsBuiltin, JsGetName;
13 13
14 import '../../../compiler_new.dart'; 14 import '../../../compiler_new.dart';
15 import '../../common.dart'; 15 import '../../common.dart';
16 import '../../compiler.dart' show Compiler; 16 import '../../compiler.dart' show Compiler;
17 import '../../constants/values.dart'; 17 import '../../constants/values.dart';
18 import '../../common_elements.dart' show CommonElements; 18 import '../../common_elements.dart' show CommonElements;
19 import '../../elements/resolution_types.dart' show ResolutionDartType; 19 import '../../elements/resolution_types.dart' show ResolutionDartType;
20 import '../../deferred_load.dart' show OutputUnit; 20 import '../../deferred_load.dart' show OutputUnit;
21 import '../../elements/elements.dart' 21 import '../../elements/elements.dart'
22 show 22 show
23 ClassElement, 23 ClassElement,
24 Element, 24 Element,
25 Elements, 25 Elements,
26 FieldElement, 26 FieldElement,
27 FunctionElement,
28 FunctionSignature, 27 FunctionSignature,
29 LibraryElement, 28 LibraryElement,
30 MethodElement, 29 MethodElement,
31 TypedefElement; 30 TypedefElement;
32 import '../../elements/entities.dart'; 31 import '../../elements/entities.dart';
33 import '../../hash/sha1.dart' show Hasher; 32 import '../../hash/sha1.dart' show Hasher;
34 import '../../io/code_output.dart'; 33 import '../../io/code_output.dart';
35 import '../../io/location_provider.dart' show LocationCollector; 34 import '../../io/location_provider.dart' show LocationCollector;
36 import '../../io/source_map_builder.dart' show SourceMapBuilder; 35 import '../../io/source_map_builder.dart' show SourceMapBuilder;
37 import '../../js/js.dart' as jsAst; 36 import '../../js/js.dart' as jsAst;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 160
162 /** 161 /**
163 * Accumulate properties for classes and libraries, describing their 162 * Accumulate properties for classes and libraries, describing their
164 * static/top-level members. 163 * static/top-level members.
165 * Later, these members are emitted when the class or library is emitted. 164 * Later, these members are emitted when the class or library is emitted.
166 * 165 *
167 * See [getElementDescriptor]. 166 * See [getElementDescriptor].
168 */ 167 */
169 // TODO(ahe): Generate statics with their class, and store only libraries in 168 // TODO(ahe): Generate statics with their class, and store only libraries in
170 // this map. 169 // this map.
171 final Map<Fragment, Map<Element, ClassBuilder>> elementDescriptors = 170 final Map<Fragment, Map<LibraryEntity, ClassBuilder>> libraryDescriptors =
172 new Map<Fragment, Map<Element, ClassBuilder>>(); 171 new Map<Fragment, Map<LibraryEntity, ClassBuilder>>();
172
173 final Map<Fragment, Map<ClassEntity, ClassBuilder>> classDescriptors =
174 new Map<Fragment, Map<ClassEntity, ClassBuilder>>();
173 175
174 final bool generateSourceMap; 176 final bool generateSourceMap;
175 177
176 Emitter(this.compiler, this.namer, this._closedWorld, this.generateSourceMap, 178 Emitter(this.compiler, this.namer, this._closedWorld, this.generateSourceMap,
177 this.task, this._sorter) 179 this.task, this._sorter)
178 : classEmitter = new ClassEmitter(_closedWorld), 180 : classEmitter = new ClassEmitter(_closedWorld),
179 interceptorEmitter = new InterceptorEmitter(_closedWorld), 181 interceptorEmitter = new InterceptorEmitter(_closedWorld),
180 nsmEmitter = new NsmEmitter(_closedWorld) { 182 nsmEmitter = new NsmEmitter(_closedWorld) {
181 constantEmitter = new ConstantEmitter( 183 constantEmitter = new ConstantEmitter(
182 compiler.options, 184 compiler.options,
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 elementOrSelector.isFunction || 471 elementOrSelector.isFunction ||
470 elementOrSelector.isConstructor) { 472 elementOrSelector.isConstructor) {
471 int positionalParameterCount; 473 int positionalParameterCount;
472 String namedArguments = ''; 474 String namedArguments = '';
473 bool isConstructor = false; 475 bool isConstructor = false;
474 if (elementOrSelector is Selector) { 476 if (elementOrSelector is Selector) {
475 CallStructure callStructure = elementOrSelector.callStructure; 477 CallStructure callStructure = elementOrSelector.callStructure;
476 positionalParameterCount = callStructure.positionalArgumentCount; 478 positionalParameterCount = callStructure.positionalArgumentCount;
477 namedArguments = namedParametersAsReflectionNames(callStructure); 479 namedArguments = namedParametersAsReflectionNames(callStructure);
478 } else { 480 } else {
479 FunctionElement function = elementOrSelector; 481 MethodElement function = elementOrSelector;
480 if (function.isConstructor) { 482 if (function.isConstructor) {
481 isConstructor = true; 483 isConstructor = true;
482 name = Elements.reconstructConstructorName(function); 484 name = Elements.reconstructConstructorName(function);
483 } 485 }
484 FunctionSignature signature = function.functionSignature; 486 FunctionSignature signature = function.functionSignature;
485 positionalParameterCount = signature.requiredParameterCount; 487 positionalParameterCount = signature.requiredParameterCount;
486 if (signature.optionalParametersAreNamed) { 488 if (signature.optionalParametersAreNamed) {
487 var names = []; 489 var names = [];
488 for (Element e in signature.optionalParameters) { 490 for (Element e in signature.optionalParameters) {
489 names.add(e.name); 491 names.add(e.name);
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 reporter.withCurrentElement(classElement, () { 559 reporter.withCurrentElement(classElement, () {
558 classEmitter.emitClass(cls, enclosingBuilder, fragment); 560 classEmitter.emitClass(cls, enclosingBuilder, fragment);
559 }); 561 });
560 } 562 }
561 563
562 void assembleStaticFunctions( 564 void assembleStaticFunctions(
563 Iterable<Method> staticFunctions, Fragment fragment) { 565 Iterable<Method> staticFunctions, Fragment fragment) {
564 if (staticFunctions == null) return; 566 if (staticFunctions == null) return;
565 567
566 for (Method method in staticFunctions) { 568 for (Method method in staticFunctions) {
567 MethodElement element = method.element; 569 FunctionEntity element = method.element;
568 // We need to filter out null-elements for the interceptors. 570 // We need to filter out null-elements for the interceptors.
569 // TODO(floitsch): use the precomputed interceptors here. 571 // TODO(floitsch): use the precomputed interceptors here.
570 if (element == null) continue; 572 if (element == null) continue;
571 ClassBuilder builder = new ClassBuilder.forStatics(element, namer); 573 ClassBuilder builder = new ClassBuilder.forStatics(element, namer);
572 containerBuilder.addMemberMethod(method, builder); 574 containerBuilder.addMemberMethod(method, builder);
573 getStaticMethodDescriptor(element, fragment) 575 getStaticMethodDescriptor(element, fragment)
574 .properties 576 .properties
575 .addAll(builder.properties); 577 .addAll(builder.properties);
576 } 578 }
577 } 579 }
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1003 } catch(_) {} 1005 } catch(_) {}
1004 1006
1005 return false; 1007 return false;
1006 })(); 1008 })();
1007 '''); 1009 ''');
1008 1010
1009 return supportsDirectProtoAccess; 1011 return supportsDirectProtoAccess;
1010 } 1012 }
1011 1013
1012 jsAst.Expression generateLibraryDescriptor( 1014 jsAst.Expression generateLibraryDescriptor(
1013 LibraryElement library, Fragment fragment) { 1015 LibraryEntity library, Fragment fragment) {
1014 var uri = ""; 1016 var uri = "";
1015 if (!compiler.options.enableMinification || 1017 if (!compiler.options.enableMinification ||
1016 backend.mirrorsData.mustPreserveUris) { 1018 backend.mirrorsData.mustPreserveUris) {
1017 uri = library.canonicalUri; 1019 uri = library.canonicalUri;
1018 if (uri.scheme == 'file' && compiler.options.outputUri != null) { 1020 if (uri.scheme == 'file' && compiler.options.outputUri != null) {
1019 uri = 1021 uri =
1020 relativize(compiler.options.outputUri, library.canonicalUri, false); 1022 relativize(compiler.options.outputUri, library.canonicalUri, false);
1021 } 1023 }
1022 } 1024 }
1023 1025
1024 String libraryName = (!compiler.options.enableMinification || 1026 String libraryName = (!compiler.options.enableMinification ||
1025 backend.mirrorsData.mustRetainLibraryNames) 1027 backend.mirrorsData.mustRetainLibraryNames)
1026 ? library.libraryName 1028 // TODO(johnniwinther): Support library names for entities.
1029 ? library is LibraryElement ? library.libraryName : library.name
1027 : ""; 1030 : "";
1028 1031
1029 jsAst.Fun metadata = 1032 jsAst.Fun metadata =
1030 task.metadataCollector.buildLibraryMetadataFunction(library); 1033 task.metadataCollector.buildLibraryMetadataFunction(library);
1031 1034
1032 ClassBuilder descriptor = elementDescriptors[fragment][library]; 1035 ClassBuilder descriptor = libraryDescriptors[fragment][library];
1033 1036
1034 jsAst.ObjectInitializer initializer; 1037 jsAst.ObjectInitializer initializer;
1035 if (descriptor == null) { 1038 if (descriptor == null) {
1036 // Nothing of the library was emitted. 1039 // Nothing of the library was emitted.
1037 // TODO(floitsch): this should not happen. We currently have an example 1040 // TODO(floitsch): this should not happen. We currently have an example
1038 // with language/prefix6_negative_test.dart where we have an instance 1041 // with language/prefix6_negative_test.dart where we have an instance
1039 // method without its corresponding class. 1042 // method without its corresponding class.
1040 initializer = new jsAst.ObjectInitializer([]); 1043 initializer = new jsAst.ObjectInitializer([]);
1041 } else { 1044 } else {
1042 initializer = descriptor.toObjectInitializer(); 1045 initializer = descriptor.toObjectInitializer();
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 } 1259 }
1257 jsAst.Expression mangledGlobalNamesAccess = 1260 jsAst.Expression mangledGlobalNamesAccess =
1258 generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES); 1261 generateEmbeddedGlobalAccess(embeddedNames.MANGLED_GLOBAL_NAMES);
1259 jsAst.ObjectInitializer map = new jsAst.ObjectInitializer(properties); 1262 jsAst.ObjectInitializer map = new jsAst.ObjectInitializer(properties);
1260 parts.add(js.statement('# = #', [mangledGlobalNamesAccess, map])); 1263 parts.add(js.statement('# = #', [mangledGlobalNamesAccess, map]));
1261 } 1264 }
1262 1265
1263 return new jsAst.Block(parts); 1266 return new jsAst.Block(parts);
1264 } 1267 }
1265 1268
1266 void checkEverythingEmitted(Iterable<Element> elements) { 1269 void checkEverythingEmitted(
1267 List<Element> pendingStatics = 1270 Map<ClassEntity, ClassBuilder> pendingClassBuilders) {
1268 Elements.sortedByPosition(elements.where((e) => !e.isLibrary)); 1271 if (pendingClassBuilders == null) return;
1272 List<ClassEntity> pendingClasses =
1273 _sorter.sortClasses(pendingClassBuilders.keys);
1269 1274
1270 pendingStatics.forEach((element) => reporter.reportInfo( 1275 pendingClasses.forEach((ClassEntity element) => reporter.reportInfo(
1271 element, MessageKind.GENERIC, {'text': 'Pending statics.'})); 1276 element, MessageKind.GENERIC, {'text': 'Pending statics.'}));
1272 1277
1273 if (pendingStatics != null && !pendingStatics.isEmpty) { 1278 if (pendingClasses != null && !pendingClasses.isEmpty) {
1274 reporter.internalError( 1279 reporter.internalError(
1275 pendingStatics.first, 'Pending statics (see above).'); 1280 pendingClasses.first, 'Pending statics (see above).');
1276 } 1281 }
1277 } 1282 }
1278 1283
1279 void assembleLibrary(Library library, Fragment fragment) { 1284 void assembleLibrary(Library library, Fragment fragment) {
1280 LibraryElement libraryElement = library.element; 1285 LibraryEntity libraryElement = library.element;
1281 1286
1282 assembleStaticFunctions(library.statics, fragment); 1287 assembleStaticFunctions(library.statics, fragment);
1283 1288
1284 ClassBuilder libraryBuilder = 1289 ClassBuilder libraryBuilder =
1285 getLibraryDescriptor(libraryElement, fragment); 1290 getLibraryDescriptor(libraryElement, fragment);
1286 for (Class cls in library.classes) { 1291 for (Class cls in library.classes) {
1287 assembleClass(cls, libraryBuilder, fragment); 1292 assembleClass(cls, libraryBuilder, fragment);
1288 } 1293 }
1289 1294
1290 classEmitter.emitFields(library, libraryBuilder, emitStatics: true); 1295 classEmitter.emitFields(library, libraryBuilder, emitStatics: true);
(...skipping 27 matching lines...) Expand all
1318 1323
1319 List<jsAst.Statement> statements = <jsAst.Statement>[]; 1324 List<jsAst.Statement> statements = <jsAst.Statement>[];
1320 1325
1321 statements..add(buildGeneratedBy())..add(js.comment(HOOKS_API_USAGE)); 1326 statements..add(buildGeneratedBy())..add(js.comment(HOOKS_API_USAGE));
1322 1327
1323 if (isProgramSplit) { 1328 if (isProgramSplit) {
1324 statements.add(buildDeferredHeader()); 1329 statements.add(buildDeferredHeader());
1325 } 1330 }
1326 1331
1327 // Collect the AST for the descriptors. 1332 // Collect the AST for the descriptors.
1328 Map<Element, ClassBuilder> descriptors = elementDescriptors[mainFragment]; 1333 Map<LibraryEntity, ClassBuilder> descriptors =
1329 if (descriptors == null) descriptors = const {}; 1334 libraryDescriptors[mainFragment] ?? const {};
1330 1335
1331 checkEverythingEmitted(descriptors.keys); 1336 checkEverythingEmitted(classDescriptors[mainFragment]);
1332 1337
1333 Iterable<LibraryEntity> libraries = outputLibraryLists[mainOutputUnit]; 1338 Iterable<LibraryEntity> libraries = outputLibraryLists[mainOutputUnit];
1334 if (libraries == null) libraries = <LibraryElement>[]; 1339 if (libraries == null) libraries = <LibraryEntity>[];
1335 1340
1336 List<jsAst.Expression> parts = <jsAst.Expression>[]; 1341 List<jsAst.Expression> parts = <jsAst.Expression>[];
1337 for (LibraryEntity library in _sorter.sortLibraries(libraries)) { 1342 for (LibraryEntity library in _sorter.sortLibraries(libraries)) {
1338 parts.add(generateLibraryDescriptor(library, mainFragment)); 1343 parts.add(generateLibraryDescriptor(library, mainFragment));
1339 descriptors.remove(library); 1344 descriptors.remove(library);
1340 } 1345 }
1341 1346
1342 if (descriptors.isNotEmpty) { 1347 if (descriptors.isNotEmpty) {
1343 List<Element> remainingLibraries = 1348 List<LibraryEntity> remainingLibraries = descriptors.keys.toList();
1344 descriptors.keys.where((Element e) => e is LibraryElement).toList();
1345 1349
1346 // The remaining descriptors are only accessible through reflection. 1350 // The remaining descriptors are only accessible through reflection.
1347 // The program builder does not collect libraries that only 1351 // The program builder does not collect libraries that only
1348 // contain typedefs that are used for reflection. 1352 // contain typedefs that are used for reflection.
1349 for (LibraryElement element in remainingLibraries) { 1353 for (LibraryEntity element in remainingLibraries) {
1350 assert(element is LibraryElement); 1354 parts.add(generateLibraryDescriptor(element, mainFragment));
1351 if (element is LibraryElement) { 1355 descriptors.remove(element);
1352 parts.add(generateLibraryDescriptor(element, mainFragment));
1353 descriptors.remove(element);
1354 }
1355 } 1356 }
1356 } 1357 }
1357 jsAst.ArrayInitializer descriptorsAst = new jsAst.ArrayInitializer(parts); 1358 jsAst.ArrayInitializer descriptorsAst = new jsAst.ArrayInitializer(parts);
1358 1359
1359 // Using a named function here produces easier to read stack traces in 1360 // Using a named function here produces easier to read stack traces in
1360 // Chrome/V8. 1361 // Chrome/V8.
1361 statements.add(js.statement( 1362 statements.add(js.statement(
1362 """ 1363 """
1363 (function() { 1364 (function() {
1364 // No renaming in the top-level function to save the locals for the 1365 // No renaming in the top-level function to save the locals for the
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1541 } 1542 }
1542 1543
1543 Map<OutputUnit, jsAst.Expression> buildDescriptorsForOutputUnits( 1544 Map<OutputUnit, jsAst.Expression> buildDescriptorsForOutputUnits(
1544 Program program) { 1545 Program program) {
1545 Map<OutputUnit, jsAst.Expression> outputs = 1546 Map<OutputUnit, jsAst.Expression> outputs =
1546 new Map<OutputUnit, jsAst.Expression>(); 1547 new Map<OutputUnit, jsAst.Expression>();
1547 1548
1548 for (Fragment fragment in program.deferredFragments) { 1549 for (Fragment fragment in program.deferredFragments) {
1549 OutputUnit outputUnit = fragment.outputUnit; 1550 OutputUnit outputUnit = fragment.outputUnit;
1550 1551
1551 Map<Element, ClassBuilder> descriptors = elementDescriptors[fragment]; 1552 Map<LibraryEntity, ClassBuilder> descriptors =
1553 libraryDescriptors[fragment];
1552 1554
1553 if (descriptors != null && descriptors.isNotEmpty) { 1555 if (descriptors != null && descriptors.isNotEmpty) {
1554 Iterable<LibraryEntity> libraries = outputLibraryLists[outputUnit]; 1556 Iterable<LibraryEntity> libraries = outputLibraryLists[outputUnit];
1555 if (libraries == null) libraries = []; 1557 if (libraries == null) libraries = <LibraryEntity>[];
1556 1558
1557 // TODO(johnniwinther): Avoid creating [CodeBuffer]s. 1559 // TODO(johnniwinther): Avoid creating [CodeBuffer]s.
1558 List<jsAst.Expression> parts = <jsAst.Expression>[]; 1560 List<jsAst.Expression> parts = <jsAst.Expression>[];
1559 for (LibraryEntity library in _sorter.sortLibraries(libraries)) { 1561 for (LibraryEntity library in _sorter.sortLibraries(libraries)) {
1560 parts.add(generateLibraryDescriptor(library, fragment)); 1562 parts.add(generateLibraryDescriptor(library, fragment));
1561 descriptors.remove(library); 1563 descriptors.remove(library);
1562 } 1564 }
1563 1565
1564 outputs[outputUnit] = new jsAst.ArrayInitializer(parts); 1566 outputs[outputUnit] = new jsAst.ArrayInitializer(parts);
1565 } 1567 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1622 1624
1623 if (_closedWorld.backendUsage.requiresPreamble && 1625 if (_closedWorld.backendUsage.requiresPreamble &&
1624 !backend.htmlLibraryIsLoaded) { 1626 !backend.htmlLibraryIsLoaded) {
1625 reporter.reportHintMessage(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE); 1627 reporter.reportHintMessage(NO_LOCATION_SPANNABLE, MessageKind.PREAMBLE);
1626 } 1628 }
1627 // Return the total program size. 1629 // Return the total program size.
1628 return outputBuffers.values.fold(0, (a, b) => a + b.length); 1630 return outputBuffers.values.fold(0, (a, b) => a + b.length);
1629 } 1631 }
1630 1632
1631 ClassBuilder getStaticMethodDescriptor( 1633 ClassBuilder getStaticMethodDescriptor(
1632 MethodElement element, Fragment fragment) { 1634 FunctionEntity element, Fragment fragment) {
1633 Element owner = element.library;
1634 if (!_nativeData.isNativeMember(element)) { 1635 if (!_nativeData.isNativeMember(element)) {
1635 // For static (not top level) elements, record their code in a buffer 1636 // For static (not top level) elements, record their code in a buffer
1636 // specific to the class. For now, not supported for native classes and 1637 // specific to the class. For now, not supported for native classes and
1637 // native elements. 1638 // native elements.
1638 ClassElement cls = element.enclosingClass; 1639 ClassEntity cls = element.enclosingClass;
1639 if (compiler.codegenWorldBuilder.directlyInstantiatedClasses 1640 if (compiler.codegenWorldBuilder.directlyInstantiatedClasses
1640 .contains(cls) && 1641 .contains(cls) &&
1641 !_nativeData.isNativeClass(cls) && 1642 !_nativeData.isNativeClass(cls) &&
1642 compiler.deferredLoadTask.outputUnitForElement(element) == 1643 compiler.deferredLoadTask.outputUnitForMember(element) ==
1643 compiler.deferredLoadTask.outputUnitForElement(cls)) { 1644 compiler.deferredLoadTask.outputUnitForClass(cls)) {
1644 owner = cls; 1645 return classDescriptors
1646 .putIfAbsent(fragment, () => new Map<ClassEntity, ClassBuilder>())
1647 .putIfAbsent(cls, () {
1648 return new ClassBuilder.forClass(cls, namer);
1649 });
1645 } 1650 }
1646 } 1651 }
1647 return _getElementDescriptor(element, owner, fragment); 1652 return _getLibraryDescriptor(element, element.library, fragment);
1648 } 1653 }
1649 1654
1650 ClassBuilder getLibraryDescriptor(LibraryElement element, Fragment fragment) { 1655 ClassBuilder getLibraryDescriptor(LibraryEntity element, Fragment fragment) {
1651 return _getElementDescriptor(element, element, fragment); 1656 return _getLibraryDescriptor(element, element, fragment);
1652 } 1657 }
1653 1658
1654 ClassBuilder _getElementDescriptor( 1659 ClassBuilder _getLibraryDescriptor(
1655 Element element, Element owner, Fragment fragment) { 1660 Entity element, LibraryEntity owner, Fragment fragment) {
1656 if (owner == null) { 1661 if (owner == null) {
1657 reporter.internalError(element, 'Owner is null.'); 1662 reporter.internalError(element, 'Owner is null.');
1658 } 1663 }
1659 return elementDescriptors 1664 return libraryDescriptors
1660 .putIfAbsent(fragment, () => new Map<Element, ClassBuilder>()) 1665 .putIfAbsent(fragment, () => new Map<LibraryEntity, ClassBuilder>())
1661 .putIfAbsent(owner, () { 1666 .putIfAbsent(owner, () {
1662 return new ClassBuilder(owner, namer, owner.isClass); 1667 return new ClassBuilder.forLibrary(owner, namer);
1663 }); 1668 });
1664 } 1669 }
1665 1670
1666 /// Emits support-code for deferred loading into [output]. 1671 /// Emits support-code for deferred loading into [output].
1667 jsAst.Statement buildDeferredBoilerPlate( 1672 jsAst.Statement buildDeferredBoilerPlate(
1668 Map<OutputUnit, _DeferredOutputUnitHash> deferredLoadHashes) { 1673 Map<OutputUnit, _DeferredOutputUnitHash> deferredLoadHashes) {
1669 List<jsAst.Statement> parts = <jsAst.Statement>[]; 1674 List<jsAst.Statement> parts = <jsAst.Statement>[];
1670 1675
1671 parts.add(js.statement( 1676 parts.add(js.statement(
1672 ''' 1677 '''
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 // data. 1916 // data.
1912 mapping["_comment"] = "This mapping shows which compiled `.js` files are " 1917 mapping["_comment"] = "This mapping shows which compiled `.js` files are "
1913 "needed for a given deferred library import."; 1918 "needed for a given deferred library import.";
1914 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); 1919 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap());
1915 compiler.outputProvider( 1920 compiler.outputProvider(
1916 compiler.options.deferredMapUri.path, '', OutputType.info) 1921 compiler.options.deferredMapUri.path, '', OutputType.info)
1917 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) 1922 ..add(const JsonEncoder.withIndent(" ").convert(mapping))
1918 ..close(); 1923 ..close();
1919 } 1924 }
1920 } 1925 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698