Chromium Code Reviews| 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 part of resolution; | 5 part of resolution; |
| 6 | 6 |
| 7 abstract class TreeElements { | 7 abstract class TreeElements { |
| 8 Element operator[](Node node); | 8 Element operator[](Node node); |
| 9 Selector getSelector(Send send); | 9 Selector getSelector(Send send); |
| 10 DartType getType(Node node); | 10 DartType getType(Node node); |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1041 Element resolveTypeName(Scope scope, TypeAnnotation node) { | 1041 Element resolveTypeName(Scope scope, TypeAnnotation node) { |
| 1042 Identifier typeName = node.typeName.asIdentifier(); | 1042 Identifier typeName = node.typeName.asIdentifier(); |
| 1043 Send send = node.typeName.asSend(); | 1043 Send send = node.typeName.asSend(); |
| 1044 return resolveTypeNameInternal(scope, typeName, send); | 1044 return resolveTypeNameInternal(scope, typeName, send); |
| 1045 } | 1045 } |
| 1046 | 1046 |
| 1047 Element resolveTypeNameInternal(Scope scope, Identifier typeName, Send send) { | 1047 Element resolveTypeNameInternal(Scope scope, Identifier typeName, Send send) { |
| 1048 if (send != null) { | 1048 if (send != null) { |
| 1049 typeName = send.selector; | 1049 typeName = send.selector; |
| 1050 } | 1050 } |
| 1051 if (identical(typeName.source.stringValue, 'void')) { | 1051 String stringValue = typeName.source.stringValue; |
| 1052 if (identical(stringValue, 'void')) { | |
| 1052 return compiler.types.voidType.element; | 1053 return compiler.types.voidType.element; |
| 1053 } else if ( | 1054 } else if (identical(stringValue, 'Dynamic')) { |
| 1054 // TODO(aprelev@gmail.com): Remove deprecated Dynamic keyword support. | 1055 // TODO(aprelev@gmail.com): Remove deprecated Dynamic keyword support. |
| 1055 identical(typeName.source.stringValue, 'Dynamic') | 1056 compiler.onDeprecatedFeature(typeName, 'Dynamic'); |
| 1056 || identical(typeName.source.stringValue, 'dynamic')) { | 1057 return compiler.dynamicClass; |
| 1058 } else if (identical(stringValue, 'dynamic')) { | |
| 1057 return compiler.dynamicClass; | 1059 return compiler.dynamicClass; |
| 1058 } else if (send != null) { | 1060 } else if (send != null) { |
| 1059 Element e = scope.lookup(send.receiver.asIdentifier().source); | 1061 Element e = scope.lookup(send.receiver.asIdentifier().source); |
| 1060 if (e != null && identical(e.kind, ElementKind.PREFIX)) { | 1062 if (e != null && identical(e.kind, ElementKind.PREFIX)) { |
| 1061 // The receiver is a prefix. Lookup in the imported members. | 1063 // The receiver is a prefix. Lookup in the imported members. |
| 1062 PrefixElement prefix = e; | 1064 PrefixElement prefix = e; |
| 1063 return prefix.lookupLocalMember(typeName.source); | 1065 return prefix.lookupLocalMember(typeName.source); |
| 1064 } else if (e != null && identical(e.kind, ElementKind.CLASS)) { | 1066 } else if (e != null && identical(e.kind, ElementKind.CLASS)) { |
| 1065 // The receiver is the class part of a named constructor. | 1067 // The receiver is the class part of a named constructor. |
| 1066 return e; | 1068 return e; |
| (...skipping 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2904 Link<Element> parameters = const Link<Element>(); | 2906 Link<Element> parameters = const Link<Element>(); |
| 2905 int requiredParameterCount = 0; | 2907 int requiredParameterCount = 0; |
| 2906 if (formalParameters == null) { | 2908 if (formalParameters == null) { |
| 2907 if (!element.isGetter()) { | 2909 if (!element.isGetter()) { |
| 2908 compiler.reportMessage(compiler.spanFromElement(element), | 2910 compiler.reportMessage(compiler.spanFromElement(element), |
| 2909 MessageKind.MISSING_FORMALS.error([]), | 2911 MessageKind.MISSING_FORMALS.error([]), |
| 2910 Diagnostic.ERROR); | 2912 Diagnostic.ERROR); |
| 2911 } | 2913 } |
| 2912 } else { | 2914 } else { |
| 2913 if (element.isGetter()) { | 2915 if (element.isGetter()) { |
| 2914 if (!element.getLibrary().isPlatformLibrary) { | 2916 if (!identical(formalParameters.getEndToken().next.stringValue, |
| 2915 // TODO(ahe): Remove the isPlatformLibrary check. | 2917 // TODO(ahe): Remove the check for native keyword. |
| 2916 if (!identical(formalParameters.getEndToken().next.stringValue, 'nativ e')) { | 2918 'native')) { |
| 2917 // TODO(ahe): Remove the check for native keyword. | 2919 if (compiler.rejectDeprecatedFeatures && |
|
ngeoffray
2012/11/15 10:34:02
Why are you special casing this one and not just c
ahe
2012/11/16 07:07:36
Because I already have a nice error message.
| |
| 2920 // TODO(ahe): Remove isPlatformLibrary check. | |
| 2921 !element.getLibrary().isPlatformLibrary) { | |
| 2918 compiler.reportMessage(compiler.spanFromNode(formalParameters), | 2922 compiler.reportMessage(compiler.spanFromNode(formalParameters), |
| 2919 MessageKind.EXTRA_FORMALS.error([]), | 2923 MessageKind.EXTRA_FORMALS.error([]), |
| 2920 Diagnostic.WARNING); | 2924 Diagnostic.ERROR); |
| 2925 } else { | |
| 2926 compiler.onDeprecatedFeature(formalParameters, 'getter parameters'); | |
| 2921 } | 2927 } |
| 2922 } | 2928 } |
| 2923 } | 2929 } |
| 2924 LinkBuilder<Element> parametersBuilder = | 2930 LinkBuilder<Element> parametersBuilder = |
| 2925 visitor.analyzeNodes(formalParameters.nodes); | 2931 visitor.analyzeNodes(formalParameters.nodes); |
| 2926 requiredParameterCount = parametersBuilder.length; | 2932 requiredParameterCount = parametersBuilder.length; |
| 2927 parameters = parametersBuilder.toLink(); | 2933 parameters = parametersBuilder.toLink(); |
| 2928 } | 2934 } |
| 2929 DartType returnType = compiler.resolveReturnType(element, returnNode); | 2935 DartType returnType = compiler.resolveReturnType(element, returnNode); |
| 2930 return new FunctionSignature(parameters, | 2936 return new FunctionSignature(parameters, |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3099 return e; | 3105 return e; |
| 3100 } | 3106 } |
| 3101 | 3107 |
| 3102 /// Assumed to be called by [resolveRedirectingFactory]. | 3108 /// Assumed to be called by [resolveRedirectingFactory]. |
| 3103 Element visitReturn(Return node) { | 3109 Element visitReturn(Return node) { |
| 3104 Node expression = node.expression; | 3110 Node expression = node.expression; |
| 3105 return finishConstructorReference(visit(expression), | 3111 return finishConstructorReference(visit(expression), |
| 3106 expression, expression); | 3112 expression, expression); |
| 3107 } | 3113 } |
| 3108 } | 3114 } |
| OLD | NEW |