| OLD | NEW |
| 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 |
| 11 import '../compiler_new.dart' as api; | 11 import '../compiler_new.dart' as api; |
| 12 import 'cache_strategy.dart' show | 12 import 'cache_strategy.dart' show |
| 13 CacheStrategy; | 13 CacheStrategy; |
| 14 import 'closure.dart' as closureMapping show | 14 import 'closure.dart' as closureMapping show |
| 15 ClosureTask; | 15 ClosureTask; |
| 16 import 'common/backend_api.dart' show | 16 import 'common/backend_api.dart' show |
| 17 Backend; | 17 Backend; |
| 18 import 'common/codegen.dart' show | 18 import 'common/codegen.dart' show |
| 19 CodegenRegistry, | 19 CodegenRegistry, |
| 20 CodegenWorkItem; | 20 CodegenWorkItem; |
| 21 import 'common/names.dart' show | 21 import 'common/names.dart' show |
| 22 Identifiers, | 22 Identifiers, |
| 23 Uris; | 23 Uris; |
| 24 import 'common/registry.dart' show | 24 import 'common/registry.dart' show |
| 25 Registry; | 25 Registry; |
| 26 import 'common/resolution.dart' show | 26 import 'common/resolution.dart' show |
| 27 Parsing, |
| 28 Resolution, |
| 27 ResolutionWorkItem; | 29 ResolutionWorkItem; |
| 28 import 'common/tasks.dart' show | 30 import 'common/tasks.dart' show |
| 29 CompilerTask, | 31 CompilerTask, |
| 30 GenericTask; | 32 GenericTask; |
| 31 import 'common/work.dart' show | 33 import 'common/work.dart' show |
| 32 WorkItem; | 34 WorkItem; |
| 33 import 'compile_time_constants.dart'; | 35 import 'compile_time_constants.dart'; |
| 34 import 'constants/values.dart'; | 36 import 'constants/values.dart'; |
| 35 import 'core_types.dart' show | 37 import 'core_types.dart' show |
| 36 CoreTypes; | 38 CoreTypes; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 import 'tokens/token.dart' show | 115 import 'tokens/token.dart' show |
| 114 StringToken, | 116 StringToken, |
| 115 Token, | 117 Token, |
| 116 TokenPair; | 118 TokenPair; |
| 117 import 'tokens/token_constants.dart' as Tokens show | 119 import 'tokens/token_constants.dart' as Tokens show |
| 118 COMMENT_TOKEN, | 120 COMMENT_TOKEN, |
| 119 EOF_TOKEN; | 121 EOF_TOKEN; |
| 120 import 'tokens/token_map.dart' show | 122 import 'tokens/token_map.dart' show |
| 121 TokenMap; | 123 TokenMap; |
| 122 import 'tree/tree.dart' show | 124 import 'tree/tree.dart' show |
| 123 Node; | 125 Node, |
| 126 TypeAnnotation; |
| 124 import 'typechecker.dart' show | 127 import 'typechecker.dart' show |
| 125 TypeCheckerTask; | 128 TypeCheckerTask; |
| 126 import 'types/types.dart' as ti; | 129 import 'types/types.dart' as ti; |
| 127 import 'universe/call_structure.dart' show | 130 import 'universe/call_structure.dart' show |
| 128 CallStructure; | 131 CallStructure; |
| 129 import 'universe/selector.dart' show | 132 import 'universe/selector.dart' show |
| 130 Selector; | 133 Selector; |
| 131 import 'universe/universe.dart' show | 134 import 'universe/universe.dart' show |
| 132 Universe; | 135 Universe; |
| 133 import 'util/util.dart' show | 136 import 'util/util.dart' show |
| 134 Link, | 137 Link, |
| 135 Setlet; | 138 Setlet; |
| 136 import 'world.dart' show | 139 import 'world.dart' show |
| 137 World; | 140 World; |
| 138 | 141 |
| 139 abstract class Compiler extends DiagnosticListener { | 142 abstract class Compiler extends DiagnosticListener { |
| 140 | 143 |
| 141 final Stopwatch totalCompileTime = new Stopwatch(); | 144 final Stopwatch totalCompileTime = new Stopwatch(); |
| 142 int nextFreeClassId = 0; | 145 int nextFreeClassId = 0; |
| 143 World world; | 146 World world; |
| 144 Types types; | 147 Types types; |
| 145 _CompilerCoreTypes _coreTypes; | 148 _CompilerCoreTypes _coreTypes; |
| 149 _CompilerResolution _resolution; |
| 150 _CompilerParsing _parsing; |
| 146 | 151 |
| 147 final CacheStrategy cacheStrategy; | 152 final CacheStrategy cacheStrategy; |
| 148 | 153 |
| 149 /** | 154 /** |
| 150 * Map from token to the first preceding comment token. | 155 * Map from token to the first preceding comment token. |
| 151 */ | 156 */ |
| 152 final TokenMap commentMap = new TokenMap(); | 157 final TokenMap commentMap = new TokenMap(); |
| 153 | 158 |
| 154 /** | 159 /** |
| 155 * Records global dependencies, that is, dependencies that don't | 160 * Records global dependencies, that is, dependencies that don't |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 ClassElement get listClass => _coreTypes.listClass; | 313 ClassElement get listClass => _coreTypes.listClass; |
| 309 ClassElement get typeClass => _coreTypes.typeClass; | 314 ClassElement get typeClass => _coreTypes.typeClass; |
| 310 ClassElement get mapClass => _coreTypes.mapClass; | 315 ClassElement get mapClass => _coreTypes.mapClass; |
| 311 ClassElement get symbolClass => _coreTypes.symbolClass; | 316 ClassElement get symbolClass => _coreTypes.symbolClass; |
| 312 ClassElement get stackTraceClass => _coreTypes.stackTraceClass; | 317 ClassElement get stackTraceClass => _coreTypes.stackTraceClass; |
| 313 ClassElement get futureClass => _coreTypes.futureClass; | 318 ClassElement get futureClass => _coreTypes.futureClass; |
| 314 ClassElement get iterableClass => _coreTypes.iterableClass; | 319 ClassElement get iterableClass => _coreTypes.iterableClass; |
| 315 ClassElement get streamClass => _coreTypes.streamClass; | 320 ClassElement get streamClass => _coreTypes.streamClass; |
| 316 | 321 |
| 317 CoreTypes get coreTypes => _coreTypes; | 322 CoreTypes get coreTypes => _coreTypes; |
| 323 Resolution get resolution => _resolution; |
| 324 Parsing get parsing => _parsing; |
| 318 | 325 |
| 319 ClassElement typedDataClass; | 326 ClassElement typedDataClass; |
| 320 | 327 |
| 321 /// The constant for the [proxy] variable defined in dart:core. | 328 /// The constant for the [proxy] variable defined in dart:core. |
| 322 ConstantValue proxyConstant; | 329 ConstantValue proxyConstant; |
| 323 | 330 |
| 324 // TODO(johnniwinther): Move this to the JavaScriptBackend. | 331 // TODO(johnniwinther): Move this to the JavaScriptBackend. |
| 325 /// The class for patch annotation defined in dart:_js_helper. | 332 /// The class for patch annotation defined in dart:_js_helper. |
| 326 ClassElement patchAnnotationClass; | 333 ClassElement patchAnnotationClass; |
| 327 | 334 |
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 this.userOutputProvider = outputProvider == null | 544 this.userOutputProvider = outputProvider == null |
| 538 ? const NullCompilerOutput() : outputProvider { | 545 ? const NullCompilerOutput() : outputProvider { |
| 539 if (hasIncrementalSupport) { | 546 if (hasIncrementalSupport) { |
| 540 // TODO(ahe): This is too much. Any method from platform and package | 547 // TODO(ahe): This is too much. Any method from platform and package |
| 541 // libraries can be inlined. | 548 // libraries can be inlined. |
| 542 disableInlining = true; | 549 disableInlining = true; |
| 543 } | 550 } |
| 544 world = new World(this); | 551 world = new World(this); |
| 545 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and | 552 // TODO(johnniwinther): Initialize core types in [initializeCoreClasses] and |
| 546 // make its field final. | 553 // make its field final. |
| 547 _coreTypes = new _CompilerCoreTypes(this); | 554 _parsing = new _CompilerParsing(this); |
| 555 _resolution = new _CompilerResolution(this); |
| 556 _coreTypes = new _CompilerCoreTypes(_resolution); |
| 548 types = new Types(this); | 557 types = new Types(this); |
| 549 tracer = new Tracer(this, this.outputProvider); | 558 tracer = new Tracer(this, this.outputProvider); |
| 550 | 559 |
| 551 if (verbose) { | 560 if (verbose) { |
| 552 progress = new Stopwatch()..start(); | 561 progress = new Stopwatch()..start(); |
| 553 } | 562 } |
| 554 | 563 |
| 555 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing | 564 // TODO(johnniwinther): Separate the dependency tracking from the enqueuing |
| 556 // for global dependencies. | 565 // for global dependencies. |
| 557 globalDependencies = | 566 globalDependencies = |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 881 MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND); | 890 MessageKind.MIRRORS_LIBRARY_NOT_SUPPORT_BY_BACKEND); |
| 882 } else { | 891 } else { |
| 883 reportWarningMessage( | 892 reportWarningMessage( |
| 884 NO_LOCATION_SPANNABLE, | 893 NO_LOCATION_SPANNABLE, |
| 885 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, | 894 MessageKind.IMPORT_EXPERIMENTAL_MIRRORS, |
| 886 {'importChain': importChains.join( | 895 {'importChain': importChains.join( |
| 887 MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING)}); | 896 MessageTemplate.IMPORT_EXPERIMENTAL_MIRRORS_PADDING)}); |
| 888 } | 897 } |
| 889 } | 898 } |
| 890 | 899 |
| 891 functionClass.ensureResolved(this); | 900 functionClass.ensureResolved(resolution); |
| 892 functionApplyMethod = functionClass.lookupLocalMember('apply'); | 901 functionApplyMethod = functionClass.lookupLocalMember('apply'); |
| 893 | 902 |
| 894 if (preserveComments) { | 903 if (preserveComments) { |
| 895 return libraryLoader.loadLibrary(Uris.dart_mirrors) | 904 return libraryLoader.loadLibrary(Uris.dart_mirrors) |
| 896 .then((LibraryElement libraryElement) { | 905 .then((LibraryElement libraryElement) { |
| 897 documentClass = libraryElement.find('Comment'); | 906 documentClass = libraryElement.find('Comment'); |
| 898 }); | 907 }); |
| 899 } | 908 } |
| 900 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); | 909 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); |
| 901 } | 910 } |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1056 internalError(main, 'Problem with ${Identifiers.main}.'); | 1065 internalError(main, 'Problem with ${Identifiers.main}.'); |
| 1057 } | 1066 } |
| 1058 mainFunction = backend.helperForBadMain(); | 1067 mainFunction = backend.helperForBadMain(); |
| 1059 } else if (!main.isFunction) { | 1068 } else if (!main.isFunction) { |
| 1060 errorElement = new ErroneousElementX( | 1069 errorElement = new ErroneousElementX( |
| 1061 MessageKind.MAIN_NOT_A_FUNCTION, {'main': Identifiers.main}, | 1070 MessageKind.MAIN_NOT_A_FUNCTION, {'main': Identifiers.main}, |
| 1062 Identifiers.main, main); | 1071 Identifiers.main, main); |
| 1063 mainFunction = backend.helperForBadMain(); | 1072 mainFunction = backend.helperForBadMain(); |
| 1064 } else { | 1073 } else { |
| 1065 mainFunction = main; | 1074 mainFunction = main; |
| 1066 mainFunction.computeType(this); | 1075 mainFunction.computeType(resolution); |
| 1067 FunctionSignature parameters = mainFunction.functionSignature; | 1076 FunctionSignature parameters = mainFunction.functionSignature; |
| 1068 if (parameters.requiredParameterCount > 2) { | 1077 if (parameters.requiredParameterCount > 2) { |
| 1069 int index = 0; | 1078 int index = 0; |
| 1070 parameters.orderedForEachParameter((Element parameter) { | 1079 parameters.orderedForEachParameter((Element parameter) { |
| 1071 if (index++ < 2) return; | 1080 if (index++ < 2) return; |
| 1072 errorElement = new ErroneousElementX( | 1081 errorElement = new ErroneousElementX( |
| 1073 MessageKind.MAIN_WITH_EXTRA_PARAMETER, {'main': Identifiers.main}, | 1082 MessageKind.MAIN_WITH_EXTRA_PARAMETER, {'main': Identifiers.main}, |
| 1074 Identifiers.main, | 1083 Identifiers.main, |
| 1075 parameter); | 1084 parameter); |
| 1076 mainFunction = backend.helperForMainArity(); | 1085 mainFunction = backend.helperForMainArity(); |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) { | 1242 void fullyEnqueueLibrary(LibraryElement library, Enqueuer world) { |
| 1234 void enqueueAll(Element element) { | 1243 void enqueueAll(Element element) { |
| 1235 fullyEnqueueTopLevelElement(element, world); | 1244 fullyEnqueueTopLevelElement(element, world); |
| 1236 } | 1245 } |
| 1237 library.implementation.forEachLocalMember(enqueueAll); | 1246 library.implementation.forEachLocalMember(enqueueAll); |
| 1238 } | 1247 } |
| 1239 | 1248 |
| 1240 void fullyEnqueueTopLevelElement(Element element, Enqueuer world) { | 1249 void fullyEnqueueTopLevelElement(Element element, Enqueuer world) { |
| 1241 if (element.isClass) { | 1250 if (element.isClass) { |
| 1242 ClassElement cls = element; | 1251 ClassElement cls = element; |
| 1243 cls.ensureResolved(this); | 1252 cls.ensureResolved(resolution); |
| 1244 cls.forEachLocalMember(enqueuer.resolution.addToWorkList); | 1253 cls.forEachLocalMember(enqueuer.resolution.addToWorkList); |
| 1245 backend.registerInstantiatedType( | 1254 backend.registerInstantiatedType( |
| 1246 cls.rawType, world, globalDependencies); | 1255 cls.rawType, world, globalDependencies); |
| 1247 } else { | 1256 } else { |
| 1248 world.addToWorkList(element); | 1257 world.addToWorkList(element); |
| 1249 } | 1258 } |
| 1250 } | 1259 } |
| 1251 | 1260 |
| 1252 // Resolves metadata on library elements. This is necessary in order to | 1261 // Resolves metadata on library elements. This is necessary in order to |
| 1253 // resolve metadata classes referenced only from metadata on library tags. | 1262 // resolve metadata classes referenced only from metadata on library tags. |
| 1254 // TODO(ahe): Figure out how to do this lazily. | 1263 // TODO(ahe): Figure out how to do this lazily. |
| 1255 void resolveLibraryMetadata() { | 1264 void resolveLibraryMetadata() { |
| 1256 for (LibraryElement library in libraryLoader.libraries) { | 1265 for (LibraryElement library in libraryLoader.libraries) { |
| 1257 if (library.metadata != null) { | 1266 if (library.metadata != null) { |
| 1258 for (MetadataAnnotation metadata in library.metadata) { | 1267 for (MetadataAnnotation metadata in library.metadata) { |
| 1259 metadata.ensureResolved(this); | 1268 metadata.ensureResolved(resolution); |
| 1260 } | 1269 } |
| 1261 } | 1270 } |
| 1262 } | 1271 } |
| 1263 } | 1272 } |
| 1264 | 1273 |
| 1265 /** | 1274 /** |
| 1266 * Empty the [world] queue. | 1275 * Empty the [world] queue. |
| 1267 */ | 1276 */ |
| 1268 void emptyQueue(Enqueuer world) { | 1277 void emptyQueue(Enqueuer world) { |
| 1269 world.forEach((WorkItem work) { | 1278 world.forEach((WorkItem work) { |
| 1270 withCurrentElement(work.element, () { | 1279 withCurrentElement(work.element, () { |
| 1271 world.applyImpact(work.element, work.run(this, world)); | 1280 world.applyImpact(work.element, work.run(this, world)); |
| 1272 }); | 1281 }); |
| 1273 }); | 1282 }); |
| 1274 } | 1283 } |
| 1275 | 1284 |
| 1276 void processQueue(Enqueuer world, Element main) { | 1285 void processQueue(Enqueuer world, Element main) { |
| 1277 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries); | 1286 world.nativeEnqueuer.processNativeClasses(libraryLoader.libraries); |
| 1278 if (main != null && !main.isErroneous) { | 1287 if (main != null && !main.isErroneous) { |
| 1279 FunctionElement mainMethod = main; | 1288 FunctionElement mainMethod = main; |
| 1280 mainMethod.computeType(this); | 1289 mainMethod.computeType(resolution); |
| 1281 if (mainMethod.functionSignature.parameterCount != 0) { | 1290 if (mainMethod.functionSignature.parameterCount != 0) { |
| 1282 // The first argument could be a list of strings. | 1291 // The first argument could be a list of strings. |
| 1283 backend.listImplementation.ensureResolved(this); | 1292 backend.listImplementation.ensureResolved(resolution); |
| 1284 backend.registerInstantiatedType( | 1293 backend.registerInstantiatedType( |
| 1285 backend.listImplementation.rawType, world, globalDependencies); | 1294 backend.listImplementation.rawType, world, globalDependencies); |
| 1286 backend.stringImplementation.ensureResolved(this); | 1295 backend.stringImplementation.ensureResolved(resolution); |
| 1287 backend.registerInstantiatedType( | 1296 backend.registerInstantiatedType( |
| 1288 backend.stringImplementation.rawType, world, globalDependencies); | 1297 backend.stringImplementation.rawType, world, globalDependencies); |
| 1289 | 1298 |
| 1290 backend.registerMainHasArguments(world); | 1299 backend.registerMainHasArguments(world); |
| 1291 } | 1300 } |
| 1292 world.addToWorkList(main); | 1301 world.addToWorkList(main); |
| 1293 } | 1302 } |
| 1294 if (verbose) { | 1303 if (verbose) { |
| 1295 progress.reset(); | 1304 progress.reset(); |
| 1296 } | 1305 } |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1746 } | 1755 } |
| 1747 } | 1756 } |
| 1748 | 1757 |
| 1749 /// Information about suppressed warnings and hints for a given library. | 1758 /// Information about suppressed warnings and hints for a given library. |
| 1750 class SuppressionInfo { | 1759 class SuppressionInfo { |
| 1751 int warnings = 0; | 1760 int warnings = 0; |
| 1752 int hints = 0; | 1761 int hints = 0; |
| 1753 } | 1762 } |
| 1754 | 1763 |
| 1755 class _CompilerCoreTypes implements CoreTypes { | 1764 class _CompilerCoreTypes implements CoreTypes { |
| 1756 final Compiler compiler; | 1765 final Resolution resolution; |
| 1757 | 1766 |
| 1758 ClassElement objectClass; | 1767 ClassElement objectClass; |
| 1759 ClassElement boolClass; | 1768 ClassElement boolClass; |
| 1760 ClassElement numClass; | 1769 ClassElement numClass; |
| 1761 ClassElement intClass; | 1770 ClassElement intClass; |
| 1762 ClassElement doubleClass; | 1771 ClassElement doubleClass; |
| 1763 ClassElement stringClass; | 1772 ClassElement stringClass; |
| 1764 ClassElement functionClass; | 1773 ClassElement functionClass; |
| 1765 ClassElement nullClass; | 1774 ClassElement nullClass; |
| 1766 ClassElement listClass; | 1775 ClassElement listClass; |
| 1767 ClassElement typeClass; | 1776 ClassElement typeClass; |
| 1768 ClassElement mapClass; | 1777 ClassElement mapClass; |
| 1769 ClassElement symbolClass; | 1778 ClassElement symbolClass; |
| 1770 ClassElement stackTraceClass; | 1779 ClassElement stackTraceClass; |
| 1771 ClassElement futureClass; | 1780 ClassElement futureClass; |
| 1772 ClassElement iterableClass; | 1781 ClassElement iterableClass; |
| 1773 ClassElement streamClass; | 1782 ClassElement streamClass; |
| 1774 ClassElement resourceClass; | 1783 ClassElement resourceClass; |
| 1775 | 1784 |
| 1776 _CompilerCoreTypes(this.compiler); | 1785 _CompilerCoreTypes(this.resolution); |
| 1777 | 1786 |
| 1778 @override | 1787 @override |
| 1779 InterfaceType get objectType => objectClass.computeType(compiler); | 1788 InterfaceType get objectType => objectClass.computeType(resolution); |
| 1780 | 1789 |
| 1781 @override | 1790 @override |
| 1782 InterfaceType get boolType => boolClass.computeType(compiler); | 1791 InterfaceType get boolType => boolClass.computeType(resolution); |
| 1783 | 1792 |
| 1784 @override | 1793 @override |
| 1785 InterfaceType get doubleType => doubleClass.computeType(compiler); | 1794 InterfaceType get doubleType => doubleClass.computeType(resolution); |
| 1786 | 1795 |
| 1787 @override | 1796 @override |
| 1788 InterfaceType get functionType => functionClass.computeType(compiler); | 1797 InterfaceType get functionType => functionClass.computeType(resolution); |
| 1789 | 1798 |
| 1790 @override | 1799 @override |
| 1791 InterfaceType get intType => intClass.computeType(compiler); | 1800 InterfaceType get intType => intClass.computeType(resolution); |
| 1792 | 1801 |
| 1793 @override | 1802 @override |
| 1794 InterfaceType get resourceType => resourceClass.computeType(compiler); | 1803 InterfaceType get resourceType => resourceClass.computeType(resolution); |
| 1795 | 1804 |
| 1796 @override | 1805 @override |
| 1797 InterfaceType listType([DartType elementType]) { | 1806 InterfaceType listType([DartType elementType]) { |
| 1798 InterfaceType type = listClass.computeType(compiler); | 1807 InterfaceType type = listClass.computeType(resolution); |
| 1799 if (elementType == null) { | 1808 if (elementType == null) { |
| 1800 return listClass.rawType; | 1809 return listClass.rawType; |
| 1801 } | 1810 } |
| 1802 return type.createInstantiation([elementType]); | 1811 return type.createInstantiation([elementType]); |
| 1803 } | 1812 } |
| 1804 | 1813 |
| 1805 @override | 1814 @override |
| 1806 InterfaceType mapType([DartType keyType, | 1815 InterfaceType mapType([DartType keyType, |
| 1807 DartType valueType]) { | 1816 DartType valueType]) { |
| 1808 InterfaceType type = mapClass.computeType(compiler); | 1817 InterfaceType type = mapClass.computeType(resolution); |
| 1809 if (keyType == null && valueType == null) { | 1818 if (keyType == null && valueType == null) { |
| 1810 return mapClass.rawType; | 1819 return mapClass.rawType; |
| 1811 } else if (keyType == null) { | 1820 } else if (keyType == null) { |
| 1812 keyType = const DynamicType(); | 1821 keyType = const DynamicType(); |
| 1813 } else if (valueType == null) { | 1822 } else if (valueType == null) { |
| 1814 valueType = const DynamicType(); | 1823 valueType = const DynamicType(); |
| 1815 } | 1824 } |
| 1816 return type.createInstantiation([keyType, valueType]); | 1825 return type.createInstantiation([keyType, valueType]); |
| 1817 } | 1826 } |
| 1818 | 1827 |
| 1819 @override | 1828 @override |
| 1820 InterfaceType get nullType => nullClass.computeType(compiler); | 1829 InterfaceType get nullType => nullClass.computeType(resolution); |
| 1821 | 1830 |
| 1822 @override | 1831 @override |
| 1823 InterfaceType get numType => numClass.computeType(compiler); | 1832 InterfaceType get numType => numClass.computeType(resolution); |
| 1824 | 1833 |
| 1825 @override | 1834 @override |
| 1826 InterfaceType get stringType => stringClass.computeType(compiler); | 1835 InterfaceType get stringType => stringClass.computeType(resolution); |
| 1827 | 1836 |
| 1828 @override | 1837 @override |
| 1829 InterfaceType get symbolType => symbolClass.computeType(compiler); | 1838 InterfaceType get symbolType => symbolClass.computeType(resolution); |
| 1830 | 1839 |
| 1831 @override | 1840 @override |
| 1832 InterfaceType get typeType => typeClass.computeType(compiler); | 1841 InterfaceType get typeType => typeClass.computeType(resolution); |
| 1833 | 1842 |
| 1834 @override | 1843 @override |
| 1835 InterfaceType iterableType([DartType elementType]) { | 1844 InterfaceType iterableType([DartType elementType]) { |
| 1836 InterfaceType type = iterableClass.computeType(compiler); | 1845 InterfaceType type = iterableClass.computeType(resolution); |
| 1837 if (elementType == null) { | 1846 if (elementType == null) { |
| 1838 return iterableClass.rawType; | 1847 return iterableClass.rawType; |
| 1839 } | 1848 } |
| 1840 return type.createInstantiation([elementType]); | 1849 return type.createInstantiation([elementType]); |
| 1841 } | 1850 } |
| 1842 | 1851 |
| 1843 @override | 1852 @override |
| 1844 InterfaceType futureType([DartType elementType]) { | 1853 InterfaceType futureType([DartType elementType]) { |
| 1845 InterfaceType type = futureClass.computeType(compiler); | 1854 InterfaceType type = futureClass.computeType(resolution); |
| 1846 if (elementType == null) { | 1855 if (elementType == null) { |
| 1847 return futureClass.rawType; | 1856 return futureClass.rawType; |
| 1848 } | 1857 } |
| 1849 return type.createInstantiation([elementType]); | 1858 return type.createInstantiation([elementType]); |
| 1850 } | 1859 } |
| 1851 | 1860 |
| 1852 @override | 1861 @override |
| 1853 InterfaceType streamType([DartType elementType]) { | 1862 InterfaceType streamType([DartType elementType]) { |
| 1854 InterfaceType type = streamClass.computeType(compiler); | 1863 InterfaceType type = streamClass.computeType(resolution); |
| 1855 if (elementType == null) { | 1864 if (elementType == null) { |
| 1856 return streamClass.rawType; | 1865 return streamClass.rawType; |
| 1857 } | 1866 } |
| 1858 return type.createInstantiation([elementType]); | 1867 return type.createInstantiation([elementType]); |
| 1859 } | 1868 } |
| 1860 } | 1869 } |
| 1870 |
| 1871 // TODO(johnniwinther): Move [ResolverTask] here. |
| 1872 class _CompilerResolution implements Resolution { |
| 1873 final Compiler compiler; |
| 1874 |
| 1875 _CompilerResolution(this.compiler); |
| 1876 |
| 1877 @override |
| 1878 DiagnosticListener get listener => compiler; |
| 1879 |
| 1880 @override |
| 1881 Parsing get parsing => compiler.parsing; |
| 1882 |
| 1883 @override |
| 1884 CoreTypes get coreTypes => compiler.coreTypes; |
| 1885 |
| 1886 @override |
| 1887 void registerClass(ClassElement cls) { |
| 1888 compiler.world.registerClass(cls); |
| 1889 } |
| 1890 |
| 1891 @override |
| 1892 void resolveClass(ClassElement cls) { |
| 1893 compiler.resolver.resolveClass(cls); |
| 1894 } |
| 1895 |
| 1896 @override |
| 1897 void resolveTypedef(TypedefElement typdef) { |
| 1898 compiler.resolver.resolve(typdef); |
| 1899 } |
| 1900 |
| 1901 @override |
| 1902 void resolveMetadataAnnotation(MetadataAnnotation metadataAnnotation) { |
| 1903 compiler.resolver.resolveMetadataAnnotation(metadataAnnotation); |
| 1904 } |
| 1905 |
| 1906 @override |
| 1907 FunctionSignature resolveSignature(FunctionElement function) { |
| 1908 return compiler.resolver.resolveSignature(function); |
| 1909 } |
| 1910 |
| 1911 @override |
| 1912 DartType resolveTypeAnnotation(Element element, TypeAnnotation node) { |
| 1913 return compiler.resolver.resolveTypeAnnotation(element, node); |
| 1914 } |
| 1915 } |
| 1916 |
| 1917 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] |
| 1918 // and [ScannerTask] here. |
| 1919 class _CompilerParsing implements Parsing { |
| 1920 final Compiler compiler; |
| 1921 |
| 1922 _CompilerParsing(this.compiler); |
| 1923 |
| 1924 @override |
| 1925 DiagnosticListener get listener => compiler; |
| 1926 |
| 1927 @override |
| 1928 measure(f()) => compiler.parser.measure(f); |
| 1929 |
| 1930 @override |
| 1931 void parsePatchClass(ClassElement cls) { |
| 1932 compiler.patchParser.measure(() { |
| 1933 if (cls.isPatch) { |
| 1934 compiler.patchParser.parsePatchClassNode(cls); |
| 1935 } |
| 1936 }); |
| 1937 } |
| 1938 } |
| OLD | NEW |