| 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.source_loader; |    5 library fasta.source_loader; | 
|    6  |    6  | 
|    7 import 'dart:async' show Future; |    7 import 'dart:async' show Future; | 
|    8  |    8  | 
|    9 import 'dart:typed_data' show Uint8List; |    9 import 'dart:typed_data' show Uint8List; | 
|   10  |   10  | 
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  332     // will have the same length. |  332     // will have the same length. | 
|  333     Iterable<ClassBuilder> input = const []; |  333     Iterable<ClassBuilder> input = const []; | 
|  334     Iterable<ClassBuilder> output = classes; |  334     Iterable<ClassBuilder> output = classes; | 
|  335     while (input.length != output.length) { |  335     while (input.length != output.length) { | 
|  336       input = output; |  336       input = output; | 
|  337       output = directSupertypes(input); |  337       output = directSupertypes(input); | 
|  338     } |  338     } | 
|  339     return output; |  339     return output; | 
|  340   } |  340   } | 
|  341  |  341  | 
 |  342   /// Whether [library] is allowed to define classes that extend or implement | 
 |  343   /// restricted types, such as `bool`, `int`, `double`, `num`, and `String`. By | 
 |  344   /// default this is only allowed within the implementation of `dart:core`, but | 
 |  345   /// some target implementations may need to override this to allow doing this | 
 |  346   /// in other internal platform libraries. | 
 |  347   bool canImplementRestrictedTypes(LibraryBuilder library) => | 
 |  348       library == coreLibrary; | 
 |  349  | 
|  342   void checkSemantics() { |  350   void checkSemantics() { | 
|  343     List<ClassBuilder> allClasses = target.collectAllClasses(); |  351     List<ClassBuilder> allClasses = target.collectAllClasses(); | 
|  344     Iterable<ClassBuilder> candidates = cyclicCandidates(allClasses); |  352     Iterable<ClassBuilder> candidates = cyclicCandidates(allClasses); | 
|  345     Map<ClassBuilder, Set<ClassBuilder>> realCycles = |  353     Map<ClassBuilder, Set<ClassBuilder>> realCycles = | 
|  346         <ClassBuilder, Set<ClassBuilder>>{}; |  354         <ClassBuilder, Set<ClassBuilder>>{}; | 
|  347     for (ClassBuilder cls in candidates) { |  355     for (ClassBuilder cls in candidates) { | 
|  348       Set<ClassBuilder> cycles = cyclicCandidates(allSupertypes(cls)); |  356       Set<ClassBuilder> cycles = cyclicCandidates(allSupertypes(cls)); | 
|  349       if (cycles.isNotEmpty) { |  357       if (cycles.isNotEmpty) { | 
|  350         realCycles[cls] = cycles; |  358         realCycles[cls] = cycles; | 
|  351       } |  359       } | 
| (...skipping 28 matching lines...) Expand all  Loading... | 
|  380     for (ClassBuilder cls in allClasses) { |  388     for (ClassBuilder cls in allClasses) { | 
|  381       if (cls.library.loader != this) continue; |  389       if (cls.library.loader != this) continue; | 
|  382       Set<ClassBuilder> directSupertypes = new Set<ClassBuilder>(); |  390       Set<ClassBuilder> directSupertypes = new Set<ClassBuilder>(); | 
|  383       target.addDirectSupertype(cls, directSupertypes); |  391       target.addDirectSupertype(cls, directSupertypes); | 
|  384       for (ClassBuilder supertype in directSupertypes) { |  392       for (ClassBuilder supertype in directSupertypes) { | 
|  385         if (supertype is EnumBuilder) { |  393         if (supertype is EnumBuilder) { | 
|  386           cls.addCompileTimeError( |  394           cls.addCompileTimeError( | 
|  387               cls.charOffset, |  395               cls.charOffset, | 
|  388               "'${supertype.name}' is an enum and can't be extended or " |  396               "'${supertype.name}' is an enum and can't be extended or " | 
|  389               "implemented."); |  397               "implemented."); | 
|  390         } else if (!cls.library.mayImplementRestrictedTypes && |  398         } else if (!canImplementRestrictedTypes(cls.library) && | 
|  391             blackListedClasses.contains(supertype)) { |  399             blackListedClasses.contains(supertype)) { | 
|  392           cls.addCompileTimeError( |  400           cls.addCompileTimeError( | 
|  393               cls.charOffset, |  401               cls.charOffset, | 
|  394               "'${supertype.name}' is restricted and can't be extended or " |  402               "'${supertype.name}' is restricted and can't be extended or " | 
|  395               "implemented."); |  403               "implemented."); | 
|  396         } |  404         } | 
|  397       } |  405       } | 
|  398       TypeBuilder mixedInType = cls.mixedInType; |  406       TypeBuilder mixedInType = cls.mixedInType; | 
|  399       if (mixedInType != null) { |  407       if (mixedInType != null) { | 
|  400         bool isClassBuilder = false; |  408         bool isClassBuilder = false; | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  512  |  520  | 
|  513   Expression throwCompileConstantError(Expression error) { |  521   Expression throwCompileConstantError(Expression error) { | 
|  514     return target.backendTarget.throwCompileConstantError(coreTypes, error); |  522     return target.backendTarget.throwCompileConstantError(coreTypes, error); | 
|  515   } |  523   } | 
|  516  |  524  | 
|  517   Expression buildCompileTimeError(String message, int offset) { |  525   Expression buildCompileTimeError(String message, int offset) { | 
|  518     return target.backendTarget |  526     return target.backendTarget | 
|  519         .buildCompileTimeError(coreTypes, message, offset); |  527         .buildCompileTimeError(coreTypes, message, offset); | 
|  520   } |  528   } | 
|  521 } |  529 } | 
| OLD | NEW |