Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: pkg/compiler/lib/src/resolution/members.dart

Issue 892583002: Support async getters. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 AnalyzableElement get analyzedElement; 8 AnalyzableElement get analyzedElement;
9 Iterable<Node> get superUses; 9 Iterable<Node> get superUses;
10 10
(...skipping 4782 matching lines...) Expand 10 before | Expand all | Expand 10 after
4793 ConstructorResolver(Compiler compiler, this.resolver, 4793 ConstructorResolver(Compiler compiler, this.resolver,
4794 {bool this.inConstContext: false}) 4794 {bool this.inConstContext: false})
4795 : super(compiler); 4795 : super(compiler);
4796 4796
4797 ResolutionRegistry get registry => resolver.registry; 4797 ResolutionRegistry get registry => resolver.registry;
4798 4798
4799 visitNode(Node node) { 4799 visitNode(Node node) {
4800 throw 'not supported'; 4800 throw 'not supported';
4801 } 4801 }
4802 4802
4803 failOrReturnErroneousElement(Element enclosing, Node diagnosticNode, 4803 failOrReturnErroneousConstructorElement(
4804 String targetName, MessageKind kind, 4804 Element enclosing, Node diagnosticNode,
4805 Map arguments) { 4805 String targetName, MessageKind kind,
4806 Map arguments) {
4806 if (kind == MessageKind.CANNOT_FIND_CONSTRUCTOR) { 4807 if (kind == MessageKind.CANNOT_FIND_CONSTRUCTOR) {
4807 registry.registerThrowNoSuchMethod(); 4808 registry.registerThrowNoSuchMethod();
4808 } else { 4809 } else {
4809 registry.registerThrowRuntimeError(); 4810 registry.registerThrowRuntimeError();
4810 } 4811 }
4811 if (inConstContext) { 4812 if (inConstContext) {
4812 compiler.reportError(diagnosticNode, kind, arguments); 4813 compiler.reportError(diagnosticNode, kind, arguments);
4813 } else { 4814 } else {
4814 compiler.reportWarning(diagnosticNode, kind, arguments); 4815 compiler.reportWarning(diagnosticNode, kind, arguments);
4815 } 4816 }
4816 return new ErroneousElementX(kind, arguments, targetName, enclosing); 4817 return new ErroneousConstructorElementX(
4818 kind, arguments, targetName, enclosing);
4817 } 4819 }
4818 4820
4819 FunctionElement resolveConstructor(ClassElement cls, 4821 FunctionElement resolveConstructor(ClassElement cls,
4820 Node diagnosticNode, 4822 Node diagnosticNode,
4821 String constructorName) { 4823 String constructorName) {
4822 cls.ensureResolved(compiler); 4824 cls.ensureResolved(compiler);
4823 Element result = cls.lookupConstructor(constructorName); 4825 Element result = cls.lookupConstructor(constructorName);
4824 if (result == null) { 4826 if (result == null) {
4825 String fullConstructorName = Elements.constructorNameForDiagnostics( 4827 String fullConstructorName = Elements.constructorNameForDiagnostics(
4826 cls.name, 4828 cls.name,
4827 constructorName); 4829 constructorName);
4828 return failOrReturnErroneousElement( 4830 return failOrReturnErroneousConstructorElement(
4829 cls, 4831 cls,
4830 diagnosticNode, 4832 diagnosticNode,
4831 fullConstructorName, 4833 fullConstructorName,
4832 MessageKind.CANNOT_FIND_CONSTRUCTOR, 4834 MessageKind.CANNOT_FIND_CONSTRUCTOR,
4833 {'constructorName': fullConstructorName}); 4835 {'constructorName': fullConstructorName});
4834 } else if (inConstContext && !result.isConst) { 4836 } else if (inConstContext && !result.isConst) {
4835 error(diagnosticNode, MessageKind.CONSTRUCTOR_IS_NOT_CONST); 4837 error(diagnosticNode, MessageKind.CONSTRUCTOR_IS_NOT_CONST);
4836 } 4838 }
4837 return result; 4839 return result;
4838 } 4840 }
(...skipping 16 matching lines...) Expand all
4855 message: 'No element return for $diagnosticNode.')); 4857 message: 'No element return for $diagnosticNode.'));
4856 // Find the unnamed constructor if the reference resolved to a 4858 // Find the unnamed constructor if the reference resolved to a
4857 // class. 4859 // class.
4858 if (!Elements.isUnresolved(element) && !element.isConstructor) { 4860 if (!Elements.isUnresolved(element) && !element.isConstructor) {
4859 if (element.isClass) { 4861 if (element.isClass) {
4860 ClassElement cls = element; 4862 ClassElement cls = element;
4861 cls.ensureResolved(compiler); 4863 cls.ensureResolved(compiler);
4862 // The unnamed constructor may not exist, so [e] may become unresolved. 4864 // The unnamed constructor may not exist, so [e] may become unresolved.
4863 element = resolveConstructor(cls, diagnosticNode, ''); 4865 element = resolveConstructor(cls, diagnosticNode, '');
4864 } else { 4866 } else {
4865 element = failOrReturnErroneousElement( 4867 element = failOrReturnErroneousConstructorElement(
4866 element, diagnosticNode, element.name, MessageKind.NOT_A_TYPE, 4868 element, diagnosticNode, element.name, MessageKind.NOT_A_TYPE,
4867 {'node': diagnosticNode}); 4869 {'node': diagnosticNode});
4868 } 4870 }
4869 } else if (element.isErroneous && element is! ErroneousElementX) { 4871 } else if (element.isErroneous && element is! ErroneousElementX) {
4870 element = new ErroneousConstructorElementX( 4872 element = new ErroneousConstructorElementX(
4871 MessageKind.NOT_A_TYPE, {'node': diagnosticNode}, 4873 MessageKind.NOT_A_TYPE, {'node': diagnosticNode},
4872 element.name, element); 4874 element.name, element);
4873 registry.registerThrowRuntimeError(); 4875 registry.registerThrowRuntimeError();
4874 } 4876 }
4875 4877
(...skipping 29 matching lines...) Expand all
4905 4907
4906 if (element.isClass) { 4908 if (element.isClass) {
4907 ClassElement cls = element; 4909 ClassElement cls = element;
4908 cls.ensureResolved(compiler); 4910 cls.ensureResolved(compiler);
4909 return resolveConstructor(cls, name, name.source); 4911 return resolveConstructor(cls, name, name.source);
4910 } else if (element.isPrefix) { 4912 } else if (element.isPrefix) {
4911 PrefixElement prefix = element; 4913 PrefixElement prefix = element;
4912 element = prefix.lookupLocalMember(name.source); 4914 element = prefix.lookupLocalMember(name.source);
4913 element = Elements.unwrap(element, compiler, node); 4915 element = Elements.unwrap(element, compiler, node);
4914 if (element == null) { 4916 if (element == null) {
4915 return failOrReturnErroneousElement( 4917 return failOrReturnErroneousConstructorElement(
4916 resolver.enclosingElement, name, 4918 resolver.enclosingElement, name,
4917 name.source, 4919 name.source,
4918 MessageKind.CANNOT_RESOLVE, 4920 MessageKind.CANNOT_RESOLVE,
4919 {'name': name}); 4921 {'name': name});
4920 } else if (!element.isClass) { 4922 } else if (!element.isClass) {
4921 error(node, MessageKind.NOT_A_TYPE, {'node': name}); 4923 error(node, MessageKind.NOT_A_TYPE, {'node': name});
4922 } 4924 }
4923 } else { 4925 } else {
4924 internalError(node.receiver, 'unexpected element $element'); 4926 internalError(node.receiver, 'unexpected element $element');
4925 } 4927 }
4926 return element; 4928 return element;
4927 } 4929 }
4928 4930
4929 Element visitIdentifier(Identifier node) { 4931 Element visitIdentifier(Identifier node) {
4930 String name = node.source; 4932 String name = node.source;
4931 Element element = resolver.reportLookupErrorIfAny( 4933 Element element = resolver.reportLookupErrorIfAny(
4932 lookupInScope(compiler, node, resolver.scope, name), node, name); 4934 lookupInScope(compiler, node, resolver.scope, name), node, name);
4933 registry.useElement(node, element); 4935 registry.useElement(node, element);
4934 // TODO(johnniwinther): Change errors to warnings, cf. 11.11.1. 4936 // TODO(johnniwinther): Change errors to warnings, cf. 11.11.1.
4935 if (element == null) { 4937 if (element == null) {
4936 return failOrReturnErroneousElement(resolver.enclosingElement, node, name, 4938 return failOrReturnErroneousConstructorElement(
4937 MessageKind.CANNOT_RESOLVE, 4939 resolver.enclosingElement, node, name,
4938 {'name': name}); 4940 MessageKind.CANNOT_RESOLVE,
4941 {'name': name});
4939 } else if (element.isErroneous) { 4942 } else if (element.isErroneous) {
4940 return element; 4943 return element;
4941 } else if (element.isTypedef) { 4944 } else if (element.isTypedef) {
4942 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF, 4945 error(node, MessageKind.CANNOT_INSTANTIATE_TYPEDEF,
4943 {'typedefName': name}); 4946 {'typedefName': name});
4944 element = new ErroneousConstructorElementX( 4947 element = new ErroneousConstructorElementX(
4945 MessageKind.CANNOT_INSTANTIATE_TYPEDEF, 4948 MessageKind.CANNOT_INSTANTIATE_TYPEDEF,
4946 {'typedefName': name}, name, resolver.enclosingElement); 4949 {'typedefName': name}, name, resolver.enclosingElement);
4947 registry.registerThrowRuntimeError(); 4950 registry.registerThrowRuntimeError();
4948 } else if (element.isTypeVariable) { 4951 } else if (element.isTypeVariable) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
5033 } 5036 }
5034 5037
5035 /// The result for the resolution of the `assert` method. 5038 /// The result for the resolution of the `assert` method.
5036 class AssertResult implements ResolutionResult { 5039 class AssertResult implements ResolutionResult {
5037 const AssertResult(); 5040 const AssertResult();
5038 5041
5039 Element get element => null; 5042 Element get element => null;
5040 5043
5041 String toString() => 'AssertResult()'; 5044 String toString() => 'AssertResult()';
5042 } 5045 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/scanner/parser.dart » ('j') | pkg/compiler/lib/src/scanner/parser.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698