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

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

Issue 10855262: Make patching of classes lazy. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 4 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 | « lib/compiler/implementation/compiler.dart ('k') | tests/compiler/dart2js/patch_test.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
11 class PartialClassElement extends ClassElement { 11 class PartialClassElement extends ClassElement {
12 final Token beginToken; 12 final Token beginToken;
13 final Token endToken; 13 final Token endToken;
14 Node cachedNode; 14 Node cachedNode;
15 15
16 PartialClassElement(SourceString name, 16 PartialClassElement(SourceString name,
17 Token this.beginToken, 17 Token this.beginToken,
18 Token this.endToken, 18 Token this.endToken,
19 Element enclosing, 19 Element enclosing,
20 int id) 20 int id)
21 : super(name, enclosing, id); 21 : super(name, enclosing, id);
22 22
23 ClassNode parseNode(DiagnosticListener diagnosticListener) { 23 ClassNode parseNode(DiagnosticListener diagnosticListener) {
24 if (cachedNode != null) return cachedNode; 24 if (cachedNode != null) return cachedNode;
25 // TODO(ahe): Measure these tasks.
25 MemberListener listener = new MemberListener(diagnosticListener, this); 26 MemberListener listener = new MemberListener(diagnosticListener, this);
26 Parser parser = new ClassElementParser(listener); 27 Parser parser = new ClassElementParser(listener);
27 Token token = parser.parseTopLevelDeclaration(beginToken); 28 Token token = parser.parseTopLevelDeclaration(beginToken);
28 assert(token === endToken.next); 29 assert(token === endToken.next);
29 cachedNode = listener.popNode(); 30 cachedNode = listener.popNode();
30 assert(listener.nodes.isEmpty()); 31 assert(listener.nodes.isEmpty());
32 if (isPatched) {
33 // TODO(lrn): Perhaps extract functionality so it doesn't need compiler.
34 Compiler compiler = diagnosticListener;
35 ClassNode patchNode = compiler.patchParser.parsePatchClassNode(patch);
36 Link<Element> patches = patch.localMembers;
37 compiler.applyContainerPatch(this, patches);
38 }
31 return cachedNode; 39 return cachedNode;
32 } 40 }
33 41
34 Token position() => beginToken; 42 Token position() => beginToken;
35 43
36 bool isInterface() => beginToken.stringValue === "interface"; 44 bool isInterface() => beginToken.stringValue === "interface";
37 45
38 PartialClassElement cloneTo(Element enclosing, DiagnosticListener listener) { 46 PartialClassElement cloneTo(Element enclosing, DiagnosticListener listener) {
39 parseNode(listener); 47 parseNode(listener);
40 // TODO(lrn): Is copying id acceptable? 48 // TODO(lrn): Is copying id acceptable?
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 } 167 }
160 168
161 void endInitializers(int count, Token beginToken, Token endToken) { 169 void endInitializers(int count, Token beginToken, Token endToken) {
162 pushNode(null); 170 pushNode(null);
163 } 171 }
164 172
165 void addMember(Element memberElement) { 173 void addMember(Element memberElement) {
166 enclosingElement.addMember(memberElement, listener); 174 enclosingElement.addMember(memberElement, listener);
167 } 175 }
168 } 176 }
OLDNEW
« no previous file with comments | « lib/compiler/implementation/compiler.dart ('k') | tests/compiler/dart2js/patch_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698