| 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.library_builder; | 5 library fasta.library_builder; |
| 6 | 6 |
| 7 import '../combinator.dart' show Combinator; | 7 import '../combinator.dart' show Combinator; |
| 8 | 8 |
| 9 import '../errors.dart' show InputError, internalError, printUnexpected; | 9 import '../errors.dart' show InputError, internalError, printUnexpected; |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 /// if no such class is exported by this library, or if the class doesn't | 99 /// if no such class is exported by this library, or if the class doesn't |
| 100 /// have a matching constructor (or factory). | 100 /// have a matching constructor (or factory). |
| 101 /// | 101 /// |
| 102 /// If [constructorName] is null or the empty string, it's assumed to be an | 102 /// If [constructorName] is null or the empty string, it's assumed to be an |
| 103 /// unnamed constructor. | 103 /// unnamed constructor. |
| 104 Builder getConstructor(String className, | 104 Builder getConstructor(String className, |
| 105 {String constructorName, bool isPrivate: false}) { | 105 {String constructorName, bool isPrivate: false}) { |
| 106 constructorName ??= ""; | 106 constructorName ??= ""; |
| 107 Builder cls = (isPrivate ? members : exports)[className]; | 107 Builder cls = (isPrivate ? members : exports)[className]; |
| 108 if (cls is ClassBuilder) { | 108 if (cls is ClassBuilder) { |
| 109 // TODO(ahe): This code is similar to code in `handleNewExpression` in | 109 // TODO(ahe): This code is similar to code in `endNewExpression` in |
| 110 // `body_builder.dart`, try to share it. | 110 // `body_builder.dart`, try to share it. |
| 111 Builder constructor = cls.findConstructorOrFactory(constructorName); | 111 Builder constructor = cls.findConstructorOrFactory(constructorName); |
| 112 if (constructor == null) { | 112 if (constructor == null) { |
| 113 // Fall-through to internal error below. | 113 // Fall-through to internal error below. |
| 114 } else if (constructor.isConstructor) { | 114 } else if (constructor.isConstructor) { |
| 115 if (!cls.isAbstract) { | 115 if (!cls.isAbstract) { |
| 116 return constructor; | 116 return constructor; |
| 117 } | 117 } |
| 118 } else if (constructor.isFactory) { | 118 } else if (constructor.isFactory) { |
| 119 return constructor; | 119 return constructor; |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 throw internalError("Internal error: No constructor named" | 122 throw internalError("Internal error: No constructor named" |
| 123 " '$className::$constructorName' in '$uri'."); | 123 " '$className::$constructorName' in '$uri'."); |
| 124 } | 124 } |
| 125 | 125 |
| 126 int finishTypeVariables(ClassBuilder object) => 0; | 126 int finishTypeVariables(ClassBuilder object) => 0; |
| 127 | 127 |
| 128 void becomeCoreLibrary(dynamicType, voidType) { | 128 void becomeCoreLibrary(dynamicType, voidType) { |
| 129 addBuilder("dynamic", | 129 addBuilder("dynamic", |
| 130 new DynamicTypeBuilder<T, dynamic>(dynamicType, this, -1), -1); | 130 new DynamicTypeBuilder<T, dynamic>(dynamicType, this, -1), -1); |
| 131 addBuilder("void", new VoidTypeBuilder<T, dynamic>(voidType, this, -1), -1); | 131 addBuilder("void", new VoidTypeBuilder<T, dynamic>(voidType, this, -1), -1); |
| 132 } | 132 } |
| 133 } | 133 } |
| OLD | NEW |