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

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

Issue 9241014: Generate AST nodes for field initializers. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: changes Created 8 years, 11 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
« no previous file with comments | « dart/frog/leg/resolver.dart ('k') | dart/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 bool isConstructor(Identifier name) { 41 bool isConstructor(Identifier name) {
42 return enclosingElement !== null && 42 return enclosingElement !== null &&
43 enclosingElement.kind == ElementKind.CLASS && 43 enclosingElement.kind == ElementKind.CLASS &&
44 enclosingElement.name == name.source; 44 enclosingElement.name == name.source;
45 } 45 }
46 46
47 void endMethod(Token beginToken, Token endToken) { 47 void endMethod(Token beginToken, Token endToken) {
48 super.endMethod(beginToken, endToken); 48 super.endMethod(beginToken, endToken);
49 FunctionExpression method = popNode(); 49 FunctionExpression method = popNode();
50 pushNode(null); 50 pushNode(null);
51 Identifier name = method.name; // TODO(ahe): Named constructors. 51 Expression qualified = method.name;
52 Identifier name = qualified.asIdentifier();
53 if (name === null) {
54 canceler.cancel('qualified names are not implemented', node: qualified);
55 }
52 ElementKind kind = isConstructor(name) ? 56 ElementKind kind = isConstructor(name) ?
53 ElementKind.GENERATIVE_CONSTRUCTOR : 57 ElementKind.GENERATIVE_CONSTRUCTOR :
54 ElementKind.FUNCTION; 58 ElementKind.FUNCTION;
55 Element memberElement = 59 Element memberElement =
56 new PartialFunctionElement(name.source, beginToken, endToken, 60 new PartialFunctionElement(name.source, beginToken, endToken,
57 kind, method.modifiers, enclosingElement); 61 kind, method.modifiers, enclosingElement);
58 enclosingElement.addMember(memberElement); 62 enclosingElement.addMember(memberElement);
59 } 63 }
60 64
61 void endFactoryMethod(Token factoryKeyword, Token periodBeforeName, 65 void endFactoryMethod(Token factoryKeyword, Token periodBeforeName,
(...skipping 11 matching lines...) Expand all
73 new PartialFunctionElement(name.source, factoryKeyword, endToken, kind, 77 new PartialFunctionElement(name.source, factoryKeyword, endToken, kind,
74 method.modifiers, enclosingElement); 78 method.modifiers, enclosingElement);
75 enclosingElement.addMember(memberElement); 79 enclosingElement.addMember(memberElement);
76 } 80 }
77 81
78 void endFields(int count, Token beginToken, Token endToken) { 82 void endFields(int count, Token beginToken, Token endToken) {
79 super.endFields(count, beginToken, endToken); 83 super.endFields(count, beginToken, endToken);
80 VariableDefinitions variableDefinitions = popNode(); 84 VariableDefinitions variableDefinitions = popNode();
81 Modifiers modifiers = variableDefinitions.modifiers; 85 Modifiers modifiers = variableDefinitions.modifiers;
82 pushNode(null); 86 pushNode(null);
83 void buildFieldElement(SourceString name, Node node, Element fields) { 87 void buildFieldElement(SourceString name, Element fields) {
84 Element element = new VariableElement( 88 Element element = new VariableElement(
85 name, node, fields, ElementKind.FIELD, enclosingElement); 89 name, fields, ElementKind.FIELD, enclosingElement);
86 enclosingElement.addMember(element); 90 enclosingElement.addMember(element);
87 } 91 }
88 buildFieldElements(modifiers, variableDefinitions.definitions, 92 buildFieldElements(modifiers, variableDefinitions.definitions,
89 buildFieldElement, beginToken, endToken); 93 buildFieldElement, beginToken, endToken);
90 } 94 }
91 95
92 void endInitializer(Token assignmentOperator) { 96 void endInitializer(Token assignmentOperator) {
93 // TODO(floitsch): Remove this cancel.
94 canceler.cancel("field initializers are not implemented",
95 token: assignmentOperator);
96 pushNode(null); // Super expects an expression, but 97 pushNode(null); // Super expects an expression, but
97 // ClassElementParser just skips expressions. 98 // ClassElementParser just skips expressions.
98 super.endInitializer(assignmentOperator); 99 super.endInitializer(assignmentOperator);
99 } 100 }
100 101
101 void endInitializers(int count, Token beginToken, Token endToken) { 102 void endInitializers(int count, Token beginToken, Token endToken) {
102 pushNode(null); 103 pushNode(null);
103 } 104 }
104 } 105 }
OLDNEW
« no previous file with comments | « dart/frog/leg/resolver.dart ('k') | dart/frog/leg/scanner/listener.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698