| 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, | 27 Parsing, |
| 28 Resolution, | 28 Resolution, |
| 29 ResolutionWorkItem; | 29 ResolutionWorkItem, |
| 30 ResolutionWorldImpact; |
| 30 import 'common/tasks.dart' show | 31 import 'common/tasks.dart' show |
| 31 CompilerTask, | 32 CompilerTask, |
| 32 GenericTask; | 33 GenericTask; |
| 33 import 'common/work.dart' show | 34 import 'common/work.dart' show |
| 34 WorkItem; | 35 WorkItem; |
| 35 import 'compile_time_constants.dart'; | 36 import 'compile_time_constants.dart'; |
| 36 import 'constants/values.dart'; | 37 import 'constants/values.dart'; |
| 37 import 'core_types.dart' show | 38 import 'core_types.dart' show |
| 38 CoreTypes; | 39 CoreTypes; |
| 39 import 'dart_backend/dart_backend.dart' as dart_backend; | 40 import 'dart_backend/dart_backend.dart' as dart_backend; |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 762 .then((LibraryElement libraryElement) { | 763 .then((LibraryElement libraryElement) { |
| 763 documentClass = libraryElement.find('Comment'); | 764 documentClass = libraryElement.find('Comment'); |
| 764 }); | 765 }); |
| 765 } | 766 } |
| 766 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); | 767 }).then((_) => backend.onLibrariesLoaded(loadedLibraries)); |
| 767 } | 768 } |
| 768 | 769 |
| 769 bool isProxyConstant(ConstantValue value) { | 770 bool isProxyConstant(ConstantValue value) { |
| 770 FieldElement field = coreLibrary.find('proxy'); | 771 FieldElement field = coreLibrary.find('proxy'); |
| 771 if (field == null) return false; | 772 if (field == null) return false; |
| 772 if (!enqueuer.resolution.hasBeenResolved(field)) return false; | 773 if (!resolution.hasBeenResolved(field)) return false; |
| 773 if (proxyConstant == null) { | 774 if (proxyConstant == null) { |
| 774 proxyConstant = | 775 proxyConstant = |
| 775 constants.getConstantValue( | 776 constants.getConstantValue( |
| 776 resolver.constantCompiler.compileConstant(field)); | 777 resolver.constantCompiler.compileConstant(field)); |
| 777 } | 778 } |
| 778 return proxyConstant == value; | 779 return proxyConstant == value; |
| 779 } | 780 } |
| 780 | 781 |
| 781 Element findRequiredElement(LibraryElement library, String name) { | 782 Element findRequiredElement(LibraryElement library, String name) { |
| 782 var element = library.find(name); | 783 var element = library.find(name); |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 * processing the queues). Also compute the number of methods that | 1154 * processing the queues). Also compute the number of methods that |
| 1154 * were resolved, but not compiled (aka excess resolution). | 1155 * were resolved, but not compiled (aka excess resolution). |
| 1155 */ | 1156 */ |
| 1156 checkQueues() { | 1157 checkQueues() { |
| 1157 for (Enqueuer world in [enqueuer.resolution, enqueuer.codegen]) { | 1158 for (Enqueuer world in [enqueuer.resolution, enqueuer.codegen]) { |
| 1158 world.forEach((WorkItem work) { | 1159 world.forEach((WorkItem work) { |
| 1159 reporter.internalError(work.element, "Work list is not empty."); | 1160 reporter.internalError(work.element, "Work list is not empty."); |
| 1160 }); | 1161 }); |
| 1161 } | 1162 } |
| 1162 if (!REPORT_EXCESS_RESOLUTION) return; | 1163 if (!REPORT_EXCESS_RESOLUTION) return; |
| 1163 var resolved = new Set.from(enqueuer.resolution.resolvedElements); | 1164 var resolved = new Set.from(enqueuer.resolution.processedElements); |
| 1164 for (Element e in enqueuer.codegen.generatedCode.keys) { | 1165 for (Element e in enqueuer.codegen.generatedCode.keys) { |
| 1165 resolved.remove(e); | 1166 resolved.remove(e); |
| 1166 } | 1167 } |
| 1167 for (Element e in new Set.from(resolved)) { | 1168 for (Element e in new Set.from(resolved)) { |
| 1168 if (e.isClass || | 1169 if (e.isClass || |
| 1169 e.isField || | 1170 e.isField || |
| 1170 e.isTypeVariable || | 1171 e.isTypeVariable || |
| 1171 e.isTypedef || | 1172 e.isTypedef || |
| 1172 identical(e.kind, ElementKind.ABSTRACT_FIELD)) { | 1173 identical(e.kind, ElementKind.ABSTRACT_FIELD)) { |
| 1173 resolved.remove(e); | 1174 resolved.remove(e); |
| 1174 } | 1175 } |
| 1175 if (identical(e.kind, ElementKind.GENERATIVE_CONSTRUCTOR)) { | 1176 if (identical(e.kind, ElementKind.GENERATIVE_CONSTRUCTOR)) { |
| 1176 resolved.remove(e); | 1177 resolved.remove(e); |
| 1177 } | 1178 } |
| 1178 if (backend.isBackendLibrary(e.library)) { | 1179 if (backend.isBackendLibrary(e.library)) { |
| 1179 resolved.remove(e); | 1180 resolved.remove(e); |
| 1180 } | 1181 } |
| 1181 } | 1182 } |
| 1182 reporter.log('Excess resolution work: ${resolved.length}.'); | 1183 reporter.log('Excess resolution work: ${resolved.length}.'); |
| 1183 for (Element e in resolved) { | 1184 for (Element e in resolved) { |
| 1184 reporter.reportWarningMessage(e, | 1185 reporter.reportWarningMessage(e, |
| 1185 MessageKind.GENERIC, | 1186 MessageKind.GENERIC, |
| 1186 {'text': 'Warning: $e resolved but not compiled.'}); | 1187 {'text': 'Warning: $e resolved but not compiled.'}); |
| 1187 } | 1188 } |
| 1188 } | 1189 } |
| 1189 | 1190 |
| 1190 WorldImpact analyzeElement(Element element) { | 1191 ResolutionWorldImpact analyzeElement(Element element) { |
| 1191 assert(invariant(element, | 1192 assert(invariant(element, |
| 1192 element.impliesType || | 1193 element.impliesType || |
| 1193 element.isField || | 1194 element.isField || |
| 1194 element.isFunction || | 1195 element.isFunction || |
| 1195 element.isGenerativeConstructor || | 1196 element.isGenerativeConstructor || |
| 1196 element.isGetter || | 1197 element.isGetter || |
| 1197 element.isSetter, | 1198 element.isSetter, |
| 1198 message: 'Unexpected element kind: ${element.kind}')); | 1199 message: 'Unexpected element kind: ${element.kind}')); |
| 1199 assert(invariant(element, element is AnalyzableElement, | 1200 assert(invariant(element, element is AnalyzableElement, |
| 1200 message: 'Element $element is not analyzable.')); | 1201 message: 'Element $element is not analyzable.')); |
| 1201 assert(invariant(element, element.isDeclaration)); | 1202 assert(invariant(element, element.isDeclaration)); |
| 1202 ResolutionEnqueuer world = enqueuer.resolution; | 1203 return resolution.analyzeElement(element); |
| 1203 if (world.hasBeenResolved(element)) { | |
| 1204 return const WorldImpact(); | |
| 1205 } | |
| 1206 assert(parser != null); | |
| 1207 Node tree = parser.parse(element); | |
| 1208 assert(invariant(element, !element.isSynthesized || tree == null)); | |
| 1209 WorldImpact worldImpact = resolver.resolve(element); | |
| 1210 if (tree != null && !analyzeSignaturesOnly && !suppressWarnings) { | |
| 1211 // Only analyze nodes with a corresponding [TreeElements]. | |
| 1212 checker.check(element); | |
| 1213 } | |
| 1214 world.registerResolvedElement(element); | |
| 1215 return worldImpact; | |
| 1216 } | 1204 } |
| 1217 | 1205 |
| 1218 WorldImpact analyze(ResolutionWorkItem work, ResolutionEnqueuer world) { | 1206 ResolutionWorldImpact analyze(ResolutionWorkItem work, |
| 1207 ResolutionEnqueuer world) { |
| 1219 assert(invariant(work.element, identical(world, enqueuer.resolution))); | 1208 assert(invariant(work.element, identical(world, enqueuer.resolution))); |
| 1220 assert(invariant(work.element, !work.isAnalyzed, | 1209 assert(invariant(work.element, !work.isAnalyzed, |
| 1221 message: 'Element ${work.element} has already been analyzed')); | 1210 message: 'Element ${work.element} has already been analyzed')); |
| 1222 if (shouldPrintProgress) { | 1211 if (shouldPrintProgress) { |
| 1223 // TODO(ahe): Add structured diagnostics to the compiler API and | 1212 // TODO(ahe): Add structured diagnostics to the compiler API and |
| 1224 // use it to separate this from the --verbose option. | 1213 // use it to separate this from the --verbose option. |
| 1225 if (phase == PHASE_RESOLVING) { | 1214 if (phase == PHASE_RESOLVING) { |
| 1226 reporter.log( | 1215 reporter.log( |
| 1227 'Resolved ${enqueuer.resolution.resolvedElements.length} ' | 1216 'Resolved ${enqueuer.resolution.processedElements.length} ' |
| 1228 'elements.'); | 1217 'elements.'); |
| 1229 progress.reset(); | 1218 progress.reset(); |
| 1230 } | 1219 } |
| 1231 } | 1220 } |
| 1232 AstElement element = work.element; | 1221 AstElement element = work.element; |
| 1233 if (world.hasBeenResolved(element)) { | 1222 if (world.hasBeenProcessed(element)) { |
| 1234 return const WorldImpact(); | 1223 return const ResolutionWorldImpact(); |
| 1235 } | 1224 } |
| 1236 WorldImpact worldImpact = analyzeElement(element); | 1225 ResolutionWorldImpact worldImpact = analyzeElement(element); |
| 1237 backend.onElementResolved(element, element.resolvedAst.elements); | 1226 backend.onElementResolved(element, element.resolvedAst.elements); |
| 1227 world.registerProcessedElement(element); |
| 1238 return worldImpact; | 1228 return worldImpact; |
| 1239 } | 1229 } |
| 1240 | 1230 |
| 1241 WorldImpact codegen(CodegenWorkItem work, CodegenEnqueuer world) { | 1231 WorldImpact codegen(CodegenWorkItem work, CodegenEnqueuer world) { |
| 1242 assert(invariant(work.element, identical(world, enqueuer.codegen))); | 1232 assert(invariant(work.element, identical(world, enqueuer.codegen))); |
| 1243 if (shouldPrintProgress) { | 1233 if (shouldPrintProgress) { |
| 1244 // TODO(ahe): Add structured diagnostics to the compiler API and | 1234 // TODO(ahe): Add structured diagnostics to the compiler API and |
| 1245 // use it to separate this from the --verbose option. | 1235 // use it to separate this from the --verbose option. |
| 1246 reporter.log( | 1236 reporter.log( |
| 1247 'Compiled ${enqueuer.codegen.generatedCode.length} methods.'); | 1237 'Compiled ${enqueuer.codegen.generatedCode.length} methods.'); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1323 prevToken = currentToken; | 1313 prevToken = currentToken; |
| 1324 currentToken = currentToken.next; | 1314 currentToken = currentToken.next; |
| 1325 } | 1315 } |
| 1326 return firstToken; | 1316 return firstToken; |
| 1327 } | 1317 } |
| 1328 | 1318 |
| 1329 void reportUnusedCode() { | 1319 void reportUnusedCode() { |
| 1330 void checkLive(member) { | 1320 void checkLive(member) { |
| 1331 if (member.isErroneous) return; | 1321 if (member.isErroneous) return; |
| 1332 if (member.isFunction) { | 1322 if (member.isFunction) { |
| 1333 if (!enqueuer.resolution.hasBeenResolved(member)) { | 1323 if (!enqueuer.resolution.hasBeenProcessed(member)) { |
| 1334 reporter.reportHintMessage( | 1324 reporter.reportHintMessage( |
| 1335 member, MessageKind.UNUSED_METHOD, {'name': member.name}); | 1325 member, MessageKind.UNUSED_METHOD, {'name': member.name}); |
| 1336 } | 1326 } |
| 1337 } else if (member.isClass) { | 1327 } else if (member.isClass) { |
| 1338 if (!member.isResolved) { | 1328 if (!member.isResolved) { |
| 1339 reporter.reportHintMessage( | 1329 reporter.reportHintMessage( |
| 1340 member, MessageKind.UNUSED_CLASS, {'name': member.name}); | 1330 member, MessageKind.UNUSED_CLASS, {'name': member.name}); |
| 1341 } else { | 1331 } else { |
| 1342 member.forEachLocalMember(checkLive); | 1332 member.forEachLocalMember(checkLive); |
| 1343 } | 1333 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1483 ClassElement symbolClass; | 1473 ClassElement symbolClass; |
| 1484 ClassElement stackTraceClass; | 1474 ClassElement stackTraceClass; |
| 1485 ClassElement futureClass; | 1475 ClassElement futureClass; |
| 1486 ClassElement iterableClass; | 1476 ClassElement iterableClass; |
| 1487 ClassElement streamClass; | 1477 ClassElement streamClass; |
| 1488 ClassElement resourceClass; | 1478 ClassElement resourceClass; |
| 1489 | 1479 |
| 1490 _CompilerCoreTypes(this.resolution); | 1480 _CompilerCoreTypes(this.resolution); |
| 1491 | 1481 |
| 1492 @override | 1482 @override |
| 1493 InterfaceType get objectType => objectClass.computeType(resolution); | 1483 InterfaceType get objectType { |
| 1484 objectClass.ensureResolved(resolution); |
| 1485 return objectClass.rawType; |
| 1486 } |
| 1494 | 1487 |
| 1495 @override | 1488 @override |
| 1496 InterfaceType get boolType => boolClass.computeType(resolution); | 1489 InterfaceType get boolType { |
| 1490 boolClass.ensureResolved(resolution); |
| 1491 return boolClass.rawType; |
| 1492 } |
| 1497 | 1493 |
| 1498 @override | 1494 @override |
| 1499 InterfaceType get doubleType => doubleClass.computeType(resolution); | 1495 InterfaceType get doubleType { |
| 1496 doubleClass.ensureResolved(resolution); |
| 1497 return doubleClass.rawType; |
| 1498 } |
| 1500 | 1499 |
| 1501 @override | 1500 @override |
| 1502 InterfaceType get functionType => functionClass.computeType(resolution); | 1501 InterfaceType get functionType { |
| 1502 functionClass.ensureResolved(resolution); |
| 1503 return functionClass.rawType; |
| 1504 } |
| 1503 | 1505 |
| 1504 @override | 1506 @override |
| 1505 InterfaceType get intType => intClass.computeType(resolution); | 1507 InterfaceType get intType { |
| 1508 intClass.ensureResolved(resolution); |
| 1509 return intClass.rawType; |
| 1510 } |
| 1506 | 1511 |
| 1507 @override | 1512 @override |
| 1508 InterfaceType get resourceType => resourceClass.computeType(resolution); | 1513 InterfaceType get resourceType { |
| 1514 resourceClass.ensureResolved(resolution); |
| 1515 return resourceClass.rawType; |
| 1516 } |
| 1509 | 1517 |
| 1510 @override | 1518 @override |
| 1511 InterfaceType listType([DartType elementType]) { | 1519 InterfaceType listType([DartType elementType]) { |
| 1512 InterfaceType type = listClass.computeType(resolution); | 1520 listClass.ensureResolved(resolution); |
| 1521 InterfaceType type = listClass.rawType; |
| 1513 if (elementType == null) { | 1522 if (elementType == null) { |
| 1514 return listClass.rawType; | 1523 return type; |
| 1515 } | 1524 } |
| 1516 return type.createInstantiation([elementType]); | 1525 return type.createInstantiation([elementType]); |
| 1517 } | 1526 } |
| 1518 | 1527 |
| 1519 @override | 1528 @override |
| 1520 InterfaceType mapType([DartType keyType, | 1529 InterfaceType mapType([DartType keyType, |
| 1521 DartType valueType]) { | 1530 DartType valueType]) { |
| 1522 InterfaceType type = mapClass.computeType(resolution); | 1531 mapClass.ensureResolved(resolution); |
| 1532 InterfaceType type = mapClass.rawType; |
| 1523 if (keyType == null && valueType == null) { | 1533 if (keyType == null && valueType == null) { |
| 1524 return mapClass.rawType; | 1534 return type; |
| 1525 } else if (keyType == null) { | 1535 } else if (keyType == null) { |
| 1526 keyType = const DynamicType(); | 1536 keyType = const DynamicType(); |
| 1527 } else if (valueType == null) { | 1537 } else if (valueType == null) { |
| 1528 valueType = const DynamicType(); | 1538 valueType = const DynamicType(); |
| 1529 } | 1539 } |
| 1530 return type.createInstantiation([keyType, valueType]); | 1540 return type.createInstantiation([keyType, valueType]); |
| 1531 } | 1541 } |
| 1532 | 1542 |
| 1533 @override | 1543 @override |
| 1534 InterfaceType get nullType => nullClass.computeType(resolution); | 1544 InterfaceType get nullType { |
| 1545 nullClass.ensureResolved(resolution); |
| 1546 return nullClass.rawType; |
| 1547 } |
| 1535 | 1548 |
| 1536 @override | 1549 @override |
| 1537 InterfaceType get numType => numClass.computeType(resolution); | 1550 InterfaceType get numType { |
| 1551 numClass.ensureResolved(resolution); |
| 1552 return numClass.rawType; |
| 1553 } |
| 1538 | 1554 |
| 1539 @override | 1555 @override |
| 1540 InterfaceType get stringType => stringClass.computeType(resolution); | 1556 InterfaceType get stringType { |
| 1557 stringClass.ensureResolved(resolution); |
| 1558 return stringClass.rawType; |
| 1559 } |
| 1541 | 1560 |
| 1542 @override | 1561 @override |
| 1543 InterfaceType get symbolType => symbolClass.computeType(resolution); | 1562 InterfaceType get symbolType { |
| 1563 symbolClass.ensureResolved(resolution); |
| 1564 return symbolClass.rawType; |
| 1565 } |
| 1544 | 1566 |
| 1545 @override | 1567 @override |
| 1546 InterfaceType get typeType => typeClass.computeType(resolution); | 1568 InterfaceType get typeType { |
| 1569 typeClass.ensureResolved(resolution); |
| 1570 return typeClass.rawType; |
| 1571 } |
| 1547 | 1572 |
| 1548 @override | 1573 @override |
| 1549 InterfaceType iterableType([DartType elementType]) { | 1574 InterfaceType iterableType([DartType elementType]) { |
| 1550 InterfaceType type = iterableClass.computeType(resolution); | 1575 iterableClass.ensureResolved(resolution); |
| 1576 InterfaceType type = iterableClass.rawType; |
| 1551 if (elementType == null) { | 1577 if (elementType == null) { |
| 1552 return iterableClass.rawType; | 1578 return type; |
| 1553 } | 1579 } |
| 1554 return type.createInstantiation([elementType]); | 1580 return type.createInstantiation([elementType]); |
| 1555 } | 1581 } |
| 1556 | 1582 |
| 1557 @override | 1583 @override |
| 1558 InterfaceType futureType([DartType elementType]) { | 1584 InterfaceType futureType([DartType elementType]) { |
| 1559 InterfaceType type = futureClass.computeType(resolution); | 1585 futureClass.ensureResolved(resolution); |
| 1586 InterfaceType type = futureClass.rawType; |
| 1560 if (elementType == null) { | 1587 if (elementType == null) { |
| 1561 return futureClass.rawType; | 1588 return type; |
| 1562 } | 1589 } |
| 1563 return type.createInstantiation([elementType]); | 1590 return type.createInstantiation([elementType]); |
| 1564 } | 1591 } |
| 1565 | 1592 |
| 1566 @override | 1593 @override |
| 1567 InterfaceType streamType([DartType elementType]) { | 1594 InterfaceType streamType([DartType elementType]) { |
| 1568 InterfaceType type = streamClass.computeType(resolution); | 1595 streamClass.ensureResolved(resolution); |
| 1596 InterfaceType type = streamClass.rawType; |
| 1569 if (elementType == null) { | 1597 if (elementType == null) { |
| 1570 return streamClass.rawType; | 1598 return type; |
| 1571 } | 1599 } |
| 1572 return type.createInstantiation([elementType]); | 1600 return type.createInstantiation([elementType]); |
| 1573 } | 1601 } |
| 1574 } | 1602 } |
| 1575 | 1603 |
| 1576 class _CompilerDiagnosticReporter extends DiagnosticReporter { | 1604 class _CompilerDiagnosticReporter extends DiagnosticReporter { |
| 1577 final Compiler compiler; | 1605 final Compiler compiler; |
| 1578 final DiagnosticOptions options; | 1606 final DiagnosticOptions options; |
| 1579 | 1607 |
| 1580 Element _currentElement; | 1608 Element _currentElement; |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 const <DiagnosticMessage>[], | 1941 const <DiagnosticMessage>[], |
| 1914 api.Diagnostic.HINT); | 1942 api.Diagnostic.HINT); |
| 1915 }); | 1943 }); |
| 1916 } | 1944 } |
| 1917 } | 1945 } |
| 1918 } | 1946 } |
| 1919 | 1947 |
| 1920 // TODO(johnniwinther): Move [ResolverTask] here. | 1948 // TODO(johnniwinther): Move [ResolverTask] here. |
| 1921 class _CompilerResolution implements Resolution { | 1949 class _CompilerResolution implements Resolution { |
| 1922 final Compiler compiler; | 1950 final Compiler compiler; |
| 1951 final Map<Element, ResolutionWorldImpact> _worldImpactCache = |
| 1952 <Element, ResolutionWorldImpact>{}; |
| 1923 | 1953 |
| 1924 _CompilerResolution(this.compiler); | 1954 _CompilerResolution(this.compiler); |
| 1925 | 1955 |
| 1926 @override | 1956 @override |
| 1927 DiagnosticReporter get reporter => compiler.reporter; | 1957 DiagnosticReporter get reporter => compiler.reporter; |
| 1928 | 1958 |
| 1929 @override | 1959 @override |
| 1930 Parsing get parsing => compiler.parsing; | 1960 Parsing get parsing => compiler.parsing; |
| 1931 | 1961 |
| 1932 @override | 1962 @override |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1954 | 1984 |
| 1955 @override | 1985 @override |
| 1956 FunctionSignature resolveSignature(FunctionElement function) { | 1986 FunctionSignature resolveSignature(FunctionElement function) { |
| 1957 return compiler.resolver.resolveSignature(function); | 1987 return compiler.resolver.resolveSignature(function); |
| 1958 } | 1988 } |
| 1959 | 1989 |
| 1960 @override | 1990 @override |
| 1961 DartType resolveTypeAnnotation(Element element, TypeAnnotation node) { | 1991 DartType resolveTypeAnnotation(Element element, TypeAnnotation node) { |
| 1962 return compiler.resolver.resolveTypeAnnotation(element, node); | 1992 return compiler.resolver.resolveTypeAnnotation(element, node); |
| 1963 } | 1993 } |
| 1994 |
| 1995 ResolutionWorldImpact analyzeElement(Element element) { |
| 1996 return _worldImpactCache.putIfAbsent(element, () { |
| 1997 assert(compiler.parser != null); |
| 1998 Node tree = compiler.parser.parse(element); |
| 1999 assert(invariant(element, !element.isSynthesized || tree == null)); |
| 2000 ResolutionWorldImpact worldImpact = compiler.resolver.resolve(element); |
| 2001 if (tree != null && |
| 2002 !compiler.analyzeSignaturesOnly && |
| 2003 !compiler.suppressWarnings) { |
| 2004 // Only analyze nodes with a corresponding [TreeElements]. |
| 2005 compiler.checker.check(element); |
| 2006 } |
| 2007 return worldImpact; |
| 2008 }); |
| 2009 } |
| 2010 |
| 2011 @override |
| 2012 bool hasBeenResolved(Element element) { |
| 2013 return _worldImpactCache.containsKey(element); |
| 2014 } |
| 1964 } | 2015 } |
| 1965 | 2016 |
| 1966 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] | 2017 // TODO(johnniwinther): Move [ParserTask], [PatchParserTask], [DietParserTask] |
| 1967 // and [ScannerTask] here. | 2018 // and [ScannerTask] here. |
| 1968 class _CompilerParsing implements Parsing { | 2019 class _CompilerParsing implements Parsing { |
| 1969 final Compiler compiler; | 2020 final Compiler compiler; |
| 1970 | 2021 |
| 1971 _CompilerParsing(this.compiler); | 2022 _CompilerParsing(this.compiler); |
| 1972 | 2023 |
| 1973 @override | 2024 @override |
| 1974 DiagnosticReporter get reporter => compiler.reporter; | 2025 DiagnosticReporter get reporter => compiler.reporter; |
| 1975 | 2026 |
| 1976 @override | 2027 @override |
| 1977 measure(f()) => compiler.parser.measure(f); | 2028 measure(f()) => compiler.parser.measure(f); |
| 1978 | 2029 |
| 1979 @override | 2030 @override |
| 1980 void parsePatchClass(ClassElement cls) { | 2031 void parsePatchClass(ClassElement cls) { |
| 1981 compiler.patchParser.measure(() { | 2032 compiler.patchParser.measure(() { |
| 1982 if (cls.isPatch) { | 2033 if (cls.isPatch) { |
| 1983 compiler.patchParser.parsePatchClassNode(cls); | 2034 compiler.patchParser.parsePatchClassNode(cls); |
| 1984 } | 2035 } |
| 1985 }); | 2036 }); |
| 1986 } | 2037 } |
| 1987 } | 2038 } |
| OLD | NEW |