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

Side by Side Diff: pkg/kernel/test/type_parser.dart

Issue 2825053002: Add typedef AST node boilerplate. (Closed)
Patch Set: Update FastaVerifyingVisitor to work with the changes in VerifyingVisitor Created 3 years, 7 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 | « pkg/kernel/lib/visitor.dart ('k') | pkg/kernel/test/typedef_unalias_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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 scanToken(); 134 scanToken();
135 String name = this.tokenText; 135 String name = this.tokenText;
136 if (name == '_') return const BottomType(); 136 if (name == '_') return const BottomType();
137 if (name == 'void') return const VoidType(); 137 if (name == 'void') return const VoidType();
138 if (name == 'dynamic') return const DynamicType(); 138 if (name == 'dynamic') return const DynamicType();
139 var target = lookupType(name); 139 var target = lookupType(name);
140 if (target == null) { 140 if (target == null) {
141 return fail('Unresolved type $name'); 141 return fail('Unresolved type $name');
142 } else if (target is Class) { 142 } else if (target is Class) {
143 return new InterfaceType(target, parseOptionalTypeArgumentList()); 143 return new InterfaceType(target, parseOptionalTypeArgumentList());
144 } else if (target is Typedef) {
145 return new TypedefType(target, parseOptionalTypeArgumentList());
144 } else if (target is TypeParameter) { 146 } else if (target is TypeParameter) {
145 if (peekToken() == Token.LeftAngle) { 147 if (peekToken() == Token.LeftAngle) {
146 return fail('Attempt to apply type arguments to a type variable'); 148 return fail('Attempt to apply type arguments to a type variable');
147 } 149 }
148 return new TypeParameterType(target); 150 return new TypeParameterType(target);
149 } 151 }
150 return fail("Unexpected lookup result for $name: $target"); 152 return fail("Unexpected lookup result for $name: $target");
151 153
152 case Token.LeftParen: 154 case Token.LeftParen:
153 List<DartType> parameters = <DartType>[]; 155 List<DartType> parameters = <DartType>[];
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 void main(List<String> args) { 322 void main(List<String> args) {
321 if (args.length != 1) { 323 if (args.length != 1) {
322 print('Usage: type_parser TYPE'); 324 print('Usage: type_parser TYPE');
323 } 325 }
324 var environment = new LazyTypeEnvironment(); 326 var environment = new LazyTypeEnvironment();
325 var type = parseDartType(args[0], environment.lookup); 327 var type = parseDartType(args[0], environment.lookup);
326 var buffer = new StringBuffer(); 328 var buffer = new StringBuffer();
327 new Printer(buffer).writeType(type); 329 new Printer(buffer).writeType(type);
328 print(buffer); 330 print(buffer);
329 } 331 }
OLDNEW
« no previous file with comments | « pkg/kernel/lib/visitor.dart ('k') | pkg/kernel/test/typedef_unalias_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698