| 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 import '../common.dart'; | 5 import '../common.dart'; |
| 6 import '../common/backend_api.dart' show ForeignResolver; | 6 import '../common/backend_api.dart' show ForeignResolver; |
| 7 import '../common/resolution.dart' show Resolution; | 7 import '../common/resolution.dart' show Resolution; |
| 8 import '../compiler.dart' show Compiler; | 8 import '../compiler.dart' show Compiler; |
| 9 import '../constants/values.dart'; | 9 import '../constants/values.dart'; |
| 10 import '../core_types.dart' show CommonElements; | 10 import '../core_types.dart' show CommonElements; |
| 11 import '../elements/elements.dart'; | 11 import '../elements/elements.dart'; |
| 12 import '../elements/entities.dart'; | 12 import '../elements/entities.dart'; |
| 13 import '../elements/modelx.dart' show FunctionElementX; | 13 import '../elements/modelx.dart' show FunctionElementX; |
| 14 import '../elements/resolution_types.dart'; | 14 import '../elements/resolution_types.dart'; |
| 15 import '../js_backend/backend_helpers.dart' show BackendHelpers; | 15 import '../js_backend/backend_helpers.dart' show BackendHelpers; |
| 16 import '../js_backend/backend_usage.dart' show BackendUsageBuilder; |
| 16 import '../js_backend/js_backend.dart'; | 17 import '../js_backend/js_backend.dart'; |
| 17 import '../js_emitter/js_emitter.dart' show CodeEmitterTask, NativeEmitter; | 18 import '../js_emitter/js_emitter.dart' show CodeEmitterTask, NativeEmitter; |
| 18 import 'package:front_end/src/fasta/scanner.dart' show BeginGroupToken, Token; | 19 import 'package:front_end/src/fasta/scanner.dart' show BeginGroupToken, Token; |
| 19 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; | 20 import 'package:front_end/src/fasta/scanner.dart' as Tokens show EOF_TOKEN; |
| 20 import '../tree/tree.dart'; | 21 import '../tree/tree.dart'; |
| 21 import '../universe/use.dart' show StaticUse, TypeUse; | 22 import '../universe/use.dart' show StaticUse, TypeUse; |
| 22 import '../universe/world_impact.dart' | 23 import '../universe/world_impact.dart' |
| 23 show WorldImpact, WorldImpactBuilder, WorldImpactBuilderImpl; | 24 show WorldImpact, WorldImpactBuilder, WorldImpactBuilderImpl; |
| 24 import 'behavior.dart'; | 25 import 'behavior.dart'; |
| 25 | 26 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 75 |
| 75 final Compiler compiler; | 76 final Compiler compiler; |
| 76 final bool enableLiveTypeAnalysis; | 77 final bool enableLiveTypeAnalysis; |
| 77 | 78 |
| 78 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend. | 79 /// Subclasses of [NativeEnqueuerBase] are constructed by the backend. |
| 79 NativeEnqueuerBase(Compiler compiler, this.enableLiveTypeAnalysis) | 80 NativeEnqueuerBase(Compiler compiler, this.enableLiveTypeAnalysis) |
| 80 : this.compiler = compiler; | 81 : this.compiler = compiler; |
| 81 | 82 |
| 82 JavaScriptBackend get backend => compiler.backend; | 83 JavaScriptBackend get backend => compiler.backend; |
| 83 BackendHelpers get helpers => backend.helpers; | 84 BackendHelpers get helpers => backend.helpers; |
| 85 BackendUsageBuilder get _backendUsageBuilder => backend.backendUsageBuilder; |
| 84 Resolution get resolution => compiler.resolution; | 86 Resolution get resolution => compiler.resolution; |
| 85 | 87 |
| 86 DiagnosticReporter get reporter => compiler.reporter; | 88 DiagnosticReporter get reporter => compiler.reporter; |
| 87 CommonElements get commonElements => compiler.commonElements; | 89 CommonElements get commonElements => compiler.commonElements; |
| 88 | 90 |
| 89 void onInstantiatedType(ResolutionInterfaceType type) { | 91 void onInstantiatedType(ResolutionInterfaceType type) { |
| 90 if (_unusedClasses.remove(type.element)) { | 92 if (_unusedClasses.remove(type.element)) { |
| 91 _registeredClasses.add(type.element); | 93 _registeredClasses.add(type.element); |
| 92 } | 94 } |
| 93 } | 95 } |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 } | 439 } |
| 438 | 440 |
| 439 Iterable<ClassElement> _findUnusedClassesMatching( | 441 Iterable<ClassElement> _findUnusedClassesMatching( |
| 440 bool predicate(classElement)) { | 442 bool predicate(classElement)) { |
| 441 return _unusedClasses.where(predicate); | 443 return _unusedClasses.where(predicate); |
| 442 } | 444 } |
| 443 | 445 |
| 444 Iterable<ClassElement> _onFirstNativeClass(WorldImpactBuilder impactBuilder) { | 446 Iterable<ClassElement> _onFirstNativeClass(WorldImpactBuilder impactBuilder) { |
| 445 void staticUse(element) { | 447 void staticUse(element) { |
| 446 impactBuilder.registerStaticUse(new StaticUse.foreignUse(element)); | 448 impactBuilder.registerStaticUse(new StaticUse.foreignUse(element)); |
| 447 backend.backendUsage.registerBackendUse(element); | 449 _backendUsageBuilder.registerBackendUse(element); |
| 448 backend.backendUsage.registerGlobalDependency(element); | 450 _backendUsageBuilder.registerGlobalDependency(element); |
| 449 } | 451 } |
| 450 | 452 |
| 451 staticUse(helpers.defineProperty); | 453 staticUse(helpers.defineProperty); |
| 452 staticUse(helpers.toStringForNativeObject); | 454 staticUse(helpers.toStringForNativeObject); |
| 453 staticUse(helpers.hashCodeForNativeObject); | 455 staticUse(helpers.hashCodeForNativeObject); |
| 454 staticUse(helpers.closureConverter); | 456 staticUse(helpers.closureConverter); |
| 455 return _findNativeExceptions(); | 457 return _findNativeExceptions(); |
| 456 } | 458 } |
| 457 | 459 |
| 458 Iterable<ClassElement> _findNativeExceptions() { | 460 Iterable<ClassElement> _findNativeExceptions() { |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 List<ClassEntity> directSubtypes = | 607 List<ClassEntity> directSubtypes = |
| 606 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassEntity>[]); | 608 emitter.directSubtypes.putIfAbsent(superclass, () => <ClassEntity>[]); |
| 607 directSubtypes.add(cls); | 609 directSubtypes.add(cls); |
| 608 } | 610 } |
| 609 | 611 |
| 610 void logSummary(log(message)) { | 612 void logSummary(log(message)) { |
| 611 log('Compiled ${_registeredClasses.length} native classes, ' | 613 log('Compiled ${_registeredClasses.length} native classes, ' |
| 612 '${_unusedClasses.length} native classes omitted.'); | 614 '${_unusedClasses.length} native classes omitted.'); |
| 613 } | 615 } |
| 614 } | 616 } |
| OLD | NEW |