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

Side by Side Diff: dart/sdk/lib/_internal/compiler/implementation/js_backend/emitter.dart

Issue 23479025: Implement reflection on function type aliases (typedef). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: ParameterMirror.isStatic Created 7 years, 3 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
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 part of js_backend; 5 part of js_backend;
6 6
7 /** 7 /**
8 * A function element that represents a closure call. The signature is copied 8 * A function element that represents a closure call. The signature is copied
9 * from the given element. 9 * from the given element.
10 */ 10 */
(...skipping 3674 matching lines...) Expand 10 before | Expand all | Expand 10 after
3685 for (; !link.isEmpty; link = link.tail) { 3685 for (; !link.isEmpty; link = link.tail) {
3686 metadata.add(reifyMetadata(link.head)); 3686 metadata.add(reifyMetadata(link.head));
3687 } 3687 }
3688 } 3688 }
3689 code.body.statements.add(js.string(metadata.join(',')).toStatement()); 3689 code.body.statements.add(js.string(metadata.join(',')).toStatement());
3690 return code; 3690 return code;
3691 }); 3691 });
3692 } 3692 }
3693 3693
3694 void emitMetadata(CodeBuffer buffer) { 3694 void emitMetadata(CodeBuffer buffer) {
3695 buffer.write('init.metadata$_=$_['); 3695 var literals = backend.typedefTypeLiterals.toList();
3696 Elements.sortedByPosition(literals);
3697 var properties = [];
3698 for (TypedefElement literal in literals) {
3699 var key = namer.getName(literal);
3700 var value = js.toExpression(reifyType(literal.rawType));
3701 properties.add(new jsAst.Property(js.string(key), value));
3702 }
3703 var map = new jsAst.ObjectInitializer(properties);
3704 buffer.write(
3705 jsAst.prettyPrint(
3706 js('init.functionAliases = #', map).toStatement(), compiler));
3707 buffer.write('${N}init.metadata$_=$_[');
3696 for (var metadata in globalMetadata) { 3708 for (var metadata in globalMetadata) {
3697 if (metadata is String) { 3709 if (metadata is String) {
3698 if (metadata != 'null') { 3710 if (metadata != 'null') {
3699 buffer.write(metadata); 3711 buffer.write(metadata);
3700 } 3712 }
3701 } else { 3713 } else {
3702 throw 'Unexpected value in metadata: ${Error.safeToString(metadata)}'; 3714 throw 'Unexpected value in metadata: ${Error.safeToString(metadata)}';
3703 } 3715 }
3704 buffer.write(',$n'); 3716 buffer.write(',$n');
3705 } 3717 }
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
4189 4201
4190 const String HOOKS_API_USAGE = """ 4202 const String HOOKS_API_USAGE = """
4191 // The code supports the following hooks: 4203 // The code supports the following hooks:
4192 // dartPrint(message) - if this function is defined it is called 4204 // dartPrint(message) - if this function is defined it is called
4193 // instead of the Dart [print] method. 4205 // instead of the Dart [print] method.
4194 // dartMainRunner(main) - if this function is defined, the Dart [main] 4206 // dartMainRunner(main) - if this function is defined, the Dart [main]
4195 // method will not be invoked directly. 4207 // method will not be invoked directly.
4196 // Instead, a closure that will invoke [main] is 4208 // Instead, a closure that will invoke [main] is
4197 // passed to [dartMainRunner]. 4209 // passed to [dartMainRunner].
4198 """; 4210 """;
OLDNEW
« no previous file with comments | « dart/sdk/lib/_internal/compiler/implementation/js_backend/backend.dart ('k') | dart/sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698