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

Side by Side Diff: pkg/compiler/lib/src/scanner/class_element_parser.dart

Issue 1132783002: Add Accessor, Getter, and Setter elements. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebased Created 5 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 if (isConstructor) { 159 if (isConstructor) {
160 if (getOrSet != null) { 160 if (getOrSet != null) {
161 recoverableError(getOrSet, 'illegal modifier'); 161 recoverableError(getOrSet, 'illegal modifier');
162 } 162 }
163 memberElement = new PartialConstructorElement( 163 memberElement = new PartialConstructorElement(
164 name, beginToken, endToken, 164 name, beginToken, endToken,
165 ElementKind.GENERATIVE_CONSTRUCTOR, 165 ElementKind.GENERATIVE_CONSTRUCTOR,
166 method.modifiers, 166 method.modifiers,
167 enclosingClass); 167 enclosingClass);
168 } else { 168 } else {
169 ElementKind kind = ElementKind.FUNCTION; 169 memberElement = new PartialFunctionElement(
170 if (getOrSet != null) { 170 name, beginToken, getOrSet, endToken,
171 kind = (identical(getOrSet.stringValue, 'get')) 171 method.modifiers, enclosingClass, hasBody: method.hasBody());
172 ? ElementKind.GETTER : ElementKind.SETTER;
173 }
174 memberElement =
175 new PartialFunctionElement(name, beginToken, getOrSet, endToken,
176 kind, method.modifiers, enclosingClass,
177 !method.hasBody());
178 } 172 }
179 addMember(memberElement); 173 addMember(memberElement);
180 } 174 }
181 175
182 void endFactoryMethod(Token beginToken, Token endToken) { 176 void endFactoryMethod(Token beginToken, Token endToken) {
183 super.endFactoryMethod(beginToken, endToken); 177 super.endFactoryMethod(beginToken, endToken);
184 FunctionExpression method = popNode(); 178 FunctionExpression method = popNode();
185 pushNode(null); 179 pushNode(null);
186 String name = getMethodNameHack(method.name); 180 String name = getMethodNameHack(method.name);
187 Identifier singleIdentifierName = method.name.asIdentifier(); 181 Identifier singleIdentifierName = method.name.asIdentifier();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 void endInitializer(Token assignmentOperator) { 215 void endInitializer(Token assignmentOperator) {
222 pushNode(null); // Super expects an expression, but 216 pushNode(null); // Super expects an expression, but
223 // ClassElementParser just skips expressions. 217 // ClassElementParser just skips expressions.
224 super.endInitializer(assignmentOperator); 218 super.endInitializer(assignmentOperator);
225 } 219 }
226 220
227 void endInitializers(int count, Token beginToken, Token endToken) { 221 void endInitializers(int count, Token beginToken, Token endToken) {
228 pushNode(null); 222 pushNode(null);
229 } 223 }
230 224
231 void addMetadata(Element memberElement) { 225 void addMetadata(ElementX memberElement) {
232 for (Link link = metadata; !link.isEmpty; link = link.tail) { 226 for (Link link = metadata; !link.isEmpty; link = link.tail) {
233 memberElement.addMetadata(link.head); 227 memberElement.addMetadata(link.head);
234 } 228 }
235 metadata = const Link<MetadataAnnotation>(); 229 metadata = const Link<MetadataAnnotation>();
236 } 230 }
237 231
238 void addMember(Element memberElement) { 232 void addMember(ElementX memberElement) {
239 addMetadata(memberElement); 233 addMetadata(memberElement);
240 enclosingClass.addMember(memberElement, listener); 234 enclosingClass.addMember(memberElement, listener);
241 } 235 }
242 236
243 void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) { 237 void endMetadata(Token beginToken, Token periodBeforeName, Token endToken) {
244 popNode(); // Discard arguments. 238 popNode(); // Discard arguments.
245 if (periodBeforeName != null) { 239 if (periodBeforeName != null) {
246 popNode(); // Discard name. 240 popNode(); // Discard name.
247 } 241 }
248 popNode(); // Discard node (Send or Identifier). 242 popNode(); // Discard node (Send or Identifier).
249 pushMetadata(new PartialMetadataAnnotation(beginToken, endToken)); 243 pushMetadata(new PartialMetadataAnnotation(beginToken, endToken));
250 } 244 }
251 } 245 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/resolution.dart ('k') | pkg/compiler/lib/src/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698