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 | 10 import '../common/names.dart' show |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 ResolverTask(Compiler compiler, this.constantCompiler) : super(compiler); | 65 ResolverTask(Compiler compiler, this.constantCompiler) : super(compiler); |
66 | 66 |
67 String get name => 'Resolver'; | 67 String get name => 'Resolver'; |
68 | 68 |
69 Resolution get resolution => compiler.resolution; | 69 Resolution get resolution => compiler.resolution; |
70 | 70 |
71 Parsing get parsing => compiler.parsing; | 71 Parsing get parsing => compiler.parsing; |
72 | 72 |
73 ResolutionImpact resolve(Element element) { | 73 ResolutionImpact resolve(Element element) { |
74 return measure(() { | 74 return measure(() { |
75 if (Elements.isErroneous(element)) { | 75 if (Elements.isMalformed(element)) { |
76 // TODO(johnniwinther): Add a predicate for this. | 76 // TODO(johnniwinther): Add a predicate for this. |
77 assert(invariant(element, element is! ErroneousElement, | 77 assert(invariant(element, element is! ErroneousElement, |
78 message: "Element $element expected to have parse errors.")); | 78 message: "Element $element expected to have parse errors.")); |
79 _ensureTreeElements(element); | 79 _ensureTreeElements(element); |
80 return const ResolutionImpact(); | 80 return const ResolutionImpact(); |
81 } | 81 } |
82 | 82 |
83 WorldImpact processMetadata([WorldImpact result]) { | 83 WorldImpact processMetadata([WorldImpact result]) { |
84 for (MetadataAnnotation metadata in element.implementation.metadata) { | 84 for (MetadataAnnotation metadata in element.implementation.metadata) { |
85 metadata.ensureResolved(resolution); | 85 metadata.ensureResolved(resolution); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 if (element.isSynthesized) { | 290 if (element.isSynthesized) { |
291 if (element.isGenerativeConstructor) { | 291 if (element.isGenerativeConstructor) { |
292 ResolutionRegistry registry = | 292 ResolutionRegistry registry = |
293 new ResolutionRegistry(compiler, _ensureTreeElements(element)); | 293 new ResolutionRegistry(compiler, _ensureTreeElements(element)); |
294 ConstructorElement constructor = element.asFunctionElement(); | 294 ConstructorElement constructor = element.asFunctionElement(); |
295 ConstructorElement target = constructor.definingConstructor; | 295 ConstructorElement target = constructor.definingConstructor; |
296 // Ensure the signature of the synthesized element is | 296 // Ensure the signature of the synthesized element is |
297 // resolved. This is the only place where the resolver is | 297 // resolved. This is the only place where the resolver is |
298 // seeing this element. | 298 // seeing this element. |
299 element.computeType(resolution); | 299 element.computeType(resolution); |
300 if (!target.isErroneous) { | 300 if (!target.isMalformed) { |
301 registry.registerImplicitSuperCall(target); | 301 registry.registerImplicitSuperCall(target); |
302 } | 302 } |
303 return registry.worldImpact; | 303 return registry.worldImpact; |
304 } else { | 304 } else { |
305 assert(element.isDeferredLoaderGetter || element.isErroneous); | 305 assert(element.isDeferredLoaderGetter || element.isMalformed); |
306 _ensureTreeElements(element); | 306 _ensureTreeElements(element); |
307 return const ResolutionImpact(); | 307 return const ResolutionImpact(); |
308 } | 308 } |
309 } else { | 309 } else { |
310 element.parseNode(resolution.parsing); | 310 element.parseNode(resolution.parsing); |
311 element.computeType(resolution); | 311 element.computeType(resolution); |
312 FunctionElementX implementation = element; | 312 FunctionElementX implementation = element; |
313 if (element.isExternal) { | 313 if (element.isExternal) { |
314 implementation = compiler.backend.resolveExternalFunction(element); | 314 implementation = compiler.backend.resolveExternalFunction(element); |
315 } | 315 } |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 // field once, so we just ignore setters. | 824 // field once, so we just ignore setters. |
825 if (!member.isGetter) return; | 825 if (!member.isGetter) return; |
826 | 826 |
827 // Find the associated abstract field. | 827 // Find the associated abstract field. |
828 ClassElement classElement = member.enclosingClass; | 828 ClassElement classElement = member.enclosingClass; |
829 Element lookupElement = classElement.lookupLocalMember(member.name); | 829 Element lookupElement = classElement.lookupLocalMember(member.name); |
830 if (lookupElement == null) { | 830 if (lookupElement == null) { |
831 reporter.internalError(member, | 831 reporter.internalError(member, |
832 "No abstract field for accessor"); | 832 "No abstract field for accessor"); |
833 } else if (!identical(lookupElement.kind, ElementKind.ABSTRACT_FIELD)) { | 833 } else if (!identical(lookupElement.kind, ElementKind.ABSTRACT_FIELD)) { |
834 if (lookupElement.isErroneous || lookupElement.isAmbiguous) return; | 834 if (lookupElement.isMalformed || lookupElement.isAmbiguous) return; |
835 reporter.internalError(member, | 835 reporter.internalError(member, |
836 "Inaccessible abstract field for accessor"); | 836 "Inaccessible abstract field for accessor"); |
837 } | 837 } |
838 AbstractFieldElement field = lookupElement; | 838 AbstractFieldElement field = lookupElement; |
839 | 839 |
840 GetterElementX getter = field.getter; | 840 GetterElementX getter = field.getter; |
841 if (getter == null) return; | 841 if (getter == null) return; |
842 SetterElementX setter = field.setter; | 842 SetterElementX setter = field.setter; |
843 if (setter == null) return; | 843 if (setter == null) return; |
844 int getterFlags = getter.modifiers.flags | Modifiers.FLAG_ABSTRACT; | 844 int getterFlags = getter.modifiers.flags | Modifiers.FLAG_ABSTRACT; |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1075 TreeElements get treeElements { | 1075 TreeElements get treeElements { |
1076 assert(invariant(this, _treeElements !=null, | 1076 assert(invariant(this, _treeElements !=null, |
1077 message: "TreeElements have not been computed for $this.")); | 1077 message: "TreeElements have not been computed for $this.")); |
1078 return _treeElements; | 1078 return _treeElements; |
1079 } | 1079 } |
1080 | 1080 |
1081 void reuseElement() { | 1081 void reuseElement() { |
1082 _treeElements = null; | 1082 _treeElements = null; |
1083 } | 1083 } |
1084 } | 1084 } |
OLD | NEW |