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

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

Issue 14907008: Remove support for interface in dart2js. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix constructor name bug. Created 7 years, 7 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 SourceString name; 81 SourceString name;
82 if (nameNode.asIdentifier() != null) { 82 if (nameNode.asIdentifier() != null) {
83 name = nameNode.asIdentifier().source; 83 name = nameNode.asIdentifier().source;
84 } else { 84 } else {
85 Send send = nameNode.asSend(); 85 Send send = nameNode.asSend();
86 name = send.receiver.asIdentifier().source; 86 name = send.receiver.asIdentifier().source;
87 } 87 }
88 return enclosingElement.name == name; 88 return enclosingElement.name == name;
89 } 89 }
90 90
91 SourceString getMethodNameHack(Node methodName) { 91 SourceString getMethodNameHack(Node methodName) {
ahe 2013/05/03 13:57:34 We should be able to get rid of this method now, I
Johnni Winther 2013/05/06 06:16:42 Done.
92 Send send = methodName.asSend(); 92 Send send = methodName.asSend();
93 if (send == null) return methodName.asIdentifier().source; 93 if (send == null) return methodName.asIdentifier().source;
94 Identifier receiver = send.receiver.asIdentifier(); 94 Identifier receiver = send.receiver.asIdentifier();
95 Identifier selector = send.selector.asIdentifier(); 95 Identifier selector = send.selector.asIdentifier();
96 Operator operator = selector.asOperator(); 96 Operator operator = selector.asOperator();
97 if (operator != null) { 97 if (operator != null) {
98 assert(identical(receiver.source.stringValue, 'operator')); 98 assert(identical(receiver.source.stringValue, 'operator'));
99 // TODO(ahe): It is a hack to compare to ')', but it beats 99 // TODO(ahe): It is a hack to compare to ')', but it beats
100 // parsing the node. 100 // parsing the node.
101 bool isUnary = identical(operator.token.next.next.stringValue, ')'); 101 bool isUnary = identical(operator.token.next.next.stringValue, ')');
102 return Elements.constructOperatorName(operator.source, isUnary); 102 return Elements.constructOperatorName(operator.source, isUnary);
103 } else { 103 } else {
104 if (receiver == null) { 104 if (receiver == null) {
105 listener.cancel('library prefix in named factory constructor not ' 105 listener.cancel('library prefix in named factory constructor not '
106 'implemented', node: send.receiver); 106 'implemented', node: send.receiver);
107 } 107 }
108 if (receiver.source != enclosingElement.name) { 108 if (receiver.source != enclosingElement.name) {
109 listener.onDeprecatedFeature(receiver, 'interface factories'); 109 listener.reportErrorCode(receiver,
110 MessageKind.INVALID_CONSTRUCTOR_NAME,
111 {'name': enclosingElement.name});
110 } 112 }
111 return Elements.constructConstructorName(receiver.source, 113 return Elements.constructConstructorName(receiver.source,
112 selector.source); 114 selector.source);
113 } 115 }
114 } 116 }
115 117
116 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 118 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
117 super.endMethod(getOrSet, beginToken, endToken); 119 super.endMethod(getOrSet, beginToken, endToken);
118 FunctionExpression method = popNode(); 120 FunctionExpression method = popNode();
119 pushNode(null); 121 pushNode(null);
(...skipping 16 matching lines...) Expand all
136 } 138 }
137 139
138 void endFactoryMethod(Token beginToken, Token endToken) { 140 void endFactoryMethod(Token beginToken, Token endToken) {
139 super.endFactoryMethod(beginToken, endToken); 141 super.endFactoryMethod(beginToken, endToken);
140 FunctionExpression method = popNode(); 142 FunctionExpression method = popNode();
141 pushNode(null); 143 pushNode(null);
142 SourceString name = getMethodNameHack(method.name); 144 SourceString name = getMethodNameHack(method.name);
143 Identifier singleIdentifierName = method.name.asIdentifier(); 145 Identifier singleIdentifierName = method.name.asIdentifier();
144 if (singleIdentifierName != null && singleIdentifierName.source == name) { 146 if (singleIdentifierName != null && singleIdentifierName.source == name) {
145 if (name != enclosingElement.name) { 147 if (name != enclosingElement.name) {
146 listener.onDeprecatedFeature(method.name, 'interface factories'); 148 listener.reportErrorCode(singleIdentifierName,
149 MessageKind.INVALID_UNNAMED_CONSTRUCTOR_NAME,
150 {'name': enclosingElement.name});
147 } 151 }
148 } 152 }
149 ElementKind kind = ElementKind.FUNCTION; 153 ElementKind kind = ElementKind.FUNCTION;
150 Element memberElement = 154 Element memberElement =
151 new PartialFunctionElement(name, beginToken, null, endToken, 155 new PartialFunctionElement(name, beginToken, null, endToken,
152 kind, method.modifiers, enclosingElement); 156 kind, method.modifiers, enclosingElement);
153 addMember(memberElement); 157 addMember(memberElement);
154 } 158 }
155 159
156 void endFields(int count, Token beginToken, Token endToken) { 160 void endFields(int count, Token beginToken, Token endToken) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 192
189 void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) { 193 void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) {
190 popNode(); // Discard arguments. 194 popNode(); // Discard arguments.
191 if (periodBeforeName != null) { 195 if (periodBeforeName != null) {
192 popNode(); // Discard name. 196 popNode(); // Discard name.
193 } 197 }
194 popNode(); // Discard node (Send or Identifier). 198 popNode(); // Discard node (Send or Identifier).
195 pushMetadata(new PartialMetadataAnnotation(beginToken, endToken)); 199 pushMetadata(new PartialMetadataAnnotation(beginToken, endToken));
196 } 200 }
197 } 201 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698