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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/scanner/class_element_parser.dart

Issue 18670003: Remove support for conflicting constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 7 years, 5 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 scanner; 5 part of scanner;
6 6
7 class ClassElementParser extends PartialParser { 7 class ClassElementParser extends PartialParser {
8 ClassElementParser(Listener listener) : super(listener); 8 ClassElementParser(Listener listener) : super(listener);
9 9
10 Token parseClassBody(Token token) => fullParseClassBody(token); 10 Token parseClassBody(Token token) => fullParseClassBody(token);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 } else { 82 } else {
83 Send send = nameNode.asSend(); 83 Send send = nameNode.asSend();
84 name = send.receiver.asIdentifier().source; 84 name = send.receiver.asIdentifier().source;
85 } 85 }
86 return enclosingElement.name == name; 86 return enclosingElement.name == name;
87 } 87 }
88 88
89 // TODO(johnniwinther): Remove this method. 89 // TODO(johnniwinther): Remove this method.
90 SourceString getMethodNameHack(Node methodName) { 90 SourceString getMethodNameHack(Node methodName) {
91 Send send = methodName.asSend(); 91 Send send = methodName.asSend();
92 if (send == null) return methodName.asIdentifier().source; 92 if (send == null) {
93 if (isConstructorName(methodName)) return const SourceString('');
94 return methodName.asIdentifier().source;
95 }
93 Identifier receiver = send.receiver.asIdentifier(); 96 Identifier receiver = send.receiver.asIdentifier();
94 Identifier selector = send.selector.asIdentifier(); 97 Identifier selector = send.selector.asIdentifier();
95 Operator operator = selector.asOperator(); 98 Operator operator = selector.asOperator();
96 if (operator != null) { 99 if (operator != null) {
97 assert(identical(receiver.source.stringValue, 'operator')); 100 assert(identical(receiver.source.stringValue, 'operator'));
98 // TODO(ahe): It is a hack to compare to ')', but it beats 101 // TODO(ahe): It is a hack to compare to ')', but it beats
99 // parsing the node. 102 // parsing the node.
100 bool isUnary = identical(operator.token.next.next.stringValue, ')'); 103 bool isUnary = identical(operator.token.next.next.stringValue, ')');
101 return Elements.constructOperatorName(operator.source, isUnary); 104 return Elements.constructOperatorName(operator.source, isUnary);
102 } else { 105 } else {
103 if (receiver == null) { 106 if (receiver == null || receiver.source != enclosingElement.name) {
104 listener.cancel('library prefix in named factory constructor not ' 107 listener.reportErrorCode(send.receiver,
105 'implemented', node: send.receiver);
106 }
107 if (receiver.source != enclosingElement.name) {
108 listener.reportErrorCode(receiver,
109 MessageKind.INVALID_CONSTRUCTOR_NAME, 108 MessageKind.INVALID_CONSTRUCTOR_NAME,
110 {'name': enclosingElement.name}); 109 {'name': enclosingElement.name});
111 } 110 }
112 return Elements.constructConstructorName(receiver.source, 111 return selector.source;
113 selector.source);
114 } 112 }
115 } 113 }
116 114
117 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 115 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
118 super.endMethod(getOrSet, beginToken, endToken); 116 super.endMethod(getOrSet, beginToken, endToken);
119 FunctionExpression method = popNode(); 117 FunctionExpression method = popNode();
120 pushNode(null); 118 pushNode(null);
121 bool isConstructor = isConstructorName(method.name); 119 bool isConstructor = isConstructorName(method.name);
122 SourceString name = getMethodNameHack(method.name); 120 SourceString name = getMethodNameHack(method.name);
123 ElementKind kind = ElementKind.FUNCTION; 121 ElementKind kind = ElementKind.FUNCTION;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 189
192 void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) { 190 void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) {
193 popNode(); // Discard arguments. 191 popNode(); // Discard arguments.
194 if (periodBeforeName != null) { 192 if (periodBeforeName != null) {
195 popNode(); // Discard name. 193 popNode(); // Discard name.
196 } 194 }
197 popNode(); // Discard node (Send or Identifier). 195 popNode(); // Discard node (Send or Identifier).
198 pushMetadata(new PartialMetadataAnnotation(beginToken, endToken)); 196 pushMetadata(new PartialMetadataAnnotation(beginToken, endToken));
199 } 197 }
200 } 198 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698