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

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

Issue 10892005: Revert "Support unary - operator." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 3 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 14 matching lines...) Expand all
25 assert(state <= STATE_DONE); 25 assert(state <= STATE_DONE);
26 super.supertypeLoadState = state; 26 super.supertypeLoadState = state;
27 } 27 }
28 28
29 void set resolutionState(int state) { 29 void set resolutionState(int state) {
30 assert(state == resolutionState + 1); 30 assert(state == resolutionState + 1);
31 assert(state <= STATE_DONE); 31 assert(state <= STATE_DONE);
32 super.resolutionState = state; 32 super.resolutionState = state;
33 } 33 }
34 34
35 ClassNode parseNode(Compiler compiler) { 35 ClassNode parseNode(DiagnosticListener diagnosticListener) {
36 if (cachedNode != null) return cachedNode; 36 if (cachedNode != null) return cachedNode;
37 compiler.withCurrentElement(this, () { 37 // TODO(ahe): Measure these tasks.
38 compiler.parser.measure(() { 38 MemberListener listener = new MemberListener(diagnosticListener, this);
39 MemberListener listener = new MemberListener(compiler, this); 39 Parser parser = new ClassElementParser(listener);
40 Parser parser = new ClassElementParser(listener); 40 Token token = parser.parseTopLevelDeclaration(beginToken);
41 Token token = parser.parseTopLevelDeclaration(beginToken); 41 assert(token === endToken.next);
42 assert(token === endToken.next); 42 cachedNode = listener.popNode();
43 cachedNode = listener.popNode(); 43 assert(listener.nodes.isEmpty());
44 assert(listener.nodes.isEmpty()); 44 if (isPatched) {
45 }); 45 // TODO(lrn): Perhaps extract functionality so it doesn't need compiler.
46 compiler.patchParser.measure(() { 46 Compiler compiler = diagnosticListener;
47 if (isPatched) { 47 ClassNode patchNode = compiler.patchParser.parsePatchClassNode(patch);
48 // TODO(lrn): Perhaps extract functionality so it doesn't 48 Link<Element> patches = patch.localMembers;
49 // need compiler. 49 compiler.applyContainerPatch(this, patches);
50 ClassNode patchNode = compiler.patchParser.parsePatchClassNode(patch); 50 }
51 Link<Element> patches = patch.localMembers;
52 compiler.applyContainerPatch(this, patches);
53 }
54 });
55 });
56 return cachedNode; 51 return cachedNode;
57 } 52 }
58 53
59 Token position() => beginToken; 54 Token position() => beginToken;
60 55
61 bool isInterface() => beginToken.stringValue === "interface"; 56 bool isInterface() => beginToken.stringValue === "interface";
62 57
63 PartialClassElement cloneTo(Element enclosing, DiagnosticListener listener) { 58 PartialClassElement cloneTo(Element enclosing, DiagnosticListener listener) {
64 parseNode(listener); 59 parseNode(listener);
65 // TODO(lrn): Is copying id acceptable? 60 // TODO(lrn): Is copying id acceptable?
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 name = send.receiver.asIdentifier().source; 107 name = send.receiver.asIdentifier().source;
113 } 108 }
114 return enclosingElement.name == name; 109 return enclosingElement.name == name;
115 } 110 }
116 111
117 SourceString getMethodNameHack(Node methodName) { 112 SourceString getMethodNameHack(Node methodName) {
118 Send send = methodName.asSend(); 113 Send send = methodName.asSend();
119 if (send === null) return methodName.asIdentifier().source; 114 if (send === null) return methodName.asIdentifier().source;
120 Identifier receiver = send.receiver.asIdentifier(); 115 Identifier receiver = send.receiver.asIdentifier();
121 Identifier selector = send.selector.asIdentifier(); 116 Identifier selector = send.selector.asIdentifier();
122 Operator operator = selector.asOperator(); 117 if (selector.asOperator() !== null) {
123 if (operator !== null) { 118 return Elements.constructOperatorName(receiver.source, selector.source);
124 assert(receiver.source.stringValue === 'operator');
125 // TODO(ahe): It is a hack to compare to ')', but it beats
126 // parsing the node.
127 bool isUnary = operator.token.next.next.stringValue === ')';
128 return Elements.constructOperatorName(operator.source, isUnary);
129 } else { 119 } else {
130 return Elements.constructConstructorName(receiver.source, 120 return Elements.constructConstructorName(receiver.source,
131 selector.source); 121 selector.source);
132 } 122 }
133 } 123 }
134 124
135 void endMethod(Token getOrSet, Token beginToken, Token endToken) { 125 void endMethod(Token getOrSet, Token beginToken, Token endToken) {
136 super.endMethod(getOrSet, beginToken, endToken); 126 super.endMethod(getOrSet, beginToken, endToken);
137 FunctionExpression method = popNode(); 127 FunctionExpression method = popNode();
138 pushNode(null); 128 pushNode(null);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 } 183 }
194 184
195 void addMember(Element memberElement) { 185 void addMember(Element memberElement) {
196 for (Link link = metadata; !link.isEmpty(); link = link.tail) { 186 for (Link link = metadata; !link.isEmpty(); link = link.tail) {
197 memberElement.addMetadata(link.head); 187 memberElement.addMetadata(link.head);
198 } 188 }
199 metadata = const EmptyLink<MetadataAnnotation>(); 189 metadata = const EmptyLink<MetadataAnnotation>();
200 enclosingElement.addMember(memberElement, listener); 190 enclosingElement.addMember(memberElement, listener);
201 } 191 }
202 } 192 }
OLDNEW
« no previous file with comments | « dart/lib/compiler/implementation/lib/interceptors.dart ('k') | dart/lib/compiler/implementation/scanner/keyword.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698