| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 js_backend.backend; | 5 library js_backend.backend; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/backend_api.dart' | 8 import '../common/backend_api.dart' |
| 9 show ForeignResolver, NativeRegistry, ImpactTransformer; | 9 show ForeignResolver, NativeRegistry, ImpactTransformer; |
| 10 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; | 10 import '../common/codegen.dart' show CodegenImpact, CodegenWorkItem; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 static const String JS = 'JS'; | 303 static const String JS = 'JS'; |
| 304 static const String JS_BUILTIN = 'JS_BUILTIN'; | 304 static const String JS_BUILTIN = 'JS_BUILTIN'; |
| 305 static const String JS_EMBEDDED_GLOBAL = 'JS_EMBEDDED_GLOBAL'; | 305 static const String JS_EMBEDDED_GLOBAL = 'JS_EMBEDDED_GLOBAL'; |
| 306 static const String JS_INTERCEPTOR_CONSTANT = 'JS_INTERCEPTOR_CONSTANT'; | 306 static const String JS_INTERCEPTOR_CONSTANT = 'JS_INTERCEPTOR_CONSTANT'; |
| 307 | 307 |
| 308 final Compiler compiler; | 308 final Compiler compiler; |
| 309 | 309 |
| 310 /// Returns true if the backend supports reflection. | 310 /// Returns true if the backend supports reflection. |
| 311 bool get supportsReflection => emitter.supportsReflection; | 311 bool get supportsReflection => emitter.supportsReflection; |
| 312 | 312 |
| 313 final Annotations annotations; | 313 final OptimizerHintsForTests annotations; |
| 314 | 314 |
| 315 /// Set of classes that need to be considered for reflection although not | 315 /// Set of classes that need to be considered for reflection although not |
| 316 /// otherwise visible during resolution. | 316 /// otherwise visible during resolution. |
| 317 Iterable<ClassEntity> get classesRequiredForReflection { | 317 Iterable<ClassEntity> get classesRequiredForReflection { |
| 318 // TODO(herhut): Clean this up when classes needed for rti are tracked. | 318 // TODO(herhut): Clean this up when classes needed for rti are tracked. |
| 319 return [commonElements.closureClass, commonElements.jsIndexableClass]; | 319 return [commonElements.closureClass, commonElements.jsIndexableClass]; |
| 320 } | 320 } |
| 321 | 321 |
| 322 FunctionCompiler functionCompiler; | 322 FunctionCompiler functionCompiler; |
| 323 | 323 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 } | 471 } |
| 472 } | 472 } |
| 473 | 473 |
| 474 JavaScriptBackend(this.compiler, | 474 JavaScriptBackend(this.compiler, |
| 475 {bool generateSourceMap: true, | 475 {bool generateSourceMap: true, |
| 476 bool useStartupEmitter: false, | 476 bool useStartupEmitter: false, |
| 477 bool useMultiSourceInfo: false, | 477 bool useMultiSourceInfo: false, |
| 478 bool useNewSourceInfo: false, | 478 bool useNewSourceInfo: false, |
| 479 bool useKernel: false}) | 479 bool useKernel: false}) |
| 480 : _rti = new _RuntimeTypes(compiler), | 480 : _rti = new _RuntimeTypes(compiler), |
| 481 annotations = new Annotations(compiler), | 481 annotations = new OptimizerHintsForTests(compiler), |
| 482 this.sourceInformationStrategy = createSourceInformationStrategy( | 482 this.sourceInformationStrategy = createSourceInformationStrategy( |
| 483 generateSourceMap: generateSourceMap, | 483 generateSourceMap: generateSourceMap, |
| 484 useMultiSourceInfo: useMultiSourceInfo, | 484 useMultiSourceInfo: useMultiSourceInfo, |
| 485 useNewSourceInfo: useNewSourceInfo), | 485 useNewSourceInfo: useNewSourceInfo), |
| 486 constantCompilerTask = new JavaScriptConstantTask(compiler), | 486 constantCompilerTask = new JavaScriptConstantTask(compiler), |
| 487 _nativeDataResolver = new NativeDataResolverImpl(compiler), | 487 _nativeDataResolver = new NativeDataResolverImpl(compiler), |
| 488 _rtiNeedBuilder = | 488 _rtiNeedBuilder = |
| 489 compiler.frontEndStrategy.createRuntimeTypesNeedBuilder() { | 489 compiler.frontEndStrategy.createRuntimeTypesNeedBuilder() { |
| 490 _target = new JavaScriptBackendTarget(this); | 490 _target = new JavaScriptBackendTarget(this); |
| 491 impacts = new BackendImpacts(compiler.options, commonElements); | 491 impacts = new BackendImpacts(compiler.options, commonElements); |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 processor.extractNativeAnnotations(library, nativeBasicDataBuilder); | 1084 processor.extractNativeAnnotations(library, nativeBasicDataBuilder); |
| 1085 } | 1085 } |
| 1086 processor.extractJsInteropAnnotations(library, nativeBasicDataBuilder); | 1086 processor.extractJsInteropAnnotations(library, nativeBasicDataBuilder); |
| 1087 } | 1087 } |
| 1088 Uri uri = library.canonicalUri; | 1088 Uri uri = library.canonicalUri; |
| 1089 if (uri == Uris.dart_html) { | 1089 if (uri == Uris.dart_html) { |
| 1090 htmlLibraryIsLoaded = true; | 1090 htmlLibraryIsLoaded = true; |
| 1091 } else if (uri == LookupMapResolutionAnalysis.PACKAGE_LOOKUP_MAP) { | 1091 } else if (uri == LookupMapResolutionAnalysis.PACKAGE_LOOKUP_MAP) { |
| 1092 lookupMapResolutionAnalysis.init(library); | 1092 lookupMapResolutionAnalysis.init(library); |
| 1093 } | 1093 } |
| 1094 annotations.onLibraryLoaded(library); | |
| 1095 } | 1094 } |
| 1096 | 1095 |
| 1097 /// This method is called when all new libraries loaded through | 1096 /// This method is called when all new libraries loaded through |
| 1098 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports | 1097 /// [LibraryLoader.loadLibrary] has been loaded and their imports/exports |
| 1099 /// have been computed. | 1098 /// have been computed. |
| 1100 void onLibrariesLoaded(LoadedLibraries loadedLibraries) { | 1099 void onLibrariesLoaded(LoadedLibraries loadedLibraries) { |
| 1101 if (loadedLibraries.containsLibrary(Uris.dart_core)) { | 1100 if (loadedLibraries.containsLibrary(Uris.dart_core)) { |
| 1102 assert(loadedLibraries.containsLibrary(Uris.dart_core)); | 1101 assert(loadedLibraries.containsLibrary(Uris.dart_core)); |
| 1103 assert(loadedLibraries.containsLibrary(Uris.dart__interceptors)); | 1102 assert(loadedLibraries.containsLibrary(Uris.dart__interceptors)); |
| 1104 assert(loadedLibraries.containsLibrary(Uris.dart__js_helper)); | 1103 assert(loadedLibraries.containsLibrary(Uris.dart__js_helper)); |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1450 |
| 1452 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { | 1451 bool canUseAliasedSuperMember(MemberEntity member, Selector selector) { |
| 1453 return !selector.isGetter; | 1452 return !selector.isGetter; |
| 1454 } | 1453 } |
| 1455 | 1454 |
| 1456 /// Returns `true` if [member] is called from a subclass via `super`. | 1455 /// Returns `true` if [member] is called from a subclass via `super`. |
| 1457 bool isAliasedSuperMember(MemberEntity member) { | 1456 bool isAliasedSuperMember(MemberEntity member) { |
| 1458 return _aliasedSuperMembers.contains(member); | 1457 return _aliasedSuperMembers.contains(member); |
| 1459 } | 1458 } |
| 1460 } | 1459 } |
| OLD | NEW |