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

Side by Side Diff: lib/compiler/implementation/patch_parser.dart

Issue 10689126: Fix type errors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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 | « no previous file | no next file » | 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 #library("patchparser"); 5 #library("patchparser");
6 #import("dart:uri"); 6 #import("dart:uri");
7 7
8 #import("tree/tree.dart", prefix: "tree"); 8 #import("tree/tree.dart", prefix: "tree");
9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler. 9 #import("leg.dart", prefix: 'leg'); // CompilerTask, Compiler.
10 #import("apiimpl.dart"); 10 #import("apiimpl.dart");
11 #import("scanner/scannerlib.dart"); // Scanner, Parsers, Listeners 11 #import("scanner/scannerlib.dart"); // Scanner, Parsers, Listeners
12 #import("elements/elements.dart"); 12 #import("elements/elements.dart");
13 #import('native_handler.dart', prefix: 'native'); 13 #import('native_handler.dart', prefix: 'native');
14 14
15 class PatchParserTask extends leg.CompilerTask { 15 class PatchParserTask extends leg.CompilerTask {
16 PatchParserTask(leg.Compiler compiler): super(compiler); 16 PatchParserTask(leg.Compiler compiler): super(compiler);
17 final String name = "Patching Parser"; 17 final String name = "Patching Parser";
18 18
19 LibraryElement loadPatchLibrary(Uri uri) { 19 LibraryElement loadPatchLibrary(Uri uri) {
20 bool newLibrary = false; 20 bool newLibrary = false;
21 PatchLibraryElement library = 21 LibraryElement library =
22 compiler.libraries.putIfAbsent(uri.toString(), () { 22 compiler.libraries.putIfAbsent(uri.toString(), () {
23 newLibrary = true; 23 newLibrary = true;
24 leg.Script script = compiler.readScript(uri, null); 24 leg.Script script = compiler.readScript(uri, null);
25 LibraryElement element = 25 LibraryElement element =
26 new LibraryElement(script); 26 new LibraryElement(script);
27 native.maybeEnableNative(compiler, element, uri); 27 native.maybeEnableNative(compiler, element, uri);
28 return element; 28 return element;
29 }); 29 });
30 if (newLibrary) { 30 if (newLibrary) {
31 compiler.withCurrentElement(library, () { 31 compiler.withCurrentElement(library, () {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 Token parseClassBody(Token token) => fullParseClassBody(token); 128 Token parseClassBody(Token token) => fullParseClassBody(token);
129 } 129 }
130 130
131 131
132 /** 132 /**
133 * Extension of [ElementListener] for parsing patch files. 133 * Extension of [ElementListener] for parsing patch files.
134 */ 134 */
135 class PatchElementListener extends ElementListener implements PatchListener { 135 class PatchElementListener extends ElementListener implements PatchListener {
136 bool isMemberPatch = false; 136 bool isMemberPatch = false;
137 bool isClassPatch = false; 137 bool isClassPatch = false;
138 PatchElementListener(DiagnosticListener listener, 138 PatchElementListener(leg.DiagnosticListener listener,
139 CompilationUnitElement patchElement, 139 CompilationUnitElement patchElement,
140 int idGenerator()) 140 int idGenerator())
141 : super(listener, patchElement, idGenerator); 141 : super(listener, patchElement, idGenerator);
142 142
143 void beginPatch(Token token) { 143 void beginPatch(Token token) {
144 if (token.next.stringValue === "class") { 144 if (token.next.stringValue === "class") {
145 isClassPatch = true; 145 isClassPatch = true;
146 } else { 146 } else {
147 isMemberPatch = true; 147 isMemberPatch = true;
148 } 148 }
149 handleIdentifier(token); 149 handleIdentifier(token);
150 } 150 }
151 151
152 void endPatch(Token token) { 152 void endPatch(Token token) {
153 if (token.next.stringValue === "class") { 153 if (token.next.stringValue === "class") {
154 isClassPatch = false; 154 isClassPatch = false;
155 } else { 155 } else {
156 isMemberPatch = false; 156 isMemberPatch = false;
157 } 157 }
158 } 158 }
159 159
160 void pushElement(Element element) { 160 void pushElement(Element element) {
161 if (isMemberPatch || (isClassPatch && element is ClassElement)) { 161 if (isMemberPatch || (isClassPatch && element is ClassElement)) {
162 element.addMetadata(popNode()); 162 element.addMetadata(popNode());
163 } 163 }
164 super.pushElement(element); 164 super.pushElement(element);
165 } 165 }
166 } 166 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698