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

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

Issue 2908153003: It's alive! (Closed)
Patch Set: Updated cf. comments Created 3 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
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 library dart2js.js_emitter.metadata_collector; 5 library dart2js.js_emitter.metadata_collector;
6 6
7 import 'package:js_ast/src/precedence.dart' as js_precedence; 7 import 'package:js_ast/src/precedence.dart' as js_precedence;
8 8
9 import '../common.dart'; 9 import '../common.dart';
10 import '../constants/values.dart'; 10 import '../constants/values.dart';
11 import '../elements/resolution_types.dart' 11 import '../elements/resolution_types.dart'
12 show ResolutionDartType, ResolutionTypedefType; 12 show ResolutionDartType, ResolutionTypedefType;
13 import '../deferred_load.dart' show DeferredLoadTask, OutputUnit; 13 import '../deferred_load.dart' show DeferredLoadTask, OutputUnit;
14 import '../elements/elements.dart' 14 import '../elements/elements.dart'
15 show 15 show
16 ClassElement, 16 ClassElement,
17 ConstructorElement, 17 ConstructorElement,
18 Element, 18 Element,
19 FieldElement, 19 FieldElement,
20 FunctionElement,
21 FunctionSignature, 20 FunctionSignature,
22 LibraryElement, 21 LibraryElement,
23 MemberElement, 22 MemberElement,
24 MethodElement, 23 MethodElement,
25 MetadataAnnotation, 24 MetadataAnnotation,
26 ParameterElement; 25 ParameterElement;
26 import '../elements/entities.dart';
27 import '../js/js.dart' as jsAst; 27 import '../js/js.dart' as jsAst;
28 import '../js/js.dart' show js; 28 import '../js/js.dart' show js;
29 import '../js_backend/constant_handler_javascript.dart'; 29 import '../js_backend/constant_handler_javascript.dart';
30 import '../js_backend/mirrors_data.dart'; 30 import '../js_backend/mirrors_data.dart';
31 import '../js_backend/runtime_types.dart' show RuntimeTypesEncoder; 31 import '../js_backend/runtime_types.dart' show RuntimeTypesEncoder;
32 import '../js_backend/type_variable_handler.dart' 32 import '../js_backend/type_variable_handler.dart'
33 show TypeVariableCodegenAnalysis; 33 show TypeVariableCodegenAnalysis;
34 import '../options.dart'; 34 import '../options.dart';
35 35
36 import 'code_emitter_task.dart' show Emitter; 36 import 'code_emitter_task.dart' show Emitter;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 this.reporter, 174 this.reporter,
175 this._deferredLoadTask, 175 this._deferredLoadTask,
176 this._emitter, 176 this._emitter,
177 this._constants, 177 this._constants,
178 this._typeVariableCodegenAnalysis, 178 this._typeVariableCodegenAnalysis,
179 this._mirrorsData, 179 this._mirrorsData,
180 this._rtiEncoder) { 180 this._rtiEncoder) {
181 _globalMetadataMap = new Map<String, _BoundMetadataEntry>(); 181 _globalMetadataMap = new Map<String, _BoundMetadataEntry>();
182 } 182 }
183 183
184 jsAst.Fun buildLibraryMetadataFunction(LibraryElement element) { 184 jsAst.Fun buildLibraryMetadataFunction(LibraryEntity element) {
185 if (!_mirrorsData.mustRetainMetadata || 185 if (!_mirrorsData.mustRetainMetadata ||
186 !_mirrorsData.isLibraryReferencedFromMirrorSystem(element)) { 186 !_mirrorsData.isLibraryReferencedFromMirrorSystem(element)) {
187 return null; 187 return null;
188 } 188 }
189 return _buildMetadataFunction(element); 189 return _buildMetadataFunction(element as LibraryElement);
190 } 190 }
191 191
192 jsAst.Fun buildClassMetadataFunction(ClassElement element) { 192 jsAst.Fun buildClassMetadataFunction(ClassElement element) {
193 if (!_mirrorsData.mustRetainMetadata || 193 if (!_mirrorsData.mustRetainMetadata ||
194 !_mirrorsData.isClassReferencedFromMirrorSystem(element)) { 194 !_mirrorsData.isClassReferencedFromMirrorSystem(element)) {
195 return null; 195 return null;
196 } 196 }
197 return _buildMetadataFunction(element); 197 return _buildMetadataFunction(element);
198 } 198 }
199 199
(...skipping 24 matching lines...) Expand all
224 } else { 224 } else {
225 metadata.add(_emitter.constantReference(constant)); 225 metadata.add(_emitter.constantReference(constant));
226 } 226 }
227 } 227 }
228 if (metadata.isEmpty) return null; 228 if (metadata.isEmpty) return null;
229 return js( 229 return js(
230 'function() { return # }', new jsAst.ArrayInitializer(metadata)); 230 'function() { return # }', new jsAst.ArrayInitializer(metadata));
231 }); 231 });
232 } 232 }
233 233
234 List<jsAst.DeferredNumber> reifyDefaultArguments(FunctionElement function) { 234 List<jsAst.DeferredNumber> reifyDefaultArguments(MethodElement function) {
235 function = function.implementation; 235 function = function.implementation;
236 FunctionSignature signature = function.functionSignature; 236 FunctionSignature signature = function.functionSignature;
237 if (signature.optionalParameterCount == 0) return const []; 237 if (signature.optionalParameterCount == 0) return const [];
238 238
239 // Optional parameters of redirecting factory constructors take their 239 // Optional parameters of redirecting factory constructors take their
240 // defaults from the corresponding parameters of the redirection target. 240 // defaults from the corresponding parameters of the redirection target.
241 Map<ParameterElement, ParameterElement> targetParameterMap; 241 Map<ParameterElement, ParameterElement> targetParameterMap;
242 if (function is ConstructorElement) { 242 if (function is ConstructorElement) {
243 // TODO(sra): dart2js generates a redirecting factory constructor body 243 // TODO(sra): dart2js generates a redirecting factory constructor body
244 // that has the signature of the redirecting constructor that calls the 244 // that has the signature of the redirecting constructor that calls the
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 if (token is _ForwardingMetadataEntry && !token.isBound) { 463 if (token is _ForwardingMetadataEntry && !token.isBound) {
464 _foundUnboundToken = true; 464 _foundUnboundToken = true;
465 } 465 }
466 } 466 }
467 467
468 bool findUnboundPlaceholders(jsAst.Node node) { 468 bool findUnboundPlaceholders(jsAst.Node node) {
469 node.accept(this); 469 node.accept(this);
470 return _foundUnboundToken; 470 return _foundUnboundToken;
471 } 471 }
472 } 472 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698