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

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

Issue 2603263002: Prefix resolution_types with Resolution. (Closed)
Patch Set: Rebased Created 3 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
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 /// Represents an entry's position in one of the global metadata arrays. 7 /// Represents an entry's position in one of the global metadata arrays.
8 /// 8 ///
9 /// [_rc] is used to count the number of references of the token in the 9 /// [_rc] is used to count the number of references of the token in the
10 /// ast for a program. 10 /// ast for a program.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 /// output unit. Once finalized, the entries represent types including 123 /// output unit. Once finalized, the entries represent types including
124 /// function types and typedefs. 124 /// function types and typedefs.
125 Map<OutputUnit, _MetadataList> _typesTokens = 125 Map<OutputUnit, _MetadataList> _typesTokens =
126 new Map<OutputUnit, _MetadataList>(); 126 new Map<OutputUnit, _MetadataList>();
127 127
128 jsAst.Expression getTypesForOutputUnit(OutputUnit outputUnit) { 128 jsAst.Expression getTypesForOutputUnit(OutputUnit outputUnit) {
129 return _typesTokens.putIfAbsent(outputUnit, () => new _MetadataList()); 129 return _typesTokens.putIfAbsent(outputUnit, () => new _MetadataList());
130 } 130 }
131 131
132 /// A map used to canonicalize the entries of types. 132 /// A map used to canonicalize the entries of types.
133 Map<OutputUnit, Map<DartType, _BoundMetadataEntry>> _typesMap = 133 Map<OutputUnit, Map<ResolutionDartType, _BoundMetadataEntry>> _typesMap =
134 <OutputUnit, Map<DartType, _BoundMetadataEntry>>{}; 134 <OutputUnit, Map<ResolutionDartType, _BoundMetadataEntry>>{};
135 135
136 // To support incremental compilation, we have to be able to eagerly emit 136 // To support incremental compilation, we have to be able to eagerly emit
137 // metadata and add metadata later on. We use the below two counters for 137 // metadata and add metadata later on. We use the below two counters for
138 // this. 138 // this.
139 int _globalMetadataCounter = 0; 139 int _globalMetadataCounter = 0;
140 int _globalTypesCounter = 0; 140 int _globalTypesCounter = 0;
141 141
142 MetadataCollector(this._compiler, this._emitter) { 142 MetadataCollector(this._compiler, this._emitter) {
143 _globalMetadataMap = new Map<String, _BoundMetadataEntry>(); 143 _globalMetadataMap = new Map<String, _BoundMetadataEntry>();
144 } 144 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 jsAst.Expression reifyMetadata(MetadataAnnotation annotation) { 259 jsAst.Expression reifyMetadata(MetadataAnnotation annotation) {
260 ConstantValue constant = 260 ConstantValue constant =
261 _backend.constants.getConstantValueForMetadata(annotation); 261 _backend.constants.getConstantValueForMetadata(annotation);
262 if (constant == null) { 262 if (constant == null) {
263 reporter.internalError(annotation, 'Annotation value is null.'); 263 reporter.internalError(annotation, 'Annotation value is null.');
264 return null; 264 return null;
265 } 265 }
266 return _addGlobalMetadata(_emitter.constantReference(constant)); 266 return _addGlobalMetadata(_emitter.constantReference(constant));
267 } 267 }
268 268
269 jsAst.Expression reifyType(DartType type, {ignoreTypeVariables: false}) { 269 jsAst.Expression reifyType(ResolutionDartType type,
270 {ignoreTypeVariables: false}) {
270 return reifyTypeForOutputUnit( 271 return reifyTypeForOutputUnit(
271 type, _compiler.deferredLoadTask.mainOutputUnit, 272 type, _compiler.deferredLoadTask.mainOutputUnit,
272 ignoreTypeVariables: ignoreTypeVariables); 273 ignoreTypeVariables: ignoreTypeVariables);
273 } 274 }
274 275
275 jsAst.Expression reifyTypeForOutputUnit(DartType type, OutputUnit outputUnit, 276 jsAst.Expression reifyTypeForOutputUnit(
277 ResolutionDartType type, OutputUnit outputUnit,
276 {ignoreTypeVariables: false}) { 278 {ignoreTypeVariables: false}) {
277 return addTypeInOutputUnit(type, outputUnit, 279 return addTypeInOutputUnit(type, outputUnit,
278 ignoreTypeVariables: ignoreTypeVariables); 280 ignoreTypeVariables: ignoreTypeVariables);
279 } 281 }
280 282
281 jsAst.Expression reifyName(String name) { 283 jsAst.Expression reifyName(String name) {
282 return _addGlobalMetadata(js.string(name)); 284 return _addGlobalMetadata(js.string(name));
283 } 285 }
284 286
285 jsAst.Expression reifyExpression(jsAst.Expression expression) { 287 jsAst.Expression reifyExpression(jsAst.Expression expression) {
(...skipping 10 matching lines...) Expand all
296 jsAst.prettyPrint(node, _compiler, renamerForNames: nameToKey); 298 jsAst.prettyPrint(node, _compiler, renamerForNames: nameToKey);
297 return _globalMetadataMap.putIfAbsent(printed, () { 299 return _globalMetadataMap.putIfAbsent(printed, () {
298 _BoundMetadataEntry result = new _BoundMetadataEntry(node); 300 _BoundMetadataEntry result = new _BoundMetadataEntry(node);
299 if (_compiler.options.hasIncrementalSupport) { 301 if (_compiler.options.hasIncrementalSupport) {
300 result.finalize(_globalMetadataCounter++); 302 result.finalize(_globalMetadataCounter++);
301 } 303 }
302 return result; 304 return result;
303 }); 305 });
304 } 306 }
305 307
306 jsAst.Expression _computeTypeRepresentation(DartType type, 308 jsAst.Expression _computeTypeRepresentation(ResolutionDartType type,
307 {ignoreTypeVariables: false}) { 309 {ignoreTypeVariables: false}) {
308 jsAst.Expression representation = 310 jsAst.Expression representation =
309 _backend.rtiEncoder.getTypeRepresentation(type, (variable) { 311 _backend.rtiEncoder.getTypeRepresentation(type, (variable) {
310 if (ignoreTypeVariables) return new jsAst.LiteralNull(); 312 if (ignoreTypeVariables) return new jsAst.LiteralNull();
311 return _typeVariableHandler.reifyTypeVariable(variable.element); 313 return _typeVariableHandler.reifyTypeVariable(variable.element);
312 }, (TypedefType typedef) { 314 }, (ResolutionTypedefType typedef) {
313 return _backend.isAccessibleByReflection(typedef.element); 315 return _backend.isAccessibleByReflection(typedef.element);
314 }); 316 });
315 317
316 if (representation is jsAst.LiteralString) { 318 if (representation is jsAst.LiteralString) {
317 // We don't want the representation to be a string, since we use 319 // We don't want the representation to be a string, since we use
318 // strings as indicator for non-initialized types in the lazy emitter. 320 // strings as indicator for non-initialized types in the lazy emitter.
319 reporter.internalError( 321 reporter.internalError(
320 NO_LOCATION_SPANNABLE, 'reified types should not be strings.'); 322 NO_LOCATION_SPANNABLE, 'reified types should not be strings.');
321 } 323 }
322 324
323 return representation; 325 return representation;
324 } 326 }
325 327
326 jsAst.Expression addTypeInOutputUnit(DartType type, OutputUnit outputUnit, 328 jsAst.Expression addTypeInOutputUnit(
329 ResolutionDartType type, OutputUnit outputUnit,
327 {ignoreTypeVariables: false}) { 330 {ignoreTypeVariables: false}) {
328 if (_typesMap[outputUnit] == null) { 331 if (_typesMap[outputUnit] == null) {
329 _typesMap[outputUnit] = new Map<DartType, _BoundMetadataEntry>(); 332 _typesMap[outputUnit] =
333 new Map<ResolutionDartType, _BoundMetadataEntry>();
330 } 334 }
331 return _typesMap[outputUnit].putIfAbsent(type, () { 335 return _typesMap[outputUnit].putIfAbsent(type, () {
332 _BoundMetadataEntry result = new _BoundMetadataEntry( 336 _BoundMetadataEntry result = new _BoundMetadataEntry(
333 _computeTypeRepresentation(type, 337 _computeTypeRepresentation(type,
334 ignoreTypeVariables: ignoreTypeVariables)); 338 ignoreTypeVariables: ignoreTypeVariables));
335 if (_compiler.options.hasIncrementalSupport) { 339 if (_compiler.options.hasIncrementalSupport) {
336 result.finalize(_globalTypesCounter++); 340 result.finalize(_globalTypesCounter++);
337 } 341 }
338 return result; 342 return result;
339 }); 343 });
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 if (token is _ForwardingMetadataEntry && !token.isBound) { 424 if (token is _ForwardingMetadataEntry && !token.isBound) {
421 _foundUnboundToken = true; 425 _foundUnboundToken = true;
422 } 426 }
423 } 427 }
424 428
425 bool findUnboundPlaceholders(jsAst.Node node) { 429 bool findUnboundPlaceholders(jsAst.Node node) {
426 node.accept(this); 430 node.accept(this);
427 return _foundUnboundToken; 431 return _foundUnboundToken;
428 } 432 }
429 } 433 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/js_emitter.dart ('k') | pkg/compiler/lib/src/js_emitter/native_emitter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698