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

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

Issue 10855125: Ensure supertypes are loaded safely. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: More cleanup of ClassElement.cloneMembersTo 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
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 19 matching lines...) Expand all
30 assert(listener.nodes.isEmpty()); 30 assert(listener.nodes.isEmpty());
31 return cachedNode; 31 return cachedNode;
32 } 32 }
33 33
34 Token position() => beginToken; 34 Token position() => beginToken;
35 35
36 bool isInterface() => beginToken.stringValue === "interface"; 36 bool isInterface() => beginToken.stringValue === "interface";
37 37
38 PartialClassElement cloneTo(Element enclosing, DiagnosticListener listener) { 38 PartialClassElement cloneTo(Element enclosing, DiagnosticListener listener) {
39 parseNode(listener); 39 parseNode(listener);
40 // TODO(lrn): Is copying id acceptable?
41 // TODO(ahe): No.
40 PartialClassElement result = 42 PartialClassElement result =
41 new PartialClassElement(name, beginToken, endToken, enclosing, id); 43 new PartialClassElement(name, beginToken, endToken, enclosing, id);
42 cloneMembersTo(result, listener); 44
45 assert(this.supertypeLoadState == ClassElement.STATE_NOT_STARTED);
46 assert(this.resolutionState == ClassElement.STATE_NOT_STARTED);
47 assert(this.type === null);
48 assert(this.supertype === null);
49 assert(this.defaultClass === null);
50 assert(this.interfaces === null);
51 assert(this.allSupertypes === null);
52 assert(this.backendMembers.isEmpty());
53
54 // Native is only used in DOM/HTML library for which we don't
55 // support patching.
56 assert(this.nativeName === null);
57
58 Link<Element> elementList = this.members;
59 while (!elementList.isEmpty()) {
60 result.addMember(elementList.head.cloneTo(result, listener), listener);
61 elementList = elementList.tail;
62 }
63
43 result.cachedNode = cachedNode; 64 result.cachedNode = cachedNode;
44 return result; 65 return result;
45 } 66 }
46 } 67 }
47 68
48 class MemberListener extends NodeListener { 69 class MemberListener extends NodeListener {
49 final ClassElement enclosingElement; 70 final ClassElement enclosingElement;
50 71
51 MemberListener(DiagnosticListener listener, 72 MemberListener(DiagnosticListener listener,
52 Element enclosingElement) 73 Element enclosingElement)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 } 159 }
139 160
140 void endInitializers(int count, Token beginToken, Token endToken) { 161 void endInitializers(int count, Token beginToken, Token endToken) {
141 pushNode(null); 162 pushNode(null);
142 } 163 }
143 164
144 void addMember(Element memberElement) { 165 void addMember(Element memberElement) {
145 enclosingElement.addMember(memberElement, listener); 166 enclosingElement.addMember(memberElement, listener);
146 } 167 }
147 } 168 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698