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

Side by Side Diff: pkg/compiler/lib/src/mirrors_used.dart

Issue 2595493002: Merge CoreTypes and CoreClasses into CommonElements. (Closed)
Patch Set: Updated cf. comment Created 4 years 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.mirrors_used; 5 library dart2js.mirrors_used;
6 6
7 import 'common/tasks.dart' show CompilerTask; 7 import 'common/tasks.dart' show CompilerTask;
8 import 'common.dart'; 8 import 'common.dart';
9 import 'compile_time_constants.dart' show ConstantCompiler; 9 import 'compile_time_constants.dart' show ConstantCompiler;
10 import 'compiler.dart' show Compiler; 10 import 'compiler.dart' show Compiler;
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 LibraryElement library, ImportElement import) { 244 LibraryElement library, ImportElement import) {
245 LibraryElement importedLibrary = import.importedLibrary; 245 LibraryElement importedLibrary = import.importedLibrary;
246 if (importedLibrary != compiler.commonElements.mirrorsLibrary) { 246 if (importedLibrary != compiler.commonElements.mirrorsLibrary) {
247 return null; 247 return null;
248 } 248 }
249 List<MirrorUsage> result = <MirrorUsage>[]; 249 List<MirrorUsage> result = <MirrorUsage>[];
250 for (MetadataAnnotation metadata in import.metadata) { 250 for (MetadataAnnotation metadata in import.metadata) {
251 metadata.ensureResolved(compiler.resolution); 251 metadata.ensureResolved(compiler.resolution);
252 ConstantValue value = 252 ConstantValue value =
253 compiler.constants.getConstantValue(metadata.constant); 253 compiler.constants.getConstantValue(metadata.constant);
254 Element element = value.getType(compiler.coreTypes).element; 254 Element element = value.getType(compiler.commonElements).element;
255 if (element == compiler.commonElements.mirrorsUsedClass) { 255 if (element == compiler.commonElements.mirrorsUsedClass) {
256 result.add(buildUsage(value)); 256 result.add(buildUsage(value));
257 } 257 }
258 } 258 }
259 return result; 259 return result;
260 } 260 }
261 261
262 /// Merge all [MirrorUsage] instances accross all libraries. 262 /// Merge all [MirrorUsage] instances accross all libraries.
263 MirrorUsage mergeUsages(Map<LibraryElement, List<MirrorUsage>> usageMap) { 263 MirrorUsage mergeUsages(Map<LibraryElement, List<MirrorUsage>> usageMap) {
264 Set<MirrorUsage> usagesToMerge = new Set<MirrorUsage>(); 264 Set<MirrorUsage> usagesToMerge = new Set<MirrorUsage>();
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 ? MessageKind.MIRRORS_EXPECTED_STRING_OR_LIST 408 ? MessageKind.MIRRORS_EXPECTED_STRING_OR_LIST
409 : MessageKind.MIRRORS_EXPECTED_STRING_TYPE_OR_LIST; 409 : MessageKind.MIRRORS_EXPECTED_STRING_TYPE_OR_LIST;
410 reporter.reportHintMessage( 410 reporter.reportHintMessage(
411 node, kind, {'name': node, 'type': apiTypeOf(constant)}); 411 node, kind, {'name': node, 'type': apiTypeOf(constant)});
412 return null; 412 return null;
413 } 413 }
414 } 414 }
415 415
416 /// Find the first non-implementation interface of constant. 416 /// Find the first non-implementation interface of constant.
417 DartType apiTypeOf(ConstantValue constant) { 417 DartType apiTypeOf(ConstantValue constant) {
418 DartType type = constant.getType(compiler.coreTypes); 418 DartType type = constant.getType(compiler.commonElements);
419 LibraryElement library = type.element.library; 419 LibraryElement library = type.element.library;
420 if (type.isInterfaceType && library.isInternalLibrary) { 420 if (type.isInterfaceType && library.isInternalLibrary) {
421 InterfaceType interface = type; 421 InterfaceType interface = type;
422 ClassElement cls = type.element; 422 ClassElement cls = type.element;
423 cls.ensureResolved(compiler.resolution); 423 cls.ensureResolved(compiler.resolution);
424 for (DartType supertype in cls.allSupertypes) { 424 for (DartType supertype in cls.allSupertypes) {
425 if (supertype.isInterfaceType && 425 if (supertype.isInterfaceType &&
426 !supertype.element.library.isInternalLibrary) { 426 !supertype.element.library.isInternalLibrary) {
427 return interface.asInstanceOf(supertype.element); 427 return interface.asInstanceOf(supertype.element);
428 } 428 }
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 // @MirrorsUsed(targets: fisk) 564 // @MirrorsUsed(targets: fisk)
565 // ^^^^ 565 // ^^^^
566 // 566 //
567 // Instead of saying 'fisk' should pretty print the problematic constant 567 // Instead of saying 'fisk' should pretty print the problematic constant
568 // value. 568 // value.
569 return spannable; 569 return spannable;
570 } 570 }
571 return node; 571 return node;
572 } 572 }
573 } 573 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart ('k') | pkg/compiler/lib/src/native/behavior.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698