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

Side by Side Diff: pkg/compiler/lib/src/patch_parser.dart

Issue 2521073003: Remove the ability in dart2js to turn off syntax-only generic methods. (Closed)
Patch Set: eernst Created 4 years 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
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 /** 5 /**
6 * This library contains the infrastructure to parse and integrate patch files. 6 * This library contains the infrastructure to parse and integrate patch files.
7 * 7 *
8 * Three types of elements can be patched: [LibraryElement], [ClassElement], 8 * Three types of elements can be patched: [LibraryElement], [ClassElement],
9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded 9 * [FunctionElement]. Patches are introduced in patch libraries which are loaded
10 * together with the corresponding origin library. Which libraries that are 10 * together with the corresponding origin library. Which libraries that are
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 show 126 show
127 BaseFunctionElementX, 127 BaseFunctionElementX,
128 ClassElementX, 128 ClassElementX,
129 GetterElementX, 129 GetterElementX,
130 LibraryElementX, 130 LibraryElementX,
131 MetadataAnnotationX, 131 MetadataAnnotationX,
132 SetterElementX; 132 SetterElementX;
133 import 'id_generator.dart'; 133 import 'id_generator.dart';
134 import 'js_backend/js_backend.dart' show JavaScriptBackend; 134 import 'js_backend/js_backend.dart' show JavaScriptBackend;
135 import 'library_loader.dart' show LibraryLoader; 135 import 'library_loader.dart' show LibraryLoader;
136 import 'options.dart' show ParserOptions;
137 import 'parser/element_listener.dart' show ElementListener; 136 import 'parser/element_listener.dart' show ElementListener;
138 import 'parser/listener.dart' show Listener, ParserError; 137 import 'parser/listener.dart' show Listener, ParserError;
139 import 'parser/member_listener.dart' show MemberListener; 138 import 'parser/member_listener.dart' show MemberListener;
140 import 'parser/parser.dart' show Parser; 139 import 'parser/parser.dart' show Parser;
141 import 'parser/partial_elements.dart' show PartialClassElement; 140 import 'parser/partial_elements.dart' show PartialClassElement;
142 import 'parser/partial_parser.dart' show PartialParser; 141 import 'parser/partial_parser.dart' show PartialParser;
143 import 'scanner/scanner.dart' show Scanner; 142 import 'scanner/scanner.dart' show Scanner;
144 import 'script.dart'; 143 import 'script.dart';
145 import 'tokens/token.dart' show StringToken, Token; 144 import 'tokens/token.dart' show StringToken, Token;
146 145
147 class PatchParserTask extends CompilerTask { 146 class PatchParserTask extends CompilerTask {
148 final String name = "Patching Parser"; 147 final String name = "Patching Parser";
149 final ParserOptions parserOptions;
150 final Compiler compiler; 148 final Compiler compiler;
151 DiagnosticReporter get reporter => compiler.reporter; 149 DiagnosticReporter get reporter => compiler.reporter;
152 150
153 PatchParserTask(Compiler compiler, this.parserOptions) 151 PatchParserTask(Compiler compiler)
154 : compiler = compiler, 152 : compiler = compiler, super(compiler.measurer);
155 super(compiler.measurer);
156 153
157 /** 154 /**
158 * Scans a library patch file, applies the method patches and 155 * Scans a library patch file, applies the method patches and
159 * injections to the library, and returns a list of class 156 * injections to the library, and returns a list of class
160 * patches. 157 * patches.
161 */ 158 */
162 Future patchLibrary( 159 Future patchLibrary(
163 LibraryLoader loader, Uri patchUri, LibraryElement originLibrary) { 160 LibraryLoader loader, Uri patchUri, LibraryElement originLibrary) {
164 return compiler.readScript(patchUri, originLibrary).then((Script script) { 161 return compiler.readScript(patchUri, originLibrary).then((Script script) {
165 var patchLibrary = new LibraryElementX(script, null, originLibrary); 162 var patchLibrary = new LibraryElementX(script, null, originLibrary);
(...skipping 11 matching lines...) Expand all
177 } 174 }
178 175
179 void scanLibraryElements(CompilationUnitElement compilationUnit) { 176 void scanLibraryElements(CompilationUnitElement compilationUnit) {
180 measure(() { 177 measure(() {
181 // TODO(johnniwinther): Test that parts and exports are handled correctly. 178 // TODO(johnniwinther): Test that parts and exports are handled correctly.
182 Script script = compilationUnit.script; 179 Script script = compilationUnit.script;
183 Token tokens = new Scanner(script.file).tokenize(); 180 Token tokens = new Scanner(script.file).tokenize();
184 Listener patchListener = new PatchElementListener( 181 Listener patchListener = new PatchElementListener(
185 compiler, compilationUnit, compiler.idGenerator); 182 compiler, compilationUnit, compiler.idGenerator);
186 try { 183 try {
187 new PartialParser(patchListener, parserOptions).parseUnit(tokens); 184 new PartialParser(patchListener).parseUnit(tokens);
188 } on ParserError catch (e) { 185 } on ParserError catch (e) {
189 // No need to recover from a parser error in platform libraries, user 186 // No need to recover from a parser error in platform libraries, user
190 // will never see this if the libraries are tested correctly. 187 // will never see this if the libraries are tested correctly.
191 reporter.internalError( 188 reporter.internalError(
192 compilationUnit, "Parser error in patch file: $e"); 189 compilationUnit, "Parser error in patch file: $e");
193 } 190 }
194 }); 191 });
195 } 192 }
196 193
197 void parsePatchClassNode(PartialClassElement cls) { 194 void parsePatchClassNode(PartialClassElement cls) {
198 // Parse [PartialClassElement] using a "patch"-aware parser instead 195 // Parse [PartialClassElement] using a "patch"-aware parser instead
199 // of calling its [parseNode] method. 196 // of calling its [parseNode] method.
200 if (cls.cachedNode != null) return; 197 if (cls.cachedNode != null) return;
201 198
202 measure(() => reporter.withCurrentElement(cls, () { 199 measure(() => reporter.withCurrentElement(cls, () {
203 MemberListener listener = new PatchMemberListener(compiler, cls); 200 MemberListener listener = new PatchMemberListener(compiler, cls);
204 Parser parser = new PatchClassElementParser(listener, parserOptions); 201 Parser parser = new PatchClassElementParser(listener);
205 try { 202 try {
206 Token token = parser.parseTopLevelDeclaration(cls.beginToken); 203 Token token = parser.parseTopLevelDeclaration(cls.beginToken);
207 assert(identical(token, cls.endToken.next)); 204 assert(identical(token, cls.endToken.next));
208 } on ParserError catch (e) { 205 } on ParserError catch (e) {
209 // No need to recover from a parser error in platform libraries, use r 206 // No need to recover from a parser error in platform libraries, use r
210 // will never see this if the libraries are tested correctly. 207 // will never see this if the libraries are tested correctly.
211 reporter.internalError(cls, "Parser error in patch file: $e"); 208 reporter.internalError(cls, "Parser error in patch file: $e");
212 } 209 }
213 cls.cachedNode = listener.popNode(); 210 cls.cachedNode = listener.popNode();
214 assert(listener.nodes.isEmpty); 211 assert(listener.nodes.isEmpty);
(...skipping 29 matching lines...) Expand all
244 enclosingClass.addMember(patch, reporter); 241 enclosingClass.addMember(patch, reporter);
245 } 242 }
246 } 243 }
247 } 244 }
248 245
249 /** 246 /**
250 * Partial parser for patch files that also handles the members of class 247 * Partial parser for patch files that also handles the members of class
251 * declarations. 248 * declarations.
252 */ 249 */
253 class PatchClassElementParser extends PartialParser { 250 class PatchClassElementParser extends PartialParser {
254 PatchClassElementParser(Listener listener, ParserOptions options) 251 PatchClassElementParser(Listener listener): super(listener);
255 : super(listener, options);
256 252
257 Token parseClassBody(Token token) => fullParseClassBody(token); 253 Token parseClassBody(Token token) => fullParseClassBody(token);
258 } 254 }
259 255
260 /** 256 /**
261 * Extension of [ElementListener] for parsing patch files. 257 * Extension of [ElementListener] for parsing patch files.
262 */ 258 */
263 class PatchElementListener extends ElementListener implements Listener { 259 class PatchElementListener extends ElementListener implements Listener {
264 final Compiler compiler; 260 final Compiler compiler;
265 261
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 614
619 class PatchVersion { 615 class PatchVersion {
620 final String tag; 616 final String tag;
621 617
622 const PatchVersion(this.tag); 618 const PatchVersion(this.tag);
623 619
624 bool isActive(String patchTag) => tag == null || tag == patchTag; 620 bool isActive(String patchTag) => tag == null || tag == patchTag;
625 621
626 String toString() => 'PatchVersion($tag)'; 622 String toString() => 'PatchVersion($tag)';
627 } 623 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/parser/partial_parser.dart ('k') | pkg/compiler/lib/src/serialization/resolved_ast_serialization.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698