OLD | NEW |
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 23 matching lines...) Expand all Loading... |
34 | 34 |
35 ClassNode parseNode(Compiler compiler) { | 35 ClassNode parseNode(Compiler compiler) { |
36 if (cachedNode != null) return cachedNode; | 36 if (cachedNode != null) return cachedNode; |
37 compiler.withCurrentElement(this, () { | 37 compiler.withCurrentElement(this, () { |
38 compiler.parser.measure(() { | 38 compiler.parser.measure(() { |
39 MemberListener listener = new MemberListener(compiler, this); | 39 MemberListener listener = new MemberListener(compiler, this); |
40 Parser parser = new ClassElementParser(listener); | 40 Parser parser = new ClassElementParser(listener); |
41 Token token = parser.parseTopLevelDeclaration(beginToken); | 41 Token token = parser.parseTopLevelDeclaration(beginToken); |
42 assert(identical(token, endToken.next)); | 42 assert(identical(token, endToken.next)); |
43 cachedNode = listener.popNode(); | 43 cachedNode = listener.popNode(); |
44 assert(listener.nodes.isEmpty()); | 44 assert(listener.nodes.isEmpty); |
45 }); | 45 }); |
46 compiler.patchParser.measure(() { | 46 compiler.patchParser.measure(() { |
47 if (isPatched) { | 47 if (isPatched) { |
48 // TODO(lrn): Perhaps extract functionality so it doesn't | 48 // TODO(lrn): Perhaps extract functionality so it doesn't |
49 // need compiler. | 49 // need compiler. |
50 compiler.patchParser.parsePatchClassNode(patch); | 50 compiler.patchParser.parsePatchClassNode(patch); |
51 } | 51 } |
52 }); | 52 }); |
53 }); | 53 }); |
54 return cachedNode; | 54 return cachedNode; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 pushNode(null); // Super expects an expression, but | 162 pushNode(null); // Super expects an expression, but |
163 // ClassElementParser just skips expressions. | 163 // ClassElementParser just skips expressions. |
164 super.endInitializer(assignmentOperator); | 164 super.endInitializer(assignmentOperator); |
165 } | 165 } |
166 | 166 |
167 void endInitializers(int count, Token beginToken, Token endToken) { | 167 void endInitializers(int count, Token beginToken, Token endToken) { |
168 pushNode(null); | 168 pushNode(null); |
169 } | 169 } |
170 | 170 |
171 void addMember(Element memberElement) { | 171 void addMember(Element memberElement) { |
172 for (Link link = metadata; !link.isEmpty(); link = link.tail) { | 172 for (Link link = metadata; !link.isEmpty; link = link.tail) { |
173 memberElement.addMetadata(link.head); | 173 memberElement.addMetadata(link.head); |
174 } | 174 } |
175 metadata = const Link<MetadataAnnotation>(); | 175 metadata = const Link<MetadataAnnotation>(); |
176 enclosingElement.addMember(memberElement, listener); | 176 enclosingElement.addMember(memberElement, listener); |
177 } | 177 } |
178 } | 178 } |
OLD | NEW |