Chromium Code Reviews| Index: pkg/compiler/lib/src/elements/elements.dart |
| diff --git a/pkg/compiler/lib/src/elements/elements.dart b/pkg/compiler/lib/src/elements/elements.dart |
| index ba4bdf0df8c06018f5de1acfb63ea0647a2454b4..bcf7ce87e64034e99dac8bcc5823b5ba94aec83b 100644 |
| --- a/pkg/compiler/lib/src/elements/elements.dart |
| +++ b/pkg/compiler/lib/src/elements/elements.dart |
| @@ -644,6 +644,13 @@ class Elements { |
| return null; |
| } |
| + /// If `true`, injected members are sorted with their corresponding class or |
| + /// library. |
| + /// |
| + /// This is used for ensuring equivalent output order when testing against |
| + /// .dill using the patched_dart2js_sdk. |
| + static bool usePatchedDart2jsSdkSorting = false; |
|
Siggi Cherem (dart-lang)
2017/06/23 20:36:34
+TODO - delete when patching is implemented in pac
Johnni Winther
2017/06/26 10:15:09
Done.
|
| + |
| /// A `compareTo` function that places [Element]s in a consistent order based |
| /// on the source code order. |
| static int compareByPosition(Element a, Element b) { |
| @@ -651,8 +658,22 @@ class Elements { |
| int r = utils.compareLibrariesUris( |
| a.library.canonicalUri, b.library.canonicalUri); |
| if (r != 0) return r; |
| - r = utils.compareSourceUris(a.compilationUnit.script.readableUri, |
| - b.compilationUnit.script.readableUri); |
| + Uri aUri = a.compilationUnit.script.readableUri; |
| + Uri bUri = b.compilationUnit.script.readableUri; |
| + if (usePatchedDart2jsSdkSorting) { |
| + Uri computePatchedDart2jsUri(Element e, Uri uri) { |
| + if (!e.isInjected) return uri; |
| + if (e.enclosingClass != null) { |
| + return e.enclosingClass.compilationUnit.script.readableUri; |
| + } else { |
| + return e.library.compilationUnit.script.readableUri; |
| + } |
| + } |
| + |
| + aUri = computePatchedDart2jsUri(a, aUri); |
| + bUri = computePatchedDart2jsUri(b, bUri); |
| + } |
| + r = utils.compareSourceUris(aUri, bUri); |
| if (r != 0) return r; |
| return utils.compareEntities(a, a.sourceOffset, -1, b, b.sourceOffset, -1); |
| } |