Chromium Code Reviews| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 125 /// If [constructorName] is null or the empty string, it's assumed to be an | 125 /// If [constructorName] is null or the empty string, it's assumed to be an |
| 126 /// unnamed constructor. | 126 /// unnamed constructor. |
| 127 Builder getConstructor(String className, | 127 Builder getConstructor(String className, |
| 128 {String constructorName, bool isPrivate: false}) { | 128 {String constructorName, bool isPrivate: false}) { |
| 129 constructorName ??= ""; | 129 constructorName ??= ""; |
| 130 Builder cls = (isPrivate ? scope : exports).lookup(className, -1, null); | 130 Builder cls = (isPrivate ? scope : exports).lookup(className, -1, null); |
| 131 if (cls is ClassBuilder) { | 131 if (cls is ClassBuilder) { |
| 132 // TODO(ahe): This code is similar to code in `endNewExpression` in | 132 // TODO(ahe): This code is similar to code in `endNewExpression` in |
| 133 // `body_builder.dart`, try to share it. | 133 // `body_builder.dart`, try to share it. |
| 134 Builder constructor = | 134 Builder constructor = |
| 135 cls.findConstructorOrFactory(constructorName, -1, null); | 135 cls.findConstructorOrFactory(constructorName, -1, null, this); |
|
Paul Berry
2017/06/01 16:54:18
This method (getConstructor) is written in a reall
ahe
2017/06/01 17:12:42
Good point.
Paul Berry
2017/06/01 17:15:11
sgtm, thanks.
ahe
2017/06/02 06:26:51
Done.
| |
| 136 if (constructor == null) { | 136 if (constructor == null) { |
| 137 // Fall-through to internal error below. | 137 // Fall-through to internal error below. |
| 138 } else if (constructor.isConstructor) { | 138 } else if (constructor.isConstructor) { |
| 139 if (!cls.isAbstract) { | 139 if (!cls.isAbstract) { |
| 140 return constructor; | 140 return constructor; |
| 141 } | 141 } |
| 142 } else if (constructor.isFactory) { | 142 } else if (constructor.isFactory) { |
| 143 return constructor; | 143 return constructor; |
| 144 } | 144 } |
| 145 } | 145 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 162 /// Don't use for scope lookup. Only use when an element is known to exist | 162 /// Don't use for scope lookup. Only use when an element is known to exist |
| 163 /// (and not a setter). | 163 /// (and not a setter). |
| 164 Builder operator [](String name) { | 164 Builder operator [](String name) { |
| 165 return scope.local[name] ?? internalError("Not found: '$name'."); | 165 return scope.local[name] ?? internalError("Not found: '$name'."); |
| 166 } | 166 } |
| 167 | 167 |
| 168 Builder lookup(String name, int charOffset, Uri fileUri) { | 168 Builder lookup(String name, int charOffset, Uri fileUri) { |
| 169 return scope.lookup(name, charOffset, fileUri); | 169 return scope.lookup(name, charOffset, fileUri); |
| 170 } | 170 } |
| 171 } | 171 } |
| OLD | NEW |