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

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

Issue 1421003004: Add CoreClasses (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Updated cf. comment. Created 5 years, 1 month 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
« no previous file with comments | « pkg/compiler/lib/src/compile_time_constants.dart ('k') | pkg/compiler/lib/src/core_types.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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.compiler_base; 5 library dart2js.compiler_base;
6 6
7 import 'dart:async' show 7 import 'dart:async' show
8 EventSink, 8 EventSink,
9 Future; 9 Future;
10 10
(...skipping 19 matching lines...) Expand all
30 ResolutionWorkItem, 30 ResolutionWorkItem,
31 ResolutionImpact; 31 ResolutionImpact;
32 import 'common/tasks.dart' show 32 import 'common/tasks.dart' show
33 CompilerTask, 33 CompilerTask,
34 GenericTask; 34 GenericTask;
35 import 'common/work.dart' show 35 import 'common/work.dart' show
36 WorkItem; 36 WorkItem;
37 import 'compile_time_constants.dart'; 37 import 'compile_time_constants.dart';
38 import 'constants/values.dart'; 38 import 'constants/values.dart';
39 import 'core_types.dart' show 39 import 'core_types.dart' show
40 CoreClasses,
40 CoreTypes; 41 CoreTypes;
41 import 'dart_backend/dart_backend.dart' as dart_backend; 42 import 'dart_backend/dart_backend.dart' as dart_backend;
42 import 'dart_types.dart' show 43 import 'dart_types.dart' show
43 DartType, 44 DartType,
44 DynamicType, 45 DynamicType,
45 InterfaceType, 46 InterfaceType,
46 Types; 47 Types;
47 import 'deferred_load.dart' show DeferredLoadTask, OutputUnit; 48 import 'deferred_load.dart' show DeferredLoadTask, OutputUnit;
48 import 'diagnostics/code_location.dart'; 49 import 'diagnostics/code_location.dart';
49 import 'diagnostics/diagnostic_listener.dart' show 50 import 'diagnostics/diagnostic_listener.dart' show
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 274
274 LibraryElement mainApp; 275 LibraryElement mainApp;
275 FunctionElement mainFunction; 276 FunctionElement mainFunction;
276 277
277 /// Initialized when dart:mirrors is loaded. 278 /// Initialized when dart:mirrors is loaded.
278 LibraryElement mirrorsLibrary; 279 LibraryElement mirrorsLibrary;
279 280
280 /// Initialized when dart:typed_data is loaded. 281 /// Initialized when dart:typed_data is loaded.
281 LibraryElement typedDataLibrary; 282 LibraryElement typedDataLibrary;
282 283
283 ClassElement get objectClass => _coreTypes.objectClass;
284 ClassElement get boolClass => _coreTypes.boolClass;
285 ClassElement get numClass => _coreTypes.numClass;
286 ClassElement get intClass => _coreTypes.intClass;
287 ClassElement get doubleClass => _coreTypes.doubleClass;
288 ClassElement get resourceClass => _coreTypes.resourceClass;
289 ClassElement get stringClass => _coreTypes.stringClass;
290 ClassElement get functionClass => _coreTypes.functionClass;
291 ClassElement get nullClass => _coreTypes.nullClass;
292 ClassElement get listClass => _coreTypes.listClass;
293 ClassElement get typeClass => _coreTypes.typeClass;
294 ClassElement get mapClass => _coreTypes.mapClass;
295 ClassElement get symbolClass => _coreTypes.symbolClass;
296 ClassElement get stackTraceClass => _coreTypes.stackTraceClass;
297 ClassElement get futureClass => _coreTypes.futureClass;
298 ClassElement get iterableClass => _coreTypes.iterableClass;
299 ClassElement get streamClass => _coreTypes.streamClass;
300
301 DiagnosticReporter get reporter => _reporter; 284 DiagnosticReporter get reporter => _reporter;
285 CoreClasses get coreClasses => _coreTypes;
302 CoreTypes get coreTypes => _coreTypes; 286 CoreTypes get coreTypes => _coreTypes;
303 Resolution get resolution => _resolution; 287 Resolution get resolution => _resolution;
304 Parsing get parsing => _parsing; 288 Parsing get parsing => _parsing;
305 289
306 ClassElement typedDataClass; 290 ClassElement typedDataClass;
307 291
308 /// The constant for the [proxy] variable defined in dart:core. 292 /// The constant for the [proxy] variable defined in dart:core.
309 ConstantValue proxyConstant; 293 ConstantValue proxyConstant;
310 294
311 // TODO(johnniwinther): Move this to the JavaScriptBackend. 295 // TODO(johnniwinther): Move this to the JavaScriptBackend.
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 } else if (importsMirrorsLibrary && !enableExperimentalMirrors) { 708 } else if (importsMirrorsLibrary && !enableExperimentalMirrors) {
725 Set<String> importChains = 709 Set<String> importChains =
726 computeImportChainsFor(loadedLibraries, Uris.dart_mirrors); 710 computeImportChainsFor(loadedLibraries, Uris.dart_mirrors);
727 reporter.reportWarningMessage( 711 reporter.reportWarningMessage(
728 NO_LOCATION_SPANNABLE, 712 NO_LOCATION_SPANNABLE,
729 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, 713 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS,
730 {'importChain': importChains.join( 714 {'importChain': importChains.join(
731 MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING)}); 715 MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING)});
732 } 716 }
733 717
734 functionClass.ensureResolved(resolution); 718 coreClasses.functionClass.ensureResolved(resolution);
735 functionApplyMethod = functionClass.lookupLocalMember('apply'); 719 functionApplyMethod =
720 coreClasses.functionClass.lookupLocalMember('apply');
736 721
737 if (preserveComments) { 722 if (preserveComments) {
738 return libraryLoader.loadLibrary(Uris.dart_mirrors) 723 return libraryLoader.loadLibrary(Uris.dart_mirrors)
739 .then((LibraryElement libraryElement) { 724 .then((LibraryElement libraryElement) {
740 documentClass = libraryElement.find('Comment'); 725 documentClass = libraryElement.find('Comment');
741 }); 726 });
742 } 727 }
743 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); 728 }).then((_) => backend.onLibrariesLoaded(loadedLibraries));
744 } 729 }
745 730
(...skipping 18 matching lines...) Expand all
764 } 749 }
765 return element; 750 return element;
766 } 751 }
767 752
768 // TODO(johnniwinther): Move this to [PatchParser] when it is moved to the 753 // TODO(johnniwinther): Move this to [PatchParser] when it is moved to the
769 // [JavaScriptBackend]. Currently needed for testing. 754 // [JavaScriptBackend]. Currently needed for testing.
770 String get patchVersion => backend.patchVersion; 755 String get patchVersion => backend.patchVersion;
771 756
772 void onClassResolved(ClassElement cls) { 757 void onClassResolved(ClassElement cls) {
773 if (mirrorSystemClass == cls) { 758 if (mirrorSystemClass == cls) {
774 mirrorSystemGetNameFunction = 759 mirrorSystemGetNameFunction = cls.lookupLocalMember('getName');
775 cls.lookupLocalMember('getName'); 760 } else if (coreClasses.symbolClass == cls) {
776 } else if (symbolClass == cls) {
777 symbolConstructor = cls.constructors.head; 761 symbolConstructor = cls.constructors.head;
778 } else if (symbolImplementationClass == cls) { 762 } else if (symbolImplementationClass == cls) {
779 symbolValidatedConstructor = symbolImplementationClass.lookupConstructor( 763 symbolValidatedConstructor = cls.lookupConstructor(
780 symbolValidatedConstructorSelector.name); 764 symbolValidatedConstructorSelector.name);
781 } else if (mirrorsUsedClass == cls) { 765 } else if (mirrorsUsedClass == cls) {
782 mirrorsUsedConstructor = cls.constructors.head; 766 mirrorsUsedConstructor = cls.constructors.head;
783 } else if (intClass == cls) { 767 } else if (coreClasses.intClass == cls) {
784 intEnvironment = intClass.lookupConstructor(Identifiers.fromEnvironment); 768 intEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment);
785 } else if (stringClass == cls) { 769 } else if (coreClasses.stringClass == cls) {
786 stringEnvironment = 770 stringEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment);
787 stringClass.lookupConstructor(Identifiers.fromEnvironment); 771 } else if (coreClasses.boolClass == cls) {
788 } else if (boolClass == cls) { 772 boolEnvironment = cls.lookupConstructor(Identifiers.fromEnvironment);
789 boolEnvironment =
790 boolClass.lookupConstructor(Identifiers.fromEnvironment);
791 } 773 }
792 } 774 }
793 775
794 void initializeCoreClasses() { 776 void initializeCoreClasses() {
795 final List missingCoreClasses = []; 777 final List missingCoreClasses = [];
796 ClassElement lookupCoreClass(String name) { 778 ClassElement lookupCoreClass(String name) {
797 ClassElement result = coreLibrary.find(name); 779 ClassElement result = coreLibrary.find(name);
798 if (result == null) { 780 if (result == null) {
799 missingCoreClasses.add(name); 781 missingCoreClasses.add(name);
800 } 782 }
(...skipping 18 matching lines...) Expand all
819 reporter.internalError( 801 reporter.internalError(
820 coreLibrary, 802 coreLibrary,
821 'dart:core library does not contain required classes: ' 803 'dart:core library does not contain required classes: '
822 '$missingCoreClasses'); 804 '$missingCoreClasses');
823 } 805 }
824 } 806 }
825 807
826 Element _unnamedListConstructor; 808 Element _unnamedListConstructor;
827 Element get unnamedListConstructor { 809 Element get unnamedListConstructor {
828 if (_unnamedListConstructor != null) return _unnamedListConstructor; 810 if (_unnamedListConstructor != null) return _unnamedListConstructor;
829 return _unnamedListConstructor = listClass.lookupDefaultConstructor(); 811 return _unnamedListConstructor =
812 coreClasses.listClass.lookupDefaultConstructor();
830 } 813 }
831 814
832 Element _filledListConstructor; 815 Element _filledListConstructor;
833 Element get filledListConstructor { 816 Element get filledListConstructor {
834 if (_filledListConstructor != null) return _filledListConstructor; 817 if (_filledListConstructor != null) return _filledListConstructor;
835 return _filledListConstructor = listClass.lookupConstructor("filled"); 818 return _filledListConstructor =
819 coreClasses.listClass.lookupConstructor("filled");
836 } 820 }
837 821
838 /** 822 /**
839 * Get an [Uri] pointing to a patch for the dart: library with 823 * Get an [Uri] pointing to a patch for the dart: library with
840 * the given path. Returns null if there is no patch. 824 * the given path. Returns null if there is no patch.
841 */ 825 */
842 Uri resolvePatchUri(String dartLibraryPath); 826 Uri resolvePatchUri(String dartLibraryPath);
843 827
844 Future runCompiler(Uri uri) { 828 Future runCompiler(Uri uri) {
845 // TODO(ahe): This prevents memory leaks when invoking the compiler 829 // TODO(ahe): This prevents memory leaks when invoking the compiler
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
1433 return userOutputProvider.createEventSink(name, extension); 1417 return userOutputProvider.createEventSink(name, extension);
1434 } 1418 }
1435 } 1419 }
1436 1420
1437 /// Information about suppressed warnings and hints for a given library. 1421 /// Information about suppressed warnings and hints for a given library.
1438 class SuppressionInfo { 1422 class SuppressionInfo {
1439 int warnings = 0; 1423 int warnings = 0;
1440 int hints = 0; 1424 int hints = 0;
1441 } 1425 }
1442 1426
1443 class _CompilerCoreTypes implements CoreTypes { 1427 class _CompilerCoreTypes implements CoreTypes, CoreClasses {
1444 final Resolution resolution; 1428 final Resolution resolution;
1445 1429
1446 ClassElement objectClass; 1430 ClassElement objectClass;
1447 ClassElement boolClass; 1431 ClassElement boolClass;
1448 ClassElement numClass; 1432 ClassElement numClass;
1449 ClassElement intClass; 1433 ClassElement intClass;
1450 ClassElement doubleClass; 1434 ClassElement doubleClass;
1451 ClassElement stringClass; 1435 ClassElement stringClass;
1452 ClassElement functionClass; 1436 ClassElement functionClass;
1453 ClassElement nullClass; 1437 ClassElement nullClass;
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 if (_otherDependencies == null) { 2039 if (_otherDependencies == null) {
2056 _otherDependencies = new Setlet<Element>(); 2040 _otherDependencies = new Setlet<Element>();
2057 } 2041 }
2058 _otherDependencies.add(element.implementation); 2042 _otherDependencies.add(element.implementation);
2059 } 2043 }
2060 2044
2061 Iterable<Element> get otherDependencies { 2045 Iterable<Element> get otherDependencies {
2062 return _otherDependencies != null ? _otherDependencies : const <Element>[]; 2046 return _otherDependencies != null ? _otherDependencies : const <Element>[];
2063 } 2047 }
2064 } 2048 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/compile_time_constants.dart ('k') | pkg/compiler/lib/src/core_types.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698