| 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 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; |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 /// The reflection name of a method 'foo' is 'foo:N:M:O', where N is the | 440 /// The reflection name of a method 'foo' is 'foo:N:M:O', where N is the |
| 441 /// number of required arguments, M is the number of optional arguments, and | 441 /// number of required arguments, M is the number of optional arguments, and |
| 442 /// O is the named arguments. | 442 /// O is the named arguments. |
| 443 /// The reflection name of a constructor is similar to a regular method but | 443 /// The reflection name of a constructor is similar to a regular method but |
| 444 /// starts with 'new '. | 444 /// starts with 'new '. |
| 445 /// The reflection name of class 'C' is 'C'. | 445 /// The reflection name of class 'C' is 'C'. |
| 446 /// An anonymous mixin application has no reflection name. | 446 /// An anonymous mixin application has no reflection name. |
| 447 /// This is used by js_mirrors.dart. | 447 /// This is used by js_mirrors.dart. |
| 448 String getReflectionName(elementOrSelector, jsAst.Name mangledName) { | 448 String getReflectionName(elementOrSelector, jsAst.Name mangledName) { |
| 449 String name = elementOrSelector.name; | 449 String name = elementOrSelector.name; |
| 450 if (backend.shouldRetainName(name) || | 450 if (backend.mirrorsData.shouldRetainName(name) || |
| 451 elementOrSelector is Element && | 451 elementOrSelector is Element && |
| 452 // Make sure to retain names of unnamed constructors, and | 452 // Make sure to retain names of unnamed constructors, and |
| 453 // for common native types. | 453 // for common native types. |
| 454 ((name == '' && | 454 ((name == '' && |
| 455 backend.isAccessibleByReflection(elementOrSelector)) || | 455 backend.mirrorsData |
| 456 .isAccessibleByReflection(elementOrSelector)) || |
| 456 _isNativeTypeNeedingReflectionName(elementOrSelector))) { | 457 _isNativeTypeNeedingReflectionName(elementOrSelector))) { |
| 457 // TODO(ahe): Enable the next line when I can tell the difference between | 458 // TODO(ahe): Enable the next line when I can tell the difference between |
| 458 // an instance method and a global. They may have the same mangled name. | 459 // an instance method and a global. They may have the same mangled name. |
| 459 // if (recordedMangledNames.contains(mangledName)) return null; | 460 // if (recordedMangledNames.contains(mangledName)) return null; |
| 460 recordedMangledNames.add(mangledName); | 461 recordedMangledNames.add(mangledName); |
| 461 return getReflectionNameInternal(elementOrSelector, mangledName); | 462 return getReflectionNameInternal(elementOrSelector, mangledName); |
| 462 } | 463 } |
| 463 return null; | 464 return null; |
| 464 } | 465 } |
| 465 | 466 |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 LibraryElement library, Fragment fragment) { | 1033 LibraryElement library, Fragment fragment) { |
| 1033 var uri = ""; | 1034 var uri = ""; |
| 1034 if (!compiler.options.enableMinification || backend.mustPreserveUris) { | 1035 if (!compiler.options.enableMinification || backend.mustPreserveUris) { |
| 1035 uri = library.canonicalUri; | 1036 uri = library.canonicalUri; |
| 1036 if (uri.scheme == 'file' && compiler.options.outputUri != null) { | 1037 if (uri.scheme == 'file' && compiler.options.outputUri != null) { |
| 1037 uri = | 1038 uri = |
| 1038 relativize(compiler.options.outputUri, library.canonicalUri, false); | 1039 relativize(compiler.options.outputUri, library.canonicalUri, false); |
| 1039 } | 1040 } |
| 1040 } | 1041 } |
| 1041 | 1042 |
| 1042 String libraryName = | 1043 String libraryName = (!compiler.options.enableMinification || |
| 1043 (!compiler.options.enableMinification || backend.mustRetainLibraryNames) | 1044 backend.mirrorsData.mustRetainLibraryNames) |
| 1044 ? library.libraryName | 1045 ? library.libraryName |
| 1045 : ""; | 1046 : ""; |
| 1046 | 1047 |
| 1047 jsAst.Fun metadata = task.metadataCollector.buildMetadataFunction(library); | 1048 jsAst.Fun metadata = task.metadataCollector.buildMetadataFunction(library); |
| 1048 | 1049 |
| 1049 ClassBuilder descriptor = elementDescriptors[fragment][library]; | 1050 ClassBuilder descriptor = elementDescriptors[fragment][library]; |
| 1050 | 1051 |
| 1051 jsAst.ObjectInitializer initializer; | 1052 jsAst.ObjectInitializer initializer; |
| 1052 if (descriptor == null) { | 1053 if (descriptor == null) { |
| 1053 // Nothing of the library was emitted. | 1054 // Nothing of the library was emitted. |
| 1054 // TODO(floitsch): this should not happen. We currently have an example | 1055 // TODO(floitsch): this should not happen. We currently have an example |
| 1055 // with language/prefix6_negative_test.dart where we have an instance | 1056 // with language/prefix6_negative_test.dart where we have an instance |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1936 // data. | 1937 // data. |
| 1937 mapping["_comment"] = "This mapping shows which compiled `.js` files are " | 1938 mapping["_comment"] = "This mapping shows which compiled `.js` files are " |
| 1938 "needed for a given deferred library import."; | 1939 "needed for a given deferred library import."; |
| 1939 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); | 1940 mapping.addAll(compiler.deferredLoadTask.computeDeferredMap()); |
| 1940 compiler.outputProvider( | 1941 compiler.outputProvider( |
| 1941 compiler.options.deferredMapUri.path, 'deferred_map') | 1942 compiler.options.deferredMapUri.path, 'deferred_map') |
| 1942 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) | 1943 ..add(const JsonEncoder.withIndent(" ").convert(mapping)) |
| 1943 ..close(); | 1944 ..close(); |
| 1944 } | 1945 } |
| 1945 } | 1946 } |
| OLD | NEW |