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

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

Issue 9284022: Operators. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' 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
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 56
57 void endMethod(Token beginToken, Token endToken) { 57 void endMethod(Token beginToken, Token endToken) {
58 super.endMethod(beginToken, endToken); 58 super.endMethod(beginToken, endToken);
59 FunctionExpression method = popNode(); 59 FunctionExpression method = popNode();
60 pushNode(null); 60 pushNode(null);
61 bool isConstructor = isConstructorName(method.name); 61 bool isConstructor = isConstructorName(method.name);
62 SourceString name; 62 SourceString name;
63 Node methodName = method.name; 63 Node methodName = method.name;
64 if (methodName.asSend() != null) { 64 if (methodName.asSend() != null) {
65 Send send = methodName.asSend(); 65 Send send = methodName.asSend();
66 // TODO(karlklose): find a better place for the construction of the name.
67 Identifier receiver = send.receiver.asIdentifier(); 66 Identifier receiver = send.receiver.asIdentifier();
68 Identifier selector = send.selector.asIdentifier(); 67 Identifier selector = send.selector.asIdentifier();
69 SourceString className = receiver.source; 68 if (selector.asOperator() != null) {
70 SourceString constructorName = selector.source; 69 name = Elements.constructOperatorName(
71 name = new SourceString('$className.$constructorName'); 70 receiver.source, selector.source);
71 } else {
72 name = Elements.constructConstructorName(
73 receiver.source, selector.source);
74 }
72 } else { 75 } else {
73 name = methodName.asIdentifier().source; 76 name = methodName.asIdentifier().source;
74 } 77 }
75 ElementKind kind = isConstructor ? 78 ElementKind kind = isConstructor ?
76 ElementKind.GENERATIVE_CONSTRUCTOR : 79 ElementKind.GENERATIVE_CONSTRUCTOR :
77 ElementKind.FUNCTION; 80 ElementKind.FUNCTION;
78 Element memberElement = 81 Element memberElement =
79 new PartialFunctionElement(name, beginToken, endToken, 82 new PartialFunctionElement(name, beginToken, endToken,
80 kind, method.modifiers, enclosingElement); 83 kind, method.modifiers, enclosingElement);
81 enclosingElement.addMember(memberElement); 84 enclosingElement.addMember(memberElement);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 void endInitializer(Token assignmentOperator) { 118 void endInitializer(Token assignmentOperator) {
116 pushNode(null); // Super expects an expression, but 119 pushNode(null); // Super expects an expression, but
117 // ClassElementParser just skips expressions. 120 // ClassElementParser just skips expressions.
118 super.endInitializer(assignmentOperator); 121 super.endInitializer(assignmentOperator);
119 } 122 }
120 123
121 void endInitializers(int count, Token beginToken, Token endToken) { 124 void endInitializers(int count, Token beginToken, Token endToken) {
122 pushNode(null); 125 pushNode(null);
123 } 126 }
124 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698