OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 fasta.kernel_library_builder; | 5 library fasta.kernel_library_builder; |
6 | 6 |
7 import 'package:kernel/ast.dart'; | 7 import 'package:kernel/ast.dart'; |
8 | 8 |
9 import 'package:kernel/clone.dart' show CloneVisitor; | 9 import 'package:kernel/clone.dart' show CloneVisitor; |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 KernelProcedureBuilder, | 44 KernelProcedureBuilder, |
45 KernelTypeBuilder, | 45 KernelTypeBuilder, |
46 KernelTypeVariableBuilder, | 46 KernelTypeVariableBuilder, |
47 MemberBuilder, | 47 MemberBuilder, |
48 MetadataBuilder, | 48 MetadataBuilder, |
49 MixedAccessor, | 49 MixedAccessor, |
50 NamedMixinApplicationBuilder, | 50 NamedMixinApplicationBuilder, |
51 PrefixBuilder, | 51 PrefixBuilder, |
52 ProcedureBuilder, | 52 ProcedureBuilder, |
53 TypeBuilder, | 53 TypeBuilder, |
54 TypeVariableBuilder; | 54 TypeVariableBuilder, |
| 55 compareProcedures; |
55 | 56 |
56 class KernelLibraryBuilder | 57 class KernelLibraryBuilder |
57 extends SourceLibraryBuilder<KernelTypeBuilder, Library> { | 58 extends SourceLibraryBuilder<KernelTypeBuilder, Library> { |
58 final Library library; | 59 final Library library; |
59 | 60 |
60 final Map<String, SourceClassBuilder> mixinApplicationClasses = | 61 final Map<String, SourceClassBuilder> mixinApplicationClasses = |
61 <String, SourceClassBuilder>{}; | 62 <String, SourceClassBuilder>{}; |
62 | 63 |
63 final List<List> argumentsWithMissingDefaultValues = <List>[]; | 64 final List<List> argumentsWithMissingDefaultValues = <List>[]; |
64 | 65 |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 } else if (builder is BuiltinTypeBuilder) { | 318 } else if (builder is BuiltinTypeBuilder) { |
318 // Nothing needed. | 319 // Nothing needed. |
319 } else { | 320 } else { |
320 internalError("Unhandled builder: ${builder.runtimeType}"); | 321 internalError("Unhandled builder: ${builder.runtimeType}"); |
321 } | 322 } |
322 } | 323 } |
323 | 324 |
324 Library build() { | 325 Library build() { |
325 super.build(); | 326 super.build(); |
326 library.name = name; | 327 library.name = name; |
| 328 library.procedures.sort(compareProcedures); |
327 return library; | 329 return library; |
328 } | 330 } |
329 | 331 |
330 @override | 332 @override |
331 Builder buildAmbiguousBuilder( | 333 Builder buildAmbiguousBuilder( |
332 String name, Builder builder, Builder other, int charOffset, | 334 String name, Builder builder, Builder other, int charOffset, |
333 {bool isExport: false, bool isImport: false}) { | 335 {bool isExport: false, bool isImport: false}) { |
334 if (builder == other) return builder; | 336 if (builder == other) return builder; |
335 if (builder is InvalidTypeBuilder) return builder; | 337 if (builder is InvalidTypeBuilder) return builder; |
336 if (other is InvalidTypeBuilder) return other; | 338 if (other is InvalidTypeBuilder) return other; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 514 } |
513 } | 515 } |
514 | 516 |
515 bool isConstructorName(String name, String className) { | 517 bool isConstructorName(String name, String className) { |
516 if (name.startsWith(className)) { | 518 if (name.startsWith(className)) { |
517 if (name.length == className.length) return true; | 519 if (name.length == className.length) return true; |
518 if (name.startsWith(".", className.length)) return true; | 520 if (name.startsWith(".", className.length)) return true; |
519 } | 521 } |
520 return false; | 522 return false; |
521 } | 523 } |
OLD | NEW |