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

Side by Side Diff: frog/leg/scanner/class_element_parser.dart

Issue 9027002: Support factory methods. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years 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
« no previous file with comments | « frog/leg/resolver.dart ('k') | frog/leg/scanner/listener.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 class ClassElementParser extends PartialParser { 5 class ClassElementParser extends PartialParser {
6 ClassElementParser(Listener listener) : super(listener); 6 ClassElementParser(Listener listener) : super(listener);
7 7
8 Token parseClassBody(Token token) => fullParseClassBody(token); 8 Token parseClassBody(Token token) => fullParseClassBody(token);
9 } 9 }
10 10
(...skipping 30 matching lines...) Expand all
41 enclosingElement.kind == ElementKind.CLASS && 41 enclosingElement.kind == ElementKind.CLASS &&
42 enclosingElement.name == name.source; 42 enclosingElement.name == name.source;
43 } 43 }
44 44
45 void endMethod(Token beginToken, Token period, Token endToken) { 45 void endMethod(Token beginToken, Token period, Token endToken) {
46 super.endMethod(beginToken, period, endToken); 46 super.endMethod(beginToken, period, endToken);
47 FunctionExpression method = popNode(); 47 FunctionExpression method = popNode();
48 pushNode(null); 48 pushNode(null);
49 Identifier name = method.name; // TODO(ahe): Named constructors. 49 Identifier name = method.name; // TODO(ahe): Named constructors.
50 ElementKind kind = isConstructor(name) ? 50 ElementKind kind = isConstructor(name) ?
51 ElementKind.CONSTRUCTOR : 51 ElementKind.GENERATIVE_CONSTRUCTOR :
52 ElementKind.FUNCTION; 52 ElementKind.FUNCTION;
53 Element memberElement = 53 Element memberElement =
54 new PartialFunctionElement(name.source, beginToken, endToken, 54 new PartialFunctionElement(name.source, beginToken, endToken,
55 kind, method.modifiers, enclosingElement); 55 kind, method.modifiers, enclosingElement);
56 enclosingElement.addMember(memberElement); 56 enclosingElement.addMember(memberElement);
57 } 57 }
58 58
59 void endFactoryMethod(Token factoryKeyword, Token periodBeforeName,
60 Token endToken) {
61 super.endFactoryMethod(factoryKeyword, periodBeforeName, endToken);
62 FunctionExpression method = popNode();
63 pushNode(null);
64 // TODO(ahe): Named constructors.
65 if (method.name.asIdentifier() == null) {
66 canceler.cancel('Qualified factory names not implemented', node: method);
67 }
68 Identifier name = method.name;
69 ElementKind kind = ElementKind.FUNCTION;
70 Element memberElement =
71 new PartialFunctionElement(name.source, factoryKeyword, endToken, kind,
72 method.modifiers, enclosingElement);
73 enclosingElement.addMember(memberElement);
74 }
75
59 void endFields(int count, Token beginToken, Token endToken) { 76 void endFields(int count, Token beginToken, Token endToken) {
60 super.endFields(count, beginToken, endToken); 77 super.endFields(count, beginToken, endToken);
61 VariableDefinitions variableDefinitions = popNode(); 78 VariableDefinitions variableDefinitions = popNode();
62 Modifiers modifiers = variableDefinitions.modifiers; 79 Modifiers modifiers = variableDefinitions.modifiers;
63 pushNode(null); 80 pushNode(null);
64 void buildFieldElement(SourceString name, Element fields) { 81 void buildFieldElement(SourceString name, Element fields) {
65 Element element = new VariableElement(name, fields, ElementKind.FIELD, 82 Element element = new VariableElement(name, fields, ElementKind.FIELD,
66 enclosingElement); 83 enclosingElement);
67 enclosingElement.addMember(element); 84 enclosingElement.addMember(element);
68 } 85 }
69 buildFieldElements(modifiers, variableDefinitions.definitions, 86 buildFieldElements(modifiers, variableDefinitions.definitions,
70 buildFieldElement, beginToken, endToken); 87 buildFieldElement, beginToken, endToken);
71 } 88 }
72 89
73 void endInitializer(Token assignmentOperator) { 90 void endInitializer(Token assignmentOperator) {
74 canceler.cancel("field initializers are not implemented", 91 canceler.cancel("field initializers are not implemented",
75 token: assignmentOperator); 92 token: assignmentOperator);
76 } 93 }
77 94
78 void endInitializers(int count, Token beginToken, Token endToken) { 95 void endInitializers(int count, Token beginToken, Token endToken) {
79 pushNode(null); 96 pushNode(null);
80 } 97 }
81 } 98 }
OLDNEW
« no previous file with comments | « frog/leg/resolver.dart ('k') | frog/leg/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698