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

Side by Side Diff: test/type_parser.dart

Issue 2439043002: Introduce Substitution class and Supertype class. (Closed)
Patch Set: Created 4 years, 2 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
« no previous file with comments | « test/class_hierarchy_basic.dart ('k') | test/type_substitute_bounds_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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 // A very simple parser for a subset of DartTypes for use in testing type 4 // A very simple parser for a subset of DartTypes for use in testing type
5 // algebra. 5 // algebra.
6 library kernel.test.type_parser; 6 library kernel.test.type_parser;
7 7
8 import 'package:kernel/kernel.dart'; 8 import 'package:kernel/kernel.dart';
9 import 'package:kernel/text/ast_to_text.dart'; 9 import 'package:kernel/text/ast_to_text.dart';
10 10
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 dummyLibrary.addClass(class_); 288 dummyLibrary.addClass(class_);
289 return class_; 289 return class_;
290 } 290 }
291 291
292 void clearTypeParameters() { 292 void clearTypeParameters() {
293 typeParameters.clear(); 293 typeParameters.clear();
294 } 294 }
295 295
296 DartType parse(String type) => parseDartType(type, lookup); 296 DartType parse(String type) => parseDartType(type, lookup);
297 297
298 Supertype parseSuper(String type) {
299 InterfaceType interfaceType = parse(type);
300 return new Supertype(interfaceType.classNode, interfaceType.typeArguments);
301 }
302
298 DartType parseFresh(String type) { 303 DartType parseFresh(String type) {
299 clearTypeParameters(); 304 clearTypeParameters();
300 return parse(type); 305 return parse(type);
301 } 306 }
302 307
303 TypeParameter getTypeParameter(String name) { 308 TypeParameter getTypeParameter(String name) {
304 if (name.length != 1) throw 'Type parameter names must have length 1'; 309 if (name.length != 1) throw 'Type parameter names must have length 1';
305 return lookup(name); 310 return lookup(name);
306 } 311 }
307 } 312 }
308 313
309 void main(List<String> args) { 314 void main(List<String> args) {
310 if (args.length != 1) { 315 if (args.length != 1) {
311 print('Usage: type_parser TYPE'); 316 print('Usage: type_parser TYPE');
312 } 317 }
313 var environment = new LazyTypeEnvironment(); 318 var environment = new LazyTypeEnvironment();
314 var type = parseDartType(args[0], environment.lookup); 319 var type = parseDartType(args[0], environment.lookup);
315 var buffer = new StringBuffer(); 320 var buffer = new StringBuffer();
316 new Printer(buffer).writeType(type); 321 new Printer(buffer).writeType(type);
317 print(buffer); 322 print(buffer);
318 } 323 }
OLDNEW
« no previous file with comments | « test/class_hierarchy_basic.dart ('k') | test/type_substitute_bounds_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698