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

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

Issue 2688413003: Extract BackendUsage, MirrorsData, and CheckedModeHelpers from Backend. (Closed)
Patch Set: Cleanup Created 3 years, 10 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 '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 MetadataCollector(this._compiler, this._emitter) { 158 MetadataCollector(this._compiler, this._emitter) {
159 _globalMetadataMap = new Map<String, _BoundMetadataEntry>(); 159 _globalMetadataMap = new Map<String, _BoundMetadataEntry>();
160 } 160 }
161 161
162 JavaScriptBackend get _backend => _compiler.backend; 162 JavaScriptBackend get _backend => _compiler.backend;
163 TypeVariableHandler get _typeVariableHandler => _backend.typeVariableHandler; 163 TypeVariableHandler get _typeVariableHandler => _backend.typeVariableHandler;
164 DiagnosticReporter get reporter => _compiler.reporter; 164 DiagnosticReporter get reporter => _compiler.reporter;
165 165
166 bool _mustEmitMetadataFor(Element element) { 166 bool _mustEmitMetadataFor(Element element) {
167 return _backend.mustRetainMetadata && 167 return _backend.mirrorsData.mustRetainMetadata &&
168 _backend.referencedFromMirrorSystem(element); 168 _backend.mirrorsData.referencedFromMirrorSystem(element);
169 } 169 }
170 170
171 /// The metadata function returns the metadata associated with 171 /// The metadata function returns the metadata associated with
172 /// [element] in generated code. The metadata needs to be wrapped 172 /// [element] in generated code. The metadata needs to be wrapped
173 /// in a function as it refers to constants that may not have been 173 /// in a function as it refers to constants that may not have been
174 /// constructed yet. For example, a class is allowed to be 174 /// constructed yet. For example, a class is allowed to be
175 /// annotated with itself. The metadata function is used by 175 /// annotated with itself. The metadata function is used by
176 /// mirrors_patch to implement DeclarationMirror.metadata. 176 /// mirrors_patch to implement DeclarationMirror.metadata.
177 jsAst.Fun buildMetadataFunction(Element element) { 177 jsAst.Fun buildMetadataFunction(Element element) {
178 if (!_mustEmitMetadataFor(element)) return null; 178 if (!_mustEmitMetadataFor(element)) return null;
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 }); 317 });
318 } 318 }
319 319
320 jsAst.Expression _computeTypeRepresentation(ResolutionDartType type, 320 jsAst.Expression _computeTypeRepresentation(ResolutionDartType type,
321 {ignoreTypeVariables: false}) { 321 {ignoreTypeVariables: false}) {
322 jsAst.Expression representation = 322 jsAst.Expression representation =
323 _backend.rtiEncoder.getTypeRepresentation(type, (variable) { 323 _backend.rtiEncoder.getTypeRepresentation(type, (variable) {
324 if (ignoreTypeVariables) return new jsAst.LiteralNull(); 324 if (ignoreTypeVariables) return new jsAst.LiteralNull();
325 return _typeVariableHandler.reifyTypeVariable(variable.element); 325 return _typeVariableHandler.reifyTypeVariable(variable.element);
326 }, (ResolutionTypedefType typedef) { 326 }, (ResolutionTypedefType typedef) {
327 return _backend.isAccessibleByReflection(typedef.element); 327 return _backend.mirrorsData.isAccessibleByReflection(typedef.element);
328 }); 328 });
329 329
330 if (representation is jsAst.LiteralString) { 330 if (representation is jsAst.LiteralString) {
331 // We don't want the representation to be a string, since we use 331 // We don't want the representation to be a string, since we use
332 // strings as indicator for non-initialized types in the lazy emitter. 332 // strings as indicator for non-initialized types in the lazy emitter.
333 reporter.internalError( 333 reporter.internalError(
334 NO_LOCATION_SPANNABLE, 'reified types should not be strings.'); 334 NO_LOCATION_SPANNABLE, 'reified types should not be strings.');
335 } 335 }
336 336
337 return representation; 337 return representation;
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 if (token is _ForwardingMetadataEntry && !token.isBound) { 426 if (token is _ForwardingMetadataEntry && !token.isBound) {
427 _foundUnboundToken = true; 427 _foundUnboundToken = true;
428 } 428 }
429 } 429 }
430 430
431 bool findUnboundPlaceholders(jsAst.Node node) { 431 bool findUnboundPlaceholders(jsAst.Node node) {
432 node.accept(this); 432 node.accept(this);
433 return _foundUnboundToken; 433 return _foundUnboundToken;
434 } 434 }
435 } 435 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698