OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 dart2js.resolution; | 5 library dart2js.resolution; |
6 | 6 |
7 import 'dart:collection' show Queue; | 7 import 'dart:collection' show Queue; |
8 | 8 |
9 import '../common.dart'; | 9 import '../common.dart'; |
10 import '../common/names.dart' show Identifiers; | 10 import '../common/names.dart' show Identifiers; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) { | 207 bool _isNativeClassOrExtendsNativeClass(ClassElement classElement) { |
208 assert(classElement != null); | 208 assert(classElement != null); |
209 while (classElement != null) { | 209 while (classElement != null) { |
210 if (target.isNativeClass(classElement)) return true; | 210 if (target.isNativeClass(classElement)) return true; |
211 classElement = classElement.superclass; | 211 classElement = classElement.superclass; |
212 } | 212 } |
213 return false; | 213 return false; |
214 } | 214 } |
215 | 215 |
216 WorldImpact resolveMethodElementImplementation( | 216 WorldImpact resolveMethodElementImplementation( |
217 FunctionElement element, FunctionExpression tree) { | 217 FunctionElementX element, FunctionExpression tree) { |
218 return reporter.withCurrentElement(element, () { | 218 return reporter.withCurrentElement(element, () { |
219 if (element.isExternal && tree.hasBody) { | 219 if (element.isExternal && tree.hasBody) { |
220 reporter.reportErrorMessage(element, MessageKind.EXTERNAL_WITH_BODY, | 220 reporter.reportErrorMessage(element, MessageKind.EXTERNAL_WITH_BODY, |
221 {'functionName': element.name}); | 221 {'functionName': element.name}); |
222 } | 222 } |
223 if (element.isConstructor) { | 223 if (element.isConstructor) { |
224 if (tree.returnType != null) { | 224 if (tree.returnType != null) { |
225 reporter.reportErrorMessage( | 225 reporter.reportErrorMessage( |
226 tree, MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE); | 226 tree, MessageKind.CONSTRUCTOR_WITH_RETURN_TYPE); |
227 } | 227 } |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 } | 279 } |
280 | 280 |
281 // TODO(9631): support noSuchMethod on native classes. | 281 // TODO(9631): support noSuchMethod on native classes. |
282 if (element.isFunction && | 282 if (element.isFunction && |
283 element.isInstanceMember && | 283 element.isInstanceMember && |
284 element.name == Identifiers.noSuchMethod_ && | 284 element.name == Identifiers.noSuchMethod_ && |
285 _isNativeClassOrExtendsNativeClass(enclosingClass)) { | 285 _isNativeClassOrExtendsNativeClass(enclosingClass)) { |
286 reporter.reportErrorMessage(tree, MessageKind.NO_SUCH_METHOD_IN_NATIVE); | 286 reporter.reportErrorMessage(tree, MessageKind.NO_SUCH_METHOD_IN_NATIVE); |
287 } | 287 } |
288 | 288 |
289 resolution.target.resolveNativeElement(element, registry.impactBuilder); | 289 resolution.target.resolveNativeMember(element, registry.impactBuilder); |
290 | 290 |
291 return registry.impactBuilder; | 291 return registry.impactBuilder; |
292 }); | 292 }); |
293 } | 293 } |
294 | 294 |
295 WorldImpact resolveMethodElement(FunctionElementX element) { | 295 WorldImpact resolveMethodElement(FunctionElementX element) { |
296 assert(invariant(element, element.isDeclaration)); | 296 assert(invariant(element, element.isDeclaration)); |
297 return reporter.withCurrentElement(element, () { | 297 return reporter.withCurrentElement(element, () { |
298 if (enqueuer.hasBeenProcessed(element)) { | 298 if (enqueuer.hasBeenProcessed(element)) { |
299 // TODO(karlklose): Remove the check for [isConstructor]. [elememts] | 299 // TODO(karlklose): Remove the check for [isConstructor]. [elememts] |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 // TODO(johnniwinther): Determine the const-ness eagerly to avoid | 427 // TODO(johnniwinther): Determine the const-ness eagerly to avoid |
428 // unnecessary registrations. | 428 // unnecessary registrations. |
429 registry.registerFeature(Feature.LAZY_FIELD); | 429 registry.registerFeature(Feature.LAZY_FIELD); |
430 } | 430 } |
431 } | 431 } |
432 } | 432 } |
433 | 433 |
434 // Perform various checks as side effect of "computing" the type. | 434 // Perform various checks as side effect of "computing" the type. |
435 element.computeType(resolution); | 435 element.computeType(resolution); |
436 | 436 |
437 resolution.target.resolveNativeElement(element, registry.impactBuilder); | 437 resolution.target.resolveNativeMember(element, registry.impactBuilder); |
438 | 438 |
439 return registry.impactBuilder; | 439 return registry.impactBuilder; |
440 }); | 440 }); |
441 } | 441 } |
442 | 442 |
443 ResolutionDartType resolveTypeAnnotation( | 443 ResolutionDartType resolveTypeAnnotation( |
444 Element element, TypeAnnotation annotation) { | 444 Element element, TypeAnnotation annotation) { |
445 ResolutionDartType type = _resolveReturnType(element, annotation); | 445 ResolutionDartType type = _resolveReturnType(element, annotation); |
446 if (type.isVoid) { | 446 if (type.isVoid) { |
447 reporter.reportErrorMessage(annotation, MessageKind.VOID_NOT_ALLOWED); | 447 reporter.reportErrorMessage(annotation, MessageKind.VOID_NOT_ALLOWED); |
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1139 TreeElements get treeElements { | 1139 TreeElements get treeElements { |
1140 assert(invariant(this, _treeElements != null, | 1140 assert(invariant(this, _treeElements != null, |
1141 message: "TreeElements have not been computed for $this.")); | 1141 message: "TreeElements have not been computed for $this.")); |
1142 return _treeElements; | 1142 return _treeElements; |
1143 } | 1143 } |
1144 | 1144 |
1145 void reuseElement() { | 1145 void reuseElement() { |
1146 _treeElements = null; | 1146 _treeElements = null; |
1147 } | 1147 } |
1148 } | 1148 } |
OLD | NEW |