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

Side by Side Diff: pkg/smoke/lib/codegen/recorder.dart

Issue 306993002: smoke: support named argument in annotations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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 | pkg/smoke/test/codegen/end_to_end_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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 /// Records accesses to Dart program declarations and generates code that will 5 /// Records accesses to Dart program declarations and generates code that will
6 /// allow to do the same accesses at runtime using `package:smoke/static.dart`. 6 /// allow to do the same accesses at runtime using `package:smoke/static.dart`.
7 /// Internally, this library relies on the `analyzer` to extract data from the 7 /// Internally, this library relies on the `analyzer` to extract data from the
8 /// program, and then uses [SmokeCodeGenerator] to produce the code needed by 8 /// program, and then uses [SmokeCodeGenerator] to produce the code needed by
9 /// the smoke system. 9 /// the smoke system.
10 /// 10 ///
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 /// library. 252 /// library.
253 ConstExpression _convertAnnotation(Annotation annotation) { 253 ConstExpression _convertAnnotation(Annotation annotation) {
254 var element = annotation.element; 254 var element = annotation.element;
255 if (element is ConstructorElement) { 255 if (element is ConstructorElement) {
256 if (!element.name.isEmpty) { 256 if (!element.name.isEmpty) {
257 throw new UnimplementedError( 257 throw new UnimplementedError(
258 'named constructors are not implemented in smoke.codegen.recorder'); 258 'named constructors are not implemented in smoke.codegen.recorder');
259 } 259 }
260 260
261 var positionalArgs = []; 261 var positionalArgs = [];
262 var namedArgs = {};
262 for (var arg in annotation.arguments.arguments) { 263 for (var arg in annotation.arguments.arguments) {
263 if (arg is NamedExpression) { 264 if (arg is NamedExpression) {
264 throw new UnimplementedError( 265 namedArgs[arg.name.label.name] = _convertExpression(arg.expression);
265 'named arguments in constructors are not implemented in ' 266 } else {
266 'smoke.codegen.recorder'); 267 positionalArgs.add(_convertExpression(arg));
267 } 268 }
268 positionalArgs.add(_convertExpression(arg));
269 } 269 }
270 270
271 return new ConstructorExpression(importUrlFor(element.library), 271 return new ConstructorExpression(importUrlFor(element.library),
272 element.enclosingElement.name, positionalArgs, const {}); 272 element.enclosingElement.name, positionalArgs, namedArgs);
273 } 273 }
274 274
275 if (element is PropertyAccessorElement) { 275 if (element is PropertyAccessorElement) {
276 return new TopLevelIdentifier( 276 return new TopLevelIdentifier(
277 importUrlFor(element.library), element.name); 277 importUrlFor(element.library), element.name);
278 } 278 }
279 279
280 throw new UnsupportedError('unsupported annotation $annotation'); 280 throw new UnsupportedError('unsupported annotation $annotation');
281 } 281 }
282 282
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 this.includeInherited: true, 387 this.includeInherited: true,
388 this.includeUpTo: null, 388 this.includeUpTo: null,
389 this.excludeFinal: false, 389 this.excludeFinal: false,
390 this.includeMethods: false, 390 this.includeMethods: false,
391 this.withAnnotations: null, 391 this.withAnnotations: null,
392 this.matches: null}); 392 this.matches: null});
393 } 393 }
394 394
395 /// Predicate that tells whether [name] should be included in query results. 395 /// Predicate that tells whether [name] should be included in query results.
396 typedef bool NameMatcher(String name); 396 typedef bool NameMatcher(String name);
OLDNEW
« no previous file with comments | « no previous file | pkg/smoke/test/codegen/end_to_end_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698