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

Side by Side Diff: pkg/compiler/lib/src/js_emitter/old_emitter/metadata_emitter.dart

Issue 830703004: Emit to StreamCodeOutput instead of CodeBuffer. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 5 years, 11 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 dart2js.js_emitter; 5 part of dart2js.js_emitter;
6 6
7 class MetadataEmitter extends CodeEmitterHelper { 7 class MetadataEmitter extends CodeEmitterHelper {
8 /// A list of JS expressions that represent metadata, parameter names and 8 /// A list of JS expressions that represent metadata, parameter names and
9 /// type, and return types. 9 /// type, and return types.
10 final List<String> globalMetadata = []; 10 final List<String> globalMetadata = [];
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 return addGlobalMetadata('"$name"'); 96 return addGlobalMetadata('"$name"');
97 } 97 }
98 98
99 int addGlobalMetadata(String string) { 99 int addGlobalMetadata(String string) {
100 return globalMetadataMap.putIfAbsent(string, () { 100 return globalMetadataMap.putIfAbsent(string, () {
101 globalMetadata.add(string); 101 globalMetadata.add(string);
102 return globalMetadata.length - 1; 102 return globalMetadata.length - 1;
103 }); 103 });
104 } 104 }
105 105
106 void emitMetadata(CodeBuffer buffer) { 106 void emitMetadata(CodeOutput output) {
107 String metadataAccess = emitter.generateEmbeddedGlobalAccessString( 107 String metadataAccess = emitter.generateEmbeddedGlobalAccessString(
108 embeddedNames.METADATA); 108 embeddedNames.METADATA);
109 buffer.write('$metadataAccess$_=$_['); 109 output.add('$metadataAccess$_=$_[');
110 for (String metadata in globalMetadata) { 110 for (String metadata in globalMetadata) {
111 if (metadata is String) { 111 if (metadata is String) {
112 if (metadata != 'null') { 112 if (metadata != 'null') {
113 buffer.write(metadata); 113 output.add(metadata);
114 } 114 }
115 } else { 115 } else {
116 throw 'Unexpected value in metadata: ${Error.safeToString(metadata)}'; 116 throw 'Unexpected value in metadata: ${Error.safeToString(metadata)}';
117 } 117 }
118 buffer.write(',$n'); 118 output.add(',$n');
119 } 119 }
120 buffer.write('];$n'); 120 output.add('];$n');
121 } 121 }
122 122
123 List<int> computeMetadata(FunctionElement element) { 123 List<int> computeMetadata(FunctionElement element) {
124 return compiler.withCurrentElement(element, () { 124 return compiler.withCurrentElement(element, () {
125 if (!mustEmitMetadataFor(element)) return const <int>[]; 125 if (!mustEmitMetadataFor(element)) return const <int>[];
126 List<int> metadata = <int>[]; 126 List<int> metadata = <int>[];
127 Link link = element.metadata; 127 Link link = element.metadata;
128 // TODO(ahe): Why is metadata sometimes null? 128 // TODO(ahe): Why is metadata sometimes null?
129 if (link != null) { 129 if (link != null) {
130 for (; !link.isEmpty; link = link.tail) { 130 for (; !link.isEmpty; link = link.tail) {
131 metadata.add(reifyMetadata(link.head)); 131 metadata.add(reifyMetadata(link.head));
132 } 132 }
133 } 133 }
134 return metadata; 134 return metadata;
135 }); 135 });
136 } 136 }
137 } 137 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/old_emitter/interceptor_emitter.dart ('k') | pkg/compiler/lib/src/scanner/scannerlib.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698